EMerchantPay_Genesis_Client - Version 1.2.5

Version Notes

1.) Added Support for GenesisLib v1.4 - Additional Transaction Types are now available using the eMerchantPay Checkout Method

2.) A possibility has been added to use an external GenesisGateway Library (installed by composer) instead of the integrated in Module

2.) A few minor issues were resolved regarding Capture / Refund Transactions

Download this release

Release Info

Developer eMerchantPay Ltd.
Extension EMerchantPay_Genesis_Client
Version 1.2.5
Comparing to
See all releases


Version 1.2.5

Files changed (110) hide show
  1. app/code/community/EMerchantPay/Genesis/Block/Form/Checkout.php +35 -0
  2. app/code/community/EMerchantPay/Genesis/Block/Form/Direct.php +130 -0
  3. app/code/community/EMerchantPay/Genesis/Block/Info/Checkout.php +37 -0
  4. app/code/community/EMerchantPay/Genesis/Block/Info/Direct.php +37 -0
  5. app/code/community/EMerchantPay/Genesis/Block/Redirect/Checkout.php +101 -0
  6. app/code/community/EMerchantPay/Genesis/Block/Redirect/Direct.php +101 -0
  7. app/code/community/EMerchantPay/Genesis/Helper/Data.php +442 -0
  8. app/code/community/EMerchantPay/Genesis/Model/Admin/Checkout/Options/Transaction/Type.php +109 -0
  9. app/code/community/EMerchantPay/Genesis/Model/Admin/Direct/Options/Transaction/Type.php +77 -0
  10. app/code/community/EMerchantPay/Genesis/Model/Admin/Environment.php +58 -0
  11. app/code/community/EMerchantPay/Genesis/Model/Checkout.php +664 -0
  12. app/code/community/EMerchantPay/Genesis/Model/Direct.php +982 -0
  13. app/code/community/EMerchantPay/Genesis/Observer/GenesisAutoLoader.php +74 -0
  14. app/code/community/EMerchantPay/Genesis/controllers/CheckoutController.php +153 -0
  15. app/code/community/EMerchantPay/Genesis/controllers/DirectController.php +133 -0
  16. app/code/community/EMerchantPay/Genesis/etc/config.xml +119 -0
  17. app/code/community/EMerchantPay/Genesis/etc/system.xml +284 -0
  18. app/design/adminhtml/default/default/template/emerchantpay/info/checkout.phtml +23 -0
  19. app/design/adminhtml/default/default/template/emerchantpay/info/direct.phtml +23 -0
  20. app/design/frontend/base/default/template/emerchantpay/form/checkout.phtml +28 -0
  21. app/design/frontend/base/default/template/emerchantpay/form/direct.phtml +86 -0
  22. app/design/frontend/base/default/template/emerchantpay/info/checkout.phtml +24 -0
  23. app/design/frontend/base/default/template/emerchantpay/info/direct.phtml +24 -0
  24. app/design/frontend/base/default/template/emerchantpay/redirect/checkout.phtml +64 -0
  25. app/design/frontend/base/default/template/emerchantpay/redirect/direct.phtml +64 -0
  26. app/etc/modules/EMerchantPay_Genesis.xml +11 -0
  27. app/locale/en_GB/EMerchantPay_Genesis.csv +36 -0
  28. app/locale/en_US/EMerchantPay_Genesis.csv +36 -0
  29. lib/Genesis/src/Genesis/API/Constants/Banks.php +153 -0
  30. lib/Genesis/src/Genesis/API/Constants/Endpoints.php +47 -0
  31. lib/Genesis/src/Genesis/API/Constants/Environments.php +45 -0
  32. lib/Genesis/src/Genesis/API/Constants/Errors.php +618 -0
  33. lib/Genesis/src/Genesis/API/Constants/Payment/Methods.php +89 -0
  34. lib/Genesis/src/Genesis/API/Constants/Transaction/States.php +219 -0
  35. lib/Genesis/src/Genesis/API/Constants/Transaction/Types.php +158 -0
  36. lib/Genesis/src/Genesis/API/Constants/i18n.php +130 -0
  37. lib/Genesis/src/Genesis/API/Notification.php +242 -0
  38. lib/Genesis/src/Genesis/API/Request.php +444 -0
  39. lib/Genesis/src/Genesis/API/Request/Financial/Alternatives/ABNiDEAL.php +399 -0
  40. lib/Genesis/src/Genesis/API/Request/Financial/Alternatives/CashU.php +387 -0
  41. lib/Genesis/src/Genesis/API/Request/Financial/Alternatives/POLi.php +385 -0
  42. lib/Genesis/src/Genesis/API/Request/Financial/Alternatives/PPRO.php +457 -0
  43. lib/Genesis/src/Genesis/API/Request/Financial/Alternatives/Paysafecard.php +387 -0
  44. lib/Genesis/src/Genesis/API/Request/Financial/Alternatives/Sofort.php +403 -0
  45. lib/Genesis/src/Genesis/API/Request/Financial/Capture.php +138 -0
  46. lib/Genesis/src/Genesis/API/Request/Financial/Cards/Authorize.php +450 -0
  47. lib/Genesis/src/Genesis/API/Request/Financial/Cards/Authorize3D.php +514 -0
  48. lib/Genesis/src/Genesis/API/Request/Financial/Cards/Credit.php +138 -0
  49. lib/Genesis/src/Genesis/API/Request/Financial/Cards/Payout.php +328 -0
  50. lib/Genesis/src/Genesis/API/Request/Financial/Cards/Recurring/InitRecurringSale.php +448 -0
  51. lib/Genesis/src/Genesis/API/Request/Financial/Cards/Recurring/InitRecurringSale3D.php +514 -0
  52. lib/Genesis/src/Genesis/API/Request/Financial/Cards/Recurring/RecurringSale.php +138 -0
  53. lib/Genesis/src/Genesis/API/Request/Financial/Cards/Sale.php +448 -0
  54. lib/Genesis/src/Genesis/API/Request/Financial/Cards/Sale3D.php +514 -0
  55. lib/Genesis/src/Genesis/API/Request/Financial/PayByVouchers/Sale.php +429 -0
  56. lib/Genesis/src/Genesis/API/Request/Financial/PayByVouchers/oBeP.php +211 -0
  57. lib/Genesis/src/Genesis/API/Request/Financial/Refund.php +138 -0
  58. lib/Genesis/src/Genesis/API/Request/Financial/Void.php +114 -0
  59. lib/Genesis/src/Genesis/API/Request/Financial/Wallets/Neteller.php +403 -0
  60. lib/Genesis/src/Genesis/API/Request/Financial/Wallets/WebMoney.php +393 -0
  61. lib/Genesis/src/Genesis/API/Request/Financial/Wallets/eZeeWallet.php +190 -0
  62. lib/Genesis/src/Genesis/API/Request/NonFinancial/AVS.php +399 -0
  63. lib/Genesis/src/Genesis/API/Request/NonFinancial/AccountVerification.php +399 -0
  64. lib/Genesis/src/Genesis/API/Request/NonFinancial/Blacklist.php +96 -0
  65. lib/Genesis/src/Genesis/API/Request/NonFinancial/Fraud/Chargeback/DateRange.php +113 -0
  66. lib/Genesis/src/Genesis/API/Request/NonFinancial/Fraud/Chargeback/Transaction.php +97 -0
  67. lib/Genesis/src/Genesis/API/Request/NonFinancial/Fraud/Reports/DateRange.php +114 -0
  68. lib/Genesis/src/Genesis/API/Request/NonFinancial/Fraud/Reports/Transaction.php +97 -0
  69. lib/Genesis/src/Genesis/API/Request/NonFinancial/Fraud/Retrieval/DateRange.php +114 -0
  70. lib/Genesis/src/Genesis/API/Request/NonFinancial/Fraud/Retrieval/Transaction.php +97 -0
  71. lib/Genesis/src/Genesis/API/Request/NonFinancial/Reconcile/DateRange.php +106 -0
  72. lib/Genesis/src/Genesis/API/Request/NonFinancial/Reconcile/Transaction.php +104 -0
  73. lib/Genesis/src/Genesis/API/Request/NonFinancial/Retrieve/AbniDealBanks.php +52 -0
  74. lib/Genesis/src/Genesis/API/Request/WPF/Create.php +470 -0
  75. lib/Genesis/src/Genesis/API/Request/WPF/Reconcile.php +88 -0
  76. lib/Genesis/src/Genesis/API/Response.php +317 -0
  77. lib/Genesis/src/Genesis/Builder.php +80 -0
  78. lib/Genesis/src/Genesis/Builders/JSON.php +68 -0
  79. lib/Genesis/src/Genesis/Builders/XML.php +205 -0
  80. lib/Genesis/src/Genesis/Certificates/ca-bundle.pem +128 -0
  81. lib/Genesis/src/Genesis/Config.php +341 -0
  82. lib/Genesis/src/Genesis/Exceptions/EnvironmentNotSet.php +47 -0
  83. lib/Genesis/src/Genesis/Exceptions/ErrorAPI.php +53 -0
  84. lib/Genesis/src/Genesis/Exceptions/ErrorNetwork.php +51 -0
  85. lib/Genesis/src/Genesis/Exceptions/ErrorParameter.php +48 -0
  86. lib/Genesis/src/Genesis/Exceptions/InvalidArgument.php +47 -0
  87. lib/Genesis/src/Genesis/Exceptions/InvalidMethod.php +49 -0
  88. lib/Genesis/src/Genesis/Exceptions/InvalidResponse.php +50 -0
  89. lib/Genesis/src/Genesis/Genesis.php +130 -0
  90. lib/Genesis/src/Genesis/Interfaces/Builder.php +48 -0
  91. lib/Genesis/src/Genesis/Interfaces/Network.php +76 -0
  92. lib/Genesis/src/Genesis/Interfaces/Parser.php +56 -0
  93. lib/Genesis/src/Genesis/Network.php +119 -0
  94. lib/Genesis/src/Genesis/Network/Stream.php +240 -0
  95. lib/Genesis/src/Genesis/Network/cURL.php +186 -0
  96. lib/Genesis/src/Genesis/Parser.php +90 -0
  97. lib/Genesis/src/Genesis/Parsers/XML.php +185 -0
  98. lib/Genesis/src/Genesis/Utils/Common.php +253 -0
  99. lib/Genesis/src/Genesis/Utils/Country.php +314 -0
  100. lib/Genesis/src/Genesis/Utils/Currency.php +1156 -0
  101. lib/Genesis/src/Genesis/Utils/Requirements.php +152 -0
  102. lib/Genesis/vendor/autoload.php +28 -0
  103. lib/Genesis/vendor/composer/ClassLoader.php +383 -0
  104. lib/Genesis/vendor/composer/LICENSE +19 -0
  105. lib/Genesis/vendor/composer/autoload_classmap.php +9 -0
  106. lib/Genesis/vendor/composer/autoload_namespaces.php +29 -0
  107. lib/Genesis/vendor/composer/autoload_psr4.php +9 -0
  108. lib/Genesis/vendor/composer/autoload_real.php +61 -0
  109. lib/Genesis/vendor/composer/installed.json +545 -0
  110. package.xml +24 -0
app/code/community/EMerchantPay/Genesis/Block/Form/Checkout.php ADDED
@@ -0,0 +1,35 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Block_Form_Checkout
22
+ *
23
+ * Form Block for Checkout method
24
+ */
25
+ class EMerchantPay_Genesis_Block_Form_Checkout extends Mage_Payment_Block_Form
26
+ {
27
+ /**
28
+ * Setup
29
+ */
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setTemplate('emerchantpay/form/checkout.phtml');
34
+ }
35
+ }
app/code/community/EMerchantPay/Genesis/Block/Form/Direct.php ADDED
@@ -0,0 +1,130 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Block_Form_Direct
22
+ *
23
+ * Form Block for Direct method
24
+ */
25
+ class EMerchantPay_Genesis_Block_Form_Direct extends Mage_Payment_Block_Form
26
+ {
27
+ /**
28
+ * Setup
29
+ */
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setTemplate('emerchantpay/form/direct.phtml');
34
+ }
35
+
36
+ /**
37
+ * Retrieve payment configuration object
38
+ *
39
+ * @return Mage_Payment_Model_Config
40
+ */
41
+ protected function _getConfig()
42
+ {
43
+ return Mage::getSingleton('payment/config');
44
+ }
45
+
46
+ /**
47
+ * Retrieve availables credit card types
48
+ *
49
+ * @return array
50
+ */
51
+ public function getCcAvailableTypes()
52
+ {
53
+ $types = $this->_getConfig()->getCcTypes();
54
+ if ($method = $this->getMethod()) {
55
+ $availableTypes = $method->getConfigData('cctypes');
56
+ if ($availableTypes) {
57
+ $availableTypes = explode(',', $availableTypes);
58
+ foreach ($types as $code=>$name) {
59
+ if (!in_array($code, $availableTypes)) {
60
+ unset($types[$code]);
61
+ }
62
+ }
63
+ }
64
+ }
65
+ return $types;
66
+ }
67
+
68
+ /**
69
+ * Retrieve credit card expire months
70
+ *
71
+ * @return array
72
+ */
73
+ public function getCcMonths()
74
+ {
75
+ $months = $this->getData('cc_months');
76
+ if (is_null($months)) {
77
+ $months[0] = $this->__('Month');
78
+ $months = array_merge($months, $this->_getConfig()->getMonths());
79
+ $this->setData('cc_months', $months);
80
+ }
81
+ return $months;
82
+ }
83
+
84
+ /**
85
+ * Retrieve credit card expire years
86
+ *
87
+ * @return array
88
+ */
89
+ public function getCcYears()
90
+ {
91
+ $years = $this->getData('cc_years');
92
+ if (is_null($years)) {
93
+ $years = $this->_getConfig()->getYears();
94
+ $years = array(0=>$this->__('Year'))+$years;
95
+ $this->setData('cc_years', $years);
96
+ }
97
+ return $years;
98
+ }
99
+
100
+ /**
101
+ * Retrieve has verification configuration
102
+ *
103
+ * @return boolean
104
+ */
105
+ public function hasVerification()
106
+ {
107
+ if ($this->getMethod()) {
108
+ $configData = $this->getMethod()->getConfigData('useccv');
109
+ if(is_null($configData)){
110
+ return true;
111
+ }
112
+ return (bool) $configData;
113
+ }
114
+ return true;
115
+ }
116
+
117
+ /**
118
+ * Render block HTML
119
+ *
120
+ * @return string
121
+ */
122
+ protected function _toHtml()
123
+ {
124
+ Mage::dispatchEvent('payment_form_block_to_html_before', array(
125
+ 'block' => $this
126
+ ));
127
+
128
+ return parent::_toHtml();
129
+ }
130
+ }
app/code/community/EMerchantPay/Genesis/Block/Info/Checkout.php ADDED
@@ -0,0 +1,37 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Block_Info_Checkout
22
+ *
23
+ * Info Block for Checkout method
24
+ */
25
+ class EMerchantPay_Genesis_Block_Info_Checkout extends Mage_Payment_Block_Info
26
+ {
27
+ protected function _construct()
28
+ {
29
+ parent::_construct();
30
+ $this->setTemplate('emerchantpay/info/checkout.phtml');
31
+ }
32
+
33
+ public function getMethodCode()
34
+ {
35
+ return $this->getInfo()->getMethodInstance()->getCode();
36
+ }
37
+ }
app/code/community/EMerchantPay/Genesis/Block/Info/Direct.php ADDED
@@ -0,0 +1,37 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Block_Info_Direct
22
+ *
23
+ * Info block for Direct method
24
+ */
25
+ class EMerchantPay_Genesis_Block_Info_Direct extends Mage_Payment_Block_Info
26
+ {
27
+ protected function _construct()
28
+ {
29
+ parent::_construct();
30
+ $this->setTemplate('emerchantpay/info/direct.phtml');
31
+ }
32
+
33
+ public function getMethodCode()
34
+ {
35
+ return $this->getInfo()->getMethodInstance()->getCode();
36
+ }
37
+ }
app/code/community/EMerchantPay/Genesis/Block/Redirect/Checkout.php ADDED
@@ -0,0 +1,101 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Block_Redirect_Checkout
22
+ *
23
+ * Redirect Block for Checkout method
24
+ */
25
+ class EMerchantPay_Genesis_Block_Redirect_Checkout extends Mage_Core_Block_Template
26
+ {
27
+ /** @var String */
28
+ private $unique_id;
29
+ /** @var EMerchantPay_Genesis_Helper_Data $helper */
30
+ private $helper;
31
+
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+
36
+ $this->setHelper();
37
+
38
+ $this->setUniqueId();
39
+
40
+ $this->setTemplate('emerchantpay/redirect/checkout.phtml');
41
+ }
42
+
43
+ /**
44
+ * Generate HTML form
45
+ *
46
+ * @return string
47
+ */
48
+ public function generateForm()
49
+ {
50
+ $form = new Varien_Data_Form();
51
+
52
+ $form
53
+ ->setAction(
54
+ $this->helper->getCheckoutSession()->getEmerchantPayCheckoutRedirectUrl()
55
+ )
56
+ ->setId('emerchantpay_redirect_notification')
57
+ ->setName('emerchantpay_redirect_notification')
58
+ ->setMethod('GET')
59
+ ->setUseContainer(true);
60
+
61
+ $submitButton = new Varien_Data_Form_Element_Submit(
62
+ array(
63
+ 'value' => $this->__('Click here, if you are not redirected within 10 seconds...'),
64
+ )
65
+ );
66
+
67
+ $submitButton->setId(
68
+ $this->getButtonId()
69
+ );
70
+
71
+ $form->addElement($submitButton);
72
+
73
+ return $form->toHtml();
74
+ }
75
+
76
+ /**
77
+ * Get the button id
78
+ *
79
+ * @return string
80
+ */
81
+ public function getButtonId()
82
+ {
83
+ return sprintf('redirect_to_dest_%s', $this->unique_id);
84
+ }
85
+
86
+ /**
87
+ * Set Helper
88
+ */
89
+ private function setHelper()
90
+ {
91
+ $this->helper = Mage::helper('emerchantpay');
92
+ }
93
+
94
+ /**
95
+ * Set Unique Id
96
+ */
97
+ private function setUniqueId()
98
+ {
99
+ $this->unique_id = Mage::helper('core')->uniqHash();
100
+ }
101
+ }
app/code/community/EMerchantPay/Genesis/Block/Redirect/Direct.php ADDED
@@ -0,0 +1,101 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Block_Redirect_Direct
22
+ *
23
+ * Redirect Block for Direct method
24
+ */
25
+ class EMerchantPay_Genesis_Block_Redirect_Direct extends Mage_Core_Block_Template
26
+ {
27
+ /** @var String */
28
+ private $unique_id;
29
+ /** @var EMerchantPay_Genesis_Helper_Data $helper */
30
+ private $helper;
31
+
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+
36
+ $this->setHelper();
37
+
38
+ $this->setUniqueId();
39
+
40
+ $this->setTemplate('emerchantpay/redirect/direct.phtml');
41
+ }
42
+
43
+ /**
44
+ * Get the button id
45
+ *
46
+ * @return string
47
+ */
48
+ public function getButtonId()
49
+ {
50
+ return sprintf('redirect_to_dest_%s', $this->unique_id);
51
+ }
52
+
53
+ /**
54
+ * Generate HTML form
55
+ *
56
+ * @return string
57
+ */
58
+ public function generateForm()
59
+ {
60
+ $form = new Varien_Data_Form();
61
+
62
+ $form
63
+ ->setAction(
64
+ $this->helper->getCheckoutSession()->getEmerchantPayDirectRedirectUrl()
65
+ )
66
+ ->setId('emerchantpay_redirect_notification')
67
+ ->setName('emerchantpay_redirect_notification')
68
+ ->setMethod('GET')
69
+ ->setUseContainer(true);
70
+
71
+ $submitButton = new Varien_Data_Form_Element_Submit(
72
+ array(
73
+ 'value' => $this->__('Click here, if you are not redirected within 10 seconds...'),
74
+ )
75
+ );
76
+
77
+ $submitButton->setId(
78
+ $this->getButtonId()
79
+ );
80
+
81
+ $form->addElement($submitButton);
82
+
83
+ return $form->toHtml();
84
+ }
85
+
86
+ /**
87
+ * Set Helper
88
+ */
89
+ private function setHelper()
90
+ {
91
+ $this->helper = Mage::helper('emerchantpay');
92
+ }
93
+
94
+ /**
95
+ * Set Unique Id
96
+ */
97
+ private function setUniqueId()
98
+ {
99
+ $this->unique_id = Mage::helper('core')->uniqHash();
100
+ }
101
+ }
app/code/community/EMerchantPay/Genesis/Helper/Data.php ADDED
@@ -0,0 +1,442 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Helper_Data
22
+ *
23
+ * Helper functions for eMerchantPay Direct / Checkout
24
+ */
25
+ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
26
+ {
27
+ /**
28
+ * Include Genesis library
29
+ *
30
+ * @return void
31
+ */
32
+ public function initLibrary()
33
+ {
34
+ // Mitigate PHP Bug #52339, as Magento already registers their AutoLoader
35
+ if (!class_exists('\Genesis\Genesis', false)) {
36
+ $genesisAutoLoadParams = array(
37
+ 'magento_root' => MAGENTO_ROOT,
38
+ 'integrated_genesis_lib_auto_loader' => Mage::getBaseDir('lib') . DS . 'Genesis' . DS . 'vendor' . DS . 'autoload.php',
39
+ 'genesis_composer_dir' => 'genesisgateway',
40
+ 'check_genesis_lib_version' => '1',
41
+ 'required_genesis_lib_version' => ">= 1.4"
42
+ );
43
+
44
+ $genesisAutoLoadVarienObj = new Varien_Object($genesisAutoLoadParams);
45
+
46
+ /* This Event will be handled from Observer EMerchantPay_Genesis_Observer_GenesisAutoLoader (defined in etc/config.xml) */
47
+ Mage::dispatchEvent('emerchantpay_genesis_init_library', array('genesis_auto_load_params' => $genesisAutoLoadVarienObj));
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Check whether Genesis is initialized and init if not
53
+ *
54
+ * @param string $model Name of the model, for which we query settings
55
+ *
56
+ * @return void
57
+ */
58
+ public function initClient($model)
59
+ {
60
+ $this->initLibrary();
61
+
62
+ \Genesis\Config::setEndpoint('emerchantpay');
63
+
64
+ \Genesis\Config::setUsername($this->getConfigData($model, 'genesis_username'));
65
+ \Genesis\Config::setPassword($this->getConfigData($model, 'genesis_password'));
66
+
67
+ \Genesis\Config::setEnvironment($this->getConfigData($model, 'genesis_environment'));
68
+
69
+ \Genesis\Config::setToken(
70
+ $this->getConfigData($model, 'genesis_token') ? $this->getConfigData($model, 'genesis_token') : ''
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Get Module Configuration Key
76
+ *
77
+ * @param string $model Name of the Model
78
+ * @param string $key Configuration Key
79
+ *
80
+ * @return mixed The content of the requested key
81
+ */
82
+ public function getConfigData($model, $key)
83
+ {
84
+ return Mage::getStoreConfig(
85
+ sprintf('payment/%s/%s', $model, $key)
86
+ );
87
+ }
88
+
89
+ /**
90
+ * Get A Success URL
91
+ *
92
+ * @see Genesis API Documentation
93
+ *
94
+ * @param string $model Name of the Model (Checkout/Direct)
95
+ *
96
+ * @return string
97
+ */
98
+ public function getSuccessURL($model)
99
+ {
100
+ return Mage::getUrl(sprintf('emerchantpay/%s/success', $model), array('_secure' => true));
101
+ }
102
+
103
+ /**
104
+ * Get A Failure URL
105
+ *
106
+ * @see Genesis API Documentation
107
+ *
108
+ * @param string $model Name of the Model (Checkout/Direct)
109
+ *
110
+ * @return string
111
+ */
112
+ public function getFailureURL($model)
113
+ {
114
+ return Mage::getUrl(sprintf('emerchantpay/%s/failure', $model), array('_secure' => true));
115
+ }
116
+
117
+ /**
118
+ * Get A Cancel URL
119
+ *
120
+ * @see Genesis API Documentation
121
+ *
122
+ * @param string $model Name of the Model (Checkout/Direct)
123
+ *
124
+ * @return string
125
+ */
126
+ public function getCancelURL($model)
127
+ {
128
+ return Mage::getUrl(sprintf('emerchantpay/%s/cancel', $model), array('_secure' => true));
129
+ }
130
+
131
+ /**
132
+ * Get A Notification URL
133
+ *
134
+ * @see Genesis API Documentation
135
+ *
136
+ * @param string $model Name of the Model (Checkout/Direct)
137
+ *
138
+ * @return string
139
+ */
140
+ public function getNotifyURL($model)
141
+ {
142
+ return Mage::getUrl(sprintf('emerchantpay/%s/notify', $model), array('_secure' => true));
143
+ }
144
+
145
+ /**
146
+ * Get a Redirect URL for the module
147
+ *
148
+ * @param string $model Name of the Model (Checkout/Direct)
149
+ *
150
+ * @return string
151
+ */
152
+ public function getRedirectUrl($model)
153
+ {
154
+ return Mage::getUrl(sprintf('emerchantpay/%s/redirect', $model), array('_secure' => true));
155
+ }
156
+
157
+ /**
158
+ * Generate Transaction Id based on the order id
159
+ * and salted to avoid duplication
160
+ *
161
+ * @param string $prefix Prefix of the orderId
162
+ *
163
+ * @return string
164
+ */
165
+ public function genTransactionId($prefix = '')
166
+ {
167
+ $hash = Mage::helper('core')->uniqHash();
168
+
169
+ return (string)$prefix . substr($hash, -(strlen($hash) - strlen($prefix)));
170
+ }
171
+
172
+ /**
173
+ * Get the current locale in 2-digit i18n format
174
+ *
175
+ * @return string
176
+ */
177
+ public function getLocale()
178
+ {
179
+ $locale = Mage::app()->getLocale()->getLocaleCode();
180
+
181
+ return substr($locale, 0, 2);
182
+ }
183
+
184
+ /**
185
+ * Return checkout session instance
186
+ *
187
+ * @return Mage_Checkout_Model_Session
188
+ */
189
+ public function getCheckoutSession()
190
+ {
191
+ return Mage::getSingleton('checkout/session');
192
+ }
193
+
194
+ public function getCustomerSession()
195
+ {
196
+ return Mage::getSingleton('customer/session');
197
+ }
198
+
199
+ /**
200
+ * Return sales quote instance for specified ID
201
+ *
202
+ * @param int $quoteId Quote identifier
203
+ * @return Mage_Sales_Model_Quote
204
+ */
205
+ public function getQuote($quoteId)
206
+ {
207
+ return Mage::getModel('sales/quote')->load(
208
+ abs(intval($quoteId))
209
+ );
210
+ }
211
+
212
+ /**
213
+ * Get an array of (k=>v) from stdClass Genesis response
214
+ *
215
+ * @param $response
216
+ * @return array
217
+ */
218
+ public function getArrayFromGatewayResponse($response)
219
+ {
220
+ $transaction_details = array();
221
+
222
+ foreach ($response as $key => $value) {
223
+ if (is_string($value)) {
224
+ $transaction_details[$key] = $value;
225
+ }
226
+
227
+ if ($value instanceof DateTime) {
228
+ $transaction_details[$key] = $value->format('c');
229
+ }
230
+ }
231
+
232
+ return $transaction_details;
233
+ }
234
+
235
+ /**
236
+ * Get DESC list of specific transactions from payment object
237
+ *
238
+ * @param Mage_Sales_Model_Order_Payment $payment
239
+ * @param array|string $type_filter
240
+ * @return array
241
+ */
242
+ public function getTransactionFromPaymentObject($payment, $type_filter)
243
+ {
244
+ $transactions = array();
245
+
246
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
247
+ ->setOrderFilter($payment->getOrder())
248
+ ->addPaymentIdFilter($payment->getId())
249
+ ->addTxnTypeFilter($type_filter)
250
+ ->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC);
251
+
252
+ /** @var Mage_Sales_Model_Order_Payment_Transaction $txn */
253
+ foreach ($collection as $txn) {
254
+ $transactions[] = $txn->setOrderPaymentObject($payment);
255
+ }
256
+
257
+ return $transactions;
258
+ }
259
+
260
+ /**
261
+ * Get list of items in the order
262
+ *
263
+ * @see API parameter "Usage" or "Description"
264
+ *
265
+ * @param Mage_Sales_Model_Order_Payment $order
266
+ *
267
+ * @return string Formatted List of Items
268
+ */
269
+ public function getItemList($order)
270
+ {
271
+ $productResult = array();
272
+
273
+ foreach ($order->getAllItems() as $item) {
274
+ /** @var $item Mage_Sales_Model_Quote_Item */
275
+ $product = $item->getProduct();
276
+
277
+ $productResult[$product->getSku()] = array(
278
+ 'sku' => $product->getSku(),
279
+ 'name' => $product->getName(),
280
+ 'qty' => isset($productResult[$product->getSku()]['qty']) ? $productResult[$product->getSku()]['qty'] : 1,
281
+ );
282
+ }
283
+
284
+ $description = '';
285
+
286
+ foreach ($productResult as $product) {
287
+ $description .= sprintf("%s (%s) x %d\r\n", $product['name'], $product['sku'], $product['qty']);
288
+ }
289
+
290
+ return $description;
291
+ }
292
+
293
+ /**
294
+ * Restore customer Quote
295
+ *
296
+ * @param $shouldCancel
297
+ * @return bool
298
+ */
299
+ public function restoreQuote($shouldCancel = false)
300
+ {
301
+ $order = $this->getCheckoutSession()->getLastRealOrder();
302
+
303
+ if ($order->getId()) {
304
+ $quote = $this->getQuote($order->getQuoteId());
305
+
306
+ if ($shouldCancel && $order->canCancel()) {
307
+ $order->cancel()->save();
308
+ }
309
+
310
+ if ($quote->getId()) {
311
+ $quote->setIsActive(1)
312
+ ->setReservedOrderId(null)
313
+ ->save();
314
+ $this->getCheckoutSession()
315
+ ->replaceQuote($quote)
316
+ ->unsLastRealOrderId();
317
+
318
+ return true;
319
+ }
320
+ }
321
+
322
+ return false;
323
+ }
324
+
325
+ /**
326
+ * Set an order status based on transaction status
327
+ *
328
+ * @param Mage_Sales_Model_Order $order
329
+ * @param string $status
330
+ * @param string $message
331
+ */
332
+ public function setOrderState($order, $status, $message = '')
333
+ {
334
+ $this->initLibrary();
335
+
336
+ switch ($status) {
337
+ case \Genesis\API\Constants\Transaction\States::APPROVED:
338
+ $order
339
+ ->setState(
340
+ Mage_Sales_Model_Order::STATE_PROCESSING,
341
+ Mage_Sales_Model_Order::STATE_PROCESSING,
342
+ $message,
343
+ false
344
+ )
345
+ ->save();
346
+ break;
347
+ case \Genesis\API\Constants\Transaction\States::PENDING:
348
+ case \Genesis\API\Constants\Transaction\States::PENDING_ASYNC:
349
+ $order
350
+ ->setState(
351
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
352
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
353
+ $message,
354
+ false
355
+ )
356
+ ->save();
357
+ break;
358
+ case \Genesis\API\Constants\Transaction\States::ERROR:
359
+ case \Genesis\API\Constants\Transaction\States::DECLINED:
360
+
361
+ /** @var Mage_Sales_Model_Order_Invoice $invoice */
362
+ foreach ($order->getInvoiceCollection() as $invoice) {
363
+ $invoice->cancel();
364
+ }
365
+
366
+ $order
367
+ ->registerCancellation($message)
368
+ ->setCustomerNoteNotify(true)
369
+ ->save();
370
+
371
+ break;
372
+ default:
373
+ $order->save();
374
+ break;
375
+ }
376
+ }
377
+
378
+ /**
379
+ * During "Checkout" we don't know have a Token,
380
+ * however its required at a latter stage, which
381
+ * means we have to extract it from the payment
382
+ * data. We save the token when we receive a
383
+ * notification from Genesis, then we only have
384
+ * to find the earliest payment_transaction
385
+ *
386
+ * @param Mage_Sales_Model_Order_Payment $payment
387
+ *
388
+ * @return void
389
+ */
390
+ public function setTokenByPaymentTransaction($payment)
391
+ {
392
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
393
+ ->setOrderFilter($payment->getOrder())
394
+ ->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_ASC);
395
+
396
+ /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
397
+ foreach ($collection as $transaction) {
398
+ $information = $transaction->getAdditionalInformation(
399
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS
400
+ );
401
+
402
+ foreach ($information as $field => $value) {
403
+ if ($field == 'terminal_token') {
404
+ \Genesis\Config::setToken($value);
405
+ }
406
+ }
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Redirect the visitor to the login page if
412
+ * they are not logged in
413
+ *
414
+ * @param string $target Alternative target, if you don't want to redirect to login
415
+ *
416
+ * @return void
417
+ */
418
+ public function redirectIfNotLoggedIn($target = null)
419
+ {
420
+ /** @var Mage_Customer_Helper_Data $customer */
421
+ $customer = Mage::helper('customer');
422
+
423
+ /** @var Mage_Core_Helper_Url $url */
424
+ $url = Mage::helper('core/url');
425
+
426
+ if (!$customer->isLoggedIn()) {
427
+ $target = $target ? $target : Mage::getUrl('customer/account/login', array('_secure' => true));
428
+
429
+ $this->getCustomerSession()->setBeforeAuthUrl(
430
+ $url->getCurrentUrl()
431
+ );
432
+
433
+ Mage::app()
434
+ ->getFrontController()
435
+ ->getResponse()
436
+ ->setRedirect($target)
437
+ ->sendHeaders();
438
+
439
+ exit(0);
440
+ }
441
+ }
442
+ }
app/code/community/EMerchantPay/Genesis/Model/Admin/Checkout/Options/Transaction/Type.php ADDED
@@ -0,0 +1,109 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Model_Admin_Transaction_Type
22
+ *
23
+ * Admin options Drop-down for Genesis Transaction Types
24
+ */
25
+ class EMerchantPay_Genesis_Model_Admin_Checkout_Options_Transaction_Type
26
+ {
27
+ /**
28
+ * Pre-load the required files
29
+ */
30
+ public function __construct()
31
+ {
32
+ /** @var EMerchantPay_Genesis_Helper_Data $helper */
33
+ $helper = Mage::helper('emerchantpay');
34
+
35
+ $helper->initLibrary();
36
+ }
37
+ /**
38
+ * Return the transaction types for an Options field
39
+ *
40
+ * @return array
41
+ */
42
+ public function toOptionArray()
43
+ {
44
+ $options = array();
45
+
46
+ foreach (static::getTransactionTypes() as $code => $name) {
47
+ $options[] = array(
48
+ 'value' => $code,
49
+ 'label' => $name
50
+ );
51
+ }
52
+
53
+ return $options;
54
+ }
55
+
56
+ /**
57
+ * Get the transaction types as:
58
+ *
59
+ * key = Code Name
60
+ * value = Localized Name
61
+ *
62
+ * @return array
63
+ */
64
+ static function getTransactionTypes()
65
+ {
66
+ return array(
67
+ \Genesis\API\Constants\Transaction\Types::ABNIDEAL =>
68
+ Mage::helper('emerchantpay')->__('ABN iDEAL'),
69
+ \Genesis\API\Constants\Transaction\Types::AUTHORIZE =>
70
+ Mage::helper('emerchantpay')->__('Authorize'),
71
+ \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D =>
72
+ Mage::helper('emerchantpay')->__('Authorize (3D-Secure)'),
73
+ \Genesis\API\Constants\Transaction\Types::CASHU =>
74
+ Mage::helper('emerchantpay')->__('CashU'),
75
+ \Genesis\API\Constants\Payment\Methods::EPS =>
76
+ Mage::helper('emerchantpay')->__('eps'),
77
+ \Genesis\API\Constants\Payment\Methods::GIRO_PAY =>
78
+ Mage::helper('emerchantpay')->__('GiroPay'),
79
+ \Genesis\API\Constants\Transaction\Types::NETELLER =>
80
+ Mage::helper('emerchantpay')->__('Neteller'),
81
+ \Genesis\API\Constants\Payment\Methods::QIWI =>
82
+ Mage::helper('emerchantpay')->__('Qiwi'),
83
+ \Genesis\API\Constants\Transaction\Types::PAYSAFECARD =>
84
+ Mage::helper('emerchantpay')->__('PaySafeCard'),
85
+ \Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_SALE =>
86
+ Mage::helper('emerchantpay')->__('PayByVoucher (Sale)'),
87
+ \Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_YEEPAY =>
88
+ Mage::helper('emerchantpay')->__('PayByVoucher (oBeP)'),
89
+ \Genesis\API\Constants\Payment\Methods::PRZELEWY24 =>
90
+ Mage::helper('emerchantpay')->__('Przelewy24'),
91
+ \Genesis\API\Constants\Transaction\Types::POLI =>
92
+ Mage::helper('emerchantpay')->__('POLi'),
93
+ \Genesis\API\Constants\Payment\Methods::SAFETY_PAY =>
94
+ Mage::helper('emerchantpay')->__('SafetyPay'),
95
+ \Genesis\API\Constants\Transaction\Types::SALE =>
96
+ Mage::helper('emerchantpay')->__('Sale'),
97
+ \Genesis\API\Constants\Transaction\Types::SALE_3D =>
98
+ Mage::helper('emerchantpay')->__('Sale (3D-Secure)'),
99
+ \Genesis\API\Constants\Transaction\Types::SOFORT =>
100
+ Mage::helper('emerchantpay')->__('SOFORT'),
101
+ \Genesis\API\Constants\Payment\Methods::TELEINGRESO =>
102
+ Mage::helper('emerchantpay')->__('TeleIngreso'),
103
+ \Genesis\API\Constants\Payment\Methods::TRUST_PAY =>
104
+ Mage::helper('emerchantpay')->__('TrustPay'),
105
+ \Genesis\API\Constants\Transaction\Types::WEBMONEY =>
106
+ Mage::helper('emerchantpay')->__('WebMoney'),
107
+ );
108
+ }
109
+ }
app/code/community/EMerchantPay/Genesis/Model/Admin/Direct/Options/Transaction/Type.php ADDED
@@ -0,0 +1,77 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Model_Admin_Direct_Options_Transaction_Type
22
+ *
23
+ * Admin options Drop-down for Genesis Transaction Types
24
+ */
25
+ class EMerchantPay_Genesis_Model_Admin_Direct_Options_Transaction_Type
26
+ {
27
+ /**
28
+ * Pre-load the required files
29
+ */
30
+ public function __construct()
31
+ {
32
+ /** @var EMerchantPay_Genesis_Helper_Data $helper */
33
+ $helper = Mage::helper('emerchantpay');
34
+
35
+ $helper->initLibrary();
36
+ }
37
+ /**
38
+ * Return the transaction types for an Options field
39
+ *
40
+ * @return array
41
+ */
42
+ public function toOptionArray()
43
+ {
44
+ $options = array();
45
+
46
+ foreach (static::getTransactionTypes() as $code => $name) {
47
+ $options[] = array(
48
+ 'value' => $code,
49
+ 'label' => $name
50
+ );
51
+ }
52
+
53
+ return $options;
54
+ }
55
+
56
+ /**
57
+ * Get the transaction types as:
58
+ *
59
+ * key = Code Name
60
+ * value = Localized Name
61
+ *
62
+ * @return array
63
+ */
64
+ static function getTransactionTypes()
65
+ {
66
+ return array(
67
+ \Genesis\API\Constants\Transaction\Types::AUTHORIZE =>
68
+ Mage::helper('emerchantpay')->__('Authorize'),
69
+ \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D =>
70
+ Mage::helper('emerchantpay')->__('Authorize (3D-Secure)'),
71
+ \Genesis\API\Constants\Transaction\Types::SALE =>
72
+ Mage::helper('emerchantpay')->__('Sale'),
73
+ \Genesis\API\Constants\Transaction\Types::SALE_3D =>
74
+ Mage::helper('emerchantpay')->__('Sale (3D-Secure)'),
75
+ );
76
+ }
77
+ }
app/code/community/EMerchantPay/Genesis/Model/Admin/Environment.php ADDED
@@ -0,0 +1,58 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ /**
21
+ * Class EMerchantPay_Genesis_Model_Admin_Environment
22
+ *
23
+ * Admin options Drop-down for Gateway environment
24
+ */
25
+ class EMerchantPay_Genesis_Model_Admin_Environment
26
+ {
27
+ /**
28
+ * Return the environment types for an Options field
29
+ *
30
+ * @return array
31
+ */
32
+ public function toOptionArray()
33
+ {
34
+ $options = array();
35
+
36
+ foreach (static::getEnvironmentOptions() as $code => $name) {
37
+ $options[] = array(
38
+ 'value' => $code,
39
+ 'label' => $name
40
+ );
41
+ }
42
+
43
+ return $options;
44
+ }
45
+
46
+ /**
47
+ * Get the available environment types
48
+ *
49
+ * @return array
50
+ */
51
+ static function getEnvironmentOptions()
52
+ {
53
+ return array(
54
+ 'sandbox' => Mage::helper('emerchantpay')->__('Yes'),
55
+ 'production' => Mage::helper('emerchantpay')->__('No'),
56
+ );
57
+ }
58
+ }
app/code/community/EMerchantPay/Genesis/Model/Checkout.php ADDED
@@ -0,0 +1,664 @@
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2015 eMerchantPay Ltd.
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @author eMerchantPay
16
+ * @copyright 2015 eMerchantPay Ltd.
17
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
18
+ */
19
+
20
+ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abstract
21
+ {
22
+ protected $_code = 'emerchantpay_checkout';
23
+
24
+ protected $_formBlockType = 'emerchantpay/form_checkout';
25
+ protected $_infoBlockType = 'emerchantpay/info_checkout';
26
+
27
+ protected $_isGateway = true;
28
+ protected $_canOrder = true;
29
+ protected $_canAuthorize = true;
30
+ protected $_canCapture = true;
31
+ protected $_canCapturePartial = true;
32
+ protected $_canRefund = true;
33
+ protected $_canVoid = true;
34
+ protected $_canUseInternal = false;
35
+ protected $_canUseCheckout = true;
36
+
37
+ protected $_canUseForMultishipping = false;
38
+ protected $_canFetchTransactionInfo = true;
39
+
40
+ /**
41
+ * WPF Create method piggyback-ing the Magento's internal Authorize method
42
+ *
43
+ * @param Mage_Sales_Model_Order_Payment|Varien_Object $payment
44
+ * @param String $amount
45
+ * @return EMerchantPay_Genesis_Model_Checkout
46
+ * @throws Mage_Core_Exception
47
+ */
48
+ public function order(Varien_Object $payment, $amount)
49
+ {
50
+ Mage::log('Checkout transaction for order #' . $payment->getOrder()->getIncrementId());
51
+
52
+ try {
53
+ $this->getHelper()->initClient($this->getCode());
54
+
55
+ /** @var Mage_Sales_Model_Order $order */
56
+ $order = $payment->getOrder();
57
+
58
+ $billing = $order->getBillingAddress();
59
+ $shipping = $order->getShippingAddress();
60
+
61
+ $genesis = new \Genesis\Genesis('WPF\Create');
62
+
63
+ $genesis
64
+ ->request()
65
+ ->setTransactionId(
66
+ $this->getHelper()->genTransactionId(
67
+ $order->getIncrementId()
68
+ )
69
+ )
70
+ ->setCurrency($order->getBaseCurrencyCode())
71
+ ->setAmount($amount)
72
+ ->setUsage(
73
+ $this->getHelper()->__('Magento Payment')
74
+ )
75
+ ->setDescription($this->getHelper()->getItemList($order))
76
+ ->setCustomerPhone($billing->getTelephone())
77
+ ->setCustomerEmail($order->getCustomerEmail())
78
+ ->setNotificationUrl(
79
+ $this->getHelper()->getNotifyURL('checkout')
80
+ )
81
+ ->setReturnSuccessUrl(
82
+ $this->getHelper()->getSuccessURL('checkout')
83
+ )
84
+ ->setReturnFailureUrl(
85
+ $this->getHelper()->getFailureURL('checkout')
86
+ )
87
+ ->setReturnCancelUrl(
88
+ $this->getHelper()->getCancelURL('checkout')
89
+ )
90
+ ->setBillingFirstName($billing->getData('firstname'))
91
+ ->setBillingLastName($billing->getData('lastname'))
92
+ ->setBillingAddress1($billing->getStreet(1))
93
+ ->setBillingAddress2($billing->getStreet(2))
94
+ ->setBillingZipCode($billing->getPostcode())
95
+ ->setBillingCity($billing->getCity())
96
+ ->setBillingState($billing->getRegion())
97
+ ->setBillingCountry($billing->getCountry())
98
+ ->setShippingFirstName($shipping->getData('firstname'))
99
+ ->setShippingLastName($shipping->getData('lastname'))
100
+ ->setShippingAddress1($shipping->getStreet(1))
101
+ ->setShippingAddress2($shipping->getStreet(2))
102
+ ->setShippingZipCode($shipping->getPostcode())
103
+ ->setShippingCity($shipping->getCity())
104
+ ->setShippingState($shipping->getRegion())
105
+ ->setShippinCountry($shipping->getCountry())
106
+ ->setLanguage($this->getHelper()->getLocale());
107
+
108
+
109
+ foreach ($this->getTransactionTypes() as $transaction_type) {
110
+ if (is_array($transaction_type)) {
111
+ $genesis->request()->addTransactionType(
112
+ $transaction_type['name'], $transaction_type['parameters']
113
+ );
114
+ } else {
115
+ $genesis->request()->addTransactionType($transaction_type);
116
+ }
117
+ }
118
+
119
+ $genesis->execute();
120
+
121
+ $payment
122
+ ->setTransactionId(
123
+ $genesis->response()->getResponseObject()->unique_id
124
+ )
125
+ ->setIsTransactionPending(true)
126
+ ->addTransaction(
127
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
128
+ );
129
+
130
+ $payment->setSkipTransactionCreation(true);
131
+
132
+ // Save the redirect url with our
133
+ $this->getHelper()->getCheckoutSession()->setEmerchantPayCheckoutRedirectUrl(
134
+ $genesis->response()->getResponseObject()->redirect_url
135
+ );
136
+ } catch (Exception $exception) {
137
+ Mage::logException($exception);
138
+
139
+ Mage::throwException(
140
+ $this->getHelper()->__($exception->getMessage())
141
+ );
142
+ }
143
+
144
+ return $this;
145
+ }
146
+
147
+ /**
148
+ * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
149
+ * @param float $amount
150
+ * @return $this|bool
151
+ * @throws Mage_Core_Exception
152
+ */
153
+ public function capture(Varien_Object $payment, $amount)
154
+ {
155
+ Mage::log('Capture transaction for order #' . $payment->getOrder()->getIncrementId());
156
+
157
+ try {
158
+ $this->getHelper()->initClient($this->getCode());
159
+
160
+ $this->getHelper()->setTokenByPaymentTransaction($payment);
161
+
162
+ $authorize = $payment->lookupTransaction(null, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
163
+
164
+ /* Capture should only be possible, when Authorize Transaction Exists */
165
+ if (!isset($authorize) || $authorize === false) {
166
+ Mage::log('Capture transaction for order #' . $payment->getOrder()->getIncrementId() . ' cannot be finished (No Authorize Transaction exists)');
167
+ return $this;
168
+ }
169
+
170
+ $reference_id = $authorize->getTxnId();
171
+
172
+ $genesis = new \Genesis\Genesis('Financial\Capture');
173
+
174
+ $genesis
175
+ ->request()
176
+ ->setTransactionId(
177
+ $this->getHelper()->genTransactionId(
178
+ $payment->getOrder()->getIncrementId()
179
+ )
180
+ )
181
+ ->setRemoteIp(
182
+ $this->getHelper('core/http')->getRemoteAddr(false)
183
+ )
184
+ ->setReferenceId(
185
+ $reference_id
186
+ )
187
+ ->setCurrency(
188
+ $payment->getOrder()->getBaseCurrencyCode()
189
+ )
190
+ ->setAmount(
191
+ $amount
192
+ );
193
+
194
+ $genesis->execute();
195
+
196
+ $payment
197
+ ->setTransactionId(
198
+ $genesis->response()->getResponseObject()->unique_id
199
+ )
200
+ ->setParentTransactionId(
201
+ $reference_id
202
+ )
203
+ ->setShouldCloseParentTransaction(
204
+ true
205
+ )
206
+ ->resetTransactionAdditionalInfo(
207
+
208
+ )
209
+ ->setTransactionAdditionalInfo(
210
+ array(
211
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->getHelper()->getArrayFromGatewayResponse(
212
+ $genesis->response()->getResponseObject()
213
+ )
214
+ ),
215
+ null
216
+ );
217
+
218
+ $payment->save();
219
+ } catch (Exception $exception) {
220
+ Mage::logException($exception);
221
+
222
+ Mage::throwException(
223
+ $this->getHelper()->__($exception->getMessage())
224
+ );
225
+ }
226
+
227
+ return $this;
228
+ }
229
+
230
+ /**
231
+ * Refund the last successful transaction
232
+ *
233
+ * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
234
+ * @param float $amount
235
+ *
236
+ * @return EMerchantPay_Genesis_Model_Checkout
237
+ */
238
+ public function refund(Varien_Object $payment, $amount)
239
+ {
240
+ Mage::log('Refund transaction for order #' . $payment->getOrder()->getIncrementId());
241
+
242
+ try {
243
+ $this->getHelper()->initClient($this->getCode());
244
+
245
+ $this->getHelper()->setTokenByPaymentTransaction($payment);
246
+
247
+ $capture = $payment->lookupTransaction(null, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
248
+
249
+ /* Refund Transaction is only possible, when Capture Transaction Exists */
250
+ if (!isset($capture) || $capture === false) {
251
+ Mage::log('Refund transaction for order #' . $payment->getOrder()->getIncrementId() . ' could not be completed! (No Capture Transaction Exists');
252
+ return $this;
253
+ }
254
+
255
+ $reference_id = $capture->getTxnId();
256
+
257
+ $genesis = new \Genesis\Genesis('Financial\Refund');
258
+
259
+ $genesis
260
+ ->request()
261
+ ->setTransactionId(
262
+ $this->getHelper()->genTransactionId(
263
+ $payment->getOrder()->getIncrementId()
264
+ )
265
+ )
266
+ ->setRemoteIp(
267
+ $this->getHelper('core/http')->getRemoteAddr(false)
268
+ )
269
+ ->setReferenceId(
270
+ $reference_id
271
+ )
272
+ ->setCurrency(
273
+ $payment->getOrder()->getBaseCurrencyCode()
274
+ )
275
+ ->setAmount($amount);
276
+
277
+ $genesis->execute();
278
+
279
+ $payment
280
+ ->setTransactionId(
281
+ $genesis->response()->getResponseObject()->unique_id
282
+ )
283
+ ->setParentTransactionId(
284
+ $reference_id
285
+ )
286
+ ->setShouldCloseParentTransaction(
287
+ true
288
+ )
289
+ ->resetTransactionAdditionalInfo(
290
+
291
+ )
292
+ ->setTransactionAdditionalInfo(
293
+ array(
294
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->getHelper()->getArrayFromGatewayResponse(
295
+ $genesis->response()->getResponseObject()
296
+ )
297
+ ),
298
+ null
299
+ );
300
+
301
+ $payment->save();
302
+ } catch (Exception $exception) {
303
+ Mage::logException($exception);
304
+
305
+ Mage::throwException(
306
+ $exception->getMessage()
307
+ );
308
+ }
309
+
310
+ return $this;
311
+ }
312
+
313
+ /**
314
+ * Void the last successful transaction
315
+ *
316
+ * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
317
+ *
318
+ * @return EMerchantPay_Genesis_Model_Checkout
319
+ */
320
+ public function void(Varien_Object $payment)
321
+ {
322
+ Mage::log('Void transaction for order #' . $payment->getOrder()->getIncrementId());
323
+
324
+ try {
325
+ $this->getHelper()->initClient($this->getCode());
326
+
327
+ $this->getHelper()->setTokenByPaymentTransaction($payment);
328
+
329
+ $transactions = $this->getHelper()->getTransactionFromPaymentObject($payment, array(
330
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
331
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
332
+ ));
333
+
334
+ $reference_id = $transactions ? reset($transactions)->getTxnId() : null;
335
+
336
+ $genesis = new \Genesis\Genesis('Financial\Void');
337
+
338
+ $genesis
339
+ ->request()
340
+ ->setTransactionId(
341
+ $this->getHelper()->genTransactionId(
342
+ $payment->getOrder()->getIncrementId()
343
+ )
344
+ )
345
+ ->setRemoteIp(
346
+ $this->getHelper('core/http')->getRemoteAddr(false)
347
+ )
348
+ ->setReferenceId(
349
+ $reference_id
350
+ );
351
+
352
+ $genesis->execute();
353
+
354
+ $payment
355
+ ->setTransactionId(
356
+ $genesis->response()->getResponseObject()->unique_id
357
+ )
358
+ ->setParentTransactionId(
359
+ $reference_id
360
+ )
361
+ ->setShouldCloseParentTransaction(
362
+ true
363
+ )
364
+ ->resetTransactionAdditionalInfo(
365
+
366
+ )
367
+ ->setTransactionAdditionalInfo(
368
+ array(
369
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->getHelper()->getArrayFromGatewayResponse(
370
+ $genesis->response()->getResponseObject()
371
+ )
372
+ ),
373
+ null
374
+ );
375
+
376
+ $payment->save();
377
+ } catch (Exception $exception) {
378
+ Mage::logException($exception);
379
+
380
+ Mage::throwException(
381
+ $exception->getMessage()
382
+ );
383
+ }
384
+
385
+ return $this;
386
+ }
387
+
388
+ /**
389
+ * Cancel payment abstract method
390
+ *
391
+ * @param Varien_Object $payment
392
+ *
393
+ * @return EMerchantPay_Genesis_Model_Checkout
394
+ */
395
+ public function cancel(Varien_Object $payment)
396
+ {
397
+ return $this->void($payment);
398
+ }
399
+
400
+ /**
401
+ * Fetch transaction details info
402
+ *
403
+ * @param Mage_Payment_Model_Info $payment
404
+ * @param string $transactionId
405
+ * @return array
406
+ */
407
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
408
+ {
409
+ /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
410
+ $transaction = Mage::getModel('sales/order_payment_transaction')->load($transactionId, 'txn_id');
411
+
412
+ $checkout_transaction = $transaction->getOrder()->getPayment()->lookupTransaction(
413
+ null,
414
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
415
+ );
416
+
417
+ $reconcile = $this->reconcile($checkout_transaction->getTxnId());
418
+
419
+ // Get the current details
420
+ $transaction_details = $payment->getAdditionalInformation(
421
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS
422
+ );
423
+
424
+ // Try to extract transaction details from the Gateway response
425
+ if ($reconcile->unique_id == $transactionId) {
426
+ $transaction_details = $reconcile;
427
+ }
428
+ else {
429
+ if ($reconcile->payment_transaction instanceof stdClass) {
430
+ if ($reconcile->payment_transaction->unique_id == $transactionId) {
431
+ $transaction_details = $reconcile->payment_transaction;
432
+ }
433
+ }
434
+
435
+ if ($reconcile->payment_transaction instanceof ArrayObject) {
436
+ foreach ($reconcile->payment_transaction as $payment_transaction) {
437
+ if ($payment_transaction->unique_id == $transactionId) {
438
+ $transaction_details = $payment_transaction;
439
+ }
440
+ }
441
+ }
442
+ }
443
+
444
+ // Remove the current details
445
+ $payment->unsAdditionalInformation(
446
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS
447
+ );
448
+
449
+ // Set the default/updated transaction details
450
+ $payment->setAdditionalInformation(
451
+ array(
452
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->getHelper()->getArrayFromGatewayResponse(
453
+ $transaction_details
454
+ )
455
+ ),
456
+ null
457
+ );
458
+
459
+ $payment->save();
460
+
461
+ return $payment->getAdditionalInformation(
462
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS
463
+ );
464
+ }
465
+
466
+ /**
467
+ * Execute a WPF Reconcile
468
+ *
469
+ * @param $unique_id
470
+ *
471
+ * @return EMerchantPay_Genesis_Model_Checkout
472
+ *
473
+ * @throws Mage_Core_Exception
474
+ */
475
+ public function reconcile($unique_id)
476
+ {
477
+ try {
478
+ $this->getHelper()->initClient($this->getCode());
479
+
480
+ $genesis = new \Genesis\Genesis('WPF\Reconcile');
481
+
482
+ $genesis->request()->setUniqueId($unique_id);
483
+
484
+ $genesis->execute();
485
+
486
+ return $genesis->response()->getResponseObject();
487
+ } catch (Exception $exception) {
488
+ Mage::logException($exception);
489
+
490
+ Mage::throwException(
491
+ $exception->getMessage()
492
+ );
493
+ }
494
+
495
+ return false;
496
+ }
497
+
498
+ public function processNotification($checkout_transaction)
499
+ {
500
+ try {
501
+ $this->getHelper()->initClient($this->getCode());
502
+
503
+ /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
504
+ $transaction = Mage::getModel('sales/order_payment_transaction')->load($checkout_transaction->unique_id, 'txn_id');
505
+
506
+ $order = $transaction->getOrder();
507
+
508
+ if ($order) {
509
+ $transaction
510
+ ->setOrderPaymentObject(
511
+ $order->getPayment()
512
+ )
513
+ ->setAdditionalInformation(
514
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
515
+ $this->getHelper()->getArrayFromGatewayResponse(
516
+ $checkout_transaction
517
+ )
518
+ )
519
+ ->save();
520
+
521
+ if (isset($checkout_transaction->payment_transaction)) {
522
+ $payment_transaction = $checkout_transaction->payment_transaction;
523
+
524
+ $payment = $order->getPayment();
525
+
526
+ $payment
527
+ ->setTransactionId($payment_transaction->unique_id)
528
+ ->setParentTransactionId($checkout_transaction->unique_id)
529
+ ->setShouldCloseParentTransaction(true)
530
+ ->setIsTransactionPending(false)
531
+ ->resetTransactionAdditionalInfo()
532
+ ->setTransactionAdditionalInfo(
533
+ array(
534
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->getHelper()->getArrayFromGatewayResponse(
535
+ $payment_transaction
536
+ )
537
+ ),
538
+ null
539
+ );
540
+
541
+ if ($payment_transaction->status == \Genesis\API\Constants\Transaction\States::APPROVED) {
542
+ $payment->setIsTransactionClosed(false);
543
+ }
544
+ else {
545
+ $payment->setIsTransactionClosed(true);
546
+ }
547
+
548
+ switch ($payment_transaction->transaction_type) {
549
+ case \Genesis\API\Constants\Transaction\Types::AUTHORIZE:
550
+ case \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D:
551
+ $payment->registerAuthorizationNotification($payment_transaction->amount, true);
552
+ break;
553
+ case \Genesis\API\Constants\Transaction\Types::ABNIDEAL:
554
+ case \Genesis\API\Constants\Transaction\Types::CASHU:
555
+ case \Genesis\API\Constants\Transaction\Types::NETELLER:
556
+ case \Genesis\API\Constants\Transaction\Types::PAYSAFECARD:
557
+ case \Genesis\API\Constants\Transaction\Types::PPRO:
558
+ case \Genesis\API\Constants\Transaction\Types::SALE:
559
+ case \Genesis\API\Constants\Transaction\Types::SALE_3D:
560
+ case \Genesis\API\Constants\Transaction\Types::SOFORT:
561
+ $payment->registerCaptureNotification($payment_transaction->amount, true);
562
+ break;
563
+ default:
564
+ break;
565
+ }
566
+
567
+
568
+ $payment->save();
569
+ }
570
+
571
+ $this->getHelper()->setOrderState(
572
+ $order,
573
+ isset($payment_transaction) ? $payment_transaction->status : $checkout_transaction->status
574
+ );
575
+
576
+ return true;
577
+ }
578
+ } catch (Exception $exception) {
579
+ Mage::logException($exception);
580
+ }
581
+
582
+ return false;
583
+ }
584
+
585
+ /**
586
+ * Get the selected transaction types in array
587
+ *
588
+ * @return array
589
+ */
590
+ public function getTransactionTypes()
591
+ {
592
+ $processed_list = array();
593
+
594
+ $selected_types = array_filter(
595
+ explode(',', $this->getConfigData('genesis_types'))
596
+ );
597
+
598
+ $alias_map = array(
599
+ \Genesis\API\Constants\Payment\Methods::EPS =>
600
+ \Genesis\API\Constants\Transaction\Types::PPRO,
601
+ \Genesis\API\Constants\Payment\Methods::GIRO_PAY =>
602
+ \Genesis\API\Constants\Transaction\Types::PPRO,
603
+ \Genesis\API\Constants\Payment\Methods::PRZELEWY24 =>
604
+ \Genesis\API\Constants\Transaction\Types::PPRO,
605
+ \Genesis\API\Constants\Payment\Methods::QIWI =>
606
+ \Genesis\API\Constants\Transaction\Types::PPRO,
607
+ \Genesis\API\Constants\Payment\Methods::SAFETY_PAY =>
608
+ \Genesis\API\Constants\Transaction\Types::PPRO,
609
+ \Genesis\API\Constants\Payment\Methods::TELEINGRESO =>
610
+ \Genesis\API\Constants\Transaction\Types::PPRO,
611
+ \Genesis\API\Constants\Payment\Methods::TRUST_PAY =>
612
+ \Genesis\API\Constants\Transaction\Types::PPRO,
613
+ );
614
+
615
+ foreach ($selected_types as $selected_type) {
616
+ if (array_key_exists($selected_type, $alias_map)) {
617
+ $transaction_type = $alias_map[$selected_type];
618
+
619
+ $processed_list[$transaction_type]['name'] = $transaction_type;
620
+
621
+ $processed_list[$transaction_type]['parameters'][] = array(
622
+ 'payment_method' => $selected_type
623
+ );
624
+ } else {
625
+ $processed_list[] = $selected_type;
626
+ }
627
+ }
628
+
629
+ return $processed_list;
630
+ }
631
+
632
+ /**
633
+ * Get URL to "Redirect" block
634
+ *
635
+ * @see EMerchantPay_Genesis_CheckoutController
636
+ *
637
+ * @note In order for redirect to work, you must
638
+ * set the session variable:
639
+ *
640
+ * EmerchantPayGenesisCheckoutRedirectUrl
641
+ *
642
+ * @return mixed
643
+ */
644
+ public function getOrderPlaceRedirectUrl()
645
+ {
646
+ return $this->getHelper()->getRedirectUrl('checkout');
647
+ }
648
+
649
+ /**
650
+ * Get the helper or return its instance
651
+ *
652
+ * @param $helper string - Name of the helper, empty for the default class helper
653
+ *
654
+ * @return EMerchantPay_Genesis_Helper_Data|mixed
655
+ */
656
+ private function getHelper($helper = '')
657
+ {
658
+ if (empty($helper)) {
659
+ return Mage::helper('emerchantpay');
660
+ } else {
661
+ return Mage::helper($helper);
662
+ }
663
+ }
664
+ }
app/code/community/EMerchantPay/Genesis/Model/Direct.php ADDED
@@ -0,0 +1,982 @@