ING_KassaCompleet - Version 1.0.3

Version Notes

ING Kassa Compleet-Magento Extension for iDEAL, Banktransfer and Creditcard
====================

# Changelog #

## Changes in version 1.0.0
+ Initial version based upon Ginger Payments version

## Changes in version 1.0.1
+ Updated the README.md

## Changes in version 1.0.2
+ Handle banktransfer correctly

## Changes in version 1.0.3
+ Added version to the webhook
+ Added cash on delivery

Download this release

Release Info

Developer ING
Extension ING_KassaCompleet
Version 1.0.3
Comparing to
See all releases


Version 1.0.3

Files changed (41) hide show
  1. app/code/community/ING/KassaCompleet/Block/Payment/Banktransfer/Form.php +31 -0
  2. app/code/community/ING/KassaCompleet/Block/Payment/Banktransfer/Info.php +57 -0
  3. app/code/community/ING/KassaCompleet/Block/Payment/Cashondelivery/Form.php +31 -0
  4. app/code/community/ING/KassaCompleet/Block/Payment/Cashondelivery/Info.php +57 -0
  5. app/code/community/ING/KassaCompleet/Block/Payment/Ideal/Form.php +31 -0
  6. app/code/community/ING/KassaCompleet/Block/Payment/Ideal/Info.php +24 -0
  7. app/code/community/ING/KassaCompleet/Helper/Banktransfer.php +138 -0
  8. app/code/community/ING/KassaCompleet/Helper/Cashondelivery.php +135 -0
  9. app/code/community/ING/KassaCompleet/Helper/Creditcard.php +129 -0
  10. app/code/community/ING/KassaCompleet/Helper/Data.php +78 -0
  11. app/code/community/ING/KassaCompleet/Helper/Ideal.php +152 -0
  12. app/code/community/ING/KassaCompleet/Model/Banktransfer.php +139 -0
  13. app/code/community/ING/KassaCompleet/Model/Cashondelivery.php +135 -0
  14. app/code/community/ING/KassaCompleet/Model/Creditcard.php +118 -0
  15. app/code/community/ING/KassaCompleet/Model/Ideal.php +143 -0
  16. app/code/community/ING/KassaCompleet/Model/Observer.php +38 -0
  17. app/code/community/ING/KassaCompleet/controllers/BanktransferController.php +226 -0
  18. app/code/community/ING/KassaCompleet/controllers/CashondeliveryController.php +222 -0
  19. app/code/community/ING/KassaCompleet/controllers/CreditcardController.php +230 -0
  20. app/code/community/ING/KassaCompleet/controllers/IdealController.php +335 -0
  21. app/code/community/ING/KassaCompleet/etc/adminhtml.xml +42 -0
  22. app/code/community/ING/KassaCompleet/etc/config.xml +198 -0
  23. app/code/community/ING/KassaCompleet/etc/system.xml +400 -0
  24. app/code/community/ING/KassaCompleet/sql/ingkassacompleet_setup/mysql4-install-0.0.1.php +37 -0
  25. app/code/community/ING/KassaCompleet/sql/ingkassacompleet_setup/mysql4-uninstall-0.0.1.php +36 -0
  26. app/code/community/ING/KassaCompleet/sql/ingkassacompleet_setup/mysql4-upgrade-0.0.1-0.0.2.php +76 -0
  27. app/code/community/ING/KassaCompleet/sql/ingkassacompleet_setup/mysql4-upgrade-0.0.2-0.0.3.php +75 -0
  28. app/design/adminhtml/default/default/template/ing_kassacompleet/info/banktransfer.phtml +29 -0
  29. app/design/adminhtml/default/default/template/ing_kassacompleet/info/cashondelivery.phtml +29 -0
  30. app/design/frontend/base/default/layout/ing_kassacompleet.xml +28 -0
  31. app/design/frontend/base/default/template/ing_kassacompleet/form/banktransfer.phtml +23 -0
  32. app/design/frontend/base/default/template/ing_kassacompleet/form/cashondelivery.phtml +23 -0
  33. app/design/frontend/base/default/template/ing_kassacompleet/form/ideal.phtml +38 -0
  34. app/design/frontend/base/default/template/ing_kassacompleet/info/banktransfer.phtml +29 -0
  35. app/design/frontend/base/default/template/ing_kassacompleet/info/cashondelivery.phtml +29 -0
  36. app/design/frontend/base/default/template/ing_kassacompleet/success.phtml +77 -0
  37. app/etc/modules/ING_KassaCompleet.xml +35 -0
  38. app/locale/en_US/ING_KassaCompleet.csv +30 -0
  39. app/locale/nl_NL/ING_KassaCompleet.csv +30 -0
  40. lib/Ing/Services/Lib.php +278 -0
  41. package.xml +35 -0
app/code/community/ING/KassaCompleet/Block/Payment/Banktransfer/Form.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Block_Payment_Banktransfer_Form extends Mage_Payment_Block_Form
22
+ {
23
+ /**
24
+ * Sets Banktransfer template into the checkout page
25
+ */
26
+ public function _construct()
27
+ {
28
+ parent::_construct();
29
+ $this->setTemplate('ing_kassacompleet/form/banktransfer.phtml');
30
+ }
31
+ }
app/code/community/ING/KassaCompleet/Block/Payment/Banktransfer/Info.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Block_Payment_Banktransfer_Info extends Mage_Payment_Block_Info
22
+ {
23
+ protected $_mailingAddress;
24
+
25
+ protected function _construct()
26
+ {
27
+ parent::_construct();
28
+ $this->setTemplate('ing_kassacompleet/info/banktransfer.phtml');
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @return string
34
+ */
35
+ public function getMailingAddress()
36
+ {
37
+ if (is_null($this->_mailingAddress)) {
38
+ $this->_convertAdditionalData();
39
+ }
40
+ return $this->_mailingAddress;
41
+ }
42
+
43
+ /**
44
+ * @return ING_KassaCompleet_Block_Payment_Banktransfer_Info
45
+ */
46
+ protected function _convertAdditionalData()
47
+ {
48
+ $details = @unserialize($this->getInfo()->getAdditionalData());
49
+ if (is_array($details)) {
50
+ $this->_mailingAddress = isset($details['mailing_address']) ? (string) $details['mailing_address'] : '';
51
+ } else {
52
+ $this->_mailingAddress = '';
53
+ }
54
+
55
+ return $this;
56
+ }
57
+ }
app/code/community/ING/KassaCompleet/Block/Payment/Cashondelivery/Form.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Block_Payment_Cashondelivery_Form extends Mage_Payment_Block_Form
22
+ {
23
+ /**
24
+ * Sets Cashondelivery template into the checkout page
25
+ */
26
+ public function _construct()
27
+ {
28
+ parent::_construct();
29
+ $this->setTemplate('ing_kassacompleet/form/cashondelivery.phtml');
30
+ }
31
+ }
app/code/community/ING/KassaCompleet/Block/Payment/Cashondelivery/Info.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Block_Payment_Cashondelivery_Info extends Mage_Payment_Block_Info
22
+ {
23
+ protected $_mailingAddress;
24
+
25
+ protected function _construct()
26
+ {
27
+ parent::_construct();
28
+ $this->setTemplate('ing_kassacompleet/info/cashondelivery.phtml');
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @return string
34
+ */
35
+ public function getMailingAddress()
36
+ {
37
+ if (is_null($this->_mailingAddress)) {
38
+ $this->_convertAdditionalData();
39
+ }
40
+ return $this->_mailingAddress;
41
+ }
42
+
43
+ /**
44
+ * @return ING_KassaCompleet_Block_Payment_Cashondelivery_Info
45
+ */
46
+ protected function _convertAdditionalData()
47
+ {
48
+ $details = @unserialize($this->getInfo()->getAdditionalData());
49
+ if (is_array($details)) {
50
+ $this->_mailingAddress = isset($details['mailing_address']) ? (string) $details['mailing_address'] : '';
51
+ } else {
52
+ $this->_mailingAddress = '';
53
+ }
54
+
55
+ return $this;
56
+ }
57
+ }
app/code/community/ING/KassaCompleet/Block/Payment/Ideal/Form.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Block_Payment_Ideal_Form extends Mage_Payment_Block_Form
22
+ {
23
+ /**
24
+ * Sets iDEAL template into the checkout page
25
+ */
26
+ public function _construct()
27
+ {
28
+ parent::_construct();
29
+ $this->setTemplate('ing_kassacompleet/form/ideal.phtml');
30
+ }
31
+ }
app/code/community/ING/KassaCompleet/Block/Payment/Ideal/Info.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Block_Payment_Ideal_Info extends Mage_Payment_Block_Info
22
+ {
23
+
24
+ }
app/code/community/ING/KassaCompleet/Helper/Banktransfer.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Helper_Banktransfer extends Mage_Core_Helper_Abstract
22
+ {
23
+ const XML_PATH_EMAIL_TEMPLATE = "payment/ingkassacompleet_banktransfer/order_email_template";
24
+ const XML_PATH_EMAIL_GUEST_TEMPLATE = "payment/ingkassacompleet_banktransfer/order_email_template_guest";
25
+
26
+ protected $orderId = null;
27
+ protected $amount = 0;
28
+ protected $description = null;
29
+ protected $orderStatus = null;
30
+ protected $consumerInfo = array();
31
+ protected $errorMessage = '';
32
+ protected $errorCode = 0;
33
+ protected $ingLib = null;
34
+
35
+ public function __construct()
36
+ {
37
+ $this->ingLib = new Ing_Services_Lib(Mage::getStoreConfig("payment/ingkassacompleet/apikey"), 'file', false);
38
+ }
39
+
40
+ /**
41
+ * Prepare an order and get a redirect URL
42
+ *
43
+ * @param int $orderId
44
+ * @param float $amount
45
+ * @param string $description
46
+ * @param array $customer
47
+ * @return bool
48
+ */
49
+ public function createOrder($orderId, $amount, $description, $customer = array())
50
+ {
51
+ if (!$this->setOrderId($orderId) ||
52
+ !$this->setAmount($amount) ||
53
+ !$this->setDescription($description)
54
+ ) {
55
+
56
+ $this->errorMessage = "Error in the given payment data";
57
+ return false;
58
+ }
59
+
60
+ $ingOrder = $this->ingLib->ingCreateBanktransferOrder($orderId, $amount, $description, $customer);
61
+ Mage::log($ingOrder);
62
+
63
+ if (!is_array($ingOrder) || array_key_exists('error', $ingOrder)) {
64
+ // TODO: handle the error
65
+ return false;
66
+ } else {
67
+ $this->orderId = (string) $ingOrder['id'];
68
+
69
+ return $ingOrder['transactions'][0]['payment_method_details']['reference'];
70
+ }
71
+ }
72
+
73
+ /**
74
+ * @param Mage_Sales_Model_Order $order
75
+ * @param string $reference
76
+ * @return string
77
+ */
78
+ public function getSuccessHtml(Mage_Sales_Model_Order $order, $reference)
79
+ {
80
+ if ($order->getPayment()->getMethodInstance() instanceof ING_KassaCompleet_Model_Banktransfer) {
81
+ $paymentBlock = $order->getPayment()->getMethodInstance()->getMailingAddress($order->getStoreId());
82
+
83
+ $grandTotal = $order->getGrandTotal();
84
+ $currency = Mage::app()->getLocale()->currency($order->getOrderCurrencyCode())->getSymbol();
85
+
86
+ $amountStr = $currency . ' ' . number_format(round($grandTotal, 2), 2, '.', '');;
87
+
88
+ $paymentBlock = str_replace('%AMOUNT%', $amountStr, $paymentBlock);
89
+ $paymentBlock = str_replace('%REFERENCE%', $reference, $paymentBlock);
90
+ $paymentBlock = str_replace('\n', PHP_EOL, $paymentBlock);
91
+
92
+ return $paymentBlock;
93
+ }
94
+
95
+ return '';
96
+ }
97
+
98
+ public function getOrderDetails($ingOrderId) {
99
+ return $this->ingLib->getOrderDetails($ingOrderId);
100
+ }
101
+
102
+ public function setAmount($amount)
103
+ {
104
+ return ($this->amount = $amount);
105
+ }
106
+
107
+ public function getAmount()
108
+ {
109
+ return $this->amount;
110
+ }
111
+
112
+ public function setOrderId($orderId)
113
+ {
114
+ return ($this->orderId = $orderId);
115
+ }
116
+
117
+ public function getOrderId()
118
+ {
119
+ return $this->orderId;
120
+ }
121
+
122
+ public function setDescription($description)
123
+ {
124
+ $description = substr($description, 0, 29);
125
+
126
+ return ($this->description = $description);
127
+ }
128
+
129
+ public function getDescription()
130
+ {
131
+ return $this->description;
132
+ }
133
+
134
+ public function getErrorMessage()
135
+ {
136
+ return $this->errorMessage;
137
+ }
138
+ }
app/code/community/ING/KassaCompleet/Helper/Cashondelivery.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Helper_Cashondelivery extends Mage_Core_Helper_Abstract
22
+ {
23
+ const XML_PATH_EMAIL_TEMPLATE = "payment/ingkassacompleet_cashondelivery/order_email_template";
24
+ const XML_PATH_EMAIL_GUEST_TEMPLATE = "payment/ingkassacompleet_cashondelivery/order_email_template_guest";
25
+
26
+ protected $orderId = null;
27
+ protected $amount = 0;
28
+ protected $description = null;
29
+ protected $orderStatus = null;
30
+ protected $consumerInfo = array();
31
+ protected $errorMessage = '';
32
+ protected $errorCode = 0;
33
+ protected $ingLib = null;
34
+
35
+ public function __construct()
36
+ {
37
+ $this->ingLib = new Ing_Services_Lib(Mage::getStoreConfig("payment/ingkassacompleet/apikey"), 'file', false);
38
+ }
39
+
40
+ /**
41
+ * Prepare an order and get a redirect URL
42
+ *
43
+ * @param int $orderId
44
+ * @param float $amount
45
+ * @param string $description
46
+ * @param array $customer
47
+ * @return bool
48
+ */
49
+ public function createOrder($orderId, $amount, $description, $customer = array())
50
+ {
51
+ if (!$this->setOrderId($orderId) ||
52
+ !$this->setAmount($amount) ||
53
+ !$this->setDescription($description)
54
+ ) {
55
+
56
+ $this->errorMessage = "Error in the given payment data";
57
+ return false;
58
+ }
59
+
60
+ $ingOrder = $this->ingLib->ingCreateCashondeliveryOrder($orderId, $amount, $description, $customer);
61
+ Mage::log($ingOrder);
62
+
63
+ if (!is_array($ingOrder) || array_key_exists('error', $ingOrder)) {
64
+ // TODO: handle the error
65
+ return false;
66
+ } else {
67
+ $this->orderId = (string) $ingOrder['id'];
68
+ return true;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * @param Mage_Sales_Model_Order $order
74
+ * @return string
75
+ */
76
+ public function getSuccessHtml(Mage_Sales_Model_Order $order)
77
+ {
78
+ if ($order->getPayment()->getMethodInstance() instanceof ING_KassaCompleet_Model_Cashondelivery) {
79
+ $paymentBlock = $order->getPayment()->getMethodInstance()->getMailingAddress($order->getStoreId());
80
+
81
+ $grandTotal = $order->getGrandTotal();
82
+ $currency = Mage::app()->getLocale()->currency($order->getOrderCurrencyCode())->getSymbol();
83
+
84
+ $amountStr = $currency . ' ' . number_format(round($grandTotal, 2), 2, '.', '');;
85
+
86
+ $paymentBlock = str_replace('%AMOUNT%', $amountStr, $paymentBlock);
87
+ $paymentBlock = str_replace('\n', PHP_EOL, $paymentBlock);
88
+
89
+ return $paymentBlock;
90
+ }
91
+
92
+ return '';
93
+ }
94
+
95
+ public function getOrderDetails($ingOrderId) {
96
+ return $this->ingLib->getOrderDetails($ingOrderId);
97
+ }
98
+
99
+ public function setAmount($amount)
100
+ {
101
+ return ($this->amount = $amount);
102
+ }
103
+
104
+ public function getAmount()
105
+ {
106
+ return $this->amount;
107
+ }
108
+
109
+ public function setOrderId($orderId)
110
+ {
111
+ return ($this->orderId = $orderId);
112
+ }
113
+
114
+ public function getOrderId()
115
+ {
116
+ return $this->orderId;
117
+ }
118
+
119
+ public function setDescription($description)
120
+ {
121
+ $description = substr($description, 0, 29);
122
+
123
+ return ($this->description = $description);
124
+ }
125
+
126
+ public function getDescription()
127
+ {
128
+ return $this->description;
129
+ }
130
+
131
+ public function getErrorMessage()
132
+ {
133
+ return $this->errorMessage;
134
+ }
135
+ }
app/code/community/ING/KassaCompleet/Helper/Creditcard.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Helper_Creditcard extends Mage_Core_Helper_Abstract
22
+ {
23
+ protected $orderId = null;
24
+ protected $amount = 0;
25
+ protected $description = null;
26
+ protected $returnUrl = null;
27
+ protected $paymentUrl = null;
28
+ protected $orderStatus = null;
29
+ protected $consumerInfo = array();
30
+ protected $errorMessage = '';
31
+ protected $errorCode = 0;
32
+ protected $ingLib = null;
33
+
34
+ public function __construct()
35
+ {
36
+ $this->ingLib = new Ing_Services_Lib(Mage::getStoreConfig("payment/ingkassacompleet/apikey"), 'file', false);
37
+ }
38
+
39
+ /**
40
+ * Prepare an order and get a redirect URL
41
+ *
42
+ * @param int $orderId
43
+ * @param float $amount
44
+ * @param string $description
45
+ * @param string $returnUrl
46
+ * @return bool
47
+ */
48
+ public function createOrder($orderId, $amount, $description, $returnUrl)
49
+ {
50
+ if (!$this->setOrderId($orderId) ||
51
+ !$this->setAmount($amount) ||
52
+ !$this->setDescription($description) ||
53
+ !$this->setReturnUrl($returnUrl)
54
+ ) {
55
+
56
+ $this->errorMessage = "Error in the given payment data";
57
+ return false;
58
+ }
59
+
60
+ $order = $this->ingLib->ingCreateCreditCardOrder($orderId, $amount, $returnUrl, $description);
61
+ Mage::log($order);
62
+
63
+ $this->orderId = (string) $order['id'];
64
+ $this->paymentUrl = (string) $order['transactions'][0]['payment_url'];
65
+
66
+ return true;
67
+ }
68
+
69
+ public function getOrderDetails($ingOrderId)
70
+ {
71
+ return $this->ingLib->getOrderDetails($ingOrderId);
72
+ }
73
+
74
+ public function setAmount($amount)
75
+ {
76
+ return ($this->amount = $amount);
77
+ }
78
+
79
+ public function getAmount()
80
+ {
81
+ return $this->amount;
82
+ }
83
+
84
+ public function setOrderId($orderId)
85
+ {
86
+ return ($this->orderId = $orderId);
87
+ }
88
+
89
+ public function getOrderId()
90
+ {
91
+ return $this->orderId;
92
+ }
93
+
94
+ public function setDescription($description)
95
+ {
96
+ $description = substr($description, 0, 29);
97
+
98
+ return ($this->description = $description);
99
+ }
100
+
101
+ public function getDescription()
102
+ {
103
+ return $this->description;
104
+ }
105
+
106
+ public function setReturnURL($returnUrl)
107
+ {
108
+ if (!preg_match('|(\w+)://([^/:]+)(:\d+)?(.*)|', $returnUrl)) {
109
+ return false;
110
+ }
111
+
112
+ return ($this->returnUrl = $returnUrl);
113
+ }
114
+
115
+ public function getReturnURL()
116
+ {
117
+ return $this->returnUrl;
118
+ }
119
+
120
+ public function getPaymentURL()
121
+ {
122
+ return (string) $this->paymentUrl;
123
+ }
124
+
125
+ public function getErrorMessage()
126
+ {
127
+ return $this->errorMessage;
128
+ }
129
+ }
app/code/community/ING/KassaCompleet/Helper/Data.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Helper_Data extends Mage_Core_Helper_Abstract
22
+ {
23
+ /**
24
+ * Parse address for split street and house number
25
+ *
26
+ * @param string $streetAddress
27
+ * @return array
28
+ */
29
+ public function parseAddress($streetAddress)
30
+ {
31
+ $address = $streetAddress;
32
+ $houseNumber = '';
33
+
34
+ $offset = strlen($streetAddress);
35
+
36
+ while (($offset = $this->_rstrpos($streetAddress, ' ', $offset)) !== false) {
37
+ if ($offset < strlen($streetAddress)-1 && is_numeric($streetAddress[$offset + 1])) {
38
+ $address = trim(substr($streetAddress, 0, $offset));
39
+ $houseNumber = trim(substr($streetAddress, $offset + 1));
40
+ break;
41
+ }
42
+ }
43
+
44
+ if (empty($houseNumber) && strlen($streetAddress) > 0 && is_numeric($streetAddress[0])) {
45
+ $pos = strpos($streetAddress, ' ');
46
+
47
+ if ($pos !== false) {
48
+ $houseNumber = trim(substr($streetAddress, 0, $pos), ", \t\n\r\0\x0B");
49
+ $address = trim(substr($streetAddress, $pos + 1));
50
+ }
51
+ }
52
+
53
+ return array($address, $houseNumber);
54
+ }
55
+
56
+ /**
57
+ * @param string $haystack
58
+ * @param string $needle
59
+ * @param null|int $offset
60
+ * @return int
61
+ */
62
+ protected function _rstrpos($haystack, $needle, $offset = null)
63
+ {
64
+ $size = strlen($haystack);
65
+
66
+ if (is_null($offset)) {
67
+ $offset = $size;
68
+ }
69
+
70
+ $pos = strpos(strrev($haystack), strrev($needle), $size - $offset);
71
+
72
+ if ($pos === false) {
73
+ return false;
74
+ }
75
+
76
+ return $size - $pos - strlen($needle);
77
+ }
78
+ }
app/code/community/ING/KassaCompleet/Helper/Ideal.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Helper_Ideal extends Mage_Core_Helper_Abstract
22
+ {
23
+ protected $orderId = null;
24
+ protected $issuerId = null;
25
+ protected $amount = 0;
26
+ protected $description = null;
27
+ protected $returnUrl = null;
28
+ protected $paymentUrl = null;
29
+ protected $orderStatus = null;
30
+ protected $consumerInfo = array();
31
+ protected $errorMessage = '';
32
+ protected $errorCode = 0;
33
+ protected $ingLib = null;
34
+
35
+ public function __construct()
36
+ {
37
+ $this->ingLib = new Ing_Services_Lib(Mage::getStoreConfig("payment/ingkassacompleet/apikey"), 'file', false);
38
+ }
39
+
40
+ /**
41
+ * Fetch the list of issuers
42
+ *
43
+ * @return null|array
44
+ */
45
+ public function getIssuers()
46
+ {
47
+ return $this->ingLib->ingGetIssuers();
48
+ }
49
+
50
+ /**
51
+ * Prepare an order and get a redirect URL
52
+ *
53
+ * @param int $orderId
54
+ * @param $issuerId
55
+ * @param float $amount
56
+ * @param string $description
57
+ * @param string $returnUrl
58
+ * @return bool
59
+ */
60
+ public function createOrder($orderId, $issuerId, $amount, $description, $returnUrl)
61
+ {
62
+ if (!$this->setOrderId($orderId) ||
63
+ !$this->setIssuerId($issuerId) ||
64
+ !$this->setAmount($amount) ||
65
+ !$this->setDescription($description) ||
66
+ !$this->setReturnUrl($returnUrl)
67
+ ) {
68
+
69
+ $this->errorMessage = "Error in the given payment data";
70
+ return false;
71
+ }
72
+
73
+ $order = $this->ingLib->ingCreateIdealOrder($orderId, $amount, $issuerId, $returnUrl, $description);
74
+ Mage::log($order);
75
+
76
+ $this->orderId = (string) $order['id'];
77
+ $this->paymentUrl = (string) $order['transactions'][0]['payment_url'];
78
+
79
+ return true;
80
+ }
81
+
82
+ public function getOrderDetails($ingOrderId)
83
+ {
84
+ return $this->ingLib->getOrderDetails($ingOrderId);
85
+ }
86
+
87
+ public function setIssuerId($issuerId)
88
+ {
89
+ return ($this->issuerId = $issuerId);
90
+ }
91
+
92
+ public function getIssuerId()
93
+ {
94
+ return $this->issuerId;
95
+ }
96
+
97
+ public function setAmount($amount)
98
+ {
99
+ return ($this->amount = $amount);
100
+ }
101
+
102
+ public function getAmount()
103
+ {
104
+ return $this->amount;
105
+ }
106
+
107
+ public function setOrderId($orderId)
108
+ {
109
+ return ($this->orderId = $orderId);
110
+ }
111
+
112
+ public function getOrderId()
113
+ {
114
+ return $this->orderId;
115
+ }
116
+
117
+ public function setDescription($description)
118
+ {
119
+ $description = substr($description, 0, 29);
120
+
121
+ return ($this->description = $description);
122
+ }
123
+
124
+ public function getDescription()
125
+ {
126
+ return $this->description;
127
+ }
128
+
129
+ public function setReturnURL($returnUrl)
130
+ {
131
+ if (!preg_match('|(\w+)://([^/:]+)(:\d+)?(.*)|', $returnUrl)) {
132
+ return false;
133
+ }
134
+
135
+ return ($this->returnUrl = $returnUrl);
136
+ }
137
+
138
+ public function getReturnURL()
139
+ {
140
+ return $this->returnUrl;
141
+ }
142
+
143
+ public function getPaymentURL()
144
+ {
145
+ return (string) $this->paymentUrl;
146
+ }
147
+
148
+ public function getErrorMessage()
149
+ {
150
+ return $this->errorMessage;
151
+ }
152
+ }
app/code/community/ING/KassaCompleet/Model/Banktransfer.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Model_Banktransfer extends Mage_Payment_Model_Method_Abstract
22
+ {
23
+ /**
24
+ * @var ING_KassaCompleet_Helper_Banktransfer
25
+ */
26
+ protected $_banktransfer;
27
+
28
+ protected $_code = 'ingkassacompleet_banktransfer';
29
+ protected $_formBlockType = 'ingkassacompleet/payment_banktransfer_form';
30
+ protected $_infoBlockType = 'ingkassacompleet/payment_banktransfer_info';
31
+ protected $_paymentMethod = 'Banktransfer';
32
+ protected $_isGateway = true;
33
+ protected $_canAuthorize = true;
34
+ protected $_canUseCheckout = true;
35
+ protected $_canUseInternal = true;
36
+ protected $_canUseForMultishipping = false;
37
+ protected $_canRefund = true;
38
+ protected $_canRefundInvoicePartial = false;
39
+ protected $_canCapture = false;
40
+
41
+ // Payment flags
42
+ const PAYMENT_FLAG_PENDING = "Payment is pending";
43
+ const PAYMENT_FLAG_COMPLETED = "Payment is completed";
44
+ const PAYMENT_FLAG_CANCELLED = "Payment is cancelled";
45
+ const PAYMENT_FLAG_ERROR = "Payment failed with an error";
46
+ const PAYMENT_FLAG_FRAUD = "Amounts don't match. Possible fraud";
47
+
48
+ /**
49
+ * Build constructor
50
+ */
51
+ public function __construct()
52
+ {
53
+ parent::_construct();
54
+ $this->_banktransfer = Mage::helper('ingkassacompleet/banktransfer');
55
+ }
56
+
57
+ /**
58
+ * @param Mage_Sales_Model_Quote|null $quote
59
+ * @return bool
60
+ */
61
+ public function isAvailable($quote = null)
62
+ {
63
+ if (Mage::getStoreConfig('payment/ingkassacompleet/apikey', $quote ? $quote->getStoreId() : null)) {
64
+ return parent::isAvailable($quote);
65
+ }
66
+
67
+ return false;
68
+ }
69
+
70
+ /**
71
+ * Get checkout session namespace
72
+ *
73
+ * @return Mage_Checkout_Model_Session
74
+ */
75
+ protected function _getCheckout()
76
+ {
77
+ return Mage::getSingleton('checkout/session');
78
+ }
79
+
80
+ /**
81
+ * Get current quote
82
+ *
83
+ * @return Mage_Sales_Model_Quote
84
+ */
85
+ public function getQuote()
86
+ {
87
+ return $this->_getCheckout()->getQuote();
88
+ }
89
+
90
+ /**
91
+ * Banktransfer is only active if 'EURO' is currency
92
+ *
93
+ * @param string $currencyCode
94
+ * @return bool
95
+ */
96
+ public function canUseForCurrency($currencyCode)
97
+ {
98
+ if ($currencyCode !== "EUR") {
99
+ return false;
100
+ }
101
+
102
+ return parent::canUseForCurrency($currencyCode);
103
+ }
104
+
105
+ public function getMailingAddress($store = null)
106
+ {
107
+ /** @var $helper ING_KassaCompleet_Helper_Data */
108
+ $helper = Mage::helper('ingkassacompleet');
109
+
110
+ $accountDetails = Mage::getStoreConfig("payment/ingkassacompleet_banktransfer/account_details", $store);
111
+
112
+ $paymentBlock = '';
113
+
114
+ $paymentBlock .= $helper->__('Amount:') . ' ' . '%AMOUNT%' . "\n";
115
+ $paymentBlock .= $helper->__('Reference:') . ' ' . '%REFERENCE%' . "\n";
116
+ $paymentBlock .= $helper->__('IBAN:') . ' ' . $accountDetails['iban'] . "\n";
117
+ $paymentBlock .= $helper->__('BIC:') . ' ' . $accountDetails['bic'] . "\n";
118
+ $paymentBlock .= $helper->__('Account holder:') . ' ' . $accountDetails['holder'] . "\n";
119
+ $paymentBlock .= $helper->__('City:') . ' ' . $accountDetails['city'];
120
+
121
+ return $paymentBlock;
122
+ }
123
+
124
+ /**
125
+ * Redirects the client on click 'Place Order' to selected Banktransfer bank
126
+ *
127
+ * @return string
128
+ */
129
+ public function getOrderPlaceRedirectUrl()
130
+ {
131
+ return Mage::getUrl(
132
+ 'ingkassacompleet/banktransfer/payment',
133
+ array(
134
+ '_secure' => true,
135
+ '_query' => array(),
136
+ )
137
+ );
138
+ }
139
+ }
app/code/community/ING/KassaCompleet/Model/Cashondelivery.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Model_Cashondelivery extends Mage_Payment_Model_Method_Abstract
22
+ {
23
+ /**
24
+ * @var ING_KassaCompleet_Helper_Cashondelivery
25
+ */
26
+ protected $_cashondelivery;
27
+
28
+ protected $_code = 'ingkassacompleet_cashondelivery';
29
+ protected $_formBlockType = 'ingkassacompleet/payment_cashondelivery_form';
30
+ protected $_infoBlockType = 'ingkassacompleet/payment_cashondelivery_info';
31
+ protected $_paymentMethod = 'Cashondelivery';
32
+ protected $_isGateway = true;
33
+ protected $_canAuthorize = true;
34
+ protected $_canUseCheckout = true;
35
+ protected $_canUseInternal = true;
36
+ protected $_canUseForMultishipping = false;
37
+ protected $_canRefund = true;
38
+ protected $_canRefundInvoicePartial = false;
39
+ protected $_canCapture = false;
40
+
41
+ // Payment flags
42
+ const PAYMENT_FLAG_PENDING = "Payment is pending";
43
+ const PAYMENT_FLAG_COMPLETED = "Payment is completed";
44
+ const PAYMENT_FLAG_CANCELLED = "Payment is cancelled";
45
+ const PAYMENT_FLAG_ERROR = "Payment failed with an error";
46
+ const PAYMENT_FLAG_FRAUD = "Amounts don't match. Possible fraud";
47
+
48
+ /**
49
+ * Build constructor
50
+ */
51
+ public function __construct()
52
+ {
53
+ parent::_construct();
54
+ $this->_cashondelivery = Mage::helper('ingkassacompleet/cashondelivery');
55
+ }
56
+
57
+ /**
58
+ * @param Mage_Sales_Model_Quote|null $quote
59
+ * @return bool
60
+ */
61
+ public function isAvailable($quote = null)
62
+ {
63
+ if (Mage::getStoreConfig('payment/ingkassacompleet/apikey', $quote ? $quote->getStoreId() : null)) {
64
+ return parent::isAvailable($quote);
65
+ }
66
+
67
+ return false;
68
+ }
69
+
70
+ /**
71
+ * Get checkout session namespace
72
+ *
73
+ * @return Mage_Checkout_Model_Session
74
+ */
75
+ protected function _getCheckout()
76
+ {
77
+ return Mage::getSingleton('checkout/session');
78
+ }
79
+
80
+ /**
81
+ * Get current quote
82
+ *
83
+ * @return Mage_Sales_Model_Quote
84
+ */
85
+ public function getQuote()
86
+ {
87
+ return $this->_getCheckout()->getQuote();
88
+ }
89
+
90
+ /**
91
+ * Cashondelivery is only active if 'EURO' is currency
92
+ *
93
+ * @param string $currencyCode
94
+ * @return bool
95
+ */
96
+ public function canUseForCurrency($currencyCode)
97
+ {
98
+ if ($currencyCode !== "EUR") {
99
+ return false;
100
+ }
101
+
102
+ return parent::canUseForCurrency($currencyCode);
103
+ }
104
+
105
+ /**
106
+ * @param null|int|Mage_Core_Model_Store $store
107
+ * @return string
108
+ */
109
+ public function getMailingAddress($store = null)
110
+ {
111
+ /** @var $helper ING_KassaCompleet_Helper_Data */
112
+ $helper = Mage::helper('ingkassacompleet');
113
+
114
+ $paymentBlock = '';
115
+ $paymentBlock .= $helper->__('Amount:') . ' ' . '%AMOUNT%' . PHP_EOL;
116
+
117
+ return $paymentBlock;
118
+ }
119
+
120
+ /**
121
+ * Redirects the client on click 'Place Order' to selected Cashondelivery bank
122
+ *
123
+ * @return string
124
+ */
125
+ public function getOrderPlaceRedirectUrl()
126
+ {
127
+ return Mage::getUrl(
128
+ 'ingkassacompleet/cashondelivery/payment',
129
+ array(
130
+ '_secure' => true,
131
+ '_query' => array(),
132
+ )
133
+ );
134
+ }
135
+ }
app/code/community/ING/KassaCompleet/Model/Creditcard.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Model_Creditcard extends Mage_Payment_Model_Method_Abstract
22
+ {
23
+ /**
24
+ * @var ING_KassaCompleet_Helper_Creditcard
25
+ */
26
+ protected $_creditCard;
27
+
28
+ protected $_code = 'ingkassacompleet_creditcard';
29
+ protected $_paymentMethod = 'CreditCard';
30
+ protected $_isGateway = true;
31
+ protected $_canAuthorize = true;
32
+ protected $_canUseCheckout = true;
33
+ protected $_canUseInternal = true;
34
+ protected $_canUseForMultishipping = false;
35
+ protected $_canRefund = true;
36
+ protected $_canRefundInvoicePartial = false;
37
+ protected $_canCapture = false;
38
+
39
+ // Payment flags
40
+ const PAYMENT_FLAG_PENDING = "Payment is pending";
41
+ const PAYMENT_FLAG_COMPLETED = "Payment is completed";
42
+ const PAYMENT_FLAG_CANCELLED = "Payment is cancelled";
43
+ const PAYMENT_FLAG_ERROR = "Payment failed with an error";
44
+ const PAYMENT_FLAG_FRAUD = "Amounts don't match. Possible fraud";
45
+
46
+ /**
47
+ * Build constructor
48
+ */
49
+ public function __construct()
50
+ {
51
+ parent::_construct();
52
+ $this->_creditCard = Mage::helper('ingkassacompleet/creditcard');
53
+ }
54
+
55
+ /**
56
+ * @param Mage_Sales_Model_Quote|null $quote
57
+ * @return bool
58
+ */
59
+ public function isAvailable($quote = null)
60
+ {
61
+ if (Mage::getStoreConfig('payment/ingkassacompleet/apikey', $quote ? $quote->getStoreId() : null)) {
62
+ return parent::isAvailable($quote);
63
+ }
64
+
65
+ return false;
66
+ }
67
+
68
+ /**
69
+ * Get checkout session namespace
70
+ *
71
+ * @return Mage_Checkout_Model_Session
72
+ */
73
+ protected function _getCheckout()
74
+ {
75
+ return Mage::getSingleton('checkout/session');
76
+ }
77
+
78
+ /**
79
+ * Get current quote
80
+ *
81
+ * @return Mage_Sales_Model_Quote
82
+ */
83
+ public function getQuote()
84
+ {
85
+ return $this->_getCheckout()->getQuote();
86
+ }
87
+
88
+ /**
89
+ * CreditCard is only active if 'EURO' is currency
90
+ *
91
+ * @param string $currencyCode
92
+ * @return bool
93
+ */
94
+ public function canUseForCurrency($currencyCode)
95
+ {
96
+ if ($currencyCode !== "EUR") {
97
+ return false;
98
+ }
99
+
100
+ return parent::canUseForCurrency($currencyCode);
101
+ }
102
+
103
+ /**
104
+ * Redirects the client on click 'Place Order' to selected CreditCard bank
105
+ *
106
+ * @return string
107
+ */
108
+ public function getOrderPlaceRedirectUrl()
109
+ {
110
+ return Mage::getUrl(
111
+ 'ingkassacompleet/creditcard/payment',
112
+ array(
113
+ '_secure' => true,
114
+ '_query' => array(),
115
+ )
116
+ );
117
+ }
118
+ }
app/code/community/ING/KassaCompleet/Model/Ideal.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Model_Ideal extends Mage_Payment_Model_Method_Abstract
22
+ {
23
+ /**
24
+ * @var ING_KassaCompleet_Helper_Ideal
25
+ */
26
+ protected $_ideal;
27
+
28
+ protected $_code = 'ingkassacompleet_ideal';
29
+ protected $_formBlockType = 'ingkassacompleet/payment_ideal_form';
30
+ protected $_infoBlockType = 'ingkassacompleet/payment_ideal_info';
31
+ protected $_paymentMethod = 'iDEAL';
32
+ protected $_isGateway = true;
33
+ protected $_canAuthorize = true;
34
+ protected $_canUseCheckout = true;
35
+ protected $_canUseInternal = true;
36
+ protected $_canUseForMultishipping = false;
37
+ protected $_canRefund = true;
38
+ protected $_canRefundInvoicePartial = false;
39
+ protected $_canCapture = false;
40
+
41
+ // Payment flags
42
+ const PAYMENT_FLAG_PENDING = "Payment is pending";
43
+ const PAYMENT_FLAG_COMPLETED = "Payment is completed";
44
+ const PAYMENT_FLAG_CANCELLED = "Payment is cancelled";
45
+ const PAYMENT_FLAG_ERROR = "Payment failed with an error";
46
+ const PAYMENT_FLAG_FRAUD = "Amounts don't match. Possible fraud";
47
+
48
+ /**
49
+ * Build constructor
50
+ */
51
+ public function __construct()
52
+ {
53
+ parent::_construct();
54
+ $this->_ideal = Mage::helper('ingkassacompleet/ideal');
55
+ }
56
+
57
+ /**
58
+ * @param Mage_Sales_Model_Quote|null $quote
59
+ * @return bool
60
+ */
61
+ public function isAvailable($quote = null)
62
+ {
63
+ if (Mage::getStoreConfig('payment/ingkassacompleet/apikey', $quote ? $quote->getStoreId() : null)) {
64
+ return parent::isAvailable($quote);
65
+ }
66
+
67
+ return false;
68
+ }
69
+
70
+ /**
71
+ * Get checkout session namespace
72
+ *
73
+ * @return Mage_Checkout_Model_Session
74
+ */
75
+ protected function _getCheckout()
76
+ {
77
+ return Mage::getSingleton('checkout/session');
78
+ }
79
+
80
+ /**
81
+ * Get current quote
82
+ *
83
+ * @return Mage_Sales_Model_Quote
84
+ */
85
+ public function getQuote()
86
+ {
87
+ return $this->_getCheckout()->getQuote();
88
+ }
89
+
90
+ /**
91
+ * iDEAL is only active if 'EURO' is currency
92
+ *
93
+ * @param type $currencyCode
94
+ * @return true/false
95
+ */
96
+ public function canUseForCurrency($currencyCode)
97
+ {
98
+ if ($currencyCode !== "EUR") {
99
+ return false;
100
+ }
101
+
102
+ return parent::canUseForCurrency($currencyCode);
103
+ }
104
+
105
+ /**
106
+ * On click payment button, this function is called to assign data
107
+ *
108
+ * @param $data
109
+ * @return $this
110
+ */
111
+ public function assignData($data)
112
+ {
113
+ if (!($data instanceof Varien_Object)) {
114
+ $data = new Varien_Object($data);
115
+ }
116
+
117
+ if (Mage::registry('issuer_id')) {
118
+ Mage::unregister('issuer_id');
119
+ }
120
+
121
+ Mage::register('issuer_id', Mage::app()->getRequest()->getParam('issuer_id'));
122
+
123
+ return $this;
124
+ }
125
+
126
+ /**
127
+ * Redirects the client on click 'Place Order' to selected iDEAL bank
128
+ *
129
+ * @return string
130
+ */
131
+ public function getOrderPlaceRedirectUrl()
132
+ {
133
+ return Mage::getUrl(
134
+ 'ingkassacompleet/ideal/payment',
135
+ array(
136
+ '_secure' => true,
137
+ '_query' => array(
138
+ 'issuer_id' => Mage::registry('issuer_id')
139
+ )
140
+ )
141
+ );
142
+ }
143
+ }
app/code/community/ING/KassaCompleet/Model/Observer.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_Model_Observer
22
+ {
23
+ /**
24
+ * @param Varien_Event_Observer $observer
25
+ * @return $this
26
+ */
27
+ public function convertPayment(Varien_Event_Observer $observer)
28
+ {
29
+ $orderPayment = $observer->getEvent()->getOrderPayment();
30
+ $quotePayment = $observer->getEvent()->getQuotePayment();
31
+
32
+ $orderPayment->setIngOrderId($quotePayment->getIngOrderId());
33
+ $orderPayment->setIngBanktransferReference($quotePayment->getIngBanktransferReference());
34
+ $orderPayment->setIngIdealIssuerId($quotePayment->getIngIdealIssuerId());
35
+
36
+ return $this;
37
+ }
38
+ }
app/code/community/ING/KassaCompleet/controllers/BanktransferController.php ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_BanktransferController extends Mage_Core_Controller_Front_Action
22
+ {
23
+ /**
24
+ * @var ING_KassaCompleet_Helper_Banktransfer
25
+ */
26
+ protected $_banktransfer;
27
+
28
+ /**
29
+ * @var ING_KassaCompleet_Helper_Data
30
+ */
31
+ protected $_helper;
32
+
33
+ /**
34
+ * @var Mage_Core_Helper_Http
35
+ */
36
+ protected $_coreHttp;
37
+
38
+ /**
39
+ * @var Varien_Db_Adapter_Pdo_Mysql
40
+ */
41
+ protected $_read;
42
+
43
+ /**
44
+ * @var Varien_Db_Adapter_Pdo_Mysql
45
+ */
46
+ protected $_write;
47
+
48
+ /**
49
+ * Get iDEAL core
50
+ * Give $_write mage writing resource
51
+ * Give $_read mage reading resource
52
+ */
53
+ public function _construct()
54
+ {
55
+ $this->_banktransfer = Mage::helper('ingkassacompleet/banktransfer');
56
+ $this->_helper = Mage::helper('ingkassacompleet');
57
+ $this->_coreHttp = Mage::helper('core/http');
58
+
59
+ $this->_read = Mage::getSingleton('core/resource')->getConnection('core_read');
60
+ $this->_write = Mage::getSingleton('core/resource')->getConnection('core_write');
61
+
62
+ parent::_construct();
63
+ }
64
+
65
+ /**
66
+ * Create the order and sets the redirect url
67
+ *
68
+ * @return void
69
+ */
70
+ public function paymentAction()
71
+ {
72
+ // Load last order
73
+ /** @var $order Mage_Sales_Model_Order */
74
+ $order = Mage::getModel('sales/order')->loadByIncrementId($this->_getCheckout()->last_real_order_id);
75
+
76
+ try {
77
+ $amount = $order->getGrandTotal();
78
+ $orderId = $order->getIncrementId();
79
+ $description = str_replace('%', $orderId, Mage::getStoreConfig("payment/ingkassacompleet_banktransfer/description", $order->getStoreId()));
80
+ // $returnUrl = Mage::getUrl('ingkassacompleet/banktransfer/return', array("order_id" => $orderId));
81
+
82
+ $customer = $this->_getCustomerData($order);
83
+ $reference = $this->_banktransfer->createOrder($orderId, $amount, $description, $customer);
84
+
85
+ if ($reference) {
86
+ if ($order->getPayment()->getMethodInstance() instanceof ING_KassaCompleet_Model_Banktransfer &&
87
+ $paymentBlock = $order->getPayment()->getMethodInstance()->getMailingAddress($order->getStoreId())) {
88
+
89
+ $details = array();
90
+ $grandTotal = $order->getGrandTotal();
91
+ $currency = Mage::app()->getLocale()->currency($order->getOrderCurrencyCode())->getSymbol();
92
+ $amountStr = $currency . ' ' . number_format(round($grandTotal, 2), 2, '.', '');
93
+
94
+ $paymentBlock = str_replace('%AMOUNT%', $amountStr, $paymentBlock);
95
+ $paymentBlock = str_replace('%REFERENCE%', $reference, $paymentBlock);
96
+ $paymentBlock = str_replace('\n', PHP_EOL, $paymentBlock);
97
+
98
+ $details['mailing_address'] = $paymentBlock;
99
+ if (!empty($details)) {
100
+ $order->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalData(serialize($details));
101
+ }
102
+ }
103
+
104
+ if (!$order->getId()) {
105
+ Mage::log('Geen order voor verwerking gevonden');
106
+ Mage::throwException('Geen order voor verwerking gevonden');
107
+ }
108
+
109
+ // Creates transaction
110
+ /** @var $payment Mage_Sales_Model_Order_Payment */
111
+ $payment = $order->getPayment();
112
+
113
+ if (!$payment->getId()) {
114
+ $payment = Mage::getModel('sales/order_payment')->setId(null);
115
+ }
116
+
117
+ $payment->setIsTransactionClosed(false)
118
+ ->setIngOrderId($this->_banktransfer->getOrderId())
119
+ ->setIngBanktransferReference($reference);
120
+
121
+ $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
122
+
123
+ // Sets the above transaction
124
+ $order->setPayment($payment);
125
+
126
+ $order->setIngOrderId($this->_banktransfer->getOrderId())
127
+ ->setIngBanktransferReference($reference);
128
+ $order->save();
129
+
130
+ $pendingMessage = Mage::helper('ingkassacompleet')->__(ING_KassaCompleet_Model_Banktransfer::PAYMENT_FLAG_PENDING);
131
+ if ($order->getData('ing_order_id')) {
132
+ $pendingMessage .= '. ' . 'ING Order ID: ' . $order->getData('ing_order_id');
133
+ }
134
+
135
+ $order->setState(
136
+ Mage_Sales_Model_Order::STATE_PROCESSING,
137
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
138
+ $pendingMessage,
139
+ false
140
+ );
141
+ $order->save();
142
+
143
+ $order->addStatusToHistory($order->getStatus(), 'Reference: '. $reference)->save();
144
+
145
+ if (Mage::getStoreConfig("payment/ingkassacompleet_banktransfer/send_order_mail", $order->getStoreId())) {
146
+ if (!$order->getEmailSent()) {
147
+ $order->setEmailSent(true);
148
+ $order->sendNewOrderEmail();
149
+ $order->save();
150
+ }
151
+ }
152
+
153
+ $this->_redirect('checkout/onepage/success', array('_secure' => true, 'reference' => $reference));
154
+ } else {
155
+ $this->_restoreCart();
156
+
157
+ // Redirect to failure page
158
+ $this->_redirect('checkout/onepage/failure', array('_secure' => true));
159
+ }
160
+ } catch (Exception $e) {
161
+ Mage::log($e);
162
+ Mage::throwException(
163
+ "Could not start transaction. Contact the owner.<br />
164
+ Error message: " . $this->_banktransfer->getErrorMessage()
165
+ );
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Gets the current checkout session with order information
171
+ *
172
+ * @return Mage_Checkout_Model_Session
173
+ */
174
+ protected function _getCheckout()
175
+ {
176
+ return Mage::getSingleton('checkout/session');
177
+ }
178
+
179
+ /**
180
+ * @return void
181
+ */
182
+ protected function _restoreCart()
183
+ {
184
+ $session = Mage::getSingleton('checkout/session');
185
+ $orderId = $session->getLastRealOrderId();
186
+ if (!empty($orderId)) {
187
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
188
+ }
189
+ $quoteId = $order->getQuoteId();
190
+
191
+ $quote = Mage::getModel('sales/quote')->load($quoteId)->setIsActive(true)->save();
192
+
193
+ Mage::getSingleton('checkout/session')->replaceQuote($quote);
194
+ }
195
+
196
+ /**
197
+ * @param Mage_Sales_Model_Order $order
198
+ * @return array
199
+ */
200
+ protected function _getCustomerData(Mage_Sales_Model_Order $order)
201
+ {
202
+ $billingAddress = $order->getBillingAddress();
203
+
204
+ list($address, $houseNumber) = $this->_helper->parseAddress($billingAddress->getStreetFull());
205
+
206
+ return array(
207
+ 'merchant_customer_id' => $order->getCustomerId(),
208
+ 'email_address' => $order->getCustomerEmail(),
209
+ 'first_name' => $order->getCustomerFirstname(),
210
+ 'last_name' => $order->getCustomerLastname(),
211
+ 'address_type' => 'billing',
212
+ 'address' => trim($billingAddress->getCity()) . ' ' . trim($address),
213
+ 'postal_code' => $billingAddress->getPostcode(),
214
+ 'housenumber' => $houseNumber,
215
+ 'country' => $billingAddress->getCountryId(),
216
+ 'phone_numbers' => $billingAddress->getTelephone(),
217
+ 'user_agent' => $this->_coreHttp->getHttpUserAgent(),
218
+ 'referrer' => $this->_coreHttp->getHttpReferer(),
219
+ 'ip_address' => $this->_coreHttp->getRemoteAddr(),
220
+ 'forwarded_ip' => $this->getRequest()->getServer('HTTP_X_FORWARDED_FOR'),
221
+ 'gender' => $order->getCustomerGender() ? ('1' ? 'male' : ('2' ? 'female' : null)) : null, // "male", "female", "other", null
222
+ 'birth_date' => $order->getCustomerDob(), // Date (ISO 8601 / RFC 3339)
223
+ 'locale' => substr(Mage::getStoreConfig('general/locale/code'), 0, 2), // "^[a-zA-Z]{2}(_[a-zA-Z]{2})?$"
224
+ );
225
+ }
226
+ }
app/code/community/ING/KassaCompleet/controllers/CashondeliveryController.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_CashondeliveryController extends Mage_Core_Controller_Front_Action
22
+ {
23
+ /**
24
+ * @var ING_KassaCompleet_Helper_Cashondelivery
25
+ */
26
+ protected $_cashondelivery;
27
+
28
+ /**
29
+ * @var ING_KassaCompleet_Helper_Data
30
+ */
31
+ protected $_helper;
32
+
33
+ /**
34
+ * @var Mage_Core_Helper_Http
35
+ */
36
+ protected $_coreHttp;
37
+
38
+ /**
39
+ * @var Varien_Db_Adapter_Pdo_Mysql
40
+ */
41
+ protected $_read;
42
+
43
+ /**
44
+ * @var Varien_Db_Adapter_Pdo_Mysql
45
+ */
46
+ protected $_write;
47
+
48
+ /**
49
+ * Get iDEAL core
50
+ * Give $_write mage writing resource
51
+ * Give $_read mage reading resource
52
+ */
53
+ public function _construct()
54
+ {
55
+ $this->_cashondelivery = Mage::helper('ingkassacompleet/cashondelivery');
56
+ $this->_helper = Mage::helper('ingkassacompleet');
57
+ $this->_coreHttp = Mage::helper('core/http');
58
+
59
+ $this->_read = Mage::getSingleton('core/resource')->getConnection('core_read');
60
+ $this->_write = Mage::getSingleton('core/resource')->getConnection('core_write');
61
+
62
+ parent::_construct();
63
+ }
64
+
65
+ /**
66
+ * Create the order and sets the redirect url
67
+ *
68
+ * @return void
69
+ */
70
+ public function paymentAction()
71
+ {
72
+ // Load last order
73
+ /** @var $order Mage_Sales_Model_Order */
74
+ $order = Mage::getModel('sales/order')->loadByIncrementId($this->_getCheckout()->last_real_order_id);
75
+
76
+ try {
77
+ $amount = $order->getGrandTotal();
78
+ $orderId = $order->getIncrementId();
79
+ $description = str_replace('%', $orderId, Mage::getStoreConfig("payment/ingkassacompleet_cashondelivery/description", $order->getStoreId()));
80
+ // $returnUrl = Mage::getUrl('ingkassacompleet/cashondelivery/return', array("order_id" => $orderId));
81
+
82
+ $customer = $this->_getCustomerData($order);
83
+
84
+ if ($this->_cashondelivery->createOrder($orderId, $amount, $description, $customer)) {
85
+ if ($order->getPayment()->getMethodInstance() instanceof ING_KassaCompleet_Model_Cashondelivery &&
86
+ $paymentBlock = $order->getPayment()->getMethodInstance()->getMailingAddress($order->getStoreId())) {
87
+
88
+ $details = array();
89
+ $grandTotal = $order->getGrandTotal();
90
+ $currency = Mage::app()->getLocale()->currency($order->getOrderCurrencyCode())->getSymbol();
91
+ $amountStr = $currency . ' ' . number_format(round($grandTotal, 2), 2, '.', '');
92
+
93
+ $paymentBlock = str_replace('%AMOUNT%', $amountStr, $paymentBlock);
94
+ $paymentBlock = str_replace('\n', PHP_EOL, $paymentBlock);
95
+
96
+ $details['mailing_address'] = $paymentBlock;
97
+ if (!empty($details)) {
98
+ $order->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalData(serialize($details));
99
+ }
100
+ }
101
+
102
+ if (!$order->getId()) {
103
+ Mage::log('Geen order voor verwerking gevonden');
104
+ Mage::throwException('Geen order voor verwerking gevonden');
105
+ }
106
+
107
+ // Creates transaction
108
+ /** @var $payment Mage_Sales_Model_Order_Payment */
109
+ $payment = $order->getPayment();
110
+
111
+ if (!$payment->getId()) {
112
+ $payment = Mage::getModel('sales/order_payment')->setId(null);
113
+ }
114
+
115
+ $payment->setIsTransactionClosed(false)
116
+ ->setIngOrderId($this->_cashondelivery->getOrderId())
117
+ ->setIngIdealIssuerId(null);
118
+
119
+ $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
120
+
121
+ // Sets the above transaction
122
+ $order->setPayment($payment);
123
+
124
+ $order->setIngOrderId($this->_cashondelivery->getOrderId())
125
+ ->setIngIdealIssuerId(null);
126
+ $order->save();
127
+
128
+ $pendingMessage = Mage::helper('ingkassacompleet')->__(ING_KassaCompleet_Model_Cashondelivery::PAYMENT_FLAG_PENDING);
129
+ if ($order->getData('ing_order_id')) {
130
+ $pendingMessage .= '. ' . 'ING Order ID: ' . $order->getData('ing_order_id');
131
+ }
132
+
133
+ $order->setState(
134
+ Mage_Sales_Model_Order::STATE_PROCESSING,
135
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
136
+ $pendingMessage,
137
+ false
138
+ );
139
+ $order->save();
140
+
141
+ if (Mage::getStoreConfig("payment/ingkassacompleet_cashondelivery/send_order_mail", $order->getStoreId())) {
142
+ if (!$order->getEmailSent()) {
143
+ $order->setEmailSent(true);
144
+ $order->sendNewOrderEmail();
145
+ $order->save();
146
+ }
147
+ }
148
+
149
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
150
+ } else {
151
+ $this->_restoreCart();
152
+
153
+ // Redirect to failure page
154
+ $this->_redirect('checkout/onepage/failure', array('_secure' => true));
155
+ }
156
+ } catch (Exception $e) {
157
+ Mage::log($e);
158
+ Mage::throwException(
159
+ "Could not start transaction. Contact the owner.<br />
160
+ Error message: " . $this->_cashondelivery->getErrorMessage()
161
+ );
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Gets the current checkout session with order information
167
+ *
168
+ * @return Mage_Checkout_Model_Session
169
+ */
170
+ protected function _getCheckout()
171
+ {
172
+ return Mage::getSingleton('checkout/session');
173
+ }
174
+
175
+ /**
176
+ * @return void
177
+ */
178
+ protected function _restoreCart()
179
+ {
180
+ $session = Mage::getSingleton('checkout/session');
181
+ $orderId = $session->getLastRealOrderId();
182
+ if (!empty($orderId)) {
183
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
184
+ }
185
+ $quoteId = $order->getQuoteId();
186
+
187
+ $quote = Mage::getModel('sales/quote')->load($quoteId)->setIsActive(true)->save();
188
+
189
+ Mage::getSingleton('checkout/session')->replaceQuote($quote);
190
+ }
191
+
192
+ /**
193
+ * @param Mage_Sales_Model_Order $order
194
+ * @return array
195
+ */
196
+ protected function _getCustomerData(Mage_Sales_Model_Order $order)
197
+ {
198
+ $billingAddress = $order->getBillingAddress();
199
+
200
+ list($address, $houseNumber) = $this->_helper->parseAddress($billingAddress->getStreetFull());
201
+
202
+ return array(
203
+ 'merchant_customer_id' => $order->getCustomerId(),
204
+ 'email_address' => $order->getCustomerEmail(),
205
+ 'first_name' => $order->getCustomerFirstname(),
206
+ 'last_name' => $order->getCustomerLastname(),
207
+ 'address_type' => 'billing',
208
+ 'address' => trim($billingAddress->getCity()) . ' ' . trim($address),
209
+ 'postal_code' => $billingAddress->getPostcode(),
210
+ 'housenumber' => $houseNumber,
211
+ 'country' => $billingAddress->getCountryId(),
212
+ 'phone_numbers' => $billingAddress->getTelephone(),
213
+ 'user_agent' => $this->_coreHttp->getHttpUserAgent(),
214
+ 'referrer' => $this->_coreHttp->getHttpReferer(),
215
+ 'ip_address' => $this->_coreHttp->getRemoteAddr(),
216
+ 'forwarded_ip' => $this->getRequest()->getServer('HTTP_X_FORWARDED_FOR'),
217
+ 'gender' => $order->getCustomerGender() ? ('1' ? 'male' : ('2' ? 'female' : null)) : null, // "male", "female", "other", null
218
+ 'birth_date' => $order->getCustomerDob(), // Date (ISO 8601 / RFC 3339)
219
+ 'locale' => substr(Mage::getStoreConfig('general/locale/code'), 0, 2), // "^[a-zA-Z]{2}(_[a-zA-Z]{2})?$"
220
+ );
221
+ }
222
+ }
app/code/community/ING/KassaCompleet/controllers/CreditcardController.php ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_CreditcardController extends Mage_Core_Controller_Front_Action
22
+ {
23
+ /**
24
+ * @var ING_KassaCompleet_Helper_Creditcard
25
+ */
26
+ protected $_creditcard;
27
+
28
+ /**
29
+ * @var Varien_Db_Adapter_Pdo_Mysql
30
+ */
31
+ protected $_read;
32
+
33
+ /**
34
+ * @var Varien_Db_Adapter_Pdo_Mysql
35
+ */
36
+ protected $_write;
37
+
38
+ /**
39
+ * Get CreditCard core
40
+ * Give $_write mage writing resource
41
+ * Give $_read mage reading resource
42
+ */
43
+ public function _construct()
44
+ {
45
+ $this->_creditcard = Mage::helper('ingkassacompleet/creditcard');
46
+
47
+ $this->_read = Mage::getSingleton('core/resource')->getConnection('core_read');
48
+ $this->_write = Mage::getSingleton('core/resource')->getConnection('core_write');
49
+
50
+ parent::_construct();
51
+ }
52
+
53
+ /**
54
+ * Gets the current checkout session with order information
55
+ *
56
+ * @return Mage_Checkout_Model_Session
57
+ */
58
+ protected function _getCheckout()
59
+ {
60
+ return Mage::getSingleton('checkout/session');
61
+ }
62
+
63
+ /**
64
+ * Creates the order and sets the redirect url
65
+ */
66
+ public function paymentAction()
67
+ {
68
+ // Load last order
69
+ /** @var $order Mage_Sales_Model_Order */
70
+ $order = Mage::getModel('sales/order')->loadByIncrementId($this->_getCheckout()->last_real_order_id);
71
+
72
+ try {
73
+ // Assign required value's
74
+ $amount = $order->getGrandTotal();
75
+ $orderId = $order->getIncrementId();
76
+ $description = str_replace('%', $orderId, Mage::getStoreConfig("payment/ingkassacompleet_creditcard/description", $order->getStoreId()));
77
+ $returnUrl = Mage::getUrl('ingkassacompleet/creditcard/return');
78
+
79
+ if ($this->_creditcard->createOrder($orderId, $amount, $description, $returnUrl)) {
80
+ if (!$order->getId()) {
81
+ Mage::log('Geen order voor verwerking gevonden');
82
+ Mage::throwException('Geen order voor verwerking gevonden');
83
+ }
84
+
85
+ // Creates transaction
86
+ /** @var $payment Mage_Sales_Model_Order_Payment */
87
+ $payment = $order->getPayment();
88
+
89
+ if (!$payment->getId()) {
90
+ $payment = Mage::getModel('sales/order_payment')->setId(null);
91
+ }
92
+
93
+ //->setMethod('CreditCard')
94
+ $payment->setIsTransactionClosed(false)
95
+ ->setIngOrderId($this->_creditcard->getOrderId())
96
+ ->setIngIdealIssuerId(null);
97
+
98
+ // Sets the above transaction
99
+ $order->setPayment($payment);
100
+
101
+ $order->setIngOrderId($this->_creditcard->getOrderId())
102
+ ->setIngIdealIssuerId(null);
103
+ $order->save();
104
+
105
+ $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
106
+
107
+ $pendingMessage = Mage::helper('ingkassacompleet')->__(ING_KassaCompleet_Model_Banktransfer::PAYMENT_FLAG_PENDING);
108
+ if ($order->getData('ing_order_id')) {
109
+ $pendingMessage .= '. ' . 'ING Order ID: ' . $order->getData('ing_order_id');
110
+ }
111
+
112
+ $order->setState(
113
+ Mage_Sales_Model_Order::STATE_PROCESSING,
114
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
115
+ $pendingMessage,
116
+ false
117
+ );
118
+ $order->save();
119
+
120
+ Mage::log("Issuer url: " . $this->_creditcard->getPaymentUrl());
121
+ $this->_redirectUrl($this->_creditcard->getPaymentUrl());
122
+ }
123
+ } catch (Exception $e) {
124
+ Mage::log($e);
125
+ Mage::throwException(
126
+ "Could not start transaction. Contact the owner.<br />
127
+ Error message: " . $this->_creditcard->getErrorMessage()
128
+ );
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Customer returning with an order_id
134
+ * Depending on the order state redirected to the corresponding page
135
+ */
136
+ public function returnAction()
137
+ {
138
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
139
+
140
+ try {
141
+ if (!empty($orderId)) {
142
+ $ingOrderDetails = $this->_creditcard->getOrderDetails($orderId);
143
+
144
+ $paymentStatus = isset($ingOrderDetails['status']) ? $ingOrderDetails['status'] : null;
145
+
146
+ if ($paymentStatus == "completed") {
147
+ // Redirect to success page
148
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
149
+ } else {
150
+ $this->_restoreCart();
151
+
152
+ // Redirect to failure page
153
+ $this->_redirect('checkout/onepage/failure', array('_secure' => true));
154
+ }
155
+ }
156
+ } catch (Exception $e) {
157
+ $this->_restoreCart();
158
+
159
+ Mage::log($e);
160
+ $this->_redirectUrl(Mage::getBaseUrl());
161
+ }
162
+ }
163
+
164
+ protected function _restoreCart()
165
+ {
166
+ $session = Mage::getSingleton('checkout/session');
167
+ $orderId = $session->getLastRealOrderId();
168
+ if (!empty($orderId)) {
169
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
170
+ }
171
+ $quoteId = $order->getQuoteId();
172
+
173
+ $quote = Mage::getModel('sales/quote')->load($quoteId)->setIsActive(true)->save();
174
+
175
+ Mage::getSingleton('checkout/session')->replaceQuote($quote);
176
+ }
177
+
178
+ /**
179
+ * @param Mage_Sales_Model_Order $order
180
+ * @param float $orderAmount
181
+ */
182
+ protected function _setAmountPaid(Mage_Sales_Model_Order $order, $orderAmount)
183
+ {
184
+ // set the amounts paid
185
+ $currentBase = Mage::app()->getStore()->getBaseCurrencyCode();
186
+ $currentStore = Mage::app()->getStore()->getCurrentCurrencyCode();
187
+
188
+ $amountBase = Mage::helper('directory')->currencyConvert($orderAmount, 'EUR', $currentBase);
189
+ $amountStore = Mage::helper('directory')->currencyConvert($orderAmount, 'EUR', $currentStore);
190
+
191
+ $order->setBaseTotalPaid($amountBase);
192
+ $order->setTotalPaid($amountStore);
193
+ }
194
+
195
+ /**
196
+ * @param Mage_Sales_Model_Order $order
197
+ * @param null|string $transactionId
198
+ * @return bool
199
+ */
200
+ protected function _savePaidInvoice(Mage_Sales_Model_Order $order, $transactionId = null)
201
+ {
202
+ $invoice = $order->prepareInvoice()
203
+ ->register()
204
+ ->setTransactionId($transactionId)
205
+ ->pay();
206
+
207
+ Mage::getModel('core/resource_transaction')
208
+ ->addObject($invoice)
209
+ ->addObject($invoice->getOrder())
210
+ ->save();
211
+
212
+ if (Mage::getStoreConfig("payment/ingkassacompleet_creditcard/send_invoice_mail", $order->getStoreId())) {
213
+ $invoice->sendEmail();
214
+ }
215
+
216
+ return true;
217
+ }
218
+
219
+ /**
220
+ * Format price with currency sign
221
+ *
222
+ * @param Mage_Sales_Model_Order $order
223
+ * @param float $amount
224
+ * @return string
225
+ */
226
+ protected function _formatPrice($order, $amount)
227
+ {
228
+ return $order->getBaseCurrency()->formatTxt($amount);
229
+ }
230
+ }
app/code/community/ING/KassaCompleet/controllers/IdealController.php ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ class ING_KassaCompleet_IdealController extends Mage_Core_Controller_Front_Action
22
+ {
23
+ /**
24
+ * @var ING_KassaCompleet_Helper_Ideal
25
+ */
26
+ protected $_ideal;
27
+
28
+ /**
29
+ * @var Varien_Db_Adapter_Pdo_Mysql
30
+ */
31
+ protected $_read;
32
+
33
+ /**
34
+ * @var Varien_Db_Adapter_Pdo_Mysql
35
+ */
36
+ protected $_write;
37
+
38
+ /**
39
+ * Get iDEAL core
40
+ * Give $_write mage writing resource
41
+ * Give $_read mage reading resource
42
+ */
43
+ public function _construct()
44
+ {
45
+ $this->_ideal = Mage::helper('ingkassacompleet/ideal');
46
+ $this->_read = Mage::getSingleton('core/resource')->getConnection('core_read');
47
+ $this->_write = Mage::getSingleton('core/resource')->getConnection('core_write');
48
+
49
+ parent::_construct();
50
+ }
51
+
52
+ /**
53
+ * Gets the current checkout session with order information
54
+ *
55
+ * @return Mage_Checkout_Model_Session
56
+ */
57
+ protected function _getCheckout()
58
+ {
59
+ return Mage::getSingleton('checkout/session');
60
+ }
61
+
62
+ /**
63
+ * Creats the order and sets the redirect url
64
+ *
65
+ */
66
+ public function paymentAction()
67
+ {
68
+ // Load last order
69
+ /** @var $order Mage_Sales_Model_Order */
70
+ $order = Mage::getModel('sales/order')->loadByIncrementId($this->_getCheckout()->last_real_order_id);
71
+
72
+ try {
73
+ // Assign required value's
74
+ $issuerId = Mage::app()->getRequest()->getParam('issuer_id');
75
+ $amount = $order->getGrandTotal();
76
+ $orderId = $order->getIncrementId();
77
+ $description = str_replace('%', $orderId, Mage::getStoreConfig("payment/ingkassacompleet_ideal/description", $order->getStoreId()));
78
+ $returnUrl = Mage::getUrl('ingkassacompleet/ideal/return');
79
+
80
+ if ($this->_ideal->createOrder($orderId, $issuerId, $amount, $description, $returnUrl)) {
81
+ if (!$order->getId()) {
82
+ Mage::log('Geen order voor verwerking gevonden');
83
+ Mage::throwException('Geen order voor verwerking gevonden');
84
+ }
85
+
86
+ // Creates transaction
87
+ /** @var $payment Mage_Sales_Model_Order_Payment */
88
+ $payment = $order->getPayment();
89
+
90
+ if (!$payment->getId()) {
91
+ $payment = Mage::getModel('sales/order_payment')->setId(null);
92
+ }
93
+
94
+ //->setMethod('iDEAL')
95
+ $payment->setIsTransactionClosed(false)
96
+ ->setIngOrderId($this->_ideal->getOrderId())
97
+ ->setIngIdealIssuerId($issuerId);
98
+
99
+ // Sets the above transaction
100
+ $order->setPayment($payment);
101
+
102
+ $order->setIngOrderId($this->_ideal->getOrderId())
103
+ ->setIngIdealIssuerId($issuerId);
104
+ $order->save();
105
+
106
+ $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
107
+
108
+ $pendingMessage = Mage::helper('ingkassacompleet')->__(ING_KassaCompleet_Model_Banktransfer::PAYMENT_FLAG_PENDING);
109
+ if ($order->getData('ing_order_id')) {
110
+ $pendingMessage .= '. ' . 'ING Order ID: ' . $order->getData('ing_order_id');
111
+ }
112
+
113
+ $order->setState(
114
+ Mage_Sales_Model_Order::STATE_PROCESSING,
115
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
116
+ $pendingMessage,
117
+ false
118
+ );
119
+ $order->save();
120
+
121
+ Mage::log("Issuer url: " . $this->_ideal->getPaymentUrl());
122
+ $this->_redirectUrl($this->_ideal->getPaymentUrl());
123
+ }
124
+ } catch (Exception $e) {
125
+ Mage::log($e);
126
+ Mage::throwException(
127
+ "Could not start transaction. Contact the owner.<br />
128
+ Error message: " . $this->_ideal->getErrorMessage()
129
+ );
130
+ }
131
+ }
132
+
133
+ /**
134
+ * This action is getting called by Payment service to report the payment status
135
+ */
136
+ public function webhookAction()
137
+ {
138
+ $input = json_decode(file_get_contents("php://input"), true);
139
+
140
+ if (!$input) {
141
+ die("Invalid JSON");
142
+ }
143
+
144
+ if (in_array($input['event'], array("status_changed"))) {
145
+
146
+ $ingOrderId = $input['order_id'];
147
+
148
+ $ingOrder = $this->_ideal->getOrderDetails($ingOrderId);
149
+
150
+ $orderId = $ingOrder['merchant_order_id'];
151
+ $orderStatus = $ingOrder['status'];
152
+
153
+ /** @var $order Mage_Sales_Model_Order */
154
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
155
+
156
+ try {
157
+ if ($order->getData('status') == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
158
+ // Creates transaction
159
+ $payment = Mage::getModel('sales/order_payment')
160
+ ->setMethod('iDEAL')
161
+ ->setIsTransactionClosed(true);
162
+
163
+ // Sets the above transaction
164
+ $order->setPayment($payment);
165
+ $orderAmountCents = (int)round($order->getGrandTotal() * 100);
166
+
167
+ switch ($orderStatus) {
168
+ case "completed":
169
+ // store the amount paid in the order
170
+ $amountPaidCents = (int)$ingOrder['amount'];
171
+ // $this->_setAmountPaid($order, $amount_paid_cents / 100);
172
+
173
+ if ($amountPaidCents == $orderAmountCents) {
174
+ $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
175
+
176
+ $order->setState(
177
+ Mage_Sales_Model_Order::STATE_PROCESSING,
178
+ Mage_Sales_Model_Order::STATE_PROCESSING,
179
+ Mage::helper('ingkassacompleet')->__(ING_KassaCompleet_Model_Ideal::PAYMENT_FLAG_COMPLETED),
180
+ true
181
+ );
182
+ $order->save();
183
+
184
+ $order->setState(
185
+ Mage_Sales_Model_Order::STATE_PROCESSING,
186
+ Mage_Sales_Model_Order::STATE_PROCESSING,
187
+ Mage::helper('sales')->__('Registered notification about captured amount of %s.', $this->_formatPrice($order, $order->getGrandTotal())),
188
+ false
189
+ );
190
+ $order->save();
191
+
192
+ // Sends email to customer.
193
+ if (Mage::getStoreConfig("payment/ingkassacompleet_ideal/send_invoice_mail", $order->getStoreId())) {
194
+ $order->sendNewOrderEmail()->setEmailSent(true)->save();
195
+ }
196
+
197
+ // Create invoice.
198
+ if (Mage::getStoreConfig("payment/ingkassacompleet_ideal/generate_invoice_upon_completion", $order->getStoreId())) {
199
+ $this->_savePaidInvoice($order);
200
+ }
201
+ } else {
202
+ $order->setState(
203
+ Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
204
+ Mage_Sales_Model_Order::STATUS_FRAUD,
205
+ Mage::helper('ingkassacompleet')->__(ING_KassaCompleet_Model_Ideal::PAYMENT_FLAG_FRAUD),
206
+ false
207
+ );
208
+ $order->save();
209
+ }
210
+ break;
211
+ case "cancelled":
212
+ $order->cancel();
213
+ $order->setState(
214
+ Mage_Sales_Model_Order::STATE_CANCELED,
215
+ Mage_Sales_Model_Order::STATE_CANCELED,
216
+ Mage::helper('ingkassacompleet')->__(ING_KassaCompleet_Model_Ideal::PAYMENT_FLAG_CANCELLED),
217
+ true
218
+ );
219
+ $order->save();
220
+ break;
221
+ case "error":
222
+ case "pending":
223
+ case "see-transactions":
224
+ case "new":
225
+ default:
226
+ // just wait
227
+ break;
228
+ }
229
+ }
230
+ } catch (Exception $e) {
231
+ Mage::log($e);
232
+ Mage::throwException($e);
233
+ }
234
+ }
235
+ }
236
+
237
+ /**
238
+ * Customer returning with an order_id
239
+ * Depending on the order state redirected to the corresponding page
240
+ */
241
+ public function returnAction()
242
+ {
243
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
244
+
245
+ try {
246
+ if (!empty($orderId)) {
247
+ $ingOrderDetails = $this->_ideal->getOrderDetails($orderId);
248
+
249
+ $paymentStatus = isset($ingOrderDetails['status']) ? $ingOrderDetails['status'] : null;
250
+
251
+ if ($paymentStatus == "completed") {
252
+ // Redirect to success page
253
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
254
+ } else {
255
+ $this->_restoreCart();
256
+
257
+ // Redirect to failure page
258
+ $this->_redirect('checkout/onepage/failure', array('_secure' => true));
259
+ }
260
+ }
261
+ } catch (Exception $e) {
262
+ $this->_restoreCart();
263
+
264
+ Mage::log($e);
265
+ $this->_redirectUrl(Mage::getBaseUrl());
266
+ }
267
+ }
268
+
269
+ protected function _restoreCart()
270
+ {
271
+ $session = Mage::getSingleton('checkout/session');
272
+ $orderId = $session->getLastRealOrderId();
273
+ if (!empty($orderId)) {
274
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
275
+ }
276
+ $quoteId = $order->getQuoteId();
277
+
278
+ $quote = Mage::getModel('sales/quote')->load($quoteId)->setIsActive(true)->save();
279
+
280
+ Mage::getSingleton('checkout/session')->replaceQuote($quote);
281
+ }
282
+
283
+ /**
284
+ * @param Mage_Sales_Model_Order $order
285
+ * @param float $orderAmount
286
+ */
287
+ protected function _setAmountPaid(Mage_Sales_Model_Order $order, $orderAmount)
288
+ {
289
+ // set the amounts paid
290
+ $currentBase = Mage::app()->getStore()->getBaseCurrencyCode();
291
+ $currentStore = Mage::app()->getStore()->getCurrentCurrencyCode();
292
+
293
+ $amountBase = Mage::helper('directory')->currencyConvert($orderAmount, 'EUR', $currentBase);
294
+ $amountStore = Mage::helper('directory')->currencyConvert($orderAmount, 'EUR', $currentStore);
295
+
296
+ $order->setBaseTotalPaid($amountBase);
297
+ $order->setTotalPaid($amountStore);
298
+ }
299
+
300
+ /**
301
+ * @param Mage_Sales_Model_Order $order
302
+ * @param null|string $transactionId
303
+ * @return bool
304
+ */
305
+ protected function _savePaidInvoice(Mage_Sales_Model_Order $order, $transactionId = null)
306
+ {
307
+ $invoice = $order->prepareInvoice()
308
+ ->register()
309
+ ->setTransactionId($transactionId)
310
+ ->pay();
311
+
312
+ Mage::getModel('core/resource_transaction')
313
+ ->addObject($invoice)
314
+ ->addObject($invoice->getOrder())
315
+ ->save();
316
+
317
+ if (Mage::getStoreConfig("payment/ingkassacompleet_ideal/send_invoice_mail", $order->getStoreId())) {
318
+ $invoice->sendEmail();
319
+ }
320
+
321
+ return true;
322
+ }
323
+
324
+ /**
325
+ * Format price with currency sign
326
+ *
327
+ * @param Mage_Sales_Model_Order $order
328
+ * @param float $amount
329
+ * @return string
330
+ */
331
+ protected function _formatPrice($order, $amount)
332
+ {
333
+ return $order->getBaseCurrency()->formatTxt($amount);
334
+ }
335
+ }
app/code/community/ING/KassaCompleet/etc/adminhtml.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ -->
19
+ <config>
20
+ <acl>
21
+ <resources>
22
+ <all>
23
+ <title>Allow Everything</title>
24
+ </all>
25
+ <admin>
26
+ <children>
27
+ <system>
28
+ <children>
29
+ <config>
30
+ <children>
31
+ <ingkassacompleet>
32
+ <title>ING Kassa Compleet Betaal Methode(s)</title>
33
+ </ingkassacompleet>
34
+ </children>
35
+ </config>
36
+ </children>
37
+ </system>
38
+ </children>
39
+ </admin>
40
+ </resources>
41
+ </acl>
42
+ </config>
app/code/community/ING/KassaCompleet/etc/config.xml ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <ING_KassaCompleet>
22
+ <version>1.0.3</version>
23
+ </ING_KassaCompleet>
24
+ </modules>
25
+ <global>
26
+ <models>
27
+ <ingkassacompleet>
28
+ <class>ING_KassaCompleet_Model</class>
29
+ </ingkassacompleet>
30
+ </models>
31
+ <blocks>
32
+ <ingkassacompleet>
33
+ <class>ING_KassaCompleet_Block</class>
34
+ </ingkassacompleet>
35
+ <payment>
36
+ <class>ING_KassaCompleet_Block</class>
37
+ <class>Mage_Payment_Block</class>
38
+ </payment>
39
+ </blocks>
40
+ <helpers>
41
+ <ingkassacompleet>
42
+ <class>ING_KassaCompleet_Helper</class>
43
+ </ingkassacompleet>
44
+ </helpers>
45
+ <payment>
46
+ <groups>
47
+ <ingkassacompleet>ingkassacompleet</ingkassacompleet>
48
+ </groups>
49
+ </payment>
50
+ <resources>
51
+ <ingkassacompleet_setup>
52
+ <setup>
53
+ <module>ING_KassaCompleet</module>
54
+ <class>Mage_Catalog_Model_Resource_Setup</class>
55
+ </setup>
56
+ <connection>
57
+ <use>core_setup</use>
58
+ </connection>
59
+ </ingkassacompleet_setup>
60
+ <ingkassacompleet_write>
61
+ <connection>
62
+ <use>core_write</use>
63
+ </connection>
64
+ </ingkassacompleet_write>
65
+ <ingkassacompleet_read>
66
+ <connection>
67
+ <use>core_read</use>
68
+ </connection>
69
+ </ingkassacompleet_read>
70
+ </resources>
71
+ <fieldsets>
72
+ <sales_convert_quote>
73
+ <ing_order_id><to_order>*</to_order></ing_order_id>
74
+ <ing_banktransfer_reference><to_order>*</to_order></ing_banktransfer_reference>
75
+ <ing_ideal_issuer_id><to_order>*</to_order></ing_ideal_issuer_id>
76
+ </sales_convert_quote>
77
+ <sales_convert_order>
78
+ <ing_order_id><to_quote>*</to_quote></ing_order_id>
79
+ <ing_banktransfer_reference><to_quote>*</to_quote></ing_banktransfer_reference>
80
+ <ing_ideal_issuer_id><to_quote>*</to_quote></ing_ideal_issuer_id>
81
+ </sales_convert_order>
82
+ </fieldsets>
83
+ </global>
84
+ <frontend>
85
+ <routers>
86
+ <ingkassacompleet>
87
+ <use>standard</use>
88
+ <args>
89
+ <module>ING_KassaCompleet</module>
90
+ <frontName>ingkassacompleet</frontName>
91
+ </args>
92
+ </ingkassacompleet>
93
+ </routers>
94
+ <layout>
95
+ <updates>
96
+ <ingkassacompleet>
97
+ <file>ing_kassacompleet.xml</file>
98
+ </ingkassacompleet>
99
+ </updates>
100
+ </layout>
101
+ <translate>
102
+ <modules>
103
+ <ING_KassaCompleet>
104
+ <files>
105
+ <default>ING_KassaCompleet.csv</default>
106
+ </files>
107
+ </ING_KassaCompleet>
108
+ </modules>
109
+ </translate>
110
+ <events>
111
+ <sales_convert_quote_payment_to_order_payment>
112
+ <observers>
113
+ <ingkassacompleet_observer>
114
+ <type>singleton</type>
115
+ <class>ingkassacompleet/observer</class>
116
+ <method>convertPayment</method>
117
+ </ingkassacompleet_observer>
118
+ </observers>
119
+ </sales_convert_quote_payment_to_order_payment>
120
+ </events>
121
+ </frontend>
122
+ <adminhtml>
123
+ <layout>
124
+ <updates>
125
+ <ingkassacompleet>
126
+ <file>ing_kassacompleet.xml</file>
127
+ </ingkassacompleet>
128
+ </updates>
129
+ </layout>
130
+ <translate>
131
+ <modules>
132
+ <ING_KassaCompleet>
133
+ <files>
134
+ <default>ING_KassaCompleet.csv</default>
135
+ </files>
136
+ </ING_KassaCompleet>
137
+ </modules>
138
+ </translate>
139
+ </adminhtml>
140
+ <default>
141
+ <payment>
142
+ <ingkassacompleet_ideal>
143
+ <group>ingkassacompleet</group>
144
+ <active>1</active>
145
+ <title>iDEAL</title>
146
+ <description>iDEAL</description>
147
+ <model>ingkassacompleet/ideal</model>
148
+ <title>iDEAL</title>
149
+ <currency>EUR</currency>
150
+ <allowspecific>1</allowspecific>
151
+ <specificcountry>NL</specificcountry>
152
+ <sort_order>101</sort_order>
153
+ </ingkassacompleet_ideal>
154
+ <ingkassacompleet_banktransfer>
155
+ <group>ingkassacompleet</group>
156
+ <active>1</active>
157
+ <title>Overboeking</title>
158
+ <description>Overboeking</description>
159
+ <model>ingkassacompleet/banktransfer</model>
160
+ <title>Overboeking</title>
161
+ <currency>EUR</currency>
162
+ <allowspecific>1</allowspecific>
163
+ <specificcountry>NL</specificcountry>
164
+ <sort_order>102</sort_order>
165
+ <account_details>
166
+ <iban>NL13INGB0005300060</iban>
167
+ <bic>INGBNL2A</bic>
168
+ <holder>ING Bank N.V. PSP</holder>
169
+ <city>Amsterdam, NL</city>
170
+ </account_details>
171
+ </ingkassacompleet_banktransfer>
172
+ <ingkassacompleet_creditcard>
173
+ <group>ingkassacompleet</group>
174
+ <active>1</active>
175
+ <title>CreditCard</title>
176
+ <description>CreditCard</description>
177
+ <model>ingkassacompleet/creditcard</model>
178
+ <title>CreditCard</title>
179
+ <currency>EUR</currency>
180
+ <allowspecific>1</allowspecific>
181
+ <specificcountry>NL</specificcountry>
182
+ <sort_order>103</sort_order>
183
+ </ingkassacompleet_creditcard>
184
+ <ingkassacompleet_cashondelivery>
185
+ <group>ingkassacompleet</group>
186
+ <active>1</active>
187
+ <title>Rembours</title>
188
+ <description>Rembours</description>
189
+ <model>ingkassacompleet/cashondelivery</model>
190
+ <title>Rembours</title>
191
+ <currency>EUR</currency>
192
+ <allowspecific>1</allowspecific>
193
+ <specificcountry>NL</specificcountry>
194
+ <sort_order>104</sort_order>
195
+ </ingkassacompleet_cashondelivery>
196
+ </payment>
197
+ </default>
198
+ </config>
app/code/community/ING/KassaCompleet/etc/system.xml ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger Payments B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ -->
20
+ <config>
21
+ <sections>
22
+ <payment>
23
+ <groups>
24
+ <ingkassacompleet translate="label comment">
25
+ <label>ING Kassa Compleet - Settings</label>
26
+ <expanded>1</expanded>
27
+ <sort_order>116</sort_order>
28
+ <frontend_type>text</frontend_type>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>1</show_in_store>
32
+ <fields>
33
+ <version>
34
+ <label>v1.0.3</label>
35
+ <sort_order>1</sort_order>
36
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
37
+ <frontend_type>label</frontend_type>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>1</show_in_store>
41
+ </version>
42
+ <apikey translate="label">
43
+ <label>API Key</label>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>2</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <validate>required-entry validate-alphanum</validate>
50
+ </apikey>
51
+ </fields>
52
+ </ingkassacompleet>
53
+ <ingkassacompleet_ideal translate="label comment" module="ingkassacompleet">
54
+ <label>ING Kassa Compleet - iDEAL</label>
55
+ <expanded>1</expanded>
56
+ <sort_order>117</sort_order>
57
+ <frontend_type>text</frontend_type>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ <fields>
62
+ <active translate="label">
63
+ <label>Enabled</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_yesno</source_model>
66
+ <sort_order>100</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>0</show_in_store>
70
+ </active>
71
+ <title translate="label">
72
+ <label>Title</label>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>150</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ <validate>required-entry</validate>
79
+ </title>
80
+ <description translate="label">
81
+ <label>Description</label>
82
+ <frontend_type>text</frontend_type>
83
+ <sort_order>200</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ <validate>required-entry</validate>
88
+ </description>
89
+ <specificcountry translate="label">
90
+ <label>Payment from Specific Countries</label>
91
+ <sort_order>300</sort_order>
92
+ <frontend_type>multiselect</frontend_type>
93
+ <source_model>adminhtml/system_config_source_country</source_model>
94
+ <can_be_empty>1</can_be_empty>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ </specificcountry>
99
+ <send_order_mail translate="label">
100
+ <label>Send order mail</label>
101
+ <sort_order>400</sort_order>
102
+ <frontend_type>select</frontend_type>
103
+ <source_model>adminhtml/system_config_source_yesno</source_model>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ </send_order_mail>
108
+ <generate_invoice_upon_completion translate="label">
109
+ <label>Generate invoice upon succesfull transaction</label>
110
+ <sort_order>500</sort_order>
111
+ <frontend_type>select</frontend_type>
112
+ <source_model>adminhtml/system_config_source_yesno</source_model>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </generate_invoice_upon_completion>
117
+ <send_invoice_mail translate="label">
118
+ <label>Send invoice mail</label>
119
+ <sort_order>600</sort_order>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>adminhtml/system_config_source_yesno</source_model>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ <depends>
126
+ <generate_invoice_upon_completion>1</generate_invoice_upon_completion>
127
+ </depends>
128
+ </send_invoice_mail>
129
+ <sort_order translate="label">
130
+ <label>Sort order</label>
131
+ <frontend_type>text</frontend_type>
132
+ <sort_order>700</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ </sort_order>
137
+ </fields>
138
+ </ingkassacompleet_ideal>
139
+ <ingkassacompleet_banktransfer translate="label comment" module="ingkassacompleet">
140
+ <label>ING Kassa Compleet - Banktransfer</label>
141
+ <expanded>1</expanded>
142
+ <sort_order>118</sort_order>
143
+ <frontend_type>text</frontend_type>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>1</show_in_store>
147
+ <fields>
148
+ <active translate="label">
149
+ <label>Enabled</label>
150
+ <frontend_type>select</frontend_type>
151
+ <source_model>adminhtml/system_config_source_yesno</source_model>
152
+ <sort_order>100</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ </active>
157
+ <title translate="label">
158
+ <label>Title</label>
159
+ <frontend_type>text</frontend_type>
160
+ <sort_order>150</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>1</show_in_website>
163
+ <show_in_store>1</show_in_store>
164
+ <validate>required-entry</validate>
165
+ </title>
166
+ <description translate="label">
167
+ <label>Description</label>
168
+ <frontend_type>text</frontend_type>
169
+ <sort_order>200</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>1</show_in_website>
172
+ <show_in_store>1</show_in_store>
173
+ <validate>required-entry</validate>
174
+ </description>
175
+ <specificcountry translate="label">
176
+ <label>Payment from Specific Countries</label>
177
+ <sort_order>300</sort_order>
178
+ <frontend_type>multiselect</frontend_type>
179
+ <source_model>adminhtml/system_config_source_country</source_model>
180
+ <can_be_empty>1</can_be_empty>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>1</show_in_store>
184
+ </specificcountry>
185
+ <send_order_mail translate="label">
186
+ <label>Send order mail</label>
187
+ <sort_order>400</sort_order>
188
+ <frontend_type>select</frontend_type>
189
+ <source_model>adminhtml/system_config_source_yesno</source_model>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>1</show_in_website>
192
+ <show_in_store>1</show_in_store>
193
+ </send_order_mail>
194
+ <generate_invoice_upon_completion translate="label">
195
+ <label>Generate invoice upon succesfull transaction</label>
196
+ <sort_order>500</sort_order>
197
+ <frontend_type>select</frontend_type>
198
+ <source_model>adminhtml/system_config_source_yesno</source_model>
199
+ <show_in_default>1</show_in_default>
200
+ <show_in_website>1</show_in_website>
201
+ <show_in_store>1</show_in_store>
202
+ </generate_invoice_upon_completion>
203
+ <send_invoice_mail translate="label">
204
+ <label>Send invoice mail</label>
205
+ <sort_order>600</sort_order>
206
+ <frontend_type>select</frontend_type>
207
+ <source_model>adminhtml/system_config_source_yesno</source_model>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ <depends>
212
+ <generate_invoice_upon_completion>1</generate_invoice_upon_completion>
213
+ </depends>
214
+ </send_invoice_mail>
215
+ <sort_order translate="label">
216
+ <label>Sort order</label>
217
+ <frontend_type>text</frontend_type>
218
+ <sort_order>700</sort_order>
219
+ <show_in_default>1</show_in_default>
220
+ <show_in_website>1</show_in_website>
221
+ <show_in_store>1</show_in_store>
222
+ </sort_order>
223
+ </fields>
224
+ </ingkassacompleet_banktransfer>
225
+ <ingkassacompleet_creditcard translate="label comment" module="ingkassacompleet">
226
+ <label>ING Kassa Compleet - Mastercard, VISA, Maestro of V PAY</label>
227
+ <expanded>1</expanded>
228
+ <sort_order>119</sort_order>
229
+ <frontend_type>text</frontend_type>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>1</show_in_store>
233
+ <fields>
234
+ <active translate="label">
235
+ <label>Enabled</label>
236
+ <frontend_type>select</frontend_type>
237
+ <source_model>adminhtml/system_config_source_yesno</source_model>
238
+ <sort_order>100</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>1</show_in_website>
241
+ <show_in_store>0</show_in_store>
242
+ </active>
243
+ <title translate="label">
244
+ <label>Title</label>
245
+ <frontend_type>text</frontend_type>
246
+ <sort_order>150</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>1</show_in_store>
250
+ <validate>required-entry</validate>
251
+ </title>
252
+ <description translate="label">
253
+ <label>Description</label>
254
+ <frontend_type>text</frontend_type>
255
+ <sort_order>200</sort_order>
256
+ <show_in_default>1</show_in_default>
257
+ <show_in_website>1</show_in_website>
258
+ <show_in_store>1</show_in_store>
259
+ <validate>required-entry</validate>
260
+ </description>
261
+ <specificcountry translate="label">
262
+ <label>Payment from Specific Countries</label>
263
+ <sort_order>300</sort_order>
264
+ <frontend_type>multiselect</frontend_type>
265
+ <source_model>adminhtml/system_config_source_country</source_model>
266
+ <can_be_empty>1</can_be_empty>
267
+ <show_in_default>1</show_in_default>
268
+ <show_in_website>1</show_in_website>
269
+ <show_in_store>1</show_in_store>
270
+ </specificcountry>
271
+ <send_order_mail translate="label">
272
+ <label>Send order mail</label>
273
+ <sort_order>400</sort_order>
274
+ <frontend_type>select</frontend_type>
275
+ <source_model>adminhtml/system_config_source_yesno</source_model>
276
+ <show_in_default>1</show_in_default>
277
+ <show_in_website>1</show_in_website>
278
+ <show_in_store>1</show_in_store>
279
+ </send_order_mail>
280
+ <generate_invoice_upon_completion translate="label">
281
+ <label>Generate invoice upon succesfull transaction</label>
282
+ <sort_order>500</sort_order>
283
+ <frontend_type>select</frontend_type>
284
+ <source_model>adminhtml/system_config_source_yesno</source_model>
285
+ <show_in_default>1</show_in_default>
286
+ <show_in_website>1</show_in_website>
287
+ <show_in_store>1</show_in_store>
288
+ </generate_invoice_upon_completion>
289
+ <send_invoice_mail translate="label">
290
+ <label>Send invoice mail</label>
291
+ <sort_order>600</sort_order>
292
+ <frontend_type>select</frontend_type>
293
+ <source_model>adminhtml/system_config_source_yesno</source_model>
294
+ <show_in_default>1</show_in_default>
295
+ <show_in_website>1</show_in_website>
296
+ <show_in_store>1</show_in_store>
297
+ <depends>
298
+ <generate_invoice_upon_completion>1</generate_invoice_upon_completion>
299
+ </depends>
300
+ </send_invoice_mail>
301
+ <sort_order translate="label">
302
+ <label>Sort order</label>
303
+ <frontend_type>text</frontend_type>
304
+ <sort_order>700</sort_order>
305
+ <show_in_default>1</show_in_default>
306
+ <show_in_website>1</show_in_website>
307
+ <show_in_store>1</show_in_store>
308
+ </sort_order>
309
+ </fields>
310
+ </ingkassacompleet_creditcard>
311
+ <ingkassacompleet_cashondelivery translate="label comment" module="ingkassacompleet">
312
+ <label>ING Kassa Compleet - Cashondelivery</label>
313
+ <expanded>1</expanded>
314
+ <sort_order>120</sort_order>
315
+ <frontend_type>text</frontend_type>
316
+ <show_in_default>1</show_in_default>
317
+ <show_in_website>1</show_in_website>
318
+ <show_in_store>1</show_in_store>
319
+ <fields>
320
+ <active translate="label">
321
+ <label>Enabled</label>
322
+ <frontend_type>select</frontend_type>
323
+ <source_model>adminhtml/system_config_source_yesno</source_model>
324
+ <sort_order>100</sort_order>
325
+ <show_in_default>1</show_in_default>
326
+ <show_in_website>1</show_in_website>
327
+ <show_in_store>0</show_in_store>
328
+ </active>
329
+ <title translate="label">
330
+ <label>Title</label>
331
+ <frontend_type>text</frontend_type>
332
+ <sort_order>150</sort_order>
333
+ <show_in_default>1</show_in_default>
334
+ <show_in_website>1</show_in_website>
335
+ <show_in_store>1</show_in_store>
336
+ <validate>required-entry</validate>
337
+ </title>
338
+ <description translate="label">
339
+ <label>Description</label>
340
+ <frontend_type>text</frontend_type>
341
+ <sort_order>200</sort_order>
342
+ <show_in_default>1</show_in_default>
343
+ <show_in_website>1</show_in_website>
344
+ <show_in_store>1</show_in_store>
345
+ <validate>required-entry</validate>
346
+ </description>
347
+ <specificcountry translate="label">
348
+ <label>Payment from Specific Countries</label>
349
+ <sort_order>300</sort_order>
350
+ <frontend_type>multiselect</frontend_type>
351
+ <source_model>adminhtml/system_config_source_country</source_model>
352
+ <can_be_empty>1</can_be_empty>
353
+ <show_in_default>1</show_in_default>
354
+ <show_in_website>1</show_in_website>
355
+ <show_in_store>1</show_in_store>
356
+ </specificcountry>
357
+ <send_order_mail translate="label">
358
+ <label>Send order mail</label>
359
+ <sort_order>400</sort_order>
360
+ <frontend_type>select</frontend_type>
361
+ <source_model>adminhtml/system_config_source_yesno</source_model>
362
+ <show_in_default>1</show_in_default>
363
+ <show_in_website>1</show_in_website>
364
+ <show_in_store>1</show_in_store>
365
+ </send_order_mail>
366
+ <generate_invoice_upon_completion translate="label">
367
+ <label>Generate invoice upon succesfull transaction</label>
368
+ <sort_order>500</sort_order>
369
+ <frontend_type>select</frontend_type>
370
+ <source_model>adminhtml/system_config_source_yesno</source_model>
371
+ <show_in_default>1</show_in_default>
372
+ <show_in_website>1</show_in_website>
373
+ <show_in_store>1</show_in_store>
374
+ </generate_invoice_upon_completion>
375
+ <send_invoice_mail translate="label">
376
+ <label>Send invoice mail</label>
377
+ <sort_order>600</sort_order>
378
+ <frontend_type>select</frontend_type>
379
+ <source_model>adminhtml/system_config_source_yesno</source_model>
380
+ <show_in_default>1</show_in_default>
381
+ <show_in_website>1</show_in_website>
382
+ <show_in_store>1</show_in_store>
383
+ <depends>
384
+ <generate_invoice_upon_completion>1</generate_invoice_upon_completion>
385
+ </depends>
386
+ </send_invoice_mail>
387
+ <sort_order translate="label">
388
+ <label>Sort order</label>
389
+ <frontend_type>text</frontend_type>
390
+ <sort_order>700</sort_order>
391
+ <show_in_default>1</show_in_default>
392
+ <show_in_website>1</show_in_website>
393
+ <show_in_store>1</show_in_store>
394
+ </sort_order>
395
+ </fields>
396
+ </ingkassacompleet_cashondelivery>
397
+ </groups>
398
+ </payment>
399
+ </sections>
400
+ </config>
app/code/community/ING/KassaCompleet/sql/ingkassacompleet_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+
21
+ /** @var $this Mage_Catalog_Model_Resource_Setup */
22
+ $this->startSetup();
23
+
24
+ $this->run(
25
+ sprintf("CREATE TABLE IF NOT EXISTS `%s` (
26
+ `order_id` int(11) NOT NULL,
27
+ `entity_id` int(11) NOT NULL,
28
+ `method` varchar(3) NOT NULL,
29
+ `transaction_id` varchar(32) NOT NULL,
30
+ `bank_account` varchar(15) NOT NULL,
31
+ `bank_status` varchar(20) NOT NULL
32
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;",
33
+ $this->getTable('ingkassacompleet_payments')
34
+ )
35
+ );
36
+
37
+ $this->endSetup();
app/code/community/ING/KassaCompleet/sql/ingkassacompleet_setup/mysql4-uninstall-0.0.1.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license http://www.opensource.org/licenses/bsd-license.php Open Software License (OSL 3.0)
18
+ *
19
+ **/
20
+
21
+ /** @var $this Mage_Catalog_Model_Resource_Setup */
22
+ $this->startSetup();
23
+
24
+ $this->run(
25
+ sprintf("DROP TABLE IF EXISTS `%s`",
26
+ $this->getTable('ingkassacompleet_payments')
27
+ )
28
+ );
29
+
30
+ $this->run("DELETE FROM `{$this->getTable('core_config_data')}` where `path` = 'ingkassacompleet/ideal/active';
31
+ DELETE FROM `{$this->getTable('core_config_data')}` where `path` = 'ingkassacompleet/ideal/description';
32
+ DELETE FROM `{$this->getTable('core_config_data')}` where `path` = 'ingkassacompleet/settings/apikey';
33
+ DELETE FROM `{$this->getTable('core_resource')}` where `code` = 'ingkassacompleet_setup';"
34
+ );
35
+
36
+ $this->endSetup();
app/code/community/ING/KassaCompleet/sql/ingkassacompleet_setup/mysql4-upgrade-0.0.1-0.0.2.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license http://www.opensource.org/licenses/bsd-license.php Open Software License (OSL 3.0)
18
+ *
19
+ **/
20
+
21
+ /** @var $this Mage_Catalog_Model_Resource_Setup */
22
+ $this->startSetup();
23
+
24
+
25
+ /** @var $conn Varien_Db_Adapter_Pdo_Mysql */
26
+ $conn = $this->getConnection();
27
+
28
+ $conn->addColumn($this->getTable('sales/quote_payment'), 'ing_order_id', array(
29
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
30
+ 'length' => 255,
31
+ 'nullable' => true,
32
+ 'default' => NULL,
33
+ 'comment' => 'ing order id',
34
+ ));
35
+
36
+ $conn->addColumn($this->getTable('sales/quote_payment'), 'ing_banktransfer_reference', array(
37
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
38
+ 'length' => 255,
39
+ 'nullable' => true,
40
+ 'default' => NULL,
41
+ 'comment' => 'ing banktransfer reference',
42
+ ));
43
+
44
+ $conn->addColumn($this->getTable('sales/quote_payment'), 'ing_ideal_issuer_id', array(
45
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
46
+ 'length' => 255,
47
+ 'nullable' => true,
48
+ 'default' => NULL,
49
+ 'comment' => 'ing ideal issuer id',
50
+ ));
51
+
52
+ $conn->addColumn($this->getTable('sales/order_payment'), 'ing_order_id', array(
53
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
54
+ 'length' => 255,
55
+ 'nullable' => true,
56
+ 'default' => NULL,
57
+ 'comment' => 'ing order id',
58
+ ));
59
+
60
+ $conn->addColumn($this->getTable('sales/order_payment'), 'ing_banktransfer_reference', array(
61
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
62
+ 'length' => 255,
63
+ 'nullable' => true,
64
+ 'default' => NULL,
65
+ 'comment' => 'ing banktransfer reference',
66
+ ));
67
+
68
+ $conn->addColumn($this->getTable('sales/order_payment'), 'ing_ideal_issuer_id', array(
69
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
70
+ 'length' => 255,
71
+ 'nullable' => true,
72
+ 'default' => NULL,
73
+ 'comment' => 'ing ideal issuer id',
74
+ ));
75
+
76
+ $this->endSetup();
app/code/community/ING/KassaCompleet/sql/ingkassacompleet_setup/mysql4-upgrade-0.0.2-0.0.3.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license http://www.opensource.org/licenses/bsd-license.php Open Software License (OSL 3.0)
18
+ *
19
+ **/
20
+
21
+ /** @var $this Mage_Catalog_Model_Resource_Setup */
22
+ $this->startSetup();
23
+
24
+ /** @var $conn Varien_Db_Adapter_Pdo_Mysql */
25
+ $conn = $this->getConnection();
26
+
27
+ $conn->addColumn($this->getTable('sales/quote'), 'ing_order_id', array(
28
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
29
+ 'length' => 255,
30
+ 'nullable' => true,
31
+ 'default' => NULL,
32
+ 'comment' => 'ing order id',
33
+ ));
34
+
35
+ $conn->addColumn($this->getTable('sales/quote'), 'ing_banktransfer_reference', array(
36
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
37
+ 'length' => 255,
38
+ 'nullable' => true,
39
+ 'default' => NULL,
40
+ 'comment' => 'ing banktransfer reference',
41
+ ));
42
+
43
+ $conn->addColumn($this->getTable('sales/quote'), 'ing_ideal_issuer_id', array(
44
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
45
+ 'length' => 255,
46
+ 'nullable' => true,
47
+ 'default' => NULL,
48
+ 'comment' => 'ing ideal issuer id',
49
+ ));
50
+
51
+ $conn->addColumn($this->getTable('sales/order'), 'ing_order_id', array(
52
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
53
+ 'length' => 255,
54
+ 'nullable' => true,
55
+ 'default' => NULL,
56
+ 'comment' => 'ing order id',
57
+ ));
58
+
59
+ $conn->addColumn($this->getTable('sales/order'), 'ing_banktransfer_reference', array(
60
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
61
+ 'length' => 255,
62
+ 'nullable' => true,
63
+ 'default' => NULL,
64
+ 'comment' => 'ing banktransfer reference',
65
+ ));
66
+
67
+ $conn->addColumn($this->getTable('sales/order'), 'ing_ideal_issuer_id', array(
68
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
69
+ 'length' => 255,
70
+ 'nullable' => true,
71
+ 'default' => NULL,
72
+ 'comment' => 'ing ideal issuer id',
73
+ ));
74
+
75
+ $this->endSetup();
app/design/adminhtml/default/default/template/ing_kassacompleet/info/banktransfer.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+ ?>
21
+ <p><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></p>
22
+ <?php if ($this->getInfo()->getAdditionalData()): ?>
23
+ <?php if ($this->getMailingAddress()): ?>
24
+ <p><strong><?php echo Mage::helper('payment')->__('Payment instructions:') ?></strong></p>
25
+ <address class="checkmo-mailing-address">
26
+ <?php echo nl2br($this->escapeHtml($this->getMailingAddress())) ?>
27
+ </address>
28
+ <?php endif ?>
29
+ <?php endif ?>
app/design/adminhtml/default/default/template/ing_kassacompleet/info/cashondelivery.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+ ?>
21
+ <p><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></p>
22
+ <?php if ($this->getInfo()->getAdditionalData()): ?>
23
+ <?php if ($this->getMailingAddress()): ?>
24
+ <p><strong><?php echo Mage::helper('payment')->__('Payment instructions:') ?></strong></p>
25
+ <address class="checkmo-mailing-address">
26
+ <?php echo nl2br($this->escapeHtml($this->getMailingAddress())) ?>
27
+ </address>
28
+ <?php endif ?>
29
+ <?php endif ?>
app/design/frontend/base/default/layout/ing_kassacompleet.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ╲ ╱
5
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
6
+ * │╭──╮ ╭──╮│
7
+ * ││//│ │//││
8
+ * │╰──╯ ╰──╯│
9
+ * ╰──────────────╯
10
+ * ╭──────────╮ The MIT License (MIT)
11
+ * │ () () () │
12
+ *
13
+ * @category ING
14
+ * @package ING_KassaCompleet
15
+ * @author Ginger B.V. (info@gingerpayments.com)
16
+ * @version v1.0.3
17
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
18
+ * @license The MIT License (MIT)
19
+ *
20
+ **/
21
+ -->
22
+ <layout version="0.1.0">
23
+ <checkout_onepage_success translate="label">
24
+ <reference name="checkout.success">
25
+ <action method="setTemplate"><template>ing_kassacompleet/success.phtml</template></action>
26
+ </reference>
27
+ </checkout_onepage_success>
28
+ </layout>
app/design/frontend/base/default/template/ing_kassacompleet/form/banktransfer.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+ ?>
21
+ <?php
22
+ $_code = $this->getMethodCode();
23
+ ?>
app/design/frontend/base/default/template/ing_kassacompleet/form/cashondelivery.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+ ?>
21
+ <?php
22
+ $_code = $this->getMethodCode();
23
+ ?>
app/design/frontend/base/default/template/ing_kassacompleet/form/ideal.phtml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+ ?>
21
+ <?php
22
+ $_code = $this->getMethodCode();
23
+ $_issuers = Mage::helper('ingkassacompleet/ideal')->getIssuers();
24
+ ?>
25
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
26
+ <li>
27
+ <label for="<?php echo $_code ?>_issuer_id" class="required"><em>*</em><?php echo $this->__('Choose your bank:') ?></label>
28
+ <span class="input-box">
29
+ <select name="issuer_id" class="required-entry input-text" id="<?php echo $_code; ?>_issuer_id" title="<?php echo $_code ?>_issuer_id">
30
+ <?php foreach ($_issuers as $issuer): ?>
31
+ <?php if (isset($issuer['id']) && isset($issuer['id'])): ?>
32
+ <option value="<?php echo $issuer['id'] ?>"><?php echo $issuer['name'] ?></option>
33
+ <?php endif ?>
34
+ <?php endforeach ?>
35
+ </select>
36
+ </span>
37
+ </li>
38
+ </ul>
app/design/frontend/base/default/template/ing_kassacompleet/info/banktransfer.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+ ?>
21
+ <p><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></p>
22
+ <?php if ($this->getInfo()->getAdditionalData()): ?>
23
+ <?php if ($this->getMailingAddress()): ?>
24
+ <p><strong><?php echo Mage::helper('payment')->__('Payment instructions:') ?></strong></p>
25
+ <address class="checkmo-mailing-address">
26
+ <?php echo nl2br($this->escapeHtml($this->getMailingAddress())) ?>
27
+ </address>
28
+ <?php endif ?>
29
+ <?php endif ?>
app/design/frontend/base/default/template/ing_kassacompleet/info/cashondelivery.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+ ?>
21
+ <p><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></p>
22
+ <?php if ($this->getInfo()->getAdditionalData()): ?>
23
+ <?php if ($this->getMailingAddress()): ?>
24
+ <p><strong><?php echo Mage::helper('payment')->__('Payment instructions:') ?></strong></p>
25
+ <address class="checkmo-mailing-address">
26
+ <?php echo nl2br($this->escapeHtml($this->getMailingAddress())) ?>
27
+ </address>
28
+ <?php endif ?>
29
+ <?php endif ?>
app/design/frontend/base/default/template/ing_kassacompleet/success.phtml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ╲ ╱
4
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
5
+ * │╭──╮ ╭──╮│
6
+ * ││//│ │//││
7
+ * │╰──╯ ╰──╯│
8
+ * ╰──────────────╯
9
+ * ╭──────────╮ The MIT License (MIT)
10
+ * │ () () () │
11
+ *
12
+ * @category ING
13
+ * @package ING_KassaCompleet
14
+ * @author Ginger B.V. (info@gingerpayments.com)
15
+ * @version v1.0.3
16
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
17
+ * @license The MIT License (MIT)
18
+ *
19
+ **/
20
+ ?>
21
+ <?php /** @var $this Mage_Checkout_Block_Onepage_Success */ ?>
22
+ <div class="page-title">
23
+ <h1><?php echo $this->__('Your order has been received.') ?></h1>
24
+ </div>
25
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
26
+ <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
27
+
28
+ <?php if ($reference = Mage::app()->getRequest()->getParam('reference')): ?>
29
+ <?php
30
+ /** @var $order Mage_Sales_Model_Order */
31
+ $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
32
+
33
+ /** @var $_helper ING_KassaCompleet_Helper_Banktransfer */
34
+ $_helper = Mage::helper('ingkassacompleet/banktransfer');
35
+ ?>
36
+ <b><?php echo $this->__('Payment instructions:') ?></b><br />
37
+ <?php echo $this->__('Please use the following data to make the banktransfer') ?><br />
38
+ <?php echo nl2br($_helper->getSuccessHtml($order, $reference)) ?>
39
+ <br />
40
+ <?php echo $this->__('ING processes the payments for'); ?> <?php echo Mage::app()->getGroup()->getName() ?><br />
41
+ <br />
42
+ <?php echo $this->__("(!) Don't forget to use the reference in your payment. Without the reference the processing of your payment can take more time!"); ?>
43
+ </p>
44
+ <?php endif ?>
45
+
46
+ <?php if ($this->getOrderId()):?>
47
+ <?php if ($this->getCanViewOrder()): ?>
48
+ <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
49
+ <?php else: ?>
50
+ <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
51
+ <?php endif ?>
52
+ <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
53
+ <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
54
+ <p>
55
+ <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
56
+ <?php echo $this->getChildHtml() ?>
57
+ </p>
58
+ <?php endif ?>
59
+ <?php endif ?>
60
+
61
+ <?php if ($this->getAgreementRefId()): ?>
62
+ <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId()))) ?></p>
63
+ <?php endif ?>
64
+
65
+ <?php if ($profiles = $this->getRecurringProfiles()): ?>
66
+ <p><?php echo $this->__('Your recurring payment profiles:') ?></p>
67
+ <ul class="disc">
68
+ <?php foreach($profiles as $profile): ?>
69
+ <?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) ?>
70
+ <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description'))) ?></li>
71
+ <?php endforeach ?>
72
+ </ul>
73
+ <?php endif ?>
74
+
75
+ <div class="buttons-set">
76
+ <button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
77
+ </div>
app/etc/modules/ING_KassaCompleet.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ╲ ╱
5
+ * ╭──────────────╮ COPYRIGHT (C) 2015 GINGER PAYMENTS B.V.
6
+ * │╭──╮ ╭──╮│
7
+ * ││//│ │//││
8
+ * │╰──╯ ╰──╯│
9
+ * ╰──────────────╯
10
+ * ╭──────────╮ The MIT License (MIT)
11
+ * │ () () () │
12
+ *
13
+ *
14
+ * @category ING
15
+ * @package ING_KassaCompleet
16
+ * @author Ginger B.V. (info@gingerpayments.com)
17
+ * @version v1.0.3
18
+ * @copyright COPYRIGHT (C) 2015 GINGER PAYMENTS B.V. (https://www.gingerpayments.com)
19
+ * @license The MIT License (MIT)
20
+ *
21
+ **/
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <ING_KassaCompleet>
26
+ <active>true</active>
27
+ <codePool>community</codePool>
28
+ <depends>
29
+ <Mage_Payment />
30
+ <Mage_Checkout />
31
+ </depends>
32
+ <version>1.0.3</version>
33
+ </ING_KassaCompleet>
34
+ </modules>
35
+ </config>
app/locale/en_US/ING_KassaCompleet.csv ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "ING Kassa Compleet - Settings","ING Kassa Compleet - Settings"
2
+ "API Key","API Key"
3
+ "ING Kassa Compleet - iDEAL","ING Kassa Compleet - iDEAL"
4
+ "ING Kassa Compleet - Banktransfer","ING Kassa Compleet - Banktransfer"
5
+ "ING Kassa Compleet - Mastercard, VISA, Maestro of V PAY","ING Kassa Compleet - Mastercard, VISA, Maestro of V PAY"
6
+ "Enabled","Enabled"
7
+ "Description","Description"
8
+
9
+ "Choose your bank:","Choose your bank:"
10
+
11
+ "Payment is pending","Payment is pending"
12
+ "Payment is completed","Payment is completed"
13
+ "Payment is cancelled","Payment is cancelled"
14
+ "Payment failed with an error","Payment failed with an error"
15
+ "Amounts don't match. Possible fraud","Amounts don't match. Possible fraud"
16
+
17
+ "Your order has been received.", "Your order has been received."
18
+ "Thank you for your purchase!","Thank you for your purchase!"
19
+ "Payment instructions:","Payment instructions:"
20
+ "Please use the following data to make the banktransfer", "Please use the following data to make the banktransfer"
21
+ "ING processes the payments for", "ING processes the payments for"
22
+ "(!) Don't forget to use the reference in your payment. Without the reference the processing of your payment can take more time!", "(!) Don't forget to use the reference in your payment. Without the reference the processing of your payment can take more time!"
23
+
24
+ "Amount:","Amount:"
25
+ "Reference:","Reference:"
26
+ "Account number:","Account number:"
27
+ "IBAN:","IBAN:"
28
+ "BIC:","BIC:"
29
+ "Account holder:","Account holder:"
30
+ "City:","City:"
app/locale/nl_NL/ING_KassaCompleet.csv ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "ING Kassa Compleet - Settings","ING Kassa Compleet - Instellingen"
2
+ "API Key","API Key"
3
+ "ING Kassa Compleet - iDEAL","ING Kassa Compleet - iDEAL"
4
+ "ING Kassa Compleet - Banktransfer","ING Kassa Compleet - Bankoverboeking"
5
+ "ING Kassa Compleet - Mastercard, VISA, Maestro of V PAY","ING Kassa Compleet - Mastercard, VISA, Maestro of V PAY"
6
+ "Enabled","Enabled"
7
+ "Description","Omschrijving"
8
+
9
+ "Choose your bank:","Kies uw bank:"
10
+
11
+ "Payment is pending","Betaling in verwerking"
12
+ "Payment is completed","Betaling afgerond"
13
+ "Payment is cancelled","Betaling is geannuleerd"
14
+ "Payment failed with an error","Betaling mislukt door een fout"
15
+ "Amounts don't match. Possible fraud","Bedragen komen niet overheen, mogelijk fraude"
16
+
17
+ "Your order has been received.", "Uw bestelling is ontvangen."
18
+ "Thank you for your purchase!","Dank voor uw aankoop!"
19
+ "Payment instructions:","Betaal instructies:"
20
+ "Please use the following data to make the banktransfer", "Gebuikt u de volgende gegevens voor de overboeking"
21
+ "ING processes the payments for", "ING verwerkt de betaling voor"
22
+ "(!) Don't forget to use the reference in your payment. Without the reference the processing of your payment can take more time!", "(!) Vergeet u niet het juiste betaalkenmerk te vermelden. Zonder het juiste betaalkenmerk kan de verwerking van uw betaling meer tijd kosten."
23
+
24
+ "Amount:","Bedrag:"
25
+ "Reference:","Kenmerk:"
26
+ "Account number:","Rekeningnummer:"
27
+ "IBAN:","IBAN:"
28
+ "BIC:","BIC:"
29
+ "Account holder:","Rekeninghouder:"
30
+ "City:","Woonplaats:"
lib/Ing/Services/Lib.php ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ing_Services_Lib
4
+ {
5
+ public $apiKey;
6
+ public $apiEndpoint;
7
+ public $apiVersion;
8
+
9
+ public $logTo;
10
+ public $logToFilename;
11
+
12
+ public $debugMode;
13
+ public $debugCurl;
14
+ public $debugCurlFilename;
15
+
16
+ public function __construct($apiKey, $logTo, $debugMode)
17
+ {
18
+ $this->apiKey = $apiKey;
19
+ $this->apiEndpoint = "https://api.kassacompleet.nl";
20
+ $this->apiVersion = "v1";
21
+
22
+ $this->logTo = $logTo;
23
+ $this->logToFilename = 'inglog.log';
24
+
25
+ $this->debugMode = $debugMode;
26
+ $this->debugCurl = false;
27
+ $this->debugCurlFilename = 'ingcurl.log';
28
+
29
+ $this->plugin_version = 'magento-ce-1.0.3';
30
+ }
31
+
32
+ public function ingLog($contents)
33
+ {
34
+ if ($this->logTo == 'file') {
35
+ // $file = dirname(__FILE__) . '/inglog.txt';
36
+ // file_put_contents($file, date('Y-m-d H.i.s') . ": ", FILE_APPEND);
37
+
38
+ if (is_array($contents)) {
39
+ $contents = var_export($contents, true);
40
+ } elseif (is_object($contents)) {
41
+ $contents = json_encode($contents);
42
+ }
43
+
44
+ // file_put_contents($file, $contents . "\n", FILE_APPEND);
45
+
46
+ Mage::log($contents, null, $this->logToFilename);
47
+ } else {
48
+ error_log($contents);
49
+ }
50
+ }
51
+
52
+ public function performApiCall($api_method, $post = false)
53
+ {
54
+ $url = implode("/", array($this->apiEndpoint, $this->apiVersion, $api_method));
55
+
56
+ $curl = curl_init($url);
57
+
58
+ $length = 0;
59
+ if ($post) {
60
+ curl_setopt($curl, CURLOPT_POST, 1);
61
+ // curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
62
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
63
+ $length = strlen($post);
64
+ }
65
+
66
+ $request_headers = array(
67
+ "Accept: application/json",
68
+ "Content-Type: application/json",
69
+ "User-Agent: gingerphplib",
70
+ "X-Ginger-Client-Info: " . php_uname(),
71
+ "Authorization: Basic " . base64_encode($this->apiKey . ":"),
72
+ "Connection: close",
73
+ "Content-length: " . $length,
74
+ );
75
+
76
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
77
+ curl_setopt($curl, CURLOPT_TIMEOUT, 10);
78
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); // 2 = to check the existence of a common name and also verify that it matches the hostname provided. In production environments the value of this option should be kept at 2 (default value).
79
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
80
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
81
+ curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
82
+ curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
83
+
84
+ if ($this->debugCurl) {
85
+ curl_setopt($curl, CURLOPT_VERBOSE, 1); // prevent caching issues
86
+ // $file = dirname(__FILE__) . '/ingcurl.txt';
87
+ // $handle = fopen($file, "a+");
88
+ $handle = fopen('php://temp', 'w+');
89
+ curl_setopt($curl, CURLOPT_STDERR, $handle); // prevent caching issues
90
+ }
91
+
92
+ $responseString = curl_exec($curl);
93
+
94
+ if ($this->debugCurl) {
95
+ rewind($handle);
96
+ $curlLogText = stream_get_contents($handle);
97
+ Mage::log($curlLogText, null, $this->debugCurlFilename);
98
+ }
99
+
100
+ if ($responseString == false) {
101
+ $response = array('error' => curl_error($curl));
102
+ } else {
103
+ $response = json_decode($responseString, true);
104
+
105
+ if (!$response) {
106
+ $this->ingLog('invalid json: JSON error code: ' . json_last_error() . "\nRequest: " . $responseString);
107
+ $response = array('error' => 'Invalid JSON');
108
+ }
109
+ }
110
+
111
+ curl_close($curl);
112
+
113
+ return $response;
114
+ }
115
+
116
+ public function ingGetIssuers()
117
+ {
118
+ // API Request to ING to fetch the issuers
119
+ return $this->performApiCall("ideal/issuers/");
120
+ }
121
+
122
+ public function ingCreateIdealOrder($orders_id, $total, $issuer_id, $return_url, $description)
123
+ {
124
+ $post = array(
125
+ "type" => "payment",
126
+ "currency" => "EUR",
127
+ "amount" => 100 * round($total, 2),
128
+ "merchant_order_id" => (string)$orders_id,
129
+ "description" => $description,
130
+ "return_url" => $return_url,
131
+ "transactions" => array(
132
+ array(
133
+ "payment_method" => "ideal",
134
+ "payment_method_details" => array("issuer_id" => $issuer_id)
135
+ )
136
+ ),
137
+ 'extra' => array(
138
+ 'plugin' => $this->plugin_version,
139
+ ),
140
+ );
141
+
142
+ $order = json_encode($post);
143
+ $result = $this->performApiCall("orders/", $order);
144
+
145
+ return $result;
146
+ }
147
+
148
+ public function ingCreateCreditCardOrder($orders_id, $total, $return_url, $description)
149
+ {
150
+ $post = array(
151
+ "type" => "payment",
152
+ "currency" => "EUR",
153
+ "amount" => 100 * round($total, 2),
154
+ "merchant_order_id" => (string)$orders_id,
155
+ "description" => $description,
156
+ "return_url" => $return_url,
157
+ "transactions" => array(
158
+ array(
159
+ "payment_method" => "credit-card",
160
+ )
161
+ ),
162
+ 'extra' => array(
163
+ 'plugin' => $this->plugin_version,
164
+ ),
165
+ );
166
+
167
+ $order = json_encode($post);
168
+ $result = $this->performApiCall("orders/", $order);
169
+
170
+ return $result;
171
+ }
172
+
173
+ public function ingCreateBanktransferOrder($orders_id, $total, $description, $customer = array())
174
+ {
175
+ $post = array(
176
+ "type" => "payment",
177
+ "currency" => "EUR",
178
+ "amount" => 100 * round($total, 2),
179
+ "description" => $description,
180
+ "transactions" => array(array(
181
+ "payment_method" => "bank-transfer",
182
+ )),
183
+ "merchant_order_id" => (string)$orders_id,
184
+ 'customer' => array(
185
+ 'merchant_customer_id' => !empty($customer['merchant_customer_id']) ? $customer['merchant_customer_id'] : null,
186
+ 'email_address' => !empty($customer['email_address']) ? $customer['email_address'] : null,
187
+ 'first_name' => !empty($customer['first_name']) ? $customer['first_name'] : null,
188
+ 'last_name' => !empty($customer['last_name']) ? $customer['last_name'] : null,
189
+ 'address_type' => !empty($customer['address_type']) ? $customer['address_type'] : null,
190
+ 'address' => !empty($customer['address']) ? $customer['address'] : null,
191
+ 'postal_code' => !empty($customer['postal_code']) ? $customer['postal_code'] : null,
192
+ 'housenumber' => !empty($customer['housenumber']) ? $customer['housenumber'] : null,
193
+ 'country' => !empty($customer['country']) ? $customer['country'] : null,
194
+ 'phone_numbers' => !empty($customer['phone_numbers']) ? array($customer['phone_numbers']) : null,
195
+ 'user_agent' => !empty($customer['user_agent']) ? $customer['user_agent'] : null,
196
+ 'referrer' => !empty($customer['referrer']) ? $customer['referrer'] : null,
197
+ 'ip_address' => !empty($customer['ip_address']) ? $customer['ip_address'] : null,
198
+ 'forwarded_ip' => !empty($customer['forwarded_ip']) ? $customer['forwarded_ip'] : null,
199
+ 'gender' => !empty($customer['gender']) ? $customer['gender'] : null,
200
+ 'birth_date' => !empty($customer['birth_date']) ? $customer['birth_date'] : null,
201
+ 'locale' => !empty($customer['locale']) ? $customer['locale'] : null,
202
+ ),
203
+ 'extra' => array(
204
+ 'plugin' => $this->plugin_version,
205
+ ),
206
+ );
207
+
208
+ $order = json_encode($post);
209
+ $result = $this->performApiCall("orders/", $order);
210
+
211
+ return $result;
212
+ }
213
+
214
+ public function ingCreateCashondeliveryOrder($orders_id, $total, $description, $customer = array())
215
+ {
216
+ $post = array(
217
+ "type" => "payment",
218
+ "currency" => "EUR",
219
+ "amount" => 100 * round($total, 2),
220
+ "description" => $description,
221
+ "transactions" => array(array(
222
+ "payment_method" => "cash-on-delivery",
223
+ )),
224
+ "merchant_order_id" => (string)$orders_id,
225
+ 'customer' => array(
226
+ 'merchant_customer_id' => !empty($customer['merchant_customer_id']) ? $customer['merchant_customer_id'] : null,
227
+ 'email_address' => !empty($customer['email_address']) ? $customer['email_address'] : null,
228
+ 'first_name' => !empty($customer['first_name']) ? $customer['first_name'] : null,
229
+ 'last_name' => !empty($customer['last_name']) ? $customer['last_name'] : null,
230
+ 'address_type' => !empty($customer['address_type']) ? $customer['address_type'] : null,
231
+ 'address' => !empty($customer['address']) ? $customer['address'] : null,
232
+ 'postal_code' => !empty($customer['postal_code']) ? $customer['postal_code'] : null,
233
+ 'housenumber' => !empty($customer['housenumber']) ? $customer['housenumber'] : null,
234
+ 'country' => !empty($customer['country']) ? $customer['country'] : null,
235
+ 'phone_numbers' => !empty($customer['phone_numbers']) ? array($customer['phone_numbers']) : null,
236
+ 'user_agent' => !empty($customer['user_agent']) ? $customer['user_agent'] : null,
237
+ 'referrer' => !empty($customer['referrer']) ? $customer['referrer'] : null,
238
+ 'ip_address' => !empty($customer['ip_address']) ? $customer['ip_address'] : null,
239
+ 'forwarded_ip' => !empty($customer['forwarded_ip']) ? $customer['forwarded_ip'] : null,
240
+ 'gender' => !empty($customer['gender']) ? $customer['gender'] : null,
241
+ 'birth_date' => !empty($customer['birth_date']) ? $customer['birth_date'] : null,
242
+ 'locale' => !empty($customer['locale']) ? $customer['locale'] : null,
243
+ ),
244
+ 'extra' => array(
245
+ 'plugin' => $this->plugin_version,
246
+ ),
247
+ );
248
+
249
+ $order = json_encode($post);
250
+ $result = $this->performApiCall("orders/", $order);
251
+
252
+ return $result;
253
+ }
254
+
255
+ public function getOrderStatus($order_id)
256
+ {
257
+ $order = $this->performApiCall("orders/" . $order_id . "/");
258
+
259
+ if (!is_array($order) || array_key_exists('error', $order)) {
260
+ return 'error';
261
+ }
262
+ else {
263
+ return $order['status'];
264
+ }
265
+ }
266
+
267
+ public function getOrderDetails($order_id)
268
+ {
269
+ $order = $this->performApiCall("orders/" . $order_id . "/");
270
+
271
+ if (!is_array($order) || array_key_exists('error', $order)) {
272
+ return 'error';
273
+ }
274
+ else {
275
+ return $order;
276
+ }
277
+ }
278
+ }
package.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ING_KassaCompleet</name>
4
+ <version>1.0.3</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://opensource.org/licenses/MIT">The MIT License (MIT)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>ING Kassa Compleet - Magento Extension for iDEAL, Banktransfer and Creditcard</summary>
10
+ <description>ING Kassa Compleet extension for Magento compatible with: 1.6, 1.6.1, 1.6.2.0, 1.7, 1.8, 1.9 (tested for 1.6.0.0, 1.8.1.0, 1.9.1.1). &#xD;
11
+ This extension installs 4 payment methods; iDEAL, CreditCard, Banktransfer and Cash on Delivery</description>
12
+ <notes>ING Kassa Compleet-Magento Extension for iDEAL, Banktransfer and Creditcard&#xD;
13
+ ====================&#xD;
14
+ &#xD;
15
+ # Changelog #&#xD;
16
+ &#xD;
17
+ ## Changes in version 1.0.0&#xD;
18
+ + Initial version based upon Ginger Payments version&#xD;
19
+ &#xD;
20
+ ## Changes in version 1.0.1&#xD;
21
+ + Updated the README.md&#xD;
22
+ &#xD;
23
+ ## Changes in version 1.0.2&#xD;
24
+ + Handle banktransfer correctly&#xD;
25
+ &#xD;
26
+ ## Changes in version 1.0.3&#xD;
27
+ + Added version to the webhook&#xD;
28
+ + Added cash on delivery</notes>
29
+ <authors><author><name>ING</name><user>ING</user><email>info@ing.nl</email></author></authors>
30
+ <date>2015-10-19</date>
31
+ <time>12:12:38</time>
32
+ <contents><target name="magecommunity"><dir name="ING"><dir name="KassaCompleet"><dir name="Block"><dir name="Payment"><dir name="Banktransfer"><file name="Form.php" hash="f1b13eff4e43f732737566ea54d00d21"/><file name="Info.php" hash="bbf96f67cb7a1aa02d6739f6f50c35cd"/></dir><dir name="Cashondelivery"><file name="Form.php" hash="1900e19dc3d2a4818d613131444fa24e"/><file name="Info.php" hash="ffc6a470b29e1b5ced4766bdf4a72799"/></dir><dir name="Ideal"><file name="Form.php" hash="28ae9f79830acd729090b1e774d46df7"/><file name="Info.php" hash="7e449555863c87acc4602e5afde9bec4"/></dir></dir></dir><dir name="Helper"><file name="Banktransfer.php" hash="f5ea882865bc9f34aa5facae07bdbc37"/><file name="Cashondelivery.php" hash="b8426e1b54d91968a187562e80332959"/><file name="Creditcard.php" hash="fc3ebfa1a6aee658ed23cd9cc762863d"/><file name="Data.php" hash="3d2910f45acf68204f721fe799b94300"/><file name="Ideal.php" hash="59ab4ede2ecbf29aca3e2a53f9eec0a2"/></dir><dir name="Model"><file name="Banktransfer.php" hash="f1613cf6d6db907587898e68253744e8"/><file name="Cashondelivery.php" hash="aedb293e8e5daf225e31f940e9a26cba"/><file name="Creditcard.php" hash="45e51cd42c13e7aceba2693972514cc6"/><file name="Ideal.php" hash="0b7da3aad3ec9c96ec5b6f18fba8e43a"/><file name="Observer.php" hash="e2adaa4d0c146bd8fa0c8916c82a3559"/></dir><dir name="controllers"><file name="BanktransferController.php" hash="cfc1acb3610bf8a947914f189056d47e"/><file name="CashondeliveryController.php" hash="dd73d6ce63db8b6a6f38e8d0c4579af0"/><file name="CreditcardController.php" hash="866b451e1b632099e53333c2aa08c51e"/><file name="IdealController.php" hash="8f2d2a1eadeeeaf3d7b5a83504943194"/></dir><dir name="etc"><file name="adminhtml.xml" hash="ddc069595a5c20400053fe178f58fed7"/><file name="config.xml" hash="9d24a30318665208ac3daf5206801c0b"/><file name="system.xml" hash="21c1cf59c2a8dcff370ebfe12975acfa"/></dir><dir name="sql"><dir name="ingkassacompleet_setup"><file name="mysql4-install-0.0.1.php" hash="ea0fe992dba6280745622cb3cf01804e"/><file name="mysql4-uninstall-0.0.1.php" hash="01fc9db0b665a91be6f024463eddf4b6"/><file name="mysql4-upgrade-0.0.1-0.0.2.php" hash="972cfd33f1be9a641b0f1c8babcb79af"/><file name="mysql4-upgrade-0.0.2-0.0.3.php" hash="1d774b6c66b07250d5f25f2e5f9c143a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="ing_kassacompleet"><dir name="info"><file name="banktransfer.phtml" hash="8e76ef1f36215bb7c0666174901b4f4d"/><file name="cashondelivery.phtml" hash="8e76ef1f36215bb7c0666174901b4f4d"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="ing_kassacompleet"><dir name="form"><file name="banktransfer.phtml" hash="9803a0b0898da0160bd54bac248ee0b2"/><file name="cashondelivery.phtml" hash="9803a0b0898da0160bd54bac248ee0b2"/><file name="ideal.phtml" hash="cd7ef72a0dc80d67314f54552a0da9fa"/></dir><dir name="info"><file name="banktransfer.phtml" hash="8e76ef1f36215bb7c0666174901b4f4d"/><file name="cashondelivery.phtml" hash="8e76ef1f36215bb7c0666174901b4f4d"/></dir><file name="success.phtml" hash="cb2ea88dc142ffa6695d65a3c5881291"/></dir></dir><dir name="layout"><file name="ing_kassacompleet.xml" hash="f5ad6a3deffa8f12cfab1bbc1b3e8c0b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ING_KassaCompleet.xml" hash="1ca256e56c46dd8f0c63ab2e6275049a"/></dir></target><target name="magelocale"><dir name="en_US"><file name="ING_KassaCompleet.csv" hash="52979402cf0ef512d212b17540d10028"/></dir><dir name="nl_NL"><file name="ING_KassaCompleet.csv" hash="570efc6e67545149115dc269a0432c8c"/></dir></target><target name="magelib"><dir name="Ing"><dir name="Services"><file name="Lib.php" hash="c61dfcc2efa3dd42366290227930599e"/></dir></dir></target></contents>
33
+ <compatible/>
34
+ <dependencies><required><php><min>5.2.13</min><max>6.2.0</max></php></required></dependencies>
35
+ </package>