sisowpayment - Version 4.1.11

Version Notes

Fix: not everything was visible in store view

Download this release

Release Info

Developer Magento Core Team
Extension sisowpayment
Version 4.1.11
Comparing to
See all releases


Version 4.1.11

Files changed (68) hide show
  1. app/code/local/Sisow/Block/Adminhtml/Notice.php +48 -0
  2. app/code/local/Sisow/Block/Paymentfee/Adminhtml/Sales/Order/Totals.php +34 -0
  3. app/code/local/Sisow/Block/Paymentfee/Checkout/Fee.php +73 -0
  4. app/code/local/Sisow/Block/Paymentfee/Creditmemo/Totals.php +31 -0
  5. app/code/local/Sisow/Block/Paymentfee/Invoice/Totals/Fee.php +31 -0
  6. app/code/local/Sisow/Block/Paymentfee/Order/Totals/Fee.php +32 -0
  7. app/code/local/Sisow/Block/Paymentmethod/Creditcard.php +34 -0
  8. app/code/local/Sisow/Block/Paymentmethod/Default.php +15 -0
  9. app/code/local/Sisow/Block/Paymentmethod/DefaultInfo.php +49 -0
  10. app/code/local/Sisow/Block/Paymentmethod/Ideal.php +27 -0
  11. app/code/local/Sisow/Block/Paymentmethod/IdealInfo.php +48 -0
  12. app/code/local/Sisow/Block/Paymentmethod/Klarna.php +66 -0
  13. app/code/local/Sisow/Block/Paymentmethod/Klarnaacc.php +76 -0
  14. app/code/local/Sisow/Block/Paymentmethod/Overboeking.php +15 -0
  15. app/code/local/Sisow/Block/Redirect.php +427 -0
  16. app/code/local/Sisow/Helper/Data.php +14 -0
  17. app/code/local/Sisow/Helper/Paymentfee.php +172 -0
  18. app/code/local/Sisow/Model/Base.php +474 -0
  19. app/code/local/Sisow/Model/Config/Autoinvoice.php +24 -0
  20. app/code/local/Sisow/Model/Config/GeneralAutoinvoice.php +23 -0
  21. app/code/local/Sisow/Model/Config/Newordermail.php +24 -0
  22. app/code/local/Sisow/Model/Config/NewordermailMethod.php +25 -0
  23. app/code/local/Sisow/Model/Methods/Abstract.php +119 -0
  24. app/code/local/Sisow/Model/Methods/Ebill.php +15 -0
  25. app/code/local/Sisow/Model/Methods/Ideal.php +32 -0
  26. app/code/local/Sisow/Model/Methods/Klarna.php +48 -0
  27. app/code/local/Sisow/Model/Methods/Klarnaacc.php +65 -0
  28. app/code/local/Sisow/Model/Methods/Maestro.php +28 -0
  29. app/code/local/Sisow/Model/Methods/Mastercard.php +28 -0
  30. app/code/local/Sisow/Model/Methods/Mistercash.php +14 -0
  31. app/code/local/Sisow/Model/Methods/Overboeking.php +14 -0
  32. app/code/local/Sisow/Model/Methods/Paypalec.php +14 -0
  33. app/code/local/Sisow/Model/Methods/Sofort.php +14 -0
  34. app/code/local/Sisow/Model/Methods/Visa.php +28 -0
  35. app/code/local/Sisow/Model/Methods/WebshopGiftcard.php +14 -0
  36. app/code/local/Sisow/Model/Observer/Order.php +50 -0
  37. app/code/local/Sisow/Model/Observer/Paymentfee.php +75 -0
  38. app/code/local/Sisow/Model/Observer/Sendebill.php +64 -0
  39. app/code/local/Sisow/Model/Observer/Submit.php +12 -0
  40. app/code/local/Sisow/Model/Paymentfee/Creditmemo/Total.php +66 -0
  41. app/code/local/Sisow/Model/Paymentfee/Invoice/Pdf/Total.php +99 -0
  42. app/code/local/Sisow/Model/Paymentfee/Invoice/Tax.php +119 -0
  43. app/code/local/Sisow/Model/Paymentfee/Invoice/Total.php +75 -0
  44. app/code/local/Sisow/Model/Paymentfee/Quote/Quote.php +51 -0
  45. app/code/local/Sisow/Model/Paymentfee/Quote/TaxTotal.php +65 -0
  46. app/code/local/Sisow/Model/Paymentfee/Quote/Total.php +142 -0
  47. app/code/local/Sisow/controllers/CheckoutController.php +276 -0
  48. app/code/local/Sisow/controllers/NotifyController.php +18 -0
  49. app/code/local/Sisow/etc/config.xml +321 -0
  50. app/code/local/Sisow/etc/system.xml +1991 -0
  51. app/design/adminhtml/default/default/template/sisow/adminhtml/notice.phtml +42 -0
  52. app/design/adminhtml/default/default/template/sisow/checkout/default_info.phtml +17 -0
  53. app/design/adminhtml/default/default/template/sisow/checkout/ideal_info.phtml +15 -0
  54. app/design/adminhtml/default/default/template/sisow/form.phtml +35 -0
  55. app/design/frontend/base/default/template/sisow/checkout/default_form.phtml +15 -0
  56. app/design/frontend/base/default/template/sisow/checkout/default_info.phtml +9 -0
  57. app/design/frontend/base/default/template/sisow/checkout/ideal_form.phtml +28 -0
  58. app/design/frontend/base/default/template/sisow/checkout/ideal_info.phtml +7 -0
  59. app/design/frontend/base/default/template/sisow/checkout/klarna_form.phtml +75 -0
  60. app/design/frontend/base/default/template/sisow/checkout/klarnaacc_form.phtml +87 -0
  61. app/design/frontend/base/default/template/sisow/checkout/overboeking_form.phtml +20 -0
  62. app/design/frontend/base/default/template/sisow/form.phtml +48 -0
  63. app/design/frontend/base/default/template/sisow/formecare.phtml +89 -0
  64. app/design/frontend/base/default/template/sisow/formovb.phtml +51 -0
  65. app/design/frontend/base/default/template/sisow/paymentfee/checkout/fee.phtml +39 -0
  66. app/etc/modules/Sisow.xml +12 -0
  67. app/locale/nl_NL/Sisow.csv +46 -0
  68. package.xml +26 -0
app/code/local/Sisow/Block/Adminhtml/Notice.php ADDED
@@ -0,0 +1,48 @@
1
+ <?php
2
+ class Sisow_Block_Adminhtml_Notice
3
+ extends Mage_Adminhtml_Block_Abstract
4
+ implements Varien_Data_Form_Element_Renderer_Interface
5
+ {
6
+ protected $_template = 'sisow/adminhtml/notice.phtml';
7
+
8
+ /**
9
+ * Render fieldset html
10
+ *
11
+ * @param Varien_Data_Form_Element_Abstract $element
12
+ * @return string
13
+ */
14
+ public function render(Varien_Data_Form_Element_Abstract $element)
15
+ {
16
+ $elementOriginalData = $element->getOriginalData();
17
+ if (isset($elementOriginalData['help_link'])) {
18
+ $this->setHelpLink($elementOriginalData['help_link']);
19
+ }
20
+ $js = '
21
+ sisowToggleSolution = function(id, url) {
22
+ var doScroll = false;
23
+ Fieldset.toggleCollapse(id, url);
24
+ if ($(this).hasClassName("open")) {
25
+ $(".with-button button.button").each(function(anotherButton) {
26
+ if (anotherButton != this && $(anotherButton).hasClassName("open")) {
27
+ $(anotherButton).click();
28
+ doScroll = true;
29
+ }
30
+ }.bind(this));
31
+ }
32
+ if (doScroll) {
33
+ var pos = Element.cumulativeOffset($(this));
34
+ window.scrollTo(pos[0], pos[1] - 45);
35
+ }
36
+ }
37
+ ';
38
+ return $this->toHtml() . $this->helper('adminhtml/js')->getScript($js);
39
+ }
40
+
41
+ public function getActive()
42
+ {
43
+ $base = Mage::getModel('sisow/base');
44
+ $base->CheckMerchant();
45
+
46
+ return $base->active;
47
+ }
48
+ }
app/code/local/Sisow/Block/Paymentfee/Adminhtml/Sales/Order/Totals.php ADDED
@@ -0,0 +1,34 @@
1
+ <?php
2
+ /**
3
+ * File used to include the invoice fee to the order totals on the admin page
4
+ *
5
+ * Order totals handling class.
6
+ *
7
+ */
8
+
9
+ class Sisow_Block_Paymentfee_Adminhtml_Sales_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
10
+ {
11
+
12
+ /**
13
+ * Initialize order totals array
14
+ *
15
+ * @return Mage_Sales_Block_Order_Totals
16
+ */
17
+ protected function _initTotals()
18
+ {
19
+ parent::_initTotals();
20
+ $order = $this->getOrder();
21
+ $payment = $order->getPayment();
22
+ if (substr($payment->getMethod(), 0, 5) != "sisow") {
23
+ return $this;
24
+ }
25
+
26
+ $info = $order->getPayment()->getMethodInstance()->getInfoInstance();
27
+ if (!$info->getAdditionalInformation("invoice_fee")) {
28
+ return $this;
29
+ }
30
+
31
+ return Mage::helper('sisow/paymentfee')->addToBlock($this);
32
+ }
33
+
34
+ }
app/code/local/Sisow/Block/Paymentfee/Checkout/Fee.php ADDED
@@ -0,0 +1,73 @@
1
+ <?php
2
+ /**
3
+ * File used to display a payment fee on the order total
4
+ *
5
+ * Class used to create a payment fee block
6
+ *
7
+ */
8
+
9
+ class Sisow_Block_Paymentfee_Checkout_Fee extends Mage_Checkout_Block_Total_Default
10
+ {
11
+ protected $_template = 'sisow/paymentfee/checkout/fee.phtml';
12
+
13
+ /**
14
+ * Get Payment fee including tax
15
+ *
16
+ * @return float
17
+ */
18
+ public function getInvoiceFeeIncludeTax()
19
+ {
20
+ return $this->getTotal()->getAddress()->getInvoiceFee();
21
+ }
22
+
23
+ /**
24
+ * Get Payment fee excluding tax
25
+ *
26
+ * @return float
27
+ */
28
+ public function getInvoiceFeeExcludeTax()
29
+ {
30
+ return $this->getTotal()->getAddress()->getInvoiceFeeExcludedVat();
31
+ }
32
+
33
+ /**
34
+ * Checks if both including and excluding tax prices should be shown
35
+ *
36
+ * @return bool
37
+ */
38
+ public function displayBoth()
39
+ {
40
+ return Mage::helper("tax")->displayCartBothPrices();
41
+ }
42
+
43
+ /**
44
+ * Checks if only including tax price should be shown
45
+ *
46
+ * @return bool
47
+ */
48
+ public function displayIncludeTax()
49
+ {
50
+ return Mage::helper("tax")->displayCartPriceInclTax();
51
+ }
52
+
53
+ /**
54
+ * Get the label to display for excluding tax
55
+ *
56
+ * @return string
57
+ */
58
+ public function getExcludeTaxLabel()
59
+ {
60
+ return Mage::helper("tax")->getIncExcTaxLabel(false);
61
+ }
62
+
63
+ /**
64
+ * Get the label to display for including tax
65
+ *
66
+ * @return string
67
+ */
68
+ public function getIncludeTaxLabel()
69
+ {
70
+ return Mage::helper("tax")->getIncExcTaxLabel(true);
71
+ }
72
+
73
+ }
app/code/local/Sisow/Block/Paymentfee/Creditmemo/Totals.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ /**
3
+ * File used to display a invoice fee on a credit memo
4
+ *
5
+ * Class used to add the invoice fee to a credit memo
6
+ *
7
+ */
8
+
9
+ class Sisow_Block_Paymentfee_Creditmemo_Totals extends Mage_Sales_Block_Order_Creditmemo_Totals
10
+ {
11
+
12
+ /**
13
+ * Initialize order totals array
14
+ *
15
+ * @return Mage_Sales_Block_Order_Creditmemo_Totals
16
+ */
17
+ protected function _initTotals()
18
+ {
19
+ parent::_initTotals();
20
+ $payment = $this->getOrder()->getPayment();
21
+ if (substr($payment->getMethod(), 0, 6) != "sisow_") {
22
+ return $this;
23
+ }
24
+ $info = $payment->getMethodInstance()->getInfoInstance();
25
+ if (!$info->getAdditionalInformation("invoice_fee")) {
26
+ return $this;
27
+ }
28
+ return Mage::helper('sisow/paymentfee')->addToBlock($this);
29
+ }
30
+
31
+ }
app/code/local/Sisow/Block/Paymentfee/Invoice/Totals/Fee.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ /**
3
+ * File used to display a invoice fee on a invoice
4
+ *
5
+ * Class used to add the invoice fee to a invoice
6
+ *
7
+ */
8
+
9
+ class Sisow_Block_Paymentfee_Invoice_Totals_Fee extends Mage_Sales_Block_Order_Invoice_Totals
10
+ {
11
+
12
+ /**
13
+ * Initialize order totals array
14
+ *
15
+ * @return Mage_Sales_Block_Order_Invoice_Totals
16
+ */
17
+ public function _initTotals()
18
+ {
19
+ parent::_initTotals();
20
+ $payment = $this->getOrder()->getPayment();
21
+ if (substr($payment->getMethod(), 0, 5) != "sisow") {
22
+ return $this;
23
+ }
24
+ $info = $payment->getMethodInstance()->getInfoInstance();
25
+ if (!$info->getAdditionalInformation("invoice_fee")) {
26
+ return $this;
27
+ }
28
+ return Mage::helper('sisow/paymentfee')->addToBlock($this);
29
+ }
30
+
31
+ }
app/code/local/Sisow/Block/Paymentfee/Order/Totals/Fee.php ADDED
@@ -0,0 +1,32 @@
1
+ <?php
2
+ /**
3
+ * File used to display a invoice fee on a order
4
+ *
5
+ * Class used to add the invoice fee to a order
6
+ *
7
+ */
8
+
9
+ class Sisow_Block_Paymentfee_Order_Totals_Fee extends Mage_Sales_Block_Order_Totals
10
+ {
11
+
12
+ /**
13
+ * Initialize order totals array
14
+ *
15
+ * @return Mage_Sales_Block_Order_Totals
16
+ */
17
+ public function _initTotals()
18
+ {
19
+ parent::_initTotals();
20
+ $payment = $this->getOrder()->getPayment();
21
+ if (substr($payment->getMethod(), 0, 5) != "sisow") {
22
+ return $this;
23
+ }
24
+ $info = $payment->getMethodInstance()->getInfoInstance();
25
+ if (!$info->getAdditionalInformation("invoice_fee")) {
26
+ return $this;
27
+ }
28
+
29
+ return Mage::helper('sisow/paymentfee')->addToBlock($this);
30
+ }
31
+
32
+ }
app/code/local/Sisow/Block/Paymentmethod/Creditcard.php ADDED
@@ -0,0 +1,34 @@
1
+ <?php
2
+ class Sisow_Block_Paymentmethod_CreditCard extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->setTemplate('sisow/checkout/creditcard_form.phtml');
7
+ parent::_construct();
8
+ }
9
+
10
+ /**
11
+ * Loading the avaible issuers
12
+ *
13
+ * @return array
14
+ */
15
+ public function getCctypes()
16
+ {
17
+ $cctypes = array();
18
+
19
+ if(Mage::getStoreConfig('payment/sisow_creditcard/choose_cc_type'))
20
+ {
21
+ $cctypes['visa'] = 'Visa';
22
+ $cctypes['mastercard'] = 'MasterCard';
23
+ $cctypes['maestro'] = 'Maestro';
24
+ }
25
+
26
+ return $cctypes;
27
+ }
28
+
29
+ public function getFee()
30
+ {
31
+ return $this->getMethod()->getFeeArray();
32
+ }
33
+ }
34
+ ?>
app/code/local/Sisow/Block/Paymentmethod/Default.php ADDED
@@ -0,0 +1,15 @@
1
+ <?php
2
+ class Sisow_Block_Paymentmethod_Default extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->setTemplate('sisow/checkout/default_form.phtml');
7
+ parent::_construct();
8
+ }
9
+
10
+ public function getFee()
11
+ {
12
+ return $this->getMethod()->getFeeArray();
13
+ }
14
+ }
15
+ ?>
app/code/local/Sisow/Block/Paymentmethod/DefaultInfo.php ADDED
@@ -0,0 +1,49 @@
1
+ <?php
2
+ class Sisow_Block_Paymentmethod_DefaultInfo extends Mage_Payment_Block_Info
3
+ {
4
+ /**
5
+ * Constructor. Set template.
6
+ */
7
+ protected function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->setTemplate('sisow/checkout/default_info.phtml');
11
+ }
12
+
13
+ /**
14
+ * Returns code of payment method
15
+ *
16
+ * @return string
17
+ */
18
+ public function getMethodCode()
19
+ {
20
+ return $this->getInfo()->getMethodInstance()->getCode();
21
+ }
22
+
23
+ /**
24
+ * Returns the payment fee
25
+ *
26
+ * @return array
27
+ */
28
+ public function getFee()
29
+ {
30
+ if( Mage::getSingleton('core/session')->getSisowFeeInc() )
31
+ $fee_array['incl'] = Mage::getSingleton('core/session')->getSisowFeeInc();
32
+ else
33
+ $fee_array = $this->getMethod()->getFeeArray();
34
+
35
+ return $fee_array;
36
+ }
37
+
38
+ public function _getAdditionalInfo()
39
+ {
40
+ $info = $this->getInfo()->getMethodInstance()->getInfoInstance();
41
+ $a_info = array();
42
+ $a_info['consumerName'] = $info->getAdditionalInformation('consumerName');
43
+ $a_info['consumerIban'] = $info->getAdditionalInformation('consumerIban');
44
+ $a_info['consumerBic'] = $info->getAdditionalInformation('consumerBic');
45
+ $a_info['trxid'] = $info->getAdditionalInformation('trxId');
46
+
47
+ return $a_info;
48
+ }
49
+ }
app/code/local/Sisow/Block/Paymentmethod/Ideal.php ADDED
@@ -0,0 +1,27 @@
1
+ <?php
2
+ class Sisow_Block_Paymentmethod_Ideal extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->setTemplate('sisow/checkout/ideal_form.phtml');
7
+ parent::_construct();
8
+ }
9
+
10
+ /**
11
+ * Loading the avaible issuers
12
+ *
13
+ * @return array
14
+ */
15
+ public function getIssuers()
16
+ {
17
+ $issuers = '';
18
+ Mage::getModel('sisow/base')->DirectoryRequest($issuers, false, (boolean)Mage::getStoreConfig('payment/sisow_ideal/testmode'));
19
+ return $issuers;
20
+ }
21
+
22
+ public function getFee()
23
+ {
24
+ return $this->getMethod()->getFeeArray();
25
+ }
26
+ }
27
+ ?>
app/code/local/Sisow/Block/Paymentmethod/IdealInfo.php ADDED
@@ -0,0 +1,48 @@
1
+ <?php
2
+ class Sisow_Block_Paymentmethod_IdealInfo extends Mage_Payment_Block_Info
3
+ {
4
+ /**
5
+ * Constructor. Set template.
6
+ */
7
+ protected function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->setTemplate('sisow/checkout/ideal_info.phtml');
11
+ }
12
+
13
+ /**
14
+ * Returns code of payment method
15
+ *
16
+ * @return string
17
+ */
18
+ public function getMethodCode()
19
+ {
20
+ return $this->getInfo()->getMethodInstance()->getCode();
21
+ }
22
+
23
+ /**
24
+ * Returns the payment fee
25
+ *
26
+ * @return array
27
+ */
28
+ public function getFee()
29
+ {
30
+ if( Mage::getSingleton('core/session')->getSisowFeeInc() )
31
+ $fee_array['incl'] = Mage::getSingleton('core/session')->getSisowFeeInc();
32
+ else
33
+ $fee_array = $this->getMethod()->getFeeArray();
34
+
35
+ return $fee_array;
36
+ }
37
+
38
+ public function _getAdditionalInfo()
39
+ {
40
+ $info = $this->getInfo()->getMethodInstance()->getInfoInstance();
41
+ $customer = array();
42
+ $customer['consumerName'] = $info->getAdditionalInformation('consumerName');
43
+ $customer['consumerIban'] = $info->getAdditionalInformation('consumerIban');
44
+ $customer['consumerBic'] = $info->getAdditionalInformation('consumerBic');
45
+
46
+ return $customer;
47
+ }
48
+ }
app/code/local/Sisow/Block/Paymentmethod/Klarna.php ADDED
@@ -0,0 +1,66 @@
1
+ <?php
2
+ class Sisow_Block_Paymentmethod_Klarna extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->setTemplate('sisow/checkout/klarna_form.phtml');
7
+ parent::_construct();
8
+ }
9
+
10
+ public function getFee()
11
+ {
12
+ return $this->getMethod()->getFeeArray();
13
+ }
14
+
15
+ public function getPhone() {
16
+ return $this->getMethod()->getPhone();
17
+ }
18
+
19
+ public function getDates()
20
+ {
21
+ $days = array();
22
+
23
+ for($i=1;$i<32;$i++)
24
+ $days[sprintf("%02d", $i)] = sprintf("%02d", $i);
25
+
26
+ return $days;
27
+ }
28
+
29
+ public function GetCountryIso()
30
+ {
31
+ return $this->GetQuote()->getBillingAddress()->getCountryId();
32
+ }
33
+
34
+ public function getMonths()
35
+ {
36
+ $months = array();
37
+ $months['01'] = $this->__('January');
38
+ $months['02'] = $this->__('February');
39
+ $months['03'] = $this->__('March');
40
+ $months['04'] = $this->__('April');
41
+ $months['05'] = $this->__('May');
42
+ $months['06'] = $this->__('June');
43
+ $months['07'] = $this->__('July');
44
+ $months['08'] = $this->__('August');
45
+ $months['09'] = $this->__('September');
46
+ $months['10'] = $this->__('October');
47
+ $months['11'] = $this->__('November');
48
+ $months['12'] = $this->__('December');
49
+ return $months;
50
+ }
51
+
52
+ public function getYears()
53
+ {
54
+ $year = array();
55
+ for($i=(date("Y")-15);$i>(date("Y")-115);$i--)
56
+ $year[$i] = $i;
57
+
58
+ return $year;
59
+ }
60
+
61
+ private function GetQuote()
62
+ {
63
+ return Mage::getSingleton('checkout/session')->getQuote();
64
+ }
65
+ }
66
+ ?>
app/code/local/Sisow/Block/Paymentmethod/Klarnaacc.php ADDED
@@ -0,0 +1,76 @@
1
+ <?php
2
+ class Sisow_Block_Paymentmethod_Klarnaacc extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->setTemplate('sisow/checkout/klarnaacc_form.phtml');
7
+ parent::_construct();
8
+ }
9
+
10
+ public function getFee()
11
+ {
12
+ return $this->getMethod()->getFeeArray();
13
+ }
14
+
15
+ public function getPhone() {
16
+ return $this->getMethod()->getPhone();
17
+ }
18
+
19
+ public function getDates()
20
+ {
21
+ $days = array();
22
+
23
+ for($i=1;$i<32;$i++)
24
+ $days[sprintf("%02d", $i)] = sprintf("%02d", $i);
25
+
26
+ return $days;
27
+ }
28
+
29
+ public function GetCountryIso()
30
+ {
31
+ return $this->GetQuote()->getBillingAddress()->getCountryId();
32
+ }
33
+
34
+ public function getMonths()
35
+ {
36
+ $months = array();
37
+ $months['01'] = $this->__('January');
38
+ $months['02'] = $this->__('February');
39
+ $months['03'] = $this->__('March');
40
+ $months['04'] = $this->__('April');
41
+ $months['05'] = $this->__('May');
42
+ $months['06'] = $this->__('June');
43
+ $months['07'] = $this->__('July');
44
+ $months['08'] = $this->__('August');
45
+ $months['09'] = $this->__('September');
46
+ $months['10'] = $this->__('October');
47
+ $months['11'] = $this->__('November');
48
+ $months['12'] = $this->__('December');
49
+ return $months;
50
+ }
51
+
52
+ public function getYears()
53
+ {
54
+ $year = array();
55
+ for($i=(date("Y")-15);$i>(date("Y")-115);$i--)
56
+ $year[$i] = $i;
57
+
58
+ return $year;
59
+ }
60
+
61
+ public function getMonthly()
62
+ {
63
+ return $this->getMethod()->getMonthly();
64
+ }
65
+
66
+ public function getPclass()
67
+ {
68
+ return $this->getMethod()->getPclass();
69
+ }
70
+
71
+ private function GetQuote()
72
+ {
73
+ return Mage::getSingleton('checkout/session')->getQuote();
74
+ }
75
+ }
76
+ ?>
app/code/local/Sisow/Block/Paymentmethod/Overboeking.php ADDED
@@ -0,0 +1,15 @@
1
+ <?php
2
+ class Sisow_Block_Paymentmethod_Overboeking extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->setTemplate('sisow/checkout/overboeking_form.phtml');
7
+ parent::_construct();
8
+ }
9
+
10
+ public function getFee()
11
+ {
12
+ return $this->getMethod()->getFeeArray();
13
+ }
14
+ }
15
+ ?>
app/code/local/Sisow/Block/Redirect.php ADDED
@@ -0,0 +1,427 @@
1
+ <?php
2
+ class Sisow_Block_Redirect extends Mage_Core_Block_Abstract
3
+ {
4
+ /**
5
+ * Get checkout session namespace
6
+ *
7
+ * @return Mage_Checkout_Model_Session
8
+ */
9
+ private function getCheckout()
10
+ {
11
+ return Mage::getSingleton('checkout/session');
12
+ }
13
+
14
+ /**
15
+ * Get current quote
16
+ *
17
+ * @return Mage_Sales_Model_Quote
18
+ */
19
+ private function getQuote()
20
+ {
21
+ return $this->getCheckout()->getQuote();
22
+ }
23
+
24
+ protected function _toHtml()
25
+ {
26
+ $orderIncrementId = $this->getCheckout()->getLastRealOrderId();
27
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
28
+ $method = (isset($_GET['method'])) ? $_GET['method'] : '';
29
+
30
+ if($orderIncrementId == '')
31
+ {
32
+ header('Location: '. Mage::getUrl('checkout/cart'));
33
+ exit;
34
+ }
35
+
36
+ $billto = $order->getBillingAddress();
37
+ if (!$billto) {
38
+ $billto = $this->getQuote()->getBillingAddress();
39
+ }
40
+ $shipto = $order->getShippingAddress();
41
+ if (!$shipto) {
42
+ $shipto = $this->getQuote()->getShippingAddress();
43
+ if (!$shipto) {
44
+ $shipto = $billto;
45
+ }
46
+ }
47
+
48
+ $arg = array();
49
+ //shipping address
50
+ $arg['shipping_firstname'] = $shipto->getFirstname();
51
+ $arg['shipping_lastname'] = $shipto->getLastname();
52
+ $arg['shipping_mail'] = $shipto->getEmail();
53
+ $arg['shipping_company'] = $shipto->getCompany();
54
+ $arg['shipping_address1'] = $shipto->getStreet1();
55
+ $arg['shipping_address2'] = $shipto->getStreet2();
56
+ $arg['shipping_zip'] = $shipto->getPostcode();
57
+ $arg['shipping_city'] = $shipto->getCity();
58
+ //$arg['shipping_country'] = $shipto;
59
+ $arg['shipping_countrycode'] = $shipto->getCountry();
60
+ $arg['shipping_phone'] = (isset($_GET['phone']) && $_GET['phone'] != '') ? $_GET['phone'] : $shipto->getTelephone();
61
+
62
+ //billing address
63
+ $arg['billing_firstname'] = $billto->getFirstname();
64
+ $arg['billing_lastname'] = $billto->getLastname();
65
+ $arg['billing_mail'] = $billto->getEmail();
66
+ $arg['billing_company'] = $billto->getCompany();
67
+ $arg['billing_address1'] = $billto->getStreet1();
68
+ $arg['billing_address2'] = $billto->getStreet2();
69
+ $arg['billing_zip'] = $billto->getPostcode();
70
+ $arg['billing_city'] = $billto->getCity();
71
+ //$arg['billing_country'] = $order->getBillingAddress()->;
72
+ $arg['billing_countrycode'] = $billto->getCountry();
73
+ $arg['billing_phone'] = (isset($_GET['phone']) && $_GET['phone'] != '') ? $_GET['phone'] : $billto->getTelephone();
74
+
75
+ $i = 0;
76
+ foreach($order->getAllVisibleItems() as $item)
77
+ {
78
+ $i++;
79
+ $arg['product_id_' . $i] = $item->getSku();
80
+ $arg['product_description_' . $i] = $item->getName();
81
+ $arg['product_quantity_' . $i] = (int)($item->getQtyOrdered() ? $item->getQtyOrdered() : $item->getQty());
82
+ $arg['product_tax_' . $i] = round($item->getTaxAmount() * 100, 0);
83
+ $arg['product_taxrate_' . $i] = round($item->getTaxPercent() * 100, 0);
84
+ $arg['product_netprice_' . $i] = round($item->getPrice() * 100, 0);
85
+ $arg['product_price_' . $i] = round($item->getPriceInclTax() * 100, 0);
86
+ $arg['product_nettotal_' . $i] = round($item->getRowTotal() * 100, 0);
87
+ $arg['product_total_' . $i] = round($item->getRowTotalInclTax() * 100, 0);
88
+ }
89
+
90
+ $shipping = $order->getShippingAmount();
91
+ if ($shipping > 0) {
92
+ $i++;
93
+ $shiptax = $shipping + $order->getShippingTaxAmount();
94
+ $arg['product_id_' . $i] = 'shipping';
95
+ $arg['product_description_' . $i] = 'Verzendkosten';
96
+ $arg['product_quantity_' . $i] = 1;
97
+ $arg['product_weight_' . $i] = 0;
98
+ $arg['product_tax_' . $i] = round($order->getShippingTaxAmount() * 100, 0);
99
+ $arg['product_taxrate_' . $i] = round($this->_getShippingTaxRate($order) * 100, 0);
100
+ $arg['product_netprice_' . $i] = round($shipping * 100, 0);
101
+ $arg['product_price_' . $i] = round($shiptax * 100, 0);
102
+ $arg['product_nettotal_' . $i] = round($shipping * 100, 0);
103
+ $arg['product_total_' . $i] = round($shiptax * 100, 0);
104
+ }
105
+
106
+ $fee = Mage::helper('sisow/paymentfee')->getPaymentFeeArray('sisow_'.$method, $this->getQuote());
107
+
108
+ if (is_array($fee) && $fee['incl'] > 0) {
109
+ $i++;
110
+ $arg['product_id_' . $i] = 'paymentfee';
111
+ $arg['product_description_' . $i] = Mage::getStoreConfig('payment/sisow_'.$method.'/payment_fee_label'); //'Payment Fee';
112
+ $arg['product_quantity_' . $i] = 1;
113
+ $arg['product_weight_' . $i] = 0;
114
+ $arg['product_tax_' . $i] = round($fee['taxamount'] * 100, 0);
115
+ $arg['product_taxrate_' . $i] = round($fee['rate'] * 100, 0);
116
+ $arg['product_netprice_' . $i] = round($fee['excl'] * 100, 0);
117
+ $arg['product_price_' . $i] = round(($fee['incl']) * 100, 0);
118
+ $arg['product_nettotal_' . $i] = round($fee['excl'] * 100, 0);
119
+ $arg['product_total_' . $i] = round(($fee['incl']) * 100, 0);
120
+ }
121
+
122
+ $giftCardsAmount = $order->getGiftCardsAmount();
123
+ if ($giftCardsAmount > 0) {
124
+ $i++;
125
+ $giftCardsAmount = -1 * $giftCardsAmount;
126
+ $arg['product_id_' . $i] = 'giftcard';
127
+ $arg['product_description_' . $i] = 'Gift Card';
128
+ $arg['product_quantity_' . $i] = 1;
129
+ $arg['product_weight_' . $i] = 0;
130
+ $arg['product_tax_' . $i] = round(0 * 100, 0);
131
+ $arg['product_taxrate_' . $i] = round(0 * 100, 0);
132
+ $arg['product_netprice_' . $i] = round($giftCardsAmount * 100, 0);
133
+ $arg['product_price_' . $i] = round($giftCardsAmount * 100, 0);
134
+ $arg['product_nettotal_' . $i] = round($giftCardsAmount * 100, 0);
135
+ $arg['product_total_' . $i] = round($giftCardsAmount * 100, 0);
136
+ }
137
+
138
+ $customerBalance = $order->getCustomerBalanceAmount();
139
+ if ($customerBalance > 0) {
140
+ $i++;
141
+ $customerBalance = -1 * $customerBalance;
142
+ $arg['product_id_' . $i] = 'storecredit';
143
+ $arg['product_description_' . $i] = 'Store Credit';
144
+ $arg['product_quantity_' . $i] = 1;
145
+ $arg['product_weight_' . $i] = 0;
146
+ $arg['product_tax_' . $i] = round(0 * 100, 0);
147
+ $arg['product_taxrate_' . $i] = round(0 * 100, 0);
148
+ $arg['product_netprice_' . $i] = round($customerBalance * 100, 0);
149
+ $arg['product_price_' . $i] = round($customerBalance * 100, 0);
150
+ $arg['product_nettotal_' . $i] = round($customerBalance * 100, 0);
151
+ $arg['product_total_' . $i] = round($customerBalance * 100, 0);
152
+ }
153
+
154
+ $rewardCurrency = $order->getRewardCurrencyAmount();
155
+ if ($rewardCurrency > 0) {
156
+ $i++;
157
+ $rewardCurrency = -1 * $rewardCurrency;
158
+ $arg['product_id_' . $i] = 'rewardpoints';
159
+ $arg['product_description_' . $i] = 'Reward points';
160
+ $arg['product_quantity_' . $i] = 1;
161
+ $arg['product_weight_' . $i] = 0;
162
+ $arg['product_tax_' . $i] = round(0 * 100, 0);
163
+ $arg['product_taxrate_' . $i] = round(0 * 100, 0);
164
+ $arg['product_netprice_' . $i] = round($rewardCurrency * 100, 0);
165
+ $arg['product_price_' . $i] = round($rewardCurrency * 100, 0);
166
+ $arg['product_nettotal_' . $i] = round($rewardCurrency * 100, 0);
167
+ $arg['product_total_' . $i] = round($rewardCurrency * 100, 0);
168
+ }
169
+
170
+ $discount = $order->getDiscountAmount();
171
+ if ($discount && $discount < 0) {
172
+ $i++;
173
+
174
+ $code = $order->getDiscountDescription();
175
+ $title = Mage::helper('sales')->__('Discount (%s)', $code);
176
+
177
+ $arg['product_id_' . $i] = 'discount';
178
+ $arg['product_description_' . $i] = $title;
179
+ $arg['product_quantity_' . $i] = 1;
180
+ $arg['product_weight_' . $i] = 0;
181
+ $arg['product_tax_' . $i] = round(0 * 100, 0);
182
+ $arg['product_taxrate_' . $i] = round(0 * 100, 0);
183
+ $arg['product_netprice_' . $i] = round($discount * 100, 0);
184
+ $arg['product_price_' . $i] = round($discount * 100, 0);
185
+ $arg['product_nettotal_' . $i] = round($discount * 100, 0);
186
+ $arg['product_total_' . $i] = round($discount * 100, 0);
187
+ }
188
+
189
+ //additional customer information
190
+ $arg['customer'] = $order->getBillingAddress()->getCustomerId();
191
+ if(isset($_GET['gender']))
192
+ $arg['gender'] = $_GET['gender'];
193
+ if(isset($_GET['dob']))
194
+ $arg['birthdate'] = $_GET['dob'];
195
+
196
+ $arg['ipaddress'] = $_SERVER['REMOTE_ADDR'];
197
+
198
+ //Klarna
199
+ if( $method == 'klarna' || $method == 'klarnaacc' )
200
+ {
201
+ $arg['directinvoice'] = (Mage::getStoreConfig('payment/sisow_'.$method.'/sendklarnainvoice') == 3) ? 'true' : 'false';
202
+ $arg['mailinvoice'] = (Mage::getStoreConfig('payment/sisow_'.$method.'/sendklarnainvoice') == 3) ? 'true' : 'false';
203
+
204
+ if($method == 'klarnaacc')
205
+ $arg['pclass'] = $_GET['pclass'];
206
+ }
207
+
208
+ $arg['currency'] = $order->getOrderCurrencyCode();
209
+ $arg['tax'] = round( ($order->getBaseTaxAmount() * 100.0) );
210
+ $arg['weight'] = round( ($order->getWeight() * 100.0) );
211
+ $arg['shipping'] = round( ($order->getBaseShippingAmount() * 100.0) );
212
+
213
+ if($method == 'overboeking')
214
+ {
215
+ $arg['days'] = Mage::getStoreConfig('payment/sisow_'.$method.'/days');
216
+ $arg['including'] = (Mage::getStoreConfig('payment/sisow_'.$method.'/include')) ? 'true' : 'false';
217
+ }
218
+
219
+ //testmode
220
+ $arg['testmode'] = (Mage::getStoreConfig('payment/sisow_'.$method.'/testmode')) ? 'true' : 'false';
221
+
222
+ $base = Mage::getModel('sisow/base');
223
+ $base->shopId = Mage::getStoreConfig('sisow_core/shopid');
224
+
225
+ if(!is_object($base) || $method == '')
226
+ {
227
+ if($method == '')
228
+ Mage::log($orderIncrementId . ': No payment method', null, 'log_sisow.log');
229
+ else
230
+ Mage::log($orderIncrementId . ": Sisow model can't be loaded", null, 'log_sisow.log');
231
+ }
232
+
233
+ $base->payment = $method;
234
+
235
+ if(isset($_GET['issuer']))
236
+ $base->issuerId = $_GET['issuer'];
237
+
238
+ $base->amount = $order->getGrandTotal();
239
+ if ($method == 'overboeking') {
240
+ $base->purchaseId = $order->getCustomerId() . $orderIncrementId;
241
+ $base->entranceCode = $orderIncrementId;
242
+ }
243
+ else
244
+ $base->purchaseId = $orderIncrementId;
245
+ $base->description = $orderIncrementId;
246
+ $base->notifyUrl = Mage::getUrl('sisow/checkout/notify', array('_secure' => true));
247
+ $base->returnUrl = Mage::getUrl('sisow/checkout/return', array('_secure' => true));
248
+
249
+ if(($ex = $base->TransactionRequest($arg)) < 0)
250
+ {
251
+ Mage::log($orderIncrementId . ': Sisow TransactionRequest failed('.$ex.', '.$base->errorCode.', '.$base->errorMessage.')', null, 'log_sisow.log');
252
+
253
+ if( ($base->payment == 'klarna' || $base->payment == 'klarnaacc') && $base->errorMessage != '')
254
+ Mage::getSingleton('checkout/session')->addError($base->errorMessage);
255
+ else
256
+ Mage::getSingleton('checkout/session')->addError("Sisow: " . $this->__('No communication')." (". $ex .", ". $base->errorCode . ")");
257
+ $order->cancel();
258
+ $order->save();
259
+
260
+ $url = Mage::getUrl('checkout/cart');
261
+ header('Location: ' . $url);
262
+ exit;
263
+ }
264
+ else
265
+ {
266
+ $transaction_closed = false;
267
+ $transaction_type = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
268
+
269
+ if(Mage::helper("sisow")->GetNewMailConfig("sisow_".$method) == "after_confirmation")
270
+ $order->sendNewOrderEmail();
271
+
272
+ if($base->payment == 'overboeking')
273
+ {
274
+ $payment = $order->getPayment();
275
+ $comm = 'Sisow OverBoeking created.<br />';
276
+ $comm .= 'Transaction ID: ' . $base->trxId . '<br/>';
277
+ $st = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
278
+ $payment->setAdditionalInformation('trxId', $base->trxId)
279
+ ->setAdditionalInformation('documentId', $base->documentId)
280
+ ->setAdditionalInformation('linkPdf', $base->GetLink(''))
281
+ ->save();
282
+ $order->setState($st, $st, $comm);
283
+ $order->save();
284
+
285
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
286
+ $url = Mage::getUrl("sisow/checkout/success");
287
+ }
288
+ else if($base->payment == 'klarna' || $base->payment == 'klarnaacc')
289
+ {
290
+ $title = ($base->payment == 'klarna') ? 'Sisow Klarna Factuur' : 'Sisow Klarna Account';
291
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
292
+ $payment = $order->getPayment();
293
+
294
+ if ($base->pendingKlarna)
295
+ {
296
+ $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
297
+ $comm = $title.' Pending.<br />';
298
+ $comm .= 'Transaction ID: ' . $base->trxId . '<br/>';
299
+ if (is_array($fee) && $fee['incl'] > 0) {
300
+ $comm .= $title.' payment fee ' . $fee['incl'] . '<br />';
301
+ }
302
+ if ($method == 'klarnaacc' && $_GET['sisow_monthly']) {
303
+ $comm .= $title.' monthly ' . round($_GET['sisow_monthly'] / 100.0, 2) . '<br/>';
304
+ }
305
+ $st = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
306
+ $payment->setAdditionalInformation('trxId', $base->trxId)->save();
307
+
308
+ $transaction_closed = false;
309
+ $transaction_type = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
310
+ }
311
+ else if ($base->invoiceNo)
312
+ {
313
+ $comm = $title.' invoice created.<br/>';
314
+ $comm .= 'Transaction ID: ' . $base->trxId . '<br/>';
315
+
316
+ if ($method == 'klarnaacc' && $_GET['sisow_monthly']) {
317
+ $comm .= $title.' monthly ' . round($_GET['sisow_monthly'] / 100.0, 2) . '<br/>';
318
+ }
319
+ $comm .= $title.' invoiceNo ' . $base->invoiceNo . '<br/>';
320
+
321
+ $st = Mage::getStoreConfig('sisow_core/status_success');
322
+ if (!$st) {
323
+ $st = Mage_Sales_Model_Order::STATE_PROCESSING;
324
+ }
325
+
326
+ $payment->setAdditionalInformation('trxId', $base->trxId)
327
+ ->setAdditionalInformation('invoiceNo', $base->invoiceNo)
328
+ ->setAdditionalInformation('documentId', $base->documentId)
329
+ ->setAdditionalInformation('linkPdf', $base->GetLink(''))
330
+ ->save();
331
+
332
+ $transaction_closed = true;
333
+ $transaction_type = Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE;
334
+ }
335
+ else
336
+ {
337
+ $comm = $text.' reservation created.<br />';
338
+ $comm .= 'Transaction ID: ' . $base->trxId . '<br/>';
339
+ if (is_array($fee) && $fee['incl'] > 0) {
340
+ $comm .= $text.' payment fee ' . $fee['incl'] . '<br />';
341
+ }
342
+ if ($method == 'klarnaacc' && $_GET['sisow_monthly']) {
343
+ $comm .= $text.' monthly ' . round($_GET['sisow_monthly'] / 100.0, 2) . '<br/>';
344
+ }
345
+ $st = Mage::getStoreConfig('sisow_core/status_success');
346
+ if (!$st) {
347
+ $st = Mage_Sales_Model_Order::STATE_PROCESSING;
348
+ }
349
+ $payment->setAdditionalInformation('trxId', $base->trxId)
350
+ ->save();
351
+
352
+ $transaction_closed = true;
353
+ $transaction_type = Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE;
354
+ }
355
+
356
+ $order->setState($state, $st, $comm);
357
+ $order->save();
358
+ $url = Mage::getUrl("sisow/checkout/success");
359
+ }
360
+ else
361
+ {
362
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
363
+ $url = $base->issuerUrl;
364
+ }
365
+
366
+ if(isset($base->trxId) && $base->trxId != '')
367
+ {
368
+ $order->getPayment()->setAdditionalInformation('trxId', $base->trxId)->save();
369
+
370
+ $transaction = Mage::getModel('sales/order_payment')
371
+ ->setMethod('sisow_'.$method)
372
+ ->setTransactionId($base->trxId)
373
+ ->setIsTransactionClosed($transaction_closed);
374
+
375
+ $order->setPayment($transaction);
376
+ $transaction->addTransaction($transaction_type);
377
+ }
378
+
379
+ if($method == 'klarna' || $method == 'klarnaacc')
380
+ {
381
+ $mail = (Mage::getStoreConfig('payment/'.$payment->getMethod().'/autoinvoice') > 0) ? Mage::getStoreConfig('payment/'.$payment->getMethod().'/autoinvoice') : Mage::getStoreConfig('sisow_core/autoinvoice');
382
+ if($mail > 1)
383
+ {
384
+ if ($order->canInvoice()) {
385
+ $invoice = $order->prepareInvoice();
386
+ $invoice->register()->capture();
387
+ $invoice->setTransactionId($trxid);
388
+ Mage::getModel('core/resource_transaction')
389
+ ->addObject($invoice)
390
+ ->addObject($invoice->getOrder())
391
+ ->save();
392
+
393
+ if ($mail == 3) {
394
+ $invoice->sendEmail();
395
+ $invoice->setEmailSent(true);
396
+ }
397
+ $invoice->save();
398
+ }
399
+ }
400
+ }
401
+
402
+ $order->save();
403
+ header('Location: ' . $url);
404
+ exit;
405
+ }
406
+ }
407
+
408
+ private function _getShippingTaxRate($order)
409
+ {
410
+ // Load the customer so we can retrevice the correct tax class id
411
+ $customer = Mage::getModel('customer/customer')
412
+ ->load($order->getCustomerId());
413
+ $taxClass = Mage::getStoreConfig(
414
+ 'tax/classes/shipping_tax_class',
415
+ $order->getStoreId()
416
+ );
417
+ $calculation = Mage::getSingleton('tax/calculation');
418
+ $request = $calculation->getRateRequest(
419
+ $order->getShippingAddress(),
420
+ $order->getBillingAddress(),
421
+ $customer->getTaxClassId(),
422
+ Mage::app()->getStore($order->getStoreId())
423
+ );
424
+ return $calculation->getRate($request->setProductClassId($taxClass));
425
+ }
426
+ }
427
+ ?>
app/code/local/Sisow/Helper/Data.php ADDED
@@ -0,0 +1,14 @@
1
+ <?php
2
+ class Sisow_Helper_Data extends Mage_Payment_Helper_Data
3
+ {
4
+ public function GetNewMailConfig($method)
5
+ {
6
+ $config = Mage::getStoreConfig('payment/'.$method.'/newordermail');
7
+
8
+ if($config == "general")
9
+ return Mage::getStoreConfig('sisow_core/newordermail');
10
+ else
11
+ return $config;
12
+ }
13
+ }
14
+ ?>
app/code/local/Sisow/Helper/Paymentfee.php ADDED
@@ -0,0 +1,172 @@
1
+ <?php
2
+ class Sisow_Helper_Paymentfee extends Mage_Payment_Helper_Data
3
+ {
4
+ /**
5
+ * getPaymentFeeAmount
6
+ * Return string value payment fee inlcuding tax
7
+ * @return string
8
+ */
9
+ public function getPaymentFeeArray($paymentcode, $quote)
10
+ {
11
+ $inctax = Mage::getStoreConfig('payment/'.$paymentcode.'/payment_fee_inc_ex');
12
+ $paymentfee = Mage::getStoreConfig('payment/'.$paymentcode.'/payment_fee');
13
+ $paymentfee_taxclass = Mage::getStoreConfig('payment/'.$paymentcode.'/payment_fee_tax');
14
+
15
+ if($paymentfee == '')
16
+ {
17
+ Mage::getSingleton('core/session')->setSisowFeeInc(0);
18
+ return;
19
+ }
20
+
21
+ if( Mage::getSingleton('core/session')->getSisowTotal() > 0)
22
+ {
23
+ if( $quote->getGrandTotal() > 0 && Mage::getSingleton('core/session')->getSisowTotal() <> $quote->getGrandTotal() )
24
+ {
25
+ Mage::getSingleton('core/session')->setSisowTotal($quote->getGrandTotal());
26
+ $order_total = Mage::getSingleton('core/session')->getSisowTotal();
27
+ }
28
+ $order_total = Mage::getSingleton('core/session')->getSisowTotal();
29
+ }
30
+ else
31
+ {
32
+ Mage::getSingleton('core/session')->setSisowTotal($quote->getGrandTotal());
33
+ $order_total = $quote->getGrandTotal();
34
+ }
35
+
36
+ $charge = 0;
37
+ if(strpos($paymentfee, ';') > 0)
38
+ {
39
+ $fees = explode(";", $paymentfee);
40
+ if($fees[0] > 0)
41
+ $charge += $fees[0];
42
+ else
43
+ $charge += $order_total * (($fees[0] * -1) / 100.0);
44
+
45
+ if($fees[1] > 0)
46
+ $charge += $fees[1];
47
+ else
48
+ $charge += $order_total * (($fees[1] * -1) / 100.0);
49
+ }
50
+ else if ($paymentfee > 0) {
51
+ $charge = $paymentfee;
52
+ } else if ($paymentfee < 0) {
53
+ $charge = $order_total * (($paymentfee * -1) / 100.0);
54
+ }
55
+
56
+ //Get the correct rate to use
57
+ $address = $quote->getShippingAddress();
58
+ $taxClassId = $quote->getCustomerTaxClassId();
59
+
60
+ $store = Mage::app()->getStore();
61
+ $calc = Mage::getSingleton('tax/calculation');
62
+ $rateRequest = $calc->getRateRequest($address, $address, $taxClassId, $store);
63
+ $rateRequest->setProductClassId($paymentfee_taxclass);
64
+ $rate = $calc->getRate($rateRequest);
65
+
66
+ if($inctax == '1')
67
+ {
68
+ $value = $calc->calcTaxAmount($charge, $rate, true, false);
69
+ $excl = ($charge - $value);
70
+ $feeArray = array(
71
+ 'excl' => $excl,
72
+ 'base_excl' => $this->calcBaseValue($excl),
73
+ 'incl' => $charge,
74
+ 'base_incl' => $this->calcBaseValue($charge),
75
+ 'taxamount' => $value,
76
+ 'base_taxamount' => $this->calcBaseValue($value),
77
+ 'rate' => $rate
78
+ );
79
+ }
80
+ else
81
+ {
82
+ //Fee entered without tax
83
+ $value = $calc->calcTaxAmount($charge, $rate, false, false);
84
+ $incl = ($charge + $value);
85
+
86
+ $feeArray = array(
87
+ 'excl' => $charge,
88
+ 'base_excl' => $this->calcBaseValue($charge),
89
+ 'incl' => $incl,
90
+ 'base_incl' => $this->calcBaseValue($incl),
91
+ 'taxamount' => $value,
92
+ 'base_taxamount' => $this->calcBaseValue($value),
93
+ 'rate' => $rate
94
+ );
95
+ }
96
+
97
+ Mage::getSingleton('core/session')->setSisowFeeInc($feeArray['incl']);
98
+
99
+ return $feeArray;
100
+ }
101
+
102
+ public function addToBlock($block)
103
+ {
104
+
105
+ $order = $block->getOrder();
106
+ $info = $order->getPayment()->getMethodInstance()->getInfoInstance();
107
+ $storeId = Mage::app()->getStore()->getId();
108
+ $taxOption = Mage::getStoreConfig("tax/sales_display/shipping", $storeId);
109
+ $country = $order->getShippingAddress()->getCountry();
110
+ //$lang = Mage::helper('klarnaPaymentModule/lang');
111
+ $label = Mage::getStoreConfig('payment/'.$order->getPayment()->getMethod().'/payment_fee_label');
112
+
113
+ $paymentFee = $info->getAdditionalInformation('invoice_fee');
114
+ $basePaymentFee = $info->getAdditionalInformation('base_invoice_fee');
115
+ $paymentFeeExcludingVat = $info->getAdditionalInformation('invoice_fee_exluding_vat');
116
+ $basePaymentFeeExcludingVat = $info->getAdditionalInformation('base_invoice_fee_exluding_vat');
117
+
118
+ /**
119
+ * 1 : Show exluding tax
120
+ * 2 : Show including tax
121
+ * 3 : Show both
122
+ */
123
+
124
+ if (($taxOption === '1') || ($taxOption === '3')) {
125
+ $label = Mage::getStoreConfig('payment/'.$order->getPayment()->getMethod().'/payment_fee_label');
126
+ $fee = new Varien_Object();
127
+ $fee->setCode('invoice_fee_excl');
128
+ if ($taxOption == '3') {
129
+ $label .= ' (Excl.Tax)';
130
+ }
131
+ $fee->setLabel($label);
132
+ $fee->setBaseValue($basePaymentFeeExcludingVat);
133
+ $fee->setValue($paymentFeeExcludingVat);
134
+ $block->addTotalBefore($fee, 'shipping');
135
+ }
136
+ if (($taxOption === '2') || ($taxOption === '3')) {
137
+ $label = Mage::getStoreConfig('payment/'.$order->getPayment()->getMethod().'/payment_fee_label');
138
+ $fee = new Varien_Object();
139
+ $fee->setCode('invoice_fee_incl');
140
+ if ($taxOption == '3') {
141
+ $label .= ' (Incl.Tax)';
142
+ }
143
+ $fee->setLabel($label);
144
+ $fee->setBaseValue($basePaymentFee);
145
+ $fee->setValue($paymentFee);
146
+ $block->addTotalBefore($fee, 'shipping');
147
+ }
148
+
149
+ return $block;
150
+ }
151
+
152
+ /**
153
+ * Try to calculate the value of the payment fee with the base currency
154
+ * of the store if the purchase was done with a different currency.
155
+ *
156
+ * @param float $value value to calculate on
157
+ *
158
+ * @return float
159
+ */
160
+ private function calcBaseValue($value) {
161
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
162
+ $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
163
+
164
+ if ($currentCurrencyCode !== $baseCurrencyCode) {
165
+ $currencyModel = Mage::getModel('directory/currency');
166
+ $currencyRates = $currencyModel->getCurrencyRates($baseCurrencyCode, array($currentCurrencyCode));
167
+ return ($value / $currencyRates[$currentCurrencyCode]);
168
+ }
169
+ return $value;
170
+ }
171
+ }
172
+ ?>
app/code/local/Sisow/Model/Base.php ADDED
@@ -0,0 +1,474 @@
1
+ <?php
2
+ class Sisow_Model_Base extends Mage_Core_Model_Abstract
3
+ {
4
+ public static $issuers; // = null;
5
+ public static $lastcheck; // = 0;
6
+
7
+ private $response;
8
+
9
+ // Merchant data
10
+ private $merchantId;
11
+ private $merchantKey;
12
+
13
+ // Transaction data
14
+ public $shopId;
15
+ public $payment; // empty=iDEAL; sofort=DIRECTebanking; mistercash=MisterCash; ...
16
+ public $issuerId; // mandatory; sisow bank code
17
+ public $purchaseId; // mandatory; max 16 alphanumeric
18
+ public $entranceCode; // max 40 strict alphanumeric (letters and numbers only)
19
+ public $description; // mandatory; max 32 alphanumeric
20
+ public $amount; // mandatory; min 0.45
21
+ public $notifyUrl;
22
+ public $returnUrl; // mandatory
23
+ public $cancelUrl;
24
+ public $callbackUrl;
25
+
26
+ // Status data
27
+ public $status;
28
+ public $timeStamp;
29
+ public $consumerAccount;
30
+ public $consumerIban;
31
+ public $consumerBic;
32
+ public $consumerName;
33
+ public $consumerCity;
34
+ public $active;
35
+
36
+ // Result/check data
37
+ public $trxId;
38
+ public $issuerUrl;
39
+ public $invoiceNo;
40
+ public $documentId;
41
+
42
+ // Klarna Factuur/Account
43
+ public $pendingKlarna;
44
+ public $monthly;
45
+ public $pclass;
46
+ public $intrestRate;
47
+ public $invoiceFee;
48
+ public $months;
49
+ public $startFee;
50
+
51
+ // Error data
52
+ public $errorCode;
53
+ public $errorMessage;
54
+
55
+ // Status
56
+ const statusSuccess = "Success";
57
+ const statusCancelled = "Cancelled";
58
+ const statusExpired = "Expired";
59
+ const statusFailure = "Failure";
60
+ const statusOpen = "Open";
61
+
62
+ /**
63
+ * Init resource model
64
+ */
65
+ protected function _construct()
66
+ {
67
+ //$this->_init('sisow/base');
68
+ $this->merchantId = Mage::getStoreConfig('sisow_core/merchantid');
69
+ $this->merchantKey = Mage::getStoreConfig('sisow_core/merchantkey');
70
+ }
71
+
72
+ /*public function __construct() { //$merchantid, $merchantkey) {
73
+ //$this->merchantId = $merchantid;
74
+ //$this->merchantKey = $merchantkey;
75
+ }*/
76
+
77
+ private function error() {
78
+ $this->errorCode = $this->parse("errorcode");
79
+ $this->errorMessage = urldecode($this->parse("errormessage"));
80
+ }
81
+
82
+ private function parse($search, $xml = false) {
83
+ if ($xml === false) {
84
+ $xml = $this->response;
85
+ }
86
+
87
+ if (($start = strpos($xml, "<" . $search . ">")) === false) {
88
+ return false;
89
+ }
90
+ $start += strlen($search) + 2;
91
+ if (($end = strpos($xml, "</" . $search . ">", $start)) === false) {
92
+ return false;
93
+ }
94
+ return substr($xml, $start, $end - $start);
95
+ }
96
+
97
+ private function send($method, array $keyvalue = NULL, $return = 1) {
98
+ $url = "https://www.sisow.nl/Sisow/iDeal/RestHandler.ashx/" . $method;
99
+ $options = array(
100
+ CURLOPT_POST => 1,
101
+ CURLOPT_HEADER => 0,
102
+ CURLOPT_URL => $url,
103
+ CURLOPT_FRESH_CONNECT => 1,
104
+ CURLOPT_RETURNTRANSFER => $return,
105
+ CURLOPT_FORBID_REUSE => 1,
106
+ CURLOPT_TIMEOUT => 120,
107
+ CURLOPT_SSL_VERIFYPEER => 0,
108
+ CURLOPT_POSTFIELDS => $keyvalue == NULL ? "" : http_build_query($keyvalue, '', '&'));
109
+ $ch = curl_init();
110
+ curl_setopt_array($ch, $options);
111
+ $this->response = curl_exec($ch);
112
+ curl_close($ch);
113
+ if (!$this->response) {
114
+ return false;
115
+ }
116
+ return true;
117
+ }
118
+
119
+ private function getDirectory() {
120
+ $diff = 24 * 60 * 60;
121
+ if (self::$lastcheck)
122
+ $diff = time() - self::$lastcheck;
123
+ if ($diff < 24 * 60 * 60)
124
+ return 0;
125
+ //$this->Report('Magento DirectoryRequest ' . self::$lastcheck);
126
+ if (!$this->send("DirectoryRequest"))
127
+ return -1;
128
+ $search = $this->parse("directory");
129
+ if (!$search) {
130
+ $this->error();
131
+ return -2;
132
+ }
133
+ self::$issuers = array();
134
+ $iss = explode("<issuer>", str_replace("</issuer>", "", $search));
135
+ foreach ($iss as $k => $v) {
136
+ $issuerid = $this->parse("issuerid", $v);
137
+ $issuername = $this->parse("issuername", $v);
138
+ if ($issuerid && $issuername) {
139
+ self::$issuers[$issuerid] = $issuername;
140
+ }
141
+ }
142
+ self::$lastcheck = time();
143
+ //$this->Report('Magento lastcheck ' . self::$lastcheck);
144
+ return 0;
145
+ }
146
+
147
+ // DirectoryRequest
148
+ public function DirectoryRequest(&$output, $select = false, $test = false) {
149
+ if ($test === true) {
150
+ // kan ook via de gateway aangevraagd worden, maar is altijd hetzelfde
151
+ if ($select === true) {
152
+ $output = "<select id=\"sisowbank\" name=\"issuerid\">";
153
+ $output .= "<option value=\"99\">Sisow Bank (test)</option>";
154
+ $output .= "</select>";
155
+ }
156
+ else {
157
+ $output = array("99" => "Sisow Bank (test)");
158
+ }
159
+ return 0;
160
+ }
161
+ $output = false;
162
+ $ex = $this->getDirectory();
163
+ if ($ex < 0) {
164
+ return $ex;
165
+ }
166
+ if ($select === true) {
167
+ $output = "<select id=\"sisowbank\" name=\"issuerid\">";
168
+ }
169
+ else {
170
+ $output = array();
171
+ }
172
+ foreach (Sisow_Model_Base::$issuers as $k => $v) {
173
+ if ($select === true) {
174
+ $output .= "<option value=\"" . $k . "\">" . $v . "</option>";
175
+ }
176
+ else {
177
+ $output[$k] = $v;
178
+ }
179
+ }
180
+ if ($select === true) {
181
+ $output .= "</select>";
182
+ }
183
+ return 0;
184
+ }
185
+
186
+ public function Report($message) {
187
+ if ($message) {
188
+ $arr['message'] = $message;
189
+ $this->send('Report', $arr);
190
+ }
191
+ }
192
+
193
+ // TransactionRequest
194
+ public function TransactionRequest($keyvalue = NULL) {
195
+ if(!isset($this->shopId))
196
+ $this->shopId = "";
197
+
198
+ $this->trxId = $this->issuerUrl = "";
199
+ if (!$this->merchantId)
200
+ return -1;
201
+ if (!$this->merchantKey)
202
+ return -2;
203
+ if (!$this->purchaseId)
204
+ return -3;
205
+ if ($this->amount < 0.45)
206
+ return -4;
207
+ if (!$this->description)
208
+ return -5;
209
+ if (!$this->returnUrl)
210
+ return -6;
211
+ if (!$this->issuerId && !$this->payment)
212
+ return -7;
213
+ if (!$this->entranceCode)
214
+ $this->entranceCode = $this->purchaseId;
215
+ $pars = array();
216
+
217
+ if(strlen($keyvalue['billing_countrycode']) == 2)
218
+ $pars["locale"] = $this->setLocale($keyvalue['billing_countrycode']);
219
+ else
220
+ $pars["locale"] = $this->setLocale("");
221
+
222
+ $pars["merchantid"] = $this->merchantId;
223
+ $pars["payment"] = $this->payment;
224
+ $pars["issuerid"] = $this->issuerId;
225
+ $pars["shopid"] = $this->shopId;
226
+ $pars["purchaseid"] = $this->purchaseId;
227
+ $pars["amount"] = round($this->amount * 100);
228
+ $pars["description"] = $this->description;
229
+ $pars["entrancecode"] = $this->entranceCode;
230
+ $pars["returnurl"] = $this->returnUrl;
231
+ $pars["cancelurl"] = $this->cancelUrl;
232
+ $pars["callbackurl"] = $this->callbackUrl;
233
+ $pars["notifyurl"] = $this->notifyUrl;
234
+ $pars["sha1"] = sha1($this->purchaseId . $this->entranceCode . round($this->amount * 100) . $this->shopId . $this->merchantId . $this->merchantKey);
235
+ if ($keyvalue) {
236
+ foreach ($keyvalue as $k => $v) {
237
+ $pars[$k] = $v;
238
+ }
239
+ }
240
+ if (!$this->send("TransactionRequest", $pars))
241
+ return -8;
242
+ $this->trxId = $this->parse("trxid");
243
+ $this->invoiceNo = $this->parse("invoiceno");
244
+ $this->documentId = $this->parse("documentid");
245
+ $this->sha = $this->parse("sha1");
246
+ $url = $this->parse("issuerurl");
247
+
248
+ /*
249
+ if($this->sha != sha1($this->trxId . '' . $this->merchantId . $this->merchantKey) )
250
+ {
251
+ $this->errorMessage = 'Illegal request';
252
+ return -9;
253
+ }
254
+ */
255
+
256
+ $this->issuerUrl = urldecode($url);
257
+ $this->pendingKlarna = $this->parse("pendingklarna") == "true";
258
+ if (!$this->issuerUrl) {
259
+ $this->error();
260
+ return -9;
261
+ }
262
+ return 0;
263
+ }
264
+
265
+ // StatusRequest
266
+ public function StatusRequest($trxid = false) {
267
+ if(!isset($this->shopId))
268
+ $this->shopId = "";
269
+
270
+ if ($trxid === false)
271
+ $trxid = $this->trxId;
272
+ if (!$this->merchantId)
273
+ return -1;
274
+ if (!$this->merchantKey)
275
+ return -2;
276
+ if (!$trxid)
277
+ return -3;
278
+ $this->trxId = $trxid;
279
+ $pars = array();
280
+ $pars["merchantid"] = $this->merchantId;
281
+ $pars["shopid"] = $this->shopId;
282
+ $pars["trxid"] = $this->trxId;
283
+ $pars["sha1"] = sha1($this->trxId . $this->shopId . $this->merchantId . $this->merchantKey);
284
+ if (!$this->send("StatusRequest", $pars))
285
+ return -4;
286
+ $this->status = $this->parse("status");
287
+ if (!$this->status) {
288
+ $this->error();
289
+ return -5;
290
+ }
291
+ $this->timeStamp = $this->parse("timestamp");
292
+ $this->amount = $this->parse("amount") / 100.0;
293
+ $this->consumerAccount = $this->parse("consumeraccount");
294
+ $this->consumerIban = $this->parse("consumeriban");
295
+ $this->consumerBic = $this->parse("consumerbic");
296
+ $this->consumerName = $this->parse("consumername");
297
+ $this->consumerCity = $this->parse("consumercity");
298
+ $this->purchaseId = $this->parse("purchaseid");
299
+ $this->description = $this->parse("description");
300
+ $this->entranceCode = $this->parse("entrancecode");
301
+ return 0;
302
+ }
303
+
304
+ // checkMerchant
305
+ public function checkMerchant() {
306
+ if (!$this->merchantId)
307
+ return -1;
308
+ if (!$this->merchantKey)
309
+ return -2;
310
+ $pars = array();
311
+ $pars["merchantid"] = $this->merchantId;
312
+ $pars["sha1"] = sha1($this->merchantId . $this->merchantKey);
313
+
314
+ if (!$this->send("CheckMerchantRequest", $pars))
315
+ return -4;
316
+ $this->timeStamp = $this->parse("timestamp");
317
+ $this->active = $this->parse("active");
318
+ return 0;
319
+ }
320
+
321
+ // FetchMonthlyRequest
322
+ public function FetchMonthlyRequest($amt = false) {
323
+ if (!$amt) $amt = round($this->amount * 100);
324
+ else $amt = round($amt * 100);
325
+ $pars = array();
326
+ $pars["merchantid"] = $this->merchantId;
327
+ $pars["amount"] = $amt;
328
+ $pars["sha1"] = sha1($amt . $this->merchantId . $this->merchantKey);
329
+ if (!$this->send("FetchMonthlyRequest", $pars))
330
+ return -1;
331
+ $this->monthly = $this->parse("monthly");
332
+ $this->pclass = $this->parse("pclass");
333
+ $this->intrestRate = $this->parse("intrestRate");
334
+ $this->invoiceFee = $this->parse("invoiceFee");
335
+ $this->months = $this->parse("months");
336
+ $this->startFee = $this->parse("startFee");
337
+ return $this->monthly;
338
+ }
339
+
340
+ // RefundRequest
341
+ public function RefundRequest($trxid) {
342
+ $pars = array();
343
+ $pars["merchantid"] = $this->merchantId;
344
+ $pars["amount"] = round($this->amount * 100.0);
345
+ $pars["trxid"] = $trxid;
346
+ $pars["sha1"] = sha1($trxid . $this->merchantId . $this->merchantKey);
347
+ if (!$this->send("RefundRequest", $pars))
348
+ return -1;
349
+ $id = $this->parse("refundid");
350
+ if (!$id) {
351
+ $this->error();
352
+ return -2;
353
+ }
354
+ return $id;
355
+ }
356
+
357
+ // InvoiceRequest
358
+ public function InvoiceRequest($trxid, $keyvalue = NULL) {
359
+ $pars = array();
360
+ $pars["merchantid"] = $this->merchantId;
361
+ $pars["trxid"] = $trxid;
362
+ $pars["sha1"] = sha1($trxid . $this->merchantId . $this->merchantKey);
363
+ if ($keyvalue) {
364
+ foreach ($keyvalue as $k => $v) {
365
+ $pars[$k] = $v;
366
+ }
367
+ }
368
+ if (!$this->send("InvoiceRequest", $pars))
369
+ return -1;
370
+ $this->invoiceNo = $this->parse("invoiceno");
371
+ if (!$this->invoiceNo) {
372
+ $this->error();
373
+ return -2;
374
+ }
375
+ $this->documentId = $this->parse("documentid");
376
+ return 0; //$this->invoiceNo;
377
+ }
378
+
379
+ // CreditInvoiceRequest
380
+ public function CreditInvoiceRequest($trxid) {
381
+ $pars = array();
382
+ $pars["merchantid"] = $this->merchantId;
383
+ $pars["trxid"] = $trxid;
384
+ $pars["sha1"] = sha1($trxid . $this->merchantId . $this->merchantKey);
385
+ if (!$this->send("CreditInvoiceRequest", $pars))
386
+ return -1;
387
+ $this->invoiceNo = $this->parse("invoiceno");
388
+ if (!$this->invoiceNo) {
389
+ $this->error();
390
+ return -2;
391
+ }
392
+ $this->documentId = $this->parse("documentid");
393
+ return 0; //$this->invoiceNo;
394
+ }
395
+
396
+ // CancelReservationRequest
397
+ public function CancelReservationRequest($trxid) {
398
+ $pars = array();
399
+ $pars["merchantid"] = $this->merchantId;
400
+ $pars["trxid"] = $trxid;
401
+ $pars["sha1"] = sha1($trxid . $this->merchantId . $this->merchantKey);
402
+ if (!$this->send("CancelReservationRequest", $pars))
403
+ return -1;
404
+ return 0;
405
+ }
406
+
407
+ public function GetLink($msg = 'hier', $method = '') {
408
+ if (!$method) {
409
+ if (!$msg)
410
+ $link = 'https://www.sisow.nl/Sisow/Opdrachtgever/download.aspx?merchantid=' .
411
+ $this->merchantId . '&doc=' . $this->documentId . '&sha1=' .
412
+ sha1($this->documentId . $this->merchantId . $this->merchantKey);
413
+ else
414
+ $link = '<a href="https://www.sisow.nl/Sisow/Opdrachtgever/download.aspx?merchantid=' .
415
+ $this->merchantId . '&doc=' . $this->documentId . '&sha1=' .
416
+ sha1($this->documentId . $this->merchantId . $this->merchantKey) . '">' . $msg . '</a>';
417
+ return $link;
418
+ }
419
+ if ($method == 'make') {
420
+ }
421
+ }
422
+
423
+ public function getMerchantId()
424
+ {
425
+ return $this->merchantId;
426
+ }
427
+
428
+ public function getMerchantKey()
429
+ {
430
+ return $this->merchantKey;
431
+ }
432
+
433
+ public function setLocale($countryIso)
434
+ {
435
+ $supported = array("US");
436
+
437
+ switch($this->payment)
438
+ {
439
+ case "paypalec":
440
+ $supported = array('AU','AT','BE','BR','CA','CH','CN','DE','ES','GB','FR','IT','NL','PL','PT','RU','US');
441
+ break;
442
+ case "mistercash":
443
+ $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR');
444
+ break;
445
+ case "creditcard":
446
+ $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR');
447
+ break;
448
+ case "maestro":
449
+ $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR');
450
+ break;
451
+ case "mastercard":
452
+ $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR');
453
+ break;
454
+ case "visa":
455
+ $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR');
456
+ break;
457
+ default:
458
+ return "NL";
459
+ break;
460
+ }
461
+
462
+ $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
463
+ $lang = strtoupper($lang);
464
+
465
+ $lang = (!isset($lang) || $lang == "") ? $countryIso : $lang;
466
+
467
+ if($lang == "")
468
+ return "US";
469
+ if(in_array($lang, $supported))
470
+ return $lang;
471
+ else
472
+ return 'US';
473
+ }
474
+ }
app/code/local/Sisow/Model/Config/Autoinvoice.php ADDED
@@ -0,0 +1,24 @@
1
+ <?php
2
+ /**
3
+ * Used in creating options for config value selection
4
+ *
5
+ */
6
+ class Sisow_Model_Config_Autoinvoice
7
+ {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray()
15
+ {
16
+ return array(
17
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Use General settings')),
18
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('No')),
19
+ array('value' => 2, 'label'=>Mage::helper('adminhtml')->__('Yes')),
20
+ array('value' => 3, 'label' => Mage::helper('adminhtml')->__('Yes') . ' ' . Mage::helper('adminhtml')->__('and send mail'))
21
+ );
22
+ }
23
+
24
+ }
app/code/local/Sisow/Model/Config/GeneralAutoinvoice.php ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+ /**
3
+ * Used in creating options for config value selection
4
+ *
5
+ */
6
+ class Sisow_Model_Config_GeneralAutoinvoice
7
+ {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray()
15
+ {
16
+ return array(
17
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('No')),
18
+ array('value' => 2, 'label'=>Mage::helper('adminhtml')->__('Yes')),
19
+ array('value' => 3, 'label' => Mage::helper('adminhtml')->__('Yes') . ' ' . Mage::helper('adminhtml')->__('and send mail'))
20
+ );
21
+ }
22
+
23
+ }
app/code/local/Sisow/Model/Config/Newordermail.php ADDED
@@ -0,0 +1,24 @@
1
+ <?php
2
+
3
+ class Sisow_Model_Config_Newordermail
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array(
10
+ "value" => "after_confirmation",
11
+ "label" => Mage::helper('adminhtml')->__("After order confirmation")
12
+ ),
13
+ array(
14
+ "value" => "after_notify_with_cancel",
15
+ "label" => Mage::helper('adminhtml')->__("After notification, including cancelled order")
16
+ ),
17
+ array(
18
+ "value" => "after_notify_without_cancel",
19
+ "label" => Mage::helper('adminhtml')->__("After notification, excluding cancelled order")
20
+ )
21
+ );
22
+ }
23
+
24
+ }
app/code/local/Sisow/Model/Config/NewordermailMethod.php ADDED
@@ -0,0 +1,25 @@
1
+ <?php
2
+
3
+ class Sisow_Model_Config_NewordermailMethod
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array('value' => "general", 'label'=>Mage::helper('adminhtml')->__('Use General settings')),
10
+ array(
11
+ "value" => "after_confirmation",
12
+ "label" => Mage::helper('adminhtml')->__("After order confirmation")
13
+ ),
14
+ array(
15
+ "value" => "after_notify_with_cancel",
16
+ "label" => Mage::helper('adminhtml')->__("After notification, including cancelled order")
17
+ ),
18
+ array(
19
+ "value" => "after_notify_without_cancel",
20
+ "label" => Mage::helper('adminhtml')->__("After notification, excluding cancelled order")
21
+ )
22
+ );
23
+ }
24
+
25
+ }
app/code/local/Sisow/Model/Methods/Abstract.php ADDED
@@ -0,0 +1,119 @@
1
+ <?php
2
+ abstract class Sisow_Model_Methods_Abstract extends Mage_Payment_Model_Method_Abstract
3
+ {
4
+ protected $_isGateway = false;
5
+ protected $_canAuthorize = false;
6
+ protected $_canCapture = true;
7
+ protected $_canCapturePartial = false;
8
+ protected $_canRefund = false;
9
+ protected $_canRefundInvoicePartial = false;
10
+ protected $_canVoid = false;
11
+ protected $_canUseInternal = true;
12
+ protected $_canUseCheckout = false;
13
+ protected $_canUseForMultishipping = true;
14
+ protected $_canSaveCc = false;
15
+
16
+ public function getQuote() {
17
+ return $this->getCheckout()->getQuote();
18
+ }
19
+
20
+ public function getCheckout() {
21
+ return Mage::getSingleton('checkout/session');
22
+ }
23
+
24
+ public function getOrderPlaceRedirectUrl()
25
+ {
26
+ $issuer = $_POST['payment']['sisow_issuer'];
27
+
28
+ /*
29
+ * Redirect to Sisow
30
+ * method = paymentcode from Sisow
31
+ * additional params (fields from the checkout page)
32
+ */
33
+ $url = Mage::getUrl('sisow/checkout/redirect/', array('_secure' => true));
34
+ if (!strpos($url, "?")) $url .= '?';
35
+ else $url .= '&';
36
+ $url .= 'method='.$this->_paymentcode;
37
+ return $url;
38
+ }
39
+
40
+ public function getFeeArray()
41
+ {
42
+ return Mage::helper('sisow/Paymentfee')->getPaymentFeeArray($this->_code, $this->getQuote());
43
+ }
44
+
45
+ public function capture(Varien_Object $payment, $amount)
46
+ {
47
+ return $this;
48
+ }
49
+
50
+ /**
51
+ * Refund a capture transaction
52
+ *
53
+ * @param Varien_Object $payment
54
+ * @param float $amount
55
+ */
56
+ public function refund(Varien_Object $payment, $amount)
57
+ {
58
+ $trxid = $this->_getParentTransactionId($payment);
59
+
60
+ if($trxid)
61
+ {
62
+ $base = Mage::getModel('sisow/base');
63
+ $base->amount = $amount;
64
+ if(($ex = $base->RefundRequest($trxid)) < 0)
65
+ {
66
+ Mage::log($trxid . ': Sisow RefundRequest failed('.$ex.', '.$base->errorCode.', '.$base->errorMessage.')', null, 'log_sisow.log');