eWAY_Payment_Rapid31 - Version 1.3.1

Version Notes

Upgrade
- Support for MageWorld One Step Checkout Pro

Minor fixes:

- Fix for stores with custom DB table prefixes
- Fix for manual payments not submitting for some stores

Download this release

Release Info

Developer eWAY Payments
Extension eWAY_Payment_Rapid31
Version 1.3.1
Comparing to
See all releases


Code changes from version 1.3.0 to 1.3.1

app/code/community/Eway/Rapid31/Block/Sales/Order/Grid.php CHANGED
@@ -1,9 +1,6 @@
1
  <?php
2
  /**
3
- * Created by PhpStorm.
4
- * User: Administrator PC
5
- * Date: 7/21/14
6
- * Time: 3:47 PM
7
  */
8
  class Eway_Rapid31_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid {
9
 
1
  <?php
2
  /**
3
+ *
 
 
 
4
  */
5
  class Eway_Rapid31_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid {
6
 
app/code/community/Eway/Rapid31/Helper/Data.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
-
3
  /**
4
- * Created by PhpStorm.
5
- * User: hiephm
6
- * Date: 4/23/14
7
- * Time: 5:30 PM
8
  */
9
  class Eway_Rapid31_Helper_Data extends Mage_Core_Helper_Abstract
10
  {
1
  <?php
 
2
  /**
3
+ *
 
 
 
4
  */
5
  class Eway_Rapid31_Helper_Data extends Mage_Core_Helper_Abstract
6
  {
app/code/community/Eway/Rapid31/Model/Config.php CHANGED
@@ -25,7 +25,7 @@ class Eway_Rapid31_Model_Config
25
  const PAYPAL_EXPRESS_METHOD = 'paypal_express';
26
  const MASTERPASS_METHOD = 'masterpass';
27
 
28
- const MESSAGE_ERROR_ORDER = 'Billing Frequency is wrong. It must be numeric and greater than 0. Status of recurring profile is changed to canceled';
29
 
30
  const TRANSPARENT_ACCESSCODE = 'AccessCodes';
31
  const TRANSPARENT_ACCESSCODE_RESULT = 'AccessCode';
25
  const PAYPAL_EXPRESS_METHOD = 'paypal_express';
26
  const MASTERPASS_METHOD = 'masterpass';
27
 
28
+ const MESSAGE_ERROR_ORDER = 'Billing Frequency is wrong. It must be numeric and greater than 0. Status of recurring profile is changed to cancelled';
29
 
30
  const TRANSPARENT_ACCESSCODE = 'AccessCodes';
31
  const TRANSPARENT_ACCESSCODE_RESULT = 'AccessCode';
app/code/community/Eway/Rapid31/Model/EwayCron.php CHANGED
@@ -1,9 +1,6 @@
1
  <?php
2
  /**
3
- * Created by PhpStorm.
4
- * User: Administrator PC
5
- * Date: 7/31/14
6
- * Time: 4:38 PM
7
  */
8
  class Eway_Rapid31_Model_EwayCron {
9
 
1
  <?php
2
  /**
3
+ *
 
 
 
4
  */
5
  class Eway_Rapid31_Model_EwayCron {
6
 
app/code/community/Eway/Rapid31/Model/Observer.php CHANGED
@@ -1,293 +1,293 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class Eway_Rapid31_Model_Observer {
6
-
7
- /* @var Magento_Sales_Model_Order_Invoice*/
8
- var $_invoice;
9
-
10
- public function myCards() {
11
-
12
- }
13
-
14
- public function checkCustomerMark() {
15
- if(Mage::getSingleton('customer/session')->isLoggedIn()) {
16
- $fraud_enabled = Mage::getStoreConfig('payment/ewayrapid_general/block_fraud_customers');
17
- $customer = Mage::getSingleton('customer/session')->getCustomer();
18
- $markFraud = $customer->getMarkFraud();
19
- $unblock = $customer->getBlockFraudCustomer();
20
- if((int)$markFraud === 1
21
- && $fraud_enabled
22
- && (int)$unblock === 0
23
- ) {
24
- Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
25
- Mage::app()->getResponse()->sendResponse();
26
- Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Your latest payment is being reviewed and you cannot place a new order temporarily. Please try again later.'));
27
- exit;
28
- }
29
- }
30
- }
31
-
32
- public function sales_order_save_before($observer) {
33
-
34
- }
35
-
36
- public function sales_order_save_after($observer) {
37
-
38
- }
39
-
40
- public function sales_order_place_before($observer) {
41
- // Check order fraud here
42
- // ...
43
- $fraud = Mage::getSingleton('core/session')->getData('fraud');
44
- if($fraud === 1) {
45
-
46
- }
47
- }
48
-
49
- public function sales_order_place_after($observer) {
50
- // Check order fraud here
51
- // ...
52
-
53
- $fraud = Mage::getSingleton('core/session')->getData('fraud');
54
- if($fraud === 1) {
55
-
56
- }
57
- }
58
-
59
- public function sales_order_invoice_save_after($observer)
60
- {
61
- try {
62
- /* @var $order Magento_Sales_Model_Order_Invoice */
63
- $this->_invoice = $observer->getEvent()->getInvoice();
64
- $this->_invoice->sendEmail();
65
- } catch (Mage_Core_Exception $e) {
66
- Mage::log("Error sending invoice email: " . $e->getMessage());
67
- }
68
- return $this;
69
- }
70
-
71
- public function checkout_submit_all_after(Varien_Event_Observer $observer) {
72
- $fraud = Mage::getSingleton('core/session')->getData('fraud');
73
- $comment = Mage::getSingleton('core/session')->getData('fraudMessage');
74
- // Read setting config enabled fraud or not
75
- if($fraud === 1 && $order = $observer->getEvent()->getOrder()) {
76
- $order->setState('fraud');
77
- $order->setStatus('fraud');
78
- if ($comment) {
79
- $comment = 'An order is marked as Suspected Fraud. Because it contains: ' . $comment;
80
- $order->addStatusHistoryComment($comment)
81
- ->setIsVisibleOnFront(false)
82
- ->setIsCustomerNotified(false);
83
- }
84
- $order->save();
85
-
86
- // Update user to fraud
87
- $session = Mage::getSingleton('customer/session');
88
- if ($session->isLoggedIn()) {
89
- $customer = $session->getCustomer();
90
- $customer->setData('mark_fraud', 1);
91
- $customer->save();
92
- }
93
-
94
- Mage::getSingleton('core/session')->unsetData('fraud');
95
- Mage::getSingleton('core/session')->unsetData('fraudMessage');
96
- }
97
- }
98
-
99
- /**
100
- * Update eway transaction for order
101
- * @param Varien_Event_Observer $observer
102
- */
103
- public function checkout_type_onepage_save_order_after(Varien_Event_Observer $observer) {
104
- $order = $observer->getData('order');
105
- $order->setEwayTransactionId($order->getPayment()->getTransactionId());
106
- $order->save();
107
-
108
- }
109
- /*
110
- * create order of recurring profile
111
- *
112
- * @param Varien_Event_Observer $observer
113
- */
114
- public function createRecurringOrder(Varien_Event_Observer $observer)
115
- {
116
- $profiles = $observer->getEvent()->getRecurringProfiles();
117
-
118
- if (isset($profiles[0])) {
119
- /** @var Mage_Sales_Model_Recurring_Profile $profile */
120
- $profile = $profiles[0];
121
- } else {
122
- return;
123
- }
124
-
125
- //if Billing Frequency <= 0 or isn't numeric, Status of recurring profile changed to canceled
126
- if (!$profile->getPeriodFrequency()
127
- || (string)(int) $profile->getPeriodFrequency() !== ltrim($profile->getPeriodFrequency(), '0')
128
- || (int) $profile->getPeriodFrequency() <= 0
129
- ) {
130
- $profile->cancel();
131
- Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Billing Frequency is wrong. It must be numeric and greater than 0. Status of recurring profile is changed to canceled'));
132
- $session = Mage::getSingleton('checkout/type_onepage')->getCheckout();
133
- $session->setLastRecurringProfileIds(null);
134
- return;
135
- }
136
-
137
- $quote = $observer->getEvent()->getQuote();
138
-
139
- /** @var Eway_Rapid31_Model_RecurringProfile $recurringProfile */
140
- $recurringProfile = Mage::getModel('ewayrapid/recurringProfile');
141
- $orderItemInfo = $profile->getOrderItemInfo();
142
- $buyRequest = unserialize($orderItemInfo['info_buyRequest']);
143
-
144
- // timezone used as store's timezone
145
- $startDate = isset($buyRequest['recurring_profile_start_datetime']) && $buyRequest['recurring_profile_start_datetime'] ? $buyRequest['recurring_profile_start_datetime'] : null;
146
-
147
- $additional = $profile->getAdditionalInfo();
148
- $token = $recurringProfile->processToken($quote);
149
- $token = json_decode($token, true);
150
- $additional['token'] = $token;
151
- $additional['startDate'] = $startDate;
152
- $additional['initialFee'] = true;
153
- $profile->setAdditionalInfo($additional);
154
- $profile->save();
155
-
156
- // charge Initial Fee if It is greater than 0 and is numeric
157
- if ($profile->getInitAmount()
158
- && (int) $profile->getInitAmount() > 0
159
- && (string)(int) $profile->getInitAmount() === ltrim($profile->getInitAmount(), '0')
160
- ) {
161
- try {
162
- $recurringProfile->processInitialFee($profile);
163
- } catch (Exception $e) {
164
- $additional = $profile->getAdditionalInfo();
165
- $additional['initialFee'] = false;
166
- if ($profile->getInitMayFail() == '1') {
167
- // Allow Initial Fee Failure = yes
168
- // change status recurring profile = suspended
169
- $profile->suspend();
170
- $errorMessage = Mage::getSingleton('core/session')->getData('errorMessage');
171
- Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while making the transaction by Initial Fee (Error message: %s). Status of recurring profile is changed to suspended.', $errorMessage));
172
- return;
173
-
174
- } else {
175
- // Allow Initial Fee Failure = no
176
- // Auto Bill on Next Cycle = no
177
- // set additionalInfo['outstanding'] = Initial Fee
178
- if (!$profile->getBillFailedLater()) {
179
- $additional['outstanding'] = $profile->getInitAmount();
180
- }
181
- }
182
- $profile->setAdditionalInfo($additional);
183
- $profile->save();
184
- }
185
- }
186
-
187
- // check current time >= started time
188
- if (!$startDate || $recurringProfile->checkRecurringTimeStart($startDate)) {
189
- try {
190
- // create order
191
- // before day = current date // check if frequency >1day
192
- // next day with current date
193
- $recurringProfile->processRequest($profile);
194
- } catch (Exception $e) {
195
- $errorMessage = Mage::getSingleton('core/session')->getData('errorMessage');
196
- Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. (Error message: %s)', $errorMessage));
197
- // suspend recurring profile when response data contains error and/or TransactionID is null
198
- $checkPaymentFailures = $recurringProfile->checkMaxPaymentFailures($profile);
199
- if (!$checkPaymentFailures) {
200
- Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Out of Payment failures. Status of recurring profile is changed to suspended.'));
201
- }
202
- return;
203
- }
204
- } else {
205
- // not created order
206
- // before day = null
207
- // next day = date of started time
208
- $additionalInfo = $profile->getAdditionalInfo();
209
- $additionalInfo['nextDate'] = $startDate;
210
- $profile->setAdditionalInfo($additionalInfo);
211
- $profile->save();
212
- }
213
- }
214
-
215
- /**
216
- * load recurring profile if methodcode = ewayrapid_saved
217
- *
218
- * @param string $methodCode
219
- * @return array
220
- */
221
- protected function _loadProfileByMethod($methodCode = 'ewayrapid_saved')
222
- {
223
- $modelRecurringProfile = Mage::getModel('sales/recurring_profile')->getCollection()
224
- ->addFieldToFilter('method_code', $methodCode)
225
- ->addFieldToFilter('state', 'active')
226
- ->addFieldToFilter('additional_info', array('notnull' => true))
227
- ->addFieldToFilter('period_max_cycles', array(
228
- array('null' => true),
229
- array('gt' => 0)
230
- )
231
- );
232
- $profiles = array();
233
-
234
- foreach ($modelRecurringProfile as $item) {
235
- /** @var Mage_Sales_Model_Recurring_Profile $item */
236
- $additionalInfo = unserialize($item->getAdditionalInfo());
237
- $billingInfo = unserialize($item->getBillingAddressInfo());
238
- $addressInfo = unserialize($item->getShippingAddressInfo());
239
- $orderItemInfo = unserialize($item->getOrderItemInfo());
240
- $orderInfo = unserialize($item->getOrderInfo());
241
- $item->setBillingAddressInfo($billingInfo);
242
- $item->setShippingAddressInfo($addressInfo);
243
- $item->setOrderItemInfo($orderItemInfo);
244
- $item->setAdditionalInfo($additionalInfo);
245
- $item->setOrderInfo($orderInfo);
246
- $profiles[] = $item;
247
- }
248
- return $profiles;
249
- }
250
-
251
- /**
252
- * cron recurring profile to create order
253
- */
254
- public function cronRecurringOrder()
255
- {
256
- $profiles = $this->_loadProfileByMethod();
257
- foreach ($profiles as $profile) {
258
- /** @var Mage_Sales_Model_Recurring_Profile $profile */
259
- /** @var Eway_Rapid31_Model_RecurringProfile $recurringProfile */
260
- $recurringProfile = Mage::getModel('ewayrapid/recurringProfile');
261
-
262
- $recurringProfile->updateNextDate($profile);
263
-
264
- // check run cron job conditions
265
- if ($recurringProfile->checkRecurringProfileRunCronJob($profile)) {
266
- // check charge money initial Fee
267
- $additional = $profile->getAdditionalInfo();
268
- if ($additional['initialFee'] == false) {
269
- if (!$profile->getInitMayFail() && $profile->getBillFailedLater()) {
270
- try {
271
- $recurringProfile->processInitialFee($profile);
272
- $additional['initialFee'] = true;
273
- $profile->setAdditionalInfo($additional);
274
- $profile->save();
275
- } catch (Exception $e) {
276
- Mage::logException($e);
277
- }
278
- }
279
- }
280
-
281
- $profile->setIsCronJob(true);
282
-
283
- try {
284
- $recurringProfile->processRequest($profile);
285
- } catch (Exception $e) {
286
- $paymentFailures = $recurringProfile->checkMaxPaymentFailures($profile);
287
- Mage::logException($e);
288
- }
289
- }
290
- }
291
- return;
292
- }
293
  }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class Eway_Rapid31_Model_Observer {
6
+
7
+ /* @var Magento_Sales_Model_Order_Invoice*/
8
+ var $_invoice;
9
+
10
+ public function myCards() {
11
+
12
+ }
13
+
14
+ public function checkCustomerMark() {
15
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
16
+ $fraud_enabled = Mage::getStoreConfig('payment/ewayrapid_general/block_fraud_customers');
17
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
18
+ $markFraud = $customer->getMarkFraud();
19
+ $unblock = $customer->getBlockFraudCustomer();
20
+ if((int)$markFraud === 1
21
+ && $fraud_enabled
22
+ && (int)$unblock === 0
23
+ ) {
24
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
25
+ Mage::app()->getResponse()->sendResponse();
26
+ Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Your latest payment is being reviewed and you cannot place a new order temporarily. Please try again later.'));
27
+ exit;
28
+ }
29
+ }
30
+ }
31
+
32
+ public function sales_order_save_before($observer) {
33
+
34
+ }
35
+
36
+ public function sales_order_save_after($observer) {
37
+
38
+ }
39
+
40
+ public function sales_order_place_before($observer) {
41
+ // Check order fraud here
42
+ // ...
43
+ $fraud = Mage::getSingleton('core/session')->getData('fraud');
44
+ if($fraud === 1) {
45
+
46
+ }
47
+ }
48
+
49
+ public function sales_order_place_after($observer) {
50
+ // Check order fraud here
51
+ // ...
52
+
53
+ $fraud = Mage::getSingleton('core/session')->getData('fraud');
54
+ if($fraud === 1) {
55
+
56
+ }
57
+ }
58
+
59
+ public function sales_order_invoice_save_after($observer)
60
+ {
61
+ try {
62
+ /* @var $order Magento_Sales_Model_Order_Invoice */
63
+ $this->_invoice = $observer->getEvent()->getInvoice();
64
+ $this->_invoice->sendEmail();
65
+ } catch (Mage_Core_Exception $e) {
66
+ Mage::log("Error sending invoice email: " . $e->getMessage());
67
+ }
68
+ return $this;
69
+ }
70
+
71
+ public function checkout_submit_all_after(Varien_Event_Observer $observer) {
72
+ $fraud = Mage::getSingleton('core/session')->getData('fraud');
73
+ $comment = Mage::getSingleton('core/session')->getData('fraudMessage');
74
+ // Read setting config enabled fraud or not
75
+ if($fraud === 1 && $order = $observer->getEvent()->getOrder()) {
76
+ $order->setState('fraud');
77
+ $order->setStatus('fraud');
78
+ if ($comment) {
79
+ $comment = 'An order is marked as Suspected Fraud. Because it contains: ' . $comment;
80
+ $order->addStatusHistoryComment($comment)
81
+ ->setIsVisibleOnFront(false)
82
+ ->setIsCustomerNotified(false);
83
+ }
84
+ $order->save();
85
+
86
+ // Update user to fraud
87
+ $session = Mage::getSingleton('customer/session');
88
+ if ($session->isLoggedIn()) {
89
+ $customer = $session->getCustomer();
90
+ $customer->setData('mark_fraud', 1);
91
+ $customer->save();
92
+ }
93
+
94
+ Mage::getSingleton('core/session')->unsetData('fraud');
95
+ Mage::getSingleton('core/session')->unsetData('fraudMessage');
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Update eway transaction for order
101
+ * @param Varien_Event_Observer $observer
102
+ */
103
+ public function checkout_type_onepage_save_order_after(Varien_Event_Observer $observer) {
104
+ $order = $observer->getData('order');
105
+ $order->setEwayTransactionId($order->getPayment()->getTransactionId());
106
+ $order->save();
107
+
108
+ }
109
+ /*
110
+ * create order of recurring profile
111
+ *
112
+ * @param Varien_Event_Observer $observer
113
+ */
114
+ public function createRecurringOrder(Varien_Event_Observer $observer)
115
+ {
116
+ $profiles = $observer->getEvent()->getRecurringProfiles();
117
+
118
+ if (isset($profiles[0])) {
119
+ /** @var Mage_Sales_Model_Recurring_Profile $profile */
120
+ $profile = $profiles[0];
121
+ } else {
122
+ return;
123
+ }
124
+
125
+ //if Billing Frequency <= 0 or isn't numeric, Status of recurring profile changed to canceled
126
+ if (!$profile->getPeriodFrequency()
127
+ || (string)(int) $profile->getPeriodFrequency() !== ltrim($profile->getPeriodFrequency(), '0')
128
+ || (int) $profile->getPeriodFrequency() <= 0
129
+ ) {
130
+ $profile->cancel();
131
+ Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Billing Frequency is wrong. It must be numeric and greater than 0. Status of recurring profile is changed to canceled'));
132
+ $session = Mage::getSingleton('checkout/type_onepage')->getCheckout();
133
+ $session->setLastRecurringProfileIds(null);
134
+ return;
135
+ }
136
+
137
+ $quote = $observer->getEvent()->getQuote();
138
+
139
+ /** @var Eway_Rapid31_Model_RecurringProfile $recurringProfile */
140
+ $recurringProfile = Mage::getModel('ewayrapid/recurringProfile');
141
+ $orderItemInfo = $profile->getOrderItemInfo();
142
+ $buyRequest = unserialize($orderItemInfo['info_buyRequest']);
143
+
144
+ // timezone used as store's timezone
145
+ $startDate = isset($buyRequest['recurring_profile_start_datetime']) && $buyRequest['recurring_profile_start_datetime'] ? $buyRequest['recurring_profile_start_datetime'] : null;
146
+
147
+ $additional = $profile->getAdditionalInfo();
148
+ $token = $recurringProfile->processToken($quote);
149
+ $token = json_decode($token, true);
150
+ $additional['token'] = $token;
151
+ $additional['startDate'] = $startDate;
152
+ $additional['initialFee'] = true;
153
+ $profile->setAdditionalInfo($additional);
154
+ $profile->save();
155
+
156
+ // charge Initial Fee if It is greater than 0 and is numeric
157
+ if ($profile->getInitAmount()
158
+ && (float) $profile->getInitAmount() > 0
159
+ //&& (string)(int) $profile->getInitAmount() === ltrim($profile->getInitAmount(), '0')
160
+ ) {
161
+ try {
162
+ $recurringProfile->processInitialFee($profile);
163
+ } catch (Exception $e) {
164
+ $additional = $profile->getAdditionalInfo();
165
+ $additional['initialFee'] = false;
166
+ if ($profile->getInitMayFail() == '1') {
167
+ // Allow Initial Fee Failure = yes
168
+ // change status recurring profile = suspended
169
+ $profile->suspend();
170
+ $errorMessage = Mage::getSingleton('core/session')->getData('errorMessage');
171
+ Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while making the transaction by Initial Fee (Error message: %s). Status of recurring profile is changed to suspended.', $errorMessage));
172
+ return;
173
+
174
+ } else {
175
+ // Allow Initial Fee Failure = no
176
+ // Auto Bill on Next Cycle = no
177
+ // set additionalInfo['outstanding'] = Initial Fee
178
+ if (!$profile->getBillFailedLater()) {
179
+ $additional['outstanding'] = $profile->getInitAmount();
180
+ }
181
+ }
182
+ $profile->setAdditionalInfo($additional);
183
+ $profile->save();
184
+ }
185
+ }
186
+
187
+ // check current time >= started time
188
+ if (!$startDate || $recurringProfile->checkRecurringTimeStart($startDate)) {
189
+ try {
190
+ // create order
191
+ // before day = current date // check if frequency >1day
192
+ // next day with current date
193
+ $recurringProfile->processRequest($profile);
194
+ } catch (Exception $e) {
195
+ $errorMessage = Mage::getSingleton('core/session')->getData('errorMessage');
196
+ Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. (Error message: %s)', $errorMessage));
197
+ // suspend recurring profile when response data contains error and/or TransactionID is null
198
+ $checkPaymentFailures = $recurringProfile->checkMaxPaymentFailures($profile);
199
+ if (!$checkPaymentFailures) {
200
+ Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Out of Payment failures. Status of recurring profile is changed to suspended.'));
201
+ }
202
+ return;
203
+ }
204
+ } else {
205
+ // not created order
206
+ // before day = null
207
+ // next day = date of started time
208
+ $additionalInfo = $profile->getAdditionalInfo();
209
+ $additionalInfo['nextDate'] = $startDate;
210
+ $profile->setAdditionalInfo($additionalInfo);
211
+ $profile->save();
212
+ }
213
+ }
214
+
215
+ /**
216
+ * load recurring profile if methodcode = ewayrapid_saved
217
+ *
218
+ * @param string $methodCode
219
+ * @return array
220
+ */
221
+ protected function _loadProfileByMethod($methodCode = 'ewayrapid_saved')
222
+ {
223
+ $modelRecurringProfile = Mage::getModel('sales/recurring_profile')->getCollection()
224
+ ->addFieldToFilter('method_code', $methodCode)
225
+ ->addFieldToFilter('state', 'active')
226
+ ->addFieldToFilter('additional_info', array('notnull' => true))
227
+ ->addFieldToFilter('period_max_cycles', array(
228
+ array('null' => true),
229
+ array('gt' => 0)
230
+ )
231
+ );
232
+ $profiles = array();
233
+
234
+ foreach ($modelRecurringProfile as $item) {
235
+ /** @var Mage_Sales_Model_Recurring_Profile $item */
236
+ $additionalInfo = unserialize($item->getAdditionalInfo());
237
+ $billingInfo = unserialize($item->getBillingAddressInfo());
238
+ $addressInfo = unserialize($item->getShippingAddressInfo());
239
+ $orderItemInfo = unserialize($item->getOrderItemInfo());
240
+ $orderInfo = unserialize($item->getOrderInfo());
241
+ $item->setBillingAddressInfo($billingInfo);
242
+ $item->setShippingAddressInfo($addressInfo);
243
+ $item->setOrderItemInfo($orderItemInfo);
244
+ $item->setAdditionalInfo($additionalInfo);
245
+ $item->setOrderInfo($orderInfo);
246
+ $profiles[] = $item;
247
+ }
248
+ return $profiles;
249
+ }
250
+
251
+ /**
252
+ * cron recurring profile to create order
253
+ */
254
+ public function cronRecurringOrder()
255
+ {
256
+ $profiles = $this->_loadProfileByMethod();
257
+ foreach ($profiles as $profile) {
258
+ /** @var Mage_Sales_Model_Recurring_Profile $profile */
259
+ /** @var Eway_Rapid31_Model_RecurringProfile $recurringProfile */
260
+ $recurringProfile = Mage::getModel('ewayrapid/recurringProfile');
261
+
262
+ $recurringProfile->updateNextDate($profile);
263
+
264
+ // check run cron job conditions
265
+ if ($recurringProfile->checkRecurringProfileRunCronJob($profile)) {
266
+ // check charge money initial Fee
267
+ $additional = $profile->getAdditionalInfo();
268
+ if ($additional['initialFee'] == false) {
269
+ if (!$profile->getInitMayFail() && $profile->getBillFailedLater()) {
270
+ try {
271
+ $recurringProfile->processInitialFee($profile);
272
+ $additional['initialFee'] = true;
273
+ $profile->setAdditionalInfo($additional);
274
+ $profile->save();
275
+ } catch (Exception $e) {
276
+ Mage::logException($e);
277
+ }
278
+ }
279
+ }
280
+
281
+ $profile->setIsCronJob(true);
282
+
283
+ try {
284
+ $recurringProfile->processRequest($profile);
285
+ } catch (Exception $e) {
286
+ $paymentFailures = $recurringProfile->checkMaxPaymentFailures($profile);
287
+ Mage::logException($e);
288
+ }
289
+ }
290
+ }
291
+ return;
292
+ }
293
  }
app/code/community/Eway/Rapid31/Model/RecurringProfile.php CHANGED
@@ -404,6 +404,8 @@ class Eway_Rapid31_Model_RecurringProfile
404
  */
405
  public function checkRecurringTimeStart($startDate = null)
406
  {
 
 
407
  // timezone used as store's timezone
408
  return strtotime(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()))) >= strtotime($startDate);
409
  }
404
  */
405
  public function checkRecurringTimeStart($startDate = null)
406
  {
407
+ // fix for ambigious timestamp (dashes force to dd/mm not mm/dd)
408
+ //$startDate = str_replace('/', '-', $startDate);
409
  // timezone used as store's timezone
410
  return strtotime(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()))) >= strtotime($startDate);
411
  }
app/code/community/Eway/Rapid31/Model/Request/Abstract.php CHANGED
@@ -1,149 +1,156 @@
1
- <?php
2
-
3
- /**
4
- * Class Eway_Rapid31_Model_Request_Abstract
5
- *
6
- * @method Eway_Rapid31_Model_Field_Customer getCustomer()
7
- * @method Eway_Rapid31_Model_Request_Abstract setCustomer(Eway_Rapid31_Model_Field_Customer $value)
8
- * @method Eway_Rapid31_Model_Field_ShippingAddress getShippingAddress()
9
- * @method Eway_Rapid31_Model_Request_Abstract setShippingAddress(Eway_Rapid31_Model_Field_ShippingAddress $value)
10
- * @method string getShippingMethod()
11
- * @method Eway_Rapid31_Model_Request_Abstract setShippingMethod(string $value)
12
- * @method array getItems()
13
- * @method Eway_Rapid31_Model_Request_Abstract setItems(array $value)
14
- * @method Eway_Rapid31_Model_Field_Payment getPayment()
15
- * @method Eway_Rapid31_Model_Request_Abstract setPayment(Eway_Rapid31_Model_Field_Payment $value)
16
- * @method string getDeviceID()
17
- * @method Eway_Rapid31_Model_Request_Abstract setDeviceID(string $value)
18
- * @method string getCustomerIP()
19
- * @method Eway_Rapid31_Model_Request_Abstract setCustomerIP(string $value)
20
- * @method string getPartnerID()
21
- * @method Eway_Rapid31_Model_Request_Abstract setPartnerID(string $value)
22
- * @method string getTransactionType()
23
- * @method Eway_Rapid31_Model_Request_Abstract setTransactionType(string $value)
24
- * @method string getMethod()
25
- * @method Eway_Rapid31_Model_Request_Abstract setMethod(string $value)
26
- * @method int getTransactionId()
27
- * @method Eway_Rapid31_Model_Request_Abstract setTransactionId(int $value)
28
- * @method Eway_Rapid31_Model_Field_Payment getRefund()
29
- * @method Eway_Rapid31_Model_Request_Abstract setRefund(Eway_Rapid31_Model_Field_Payment $value)
30
- * @method string getRedirectUrl()
31
- * @method Eway_Rapid31_Model_Request_Abstract setRedirectUrl(string $value)
32
- * @method string getCheckoutPayment()
33
- * @method Eway_Rapid31_Model_Request_Abstract setCheckoutPayment(bool $value)
34
- * @method string getCheckoutURL()
35
- * @method Eway_Rapid31_Model_Request_Abstract setCheckoutURL(string $value)
36
- * @method string getCancelUrl()
37
- * @method Eway_Rapid31_Model_Request_Abstract setCancelUrl(string $value)
38
- * @method Eway_Rapid31_Model_Request_Abstract setCustomerReadOnly(bool $value)
39
- */
40
- abstract class Eway_Rapid31_Model_Request_Abstract extends Eway_Rapid31_Model_JsonSerializableAbstract
41
- {
42
- const DEBUG_FILE = 'ewayrapid31_api_request.log';
43
-
44
- /**
45
- * @var Eway_Rapid31_Model_Config
46
- */
47
- protected $_config = null;
48
-
49
- protected function _construct()
50
- {
51
- $this->_config = Mage::getSingleton('ewayrapid/config');
52
- }
53
-
54
- /**
55
- * Do the main API request.
56
- * All API request to eWAY should call this function with appropriate parameters, after set all necessary data.
57
- *
58
- * @param string $action can be one of POST, GET, DELETE or PUT
59
- * @param string $method
60
- * @return Eway_Rapid31_Model_Response
61
- */
62
- protected function _doRapidAPI($action, $method = 'POST') {
63
-
64
- $url = $this->_config->getRapidAPIUrl($action);
65
- $mode = $this->_config->isSandbox() ? '(Sandbox)' : '(Live)';
66
- $this->_log('>>>>> START REQUEST ' . $mode . ' (' . $method . ') ' . ' : ' . $url);
67
-
68
- $ch = curl_init($url);
69
- curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));
70
- curl_setopt($ch, CURLOPT_USERPWD, $this->_config->getBasicAuthenticationHeader());
71
- switch($method) {
72
- case 'POST':
73
- curl_setopt($ch, CURLOPT_POST, true);
74
- curl_setopt($ch, CURLOPT_POSTFIELDS, $this->jsonSerialize());
75
- $this->_logPostJSON();
76
- break;
77
- case 'GET':
78
- case 'DELETE':
79
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
80
- break;
81
- case 'PUT':
82
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
83
- curl_setopt($ch, CURLOPT_POSTFIELDS, $this->jsonSerialize());
84
- $this->_logPostJSON();
85
- break;
86
- }
87
-
88
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
89
- curl_setopt($ch, CURLOPT_TIMEOUT, 60);
90
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->_config->isEnableSSLVerification());
91
-
92
- $result = curl_exec($ch);
93
-
94
- $this->_log('<<<<< RESPONSE:');
95
- $response = Mage::getModel('ewayrapid/response');
96
- if (curl_errno($ch) != CURLE_OK) {
97
- $response->isSuccess(false);
98
- $response->setMessage(Mage::helper('ewayrapid')->__("There is an error in making API request: %s", curl_error($ch)));
99
- $this->_log("There is an error in making API request: " . curl_error($ch));
100
- } else {
101
- $info = curl_getinfo($ch);
102
- $http_code = intval(trim($info['http_code']));
103
- if ($http_code == 401 || $http_code == 404 || $http_code == 403) {
104
- $response->isSuccess(false);
105
- $response->setMessage(Mage::helper('ewayrapid')->__("Please check the API Key and Password %s", $mode));
106
- $this->_log('Access denied. HTTP_CODE = ' . $info['http_code']);
107
- } elseif ($http_code != 200) {
108
- $response->isSuccess(false);
109
- $response->setMessage(Mage::helper('ewayrapid')->__("Error connecting to payment gateway, please try again"));
110
- $this->_log('Error connecting to payment gateway. HTTP_CODE = ' . $info['http_code']);
111
- } else {
112
- $response->isSuccess(true);
113
- $response->decodeJSON($result);
114
- if($this->_config->isDebug()) {
115
- $this->_log('SUCCESS. Response body: ');
116
- $this->_log(print_r(json_decode($result, true), true));
117
- }
118
- $this->_log('SUCCESS. HTTP_CODE = ' . $info['http_code']);
119
- }
120
- curl_close($ch);
121
- }
122
-
123
- $this->_log('===== END REQUEST.');
124
- return $response;
125
- }
126
-
127
- protected function _logPostJSON()
128
- {
129
- if($this->_config->isDebug()) {
130
- $cardDetails = null;
131
- if($this->getCustomer() && $this->getCustomer()->getCardDetails()) {
132
- $cardDetails = $this->getCustomer()->getCardDetails();
133
- $cardDetails->shouldBeMasked();
134
- }
135
- $this->_log('Request body:');
136
- $this->_log(print_r($this->getJsonData(), true));
137
- if(!is_null($cardDetails)) {
138
- $cardDetails->shouldBeMasked(false);
139
- }
140
- }
141
- }
142
-
143
- protected function _log($message, $file = self::DEBUG_FILE)
144
- {
145
- if($this->_config->isDebug()) {
146
- Mage::log($message, Zend_Log::DEBUG, $file, true);
147
- }
148
- }
 
 
 
 
 
 
 
149
  }
1
+ <?php
2
+
3
+ /**
4
+ * Class Eway_Rapid31_Model_Request_Abstract
5
+ *
6
+ * @method Eway_Rapid31_Model_Field_Customer getCustomer()
7
+ * @method Eway_Rapid31_Model_Request_Abstract setCustomer(Eway_Rapid31_Model_Field_Customer $value)
8
+ * @method Eway_Rapid31_Model_Field_ShippingAddress getShippingAddress()
9
+ * @method Eway_Rapid31_Model_Request_Abstract setShippingAddress(Eway_Rapid31_Model_Field_ShippingAddress $value)
10
+ * @method string getShippingMethod()
11
+ * @method Eway_Rapid31_Model_Request_Abstract setShippingMethod(string $value)
12
+ * @method array getItems()
13
+ * @method Eway_Rapid31_Model_Request_Abstract setItems(array $value)
14
+ * @method Eway_Rapid31_Model_Field_Payment getPayment()
15
+ * @method Eway_Rapid31_Model_Request_Abstract setPayment(Eway_Rapid31_Model_Field_Payment $value)
16
+ * @method string getDeviceID()
17
+ * @method Eway_Rapid31_Model_Request_Abstract setDeviceID(string $value)
18
+ * @method string getCustomerIP()
19
+ * @method Eway_Rapid31_Model_Request_Abstract setCustomerIP(string $value)
20
+ * @method string getPartnerID()
21
+ * @method Eway_Rapid31_Model_Request_Abstract setPartnerID(string $value)
22
+ * @method string getTransactionType()
23
+ * @method Eway_Rapid31_Model_Request_Abstract setTransactionType(string $value)
24
+ * @method string getMethod()
25
+ * @method Eway_Rapid31_Model_Request_Abstract setMethod(string $value)
26
+ * @method int getTransactionId()
27
+ * @method Eway_Rapid31_Model_Request_Abstract setTransactionId(int $value)
28
+ * @method Eway_Rapid31_Model_Field_Payment getRefund()
29
+ * @method Eway_Rapid31_Model_Request_Abstract setRefund(Eway_Rapid31_Model_Field_Payment $value)
30
+ * @method string getRedirectUrl()
31
+ * @method Eway_Rapid31_Model_Request_Abstract setRedirectUrl(string $value)
32
+ * @method string getCheckoutPayment()
33
+ * @method Eway_Rapid31_Model_Request_Abstract setCheckoutPayment(bool $value)
34
+ * @method string getCheckoutURL()
35
+ * @method Eway_Rapid31_Model_Request_Abstract setCheckoutURL(string $value)
36
+ * @method string getCancelUrl()
37
+ * @method Eway_Rapid31_Model_Request_Abstract setCancelUrl(string $value)
38
+ * @method Eway_Rapid31_Model_Request_Abstract setCustomerReadOnly(bool $value)
39
+ */
40
+ abstract class Eway_Rapid31_Model_Request_Abstract extends Eway_Rapid31_Model_JsonSerializableAbstract
41
+ {
42
+ const DEBUG_FILE = 'ewayrapid31_api_request.log';
43
+
44
+ /**
45
+ * @var Eway_Rapid31_Model_Config
46
+ */
47
+ protected $_config = null;
48
+
49
+ protected function _construct()
50
+ {
51
+ $this->_config = Mage::getSingleton('ewayrapid/config');
52
+ }
53
+
54
+ /**
55
+ * Do the main API request.
56
+ * All API request to eWAY should call this function with appropriate parameters, after set all necessary data.
57
+ *
58
+ * @param string $action can be one of POST, GET, DELETE or PUT
59
+ * @param string $method
60
+ * @return Eway_Rapid31_Model_Response
61
+ */
62
+ protected function _doRapidAPI($action, $method = 'POST') {
63
+
64
+ $url = $this->_config->getRapidAPIUrl($action);
65
+ $mode = $this->_config->isSandbox() ? '(Sandbox)' : '(Live)';
66
+ $this->_log('>>>>> START REQUEST ' . $mode . ' (' . $method . ') ' . ' : ' . $url);
67
+
68
+ $ch = curl_init($url);
69
+ curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));
70
+ curl_setopt($ch, CURLOPT_USERPWD, $this->_config->getBasicAuthenticationHeader());
71
+ switch($method) {
72
+ case 'POST':
73
+ curl_setopt($ch, CURLOPT_POST, true);
74
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $this->jsonSerialize());
75
+ $this->_logPostJSON();
76
+ break;
77
+ case 'GET':
78
+ case 'DELETE':
79
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
80
+ break;
81
+ case 'PUT':
82
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
83
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $this->jsonSerialize());
84
+ $this->_logPostJSON();
85
+ break;
86
+ }
87
+
88
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
89
+ curl_setopt($ch, CURLOPT_TIMEOUT, 60);
90
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->_config->isEnableSSLVerification());
91
+
92
+ $result = curl_exec($ch);
93
+
94
+ $this->_log('<<<<< RESPONSE:');
95
+ $response = Mage::getModel('ewayrapid/response');
96
+ if (curl_errno($ch) != CURLE_OK) {
97
+ $response->isSuccess(false);
98
+ $response->setMessage(Mage::helper('ewayrapid')->__("There is an error in making API request: %s", curl_error($ch)));
99
+ $this->_log("There is an error in making API request: " . curl_error($ch));
100
+ } else {
101
+ $info = curl_getinfo($ch);
102
+ $http_code = intval(trim($info['http_code']));
103
+ if ($http_code == 401 || $http_code == 404 || $http_code == 403) {
104
+ $response->isSuccess(false);
105
+ $response->setMessage(Mage::helper('ewayrapid')->__("Please check the API Key and Password %s", $mode));
106
+ $this->_log('Access denied. HTTP_CODE = ' . $info['http_code']);
107
+ } elseif ($http_code != 200) {
108
+ $response->isSuccess(false);
109
+ $response->setMessage(Mage::helper('ewayrapid')->__("Error connecting to payment gateway, please try again"));
110
+ $this->_log('Error connecting to payment gateway. HTTP_CODE = ' . $info['http_code']);
111
+ } else {
112
+ $response->isSuccess(true);
113
+ $response->decodeJSON($result);
114
+ if($this->_config->isDebug()) {
115
+ $this->_log('SUCCESS. Response body: ');
116
+ $this->_log(print_r(json_decode($result, true), true));
117
+ }
118
+ $this->_log('SUCCESS. HTTP_CODE = ' . $info['http_code']);
119
+ }
120
+ curl_close($ch);
121
+ }
122
+
123
+ $this->_log('===== END REQUEST.');
124
+ return $response;
125
+ }
126
+
127
+ protected function _logPostJSON()
128
+ {
129
+ if($this->_config->isDebug()) {
130
+ $cardDetails = null;
131
+ if($this->getCustomer() && $this->getCustomer()->getCardDetails()) {
132
+ $cardDetails = $this->getCustomer()->getCardDetails();
133
+ $cardDetails->shouldBeMasked();
134
+ }
135
+ $this->_log('Request body:');
136
+ $this->_log(print_r($this->getJsonData(), true));
137
+ if(!is_null($cardDetails)) {
138
+ $cardDetails->shouldBeMasked(false);
139
+ }
140
+ }
141
+ }
142
+
143
+ protected function _log($message, $file = self::DEBUG_FILE)
144
+ {
145
+ if($this->_config->isDebug()) {
146
+ Mage::log($message, Zend_Log::DEBUG, $file, true);
147
+ }
148
+ }
149
+
150
+ protected function _fixTitle($title) {
151
+ if ($title == 'n/a' || empty($title)) {
152
+ return 'Mr.';
153
+ }
154
+ return $title;
155
+ }
156
  }
app/code/community/Eway/Rapid31/Model/Request/Direct.php CHANGED
@@ -1,269 +1,271 @@
1
- <?php
2
- class Eway_Rapid31_Model_Request_Direct extends Eway_Rapid31_Model_Request_Abstract
3
- {
4
- /**
5
- * Call Transaction API (Authorized & Capture at the same time)
6
- *
7
- * @param Mage_Sales_Model_Order_Payment $payment
8
- * @param float $amount
9
- * @return Eway_Rapid31_Model_Request_Direct $this
10
- */
11
- public function doTransaction(Mage_Sales_Model_Order_Payment $payment, $amount)
12
- {
13
- $this->_buildRequest($payment, $amount);
14
- $this->setMethod(Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT);
15
- $response = $this->_doRapidAPI('Transaction');
16
-
17
- if($response->isSuccess()) {
18
- $payment->setTransactionId($response->getTransactionID());
19
- $payment->setCcLast4($response->getCcLast4());
20
- return $this;
21
- } else {
22
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. Please try again. (Error message: %s)',
23
- $response->getMessage()));
24
- }
25
- }
26
-
27
- /**
28
- * Call Authorisation API (Authorized only)
29
- *
30
- * @param Mage_Sales_Model_Order_Payment $payment
31
- * @param $amount
32
- * @return Eway_Rapid31_Model_Request_Direct
33
- */
34
- public function doAuthorisation(Mage_Sales_Model_Order_Payment $payment, $amount)
35
- {
36
- $this->_buildRequest($payment, $amount);
37
- $this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
38
- $response = $this->_doRapidAPI('Authorisation');
39
-
40
- if($response->isSuccess()) {
41
- $payment->setTransactionId($response->getTransactionID());
42
- $payment->setIsTransactionClosed(0);
43
- $payment->setCcLast4($response->getCcLast4());
44
- return $this;
45
- } else {
46
- if ($payment->getIsRecurring()) {
47
- Mage::getSingleton('core/session')->setData('errorMessage', $response->getMessage());
48
- }
49
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the authorisation. Please try again. (Error message: %s)',
50
- $response->getMessage()));
51
- }
52
- }
53
-
54
- /**
55
- * Call Capture API (do the Capture only, must Authorized previously)
56
- *
57
- * @param Mage_Sales_Model_Order_Payment $payment
58
- * @param $amount
59
- * @return Eway_Rapid31_Model_Request_Direct
60
- */
61
- public function doCapturePayment(Mage_Sales_Model_Order_Payment $payment, $amount)
62
- {
63
- // Empty Varien_Object's data
64
- $this->unsetData();
65
-
66
- /* @var Mage_Sales_Model_Order_Invoice $invoice */
67
- $invoice = Mage::registry('current_invoice');
68
- $order = $payment->getOrder();
69
-
70
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
71
- $paymentParam->setTotalAmount($amount)
72
- ->setCurrencyCode($order->getBaseCurrencyCode());
73
- if($invoice && $invoice->getIncrementId()) {
74
- $paymentParam->setInvoiceNumber($invoice->getIncrementId())
75
- ->setInvoiceReference($invoice->getIncrementId())
76
- ->setInvoiceDescription(Mage::helper('ewayrapid')->__('Invoice created from Magento'));
77
- }
78
- $this->setPayment($paymentParam);
79
- $this->setTransactionId($payment->getLastTransId());
80
-
81
- $response = $this->_doRapidAPI('CapturePayment');
82
-
83
- if($response->isSuccess()) {
84
- $payment->setTransactionId($response->getTransactionID());
85
- return $this;
86
- } else {
87
- if ($payment->getIsRecurring()) {
88
- Mage::getSingleton('core/session')->setData('errorMessage', $response->getMessage());
89
- }
90
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the capture. Please try again. (Error message: %s)',
91
- $response->getMessage()));
92
- }
93
- }
94
-
95
- /**
96
- * Call Refund API, must complete the transaction (Authorized & Capture) beforehand
97
- *
98
- * @param Mage_Sales_Model_Order_Payment $payment
99
- * @param $amount
100
- * @return Eway_Rapid31_Model_Request_Direct
101
- */
102
- public function doRefund(Mage_Sales_Model_Order_Payment $payment, $amount)
103
- {
104
- // Empty Varien_Object's data
105
- $this->unsetData();
106
-
107
- $order = $payment->getOrder();
108
- /* @var Mage_Sales_Model_Order_Creditmemo $creditMemo */
109
- $creditMemo = Mage::registry('current_creditmemo');
110
-
111
- $invoice = ($creditMemo ? $creditMemo->getInvoice() : null);
112
- /* @var Mage_Sales_Model_Order_Invoice $invoice */
113
- if(!$invoice || !$invoice->getTransactionId()) {
114
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the online refund: Invoice or transaction does not exist.'));
115
- }
116
-
117
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
118
- $paymentParam->setTotalAmount($amount)
119
- ->setCurrencyCode($order->getBaseCurrencyCode())
120
- ->setTransactionID($invoice->getTransactionId());
121
- if($creditMemo && $creditMemo->getIncrementId()) {
122
- $paymentParam->setInvoiceDescription("Creditmemo ID " . $creditMemo->getIncrementId());
123
- }
124
-
125
- if($invoice && $invoice->getIncrementId()) {
126
- $paymentParam->setInvoiceNumber($invoice->getIncrementId())
127
- ->setInvoiceReference($invoice->getIncrementId());
128
- }
129
- $this->setRefund($paymentParam);
130
-
131
- $response = $this->_doRapidAPI('Transaction/' . $invoice->getTransactionId() . '/Refund');
132
-
133
- if($response->isSuccess()) {
134
- $payment->setTransactionId($response->getTransactionID());
135
- return $this;
136
- } else {
137
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the refund. Please try again. (Error message: %s)',
138
- $response->getMessage()));
139
- }
140
- }
141
-
142
- /**
143
- * Call Cancel API, the transaction must be Authorized beforehand
144
- *
145
- * @param Mage_Sales_Model_Order_Payment $payment
146
- * @return Eway_Rapid31_Model_Request_Direct
147
- */
148
- public function doCancel(Mage_Sales_Model_Order_Payment $payment)
149
- {
150
- // Empty Varien_Object's data
151
- $this->unsetData();
152
-
153
- $transactionId = $payment->getLastTransId();
154
- $this->setTransactionId($transactionId);
155
- $response = $this->_doRapidAPI('CancelAuthorisation');
156
-
157
- if($response->isSuccess()) {
158
- $payment->setTransactionId($response->getTransactionID());
159
- $payment->setIsTransactionClosed(1);
160
- return $this;
161
- } else {
162
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the cancel. Please try again. (Error message: %s)',
163
- $response->getMessage()));
164
- }
165
-
166
- }
167
-
168
- /**
169
- * Build the request with necessary parameters for doAuthorisation() and doTransaction()
170
- *
171
- * @param Mage_Sales_Model_Order_Payment $payment
172
- * @param $amount
173
- * @return Eway_Rapid31_Model_Request_Direct
174
- */
175
- protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
176
- {
177
- // Empty Varien_Object's data
178
- $this->unsetData();
179
- $methodInstance = $payment->getMethodInstance();
180
- $infoInstance = $methodInstance->getInfoInstance();
181
- $order = $payment->getOrder();
182
- $billing = $order->getBillingAddress();
183
- $shipping = $order->getShippingAddress();
184
-
185
- // if item is virtual product
186
- if (!$shipping) {
187
- $quote = Mage::getModel('checkout/cart')->getQuote();
188
- if ($quote->isVirtual()) {
189
- $shipping = $quote->getBillingAddress();
190
- }
191
- }
192
-
193
- $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
194
- if(Mage::helper('ewayrapid')->isBackendOrder()) {
195
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
196
- } else {
197
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
198
- }
199
- $version = Mage::helper('ewayrapid')->getExtensionVersion();
200
- $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY Official '.$version);
201
- $this->setShippingMethod('Other');
202
-
203
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
204
- $paymentParam->setTotalAmount($amount)
205
- ->setCurrencyCode($order->getBaseCurrencyCode());
206
- $this->setPayment($paymentParam);
207
-
208
- $customerParam = Mage::getModel('ewayrapid/field_customer');
209
- $customerParam->setTitle($billing->getPrefix())
210
- ->setFirstName($billing->getFirstname())
211
- ->setLastName($billing->getLastname())
212
- ->setCompanyName($billing->getCompany())
213
- ->setJobDescription('')
214
- ->setStreet1($billing->getStreet1())
215
- ->setStreet2($billing->getStreet2())
216
- ->setCity($billing->getCity())
217
- ->setState($billing->getRegion())
218
- ->setPostalCode($billing->getPostcode())
219
- ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
220
- ->setEmail($billing->getEmail())
221
- ->setPhone($billing->getTelephone())
222
- ->setMobile('')
223
- ->setComments('')
224
- ->setFax($billing->getFax())
225
- ->setUrl('');
226
- $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
227
- $cardDetails->setName($infoInstance->getCcOwner())
228
- ->setNumber($infoInstance->getCcNumber())
229
- ->setExpiryMonth($infoInstance->getCcExpMonth())
230
- ->setExpiryYear($infoInstance->getCcExpYear())
231
- ->setCVN($infoInstance->getCcCid());
232
-
233
- $customerParam->setCardDetails($cardDetails);
234
- $this->setCustomer($customerParam);
235
-
236
- $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
237
- $shippingParam->setFirstName($shipping->getFirstname())
238
- ->setLastName($shipping->getLastname())
239
- ->setStreet1($shipping->getStreet1())
240
- ->setStreet2($shipping->getStreet2())
241
- ->setCity($shipping->getCity())
242
- ->setState($shipping->getRegion())
243
- ->setPostalCode($shipping->getPostcode())
244
- ->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))
245
- ->setEmail($shipping->getEmail())
246
- ->setPhone($shipping->getTelephone())
247
- ->setFax($shipping->getFax());
248
- $this->setShippingAddress($shippingParam);
249
-
250
- if($methodInstance->getConfigData('transfer_cart_items')) {
251
- $orderItems = $order->getAllVisibleItems();
252
- $lineItems = array();
253
- foreach($orderItems as $orderItem) {
254
- /* @var Mage_Sales_Model_Order_Item $orderItem */
255
- $lineItem = Mage::getModel('ewayrapid/field_lineItem');
256
- $lineItem->setSKU($orderItem->getSku());
257
- $lineItem->setDescription(substr($orderItem->getName(), 0, 26));
258
- $lineItem->setQuantity($orderItem->getQtyOrdered());
259
- $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
260
- $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
261
- $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
262
- $lineItems[] = $lineItem;
263
- }
264
- $this->setItems($lineItems);
265
- }
266
-
267
- return $this;
268
- }
 
 
269
  }
1
+ <?php
2
+ class Eway_Rapid31_Model_Request_Direct extends Eway_Rapid31_Model_Request_Abstract
3
+ {
4
+ /**
5
+ * Call Transaction API (Authorized & Capture at the same time)
6
+ *
7
+ * @param Mage_Sales_Model_Order_Payment $payment
8
+ * @param float $amount
9
+ * @return Eway_Rapid31_Model_Request_Direct $this
10
+ */
11
+ public function doTransaction(Mage_Sales_Model_Order_Payment $payment, $amount)
12
+ {
13
+ $this->_buildRequest($payment, $amount);
14
+ $this->setMethod(Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT);
15
+ $response = $this->_doRapidAPI('Transaction');
16
+
17
+ if($response->isSuccess()) {
18
+ $payment->setTransactionId($response->getTransactionID());
19
+ $payment->setCcLast4($response->getCcLast4());
20
+ return $this;
21
+ } else {
22
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. Please try again. (Error message: %s)',
23
+ $response->getMessage()));
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Call Authorisation API (Authorized only)
29
+ *
30
+ * @param Mage_Sales_Model_Order_Payment $payment
31
+ * @param $amount
32
+ * @return Eway_Rapid31_Model_Request_Direct
33
+ */
34
+ public function doAuthorisation(Mage_Sales_Model_Order_Payment $payment, $amount)
35
+ {
36
+ $this->_buildRequest($payment, $amount);
37
+ $this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
38
+ $response = $this->_doRapidAPI('Authorisation');
39
+
40
+ if($response->isSuccess()) {
41
+ $payment->setTransactionId($response->getTransactionID());
42
+ $payment->setIsTransactionClosed(0);
43
+ $payment->setCcLast4($response->getCcLast4());
44
+ return $this;
45
+ } else {
46
+ if ($payment->getIsRecurring()) {
47
+ Mage::getSingleton('core/session')->setData('errorMessage', $response->getMessage());
48
+ }
49
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the authorisation. Please try again. (Error message: %s)',
50
+ $response->getMessage()));
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Call Capture API (do the Capture only, must Authorized previously)
56
+ *
57
+ * @param Mage_Sales_Model_Order_Payment $payment
58
+ * @param $amount
59
+ * @return Eway_Rapid31_Model_Request_Direct
60
+ */
61
+ public function doCapturePayment(Mage_Sales_Model_Order_Payment $payment, $amount)
62
+ {
63
+ // Empty Varien_Object's data
64
+ $this->unsetData();
65
+
66
+ /* @var Mage_Sales_Model_Order_Invoice $invoice */
67
+ $invoice = Mage::registry('current_invoice');
68
+ $order = $payment->getOrder();
69
+
70
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
71
+ $paymentParam->setTotalAmount($amount)
72
+ ->setCurrencyCode($order->getBaseCurrencyCode());
73
+ if($invoice && $invoice->getIncrementId()) {
74
+ $paymentParam->setInvoiceNumber($invoice->getIncrementId())
75
+ ->setInvoiceReference($invoice->getIncrementId())
76
+ ->setInvoiceDescription(Mage::helper('ewayrapid')->__('Invoice created from Magento'));
77
+ }
78
+ $this->setPayment($paymentParam);
79
+ $this->setTransactionId($payment->getLastTransId());
80
+
81
+ $response = $this->_doRapidAPI('CapturePayment');
82
+
83
+ if($response->isSuccess()) {
84
+ $payment->setTransactionId($response->getTransactionID());
85
+ return $this;
86
+ } else {
87
+ if ($payment->getIsRecurring()) {
88
+ Mage::getSingleton('core/session')->setData('errorMessage', $response->getMessage());
89
+ }
90
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the capture. Please try again. (Error message: %s)',
91
+ $response->getMessage()));
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Call Refund API, must complete the transaction (Authorized & Capture) beforehand
97
+ *
98
+ * @param Mage_Sales_Model_Order_Payment $payment
99
+ * @param $amount
100
+ * @return Eway_Rapid31_Model_Request_Direct
101
+ */
102
+ public function doRefund(Mage_Sales_Model_Order_Payment $payment, $amount)
103
+ {
104
+ // Empty Varien_Object's data
105
+ $this->unsetData();
106
+
107
+ $order = $payment->getOrder();
108
+ /* @var Mage_Sales_Model_Order_Creditmemo $creditMemo */
109
+ $creditMemo = Mage::registry('current_creditmemo');
110
+
111
+ $invoice = ($creditMemo ? $creditMemo->getInvoice() : null);
112
+ /* @var Mage_Sales_Model_Order_Invoice $invoice */
113
+ if(!$invoice || !$invoice->getTransactionId()) {
114
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the online refund: Invoice or transaction does not exist.'));
115
+ }
116
+
117
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
118
+ $paymentParam->setTotalAmount($amount)
119
+ ->setCurrencyCode($order->getBaseCurrencyCode())
120
+ ->setTransactionID($invoice->getTransactionId());
121
+ if($creditMemo && $creditMemo->getIncrementId()) {
122
+ $paymentParam->setInvoiceDescription("Creditmemo ID " . $creditMemo->getIncrementId());
123
+ }
124
+
125
+ if($invoice && $invoice->getIncrementId()) {
126
+ $paymentParam->setInvoiceNumber($invoice->getIncrementId())
127
+ ->setInvoiceReference($invoice->getIncrementId());
128
+ }
129
+ $this->setRefund($paymentParam);
130
+
131
+ $response = $this->_doRapidAPI('Transaction/' . $invoice->getTransactionId() . '/Refund');
132
+
133
+ if($response->isSuccess()) {
134
+ $payment->setTransactionId($response->getTransactionID());
135
+ return $this;
136
+ } else {
137
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the refund. Please try again. (Error message: %s)',
138
+ $response->getMessage()));
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Call Cancel API, the transaction must be Authorized beforehand
144
+ *
145
+ * @param Mage_Sales_Model_Order_Payment $payment
146
+ * @return Eway_Rapid31_Model_Request_Direct
147
+ */
148
+ public function doCancel(Mage_Sales_Model_Order_Payment $payment)
149
+ {
150
+ // Empty Varien_Object's data
151
+ $this->unsetData();
152
+
153
+ $transactionId = $payment->getLastTransId();
154
+ $this->setTransactionId($transactionId);
155
+ $response = $this->_doRapidAPI('CancelAuthorisation');
156
+
157
+ if($response->isSuccess()) {
158
+ $payment->setTransactionId($response->getTransactionID());
159
+ $payment->setIsTransactionClosed(1);
160
+ return $this;
161
+ } else {
162
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the cancel. Please try again. (Error message: %s)',
163
+ $response->getMessage()));
164
+ }
165
+
166
+ }
167
+
168
+ /**
169
+ * Build the request with necessary parameters for doAuthorisation() and doTransaction()
170
+ *
171
+ * @param Mage_Sales_Model_Order_Payment $payment
172
+ * @param $amount
173
+ * @return Eway_Rapid31_Model_Request_Direct
174
+ */
175
+ protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
176
+ {
177
+ // Empty Varien_Object's data
178
+ $this->unsetData();
179
+ $methodInstance = $payment->getMethodInstance();
180
+ $infoInstance = $methodInstance->getInfoInstance();
181
+ $order = $payment->getOrder();
182
+ $billing = $order->getBillingAddress();
183
+ $shipping = $order->getShippingAddress();
184
+
185
+ // if item is virtual product
186
+ if (!$shipping) {
187
+ $quote = Mage::getModel('checkout/cart')->getQuote();
188
+ if ($quote->isVirtual()) {
189
+ $shipping = $quote->getBillingAddress();
190
+ }
191
+ }
192
+
193
+ $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
194
+ if(Mage::helper('ewayrapid')->isBackendOrder()) {
195
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
196
+ } else {
197
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
198
+ }
199
+ $version = Mage::helper('ewayrapid')->getExtensionVersion();
200
+ $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
201
+ $this->setShippingMethod('Other');
202
+
203
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
204
+ $paymentParam->setTotalAmount($amount)
205
+ ->setCurrencyCode($order->getBaseCurrencyCode());
206
+ $this->setPayment($paymentParam);
207
+
208
+ $title = $this->_fixTitle($billing->getPrefix());
209
+
210
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
211
+ $customerParam->setTitle($title)
212
+ ->setFirstName($billing->getFirstname())
213
+ ->setLastName($billing->getLastname())
214
+ ->setCompanyName($billing->getCompany())
215
+ ->setJobDescription('')
216
+ ->setStreet1($billing->getStreet1())
217
+ ->setStreet2($billing->getStreet2())
218
+ ->setCity($billing->getCity())
219
+ ->setState($billing->getRegion())
220
+ ->setPostalCode($billing->getPostcode())
221
+ ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
222
+ ->setEmail($billing->getEmail())
223
+ ->setPhone($billing->getTelephone())
224
+ ->setMobile('')
225
+ ->setComments('')
226
+ ->setFax($billing->getFax())
227
+ ->setUrl('');
228
+ $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
229
+ $cardDetails->setName($infoInstance->getCcOwner())
230
+ ->setNumber($infoInstance->getCcNumber())
231
+ ->setExpiryMonth($infoInstance->getCcExpMonth())
232
+ ->setExpiryYear($infoInstance->getCcExpYear())
233
+ ->setCVN($infoInstance->getCcCid());
234
+
235
+ $customerParam->setCardDetails($cardDetails);
236
+ $this->setCustomer($customerParam);
237
+
238
+ $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
239
+ $shippingParam->setFirstName($shipping->getFirstname())
240
+ ->setLastName($shipping->getLastname())
241
+ ->setStreet1($shipping->getStreet1())
242
+ ->setStreet2($shipping->getStreet2())
243
+ ->setCity($shipping->getCity())
244
+ ->setState($shipping->getRegion())
245
+ ->setPostalCode($shipping->getPostcode())
246
+ ->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))
247
+ ->setEmail($shipping->getEmail())
248
+ ->setPhone($shipping->getTelephone())
249
+ ->setFax($shipping->getFax());
250
+ $this->setShippingAddress($shippingParam);
251
+
252
+ if($methodInstance->getConfigData('transfer_cart_items')) {
253
+ $orderItems = $order->getAllVisibleItems();
254
+ $lineItems = array();
255
+ foreach($orderItems as $orderItem) {
256
+ /* @var Mage_Sales_Model_Order_Item $orderItem */
257
+ $lineItem = Mage::getModel('ewayrapid/field_lineItem');
258
+ $lineItem->setSKU($orderItem->getSku());
259
+ $lineItem->setDescription(substr($orderItem->getName(), 0, 26));
260
+ $lineItem->setQuantity($orderItem->getQtyOrdered());
261
+ $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
262
+ $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
263
+ $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
264
+ $lineItems[] = $lineItem;
265
+ }
266
+ $this->setItems($lineItems);
267
+ }
268
+
269
+ return $this;
270
+ }
271
  }
app/code/community/Eway/Rapid31/Model/Request/Sharedpage.php CHANGED
@@ -1,530 +1,533 @@
1
- <?php
2
-
3
- class Eway_Rapid31_Model_Request_Sharedpage extends Eway_Rapid31_Model_Request_Abstract
4
- {
5
- /**
6
- * @var Mage_Sales_Model_Quote
7
- */
8
- protected $_quote = null;
9
-
10
- /**
11
- * @var Mage_Customer_Model_Session
12
- */
13
- protected $_customerSession;
14
-
15
- public function __construct($params = array())
16
- {
17
- if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
18
- $this->_quote = $params['quote'];
19
- } else {
20
- throw new Exception('Quote instance is required.');
21
- }
22
-
23
- $this->_config = Mage::getSingleton('ewayrapid/config');
24
- $this->_customerSession = Mage::getSingleton('customer/session');
25
- }
26
-
27
- /**
28
- * create AccessCode for process checkout
29
- *
30
- * @param null $returnUrl
31
- * @param null $cancelUrl
32
- * @return Eway_Rapid31_Model_Response
33
- */
34
- public function createAccessCode($returnUrl = null, $cancelUrl = null)
35
- {
36
- // Empty Varien_Object's data
37
- $this->unsetData();
38
- $token = null;
39
- $paypal = null;
40
- $totalAmount = 0;
41
-
42
- if ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD) {
43
- if ($this->_isNewToken()) {
44
- $returnUrl .= '?newToken=1';
45
- $method = Eway_Rapid31_Model_Config::METHOD_CREATE_TOKEN;
46
- } elseif ($token = $this->_editToken()) {
47
- $returnUrl .= '?editToken=' . $token;
48
- $token = Mage::helper('ewayrapid/customer')->getCustomerTokenId($token);
49
- $method = Eway_Rapid31_Model_Config::METHOD_UPDATE_TOKEN;
50
- }
51
- } else {
52
- if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
53
- $method = Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT;
54
- } else {
55
- $method = Eway_Rapid31_Model_Config::METHOD_AUTHORISE;
56
- }
57
- $totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
58
- $paypal = $this->_getPaypalCheckout();
59
- if ($paypal === Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
60
- $this->setCheckoutPayment(true);
61
- $this->setCheckoutURL(Mage::getUrl('ewayrapid/sharedpage/review'));
62
- }
63
- }
64
-
65
- $this->_buildRequest();
66
-
67
- $customer = $this->getCustomer();
68
- $customer->setTokenCustomerID($token ? $token : '');
69
- $this->setCustomer($customer);
70
-
71
- // prepare API
72
- $this->setRedirectUrl($returnUrl);
73
- $this->setCancelUrl($cancelUrl);
74
- $this->setMethod($method);
75
-
76
- if (Mage::helper('ewayrapid')->getTransferCartLineItems()) {
77
- // add Shipping item and Line items
78
- $lineItems = Mage::helper('ewayrapid')->getLineItems();
79
- $this->setItems($lineItems);
80
- }
81
-
82
- // add Payment
83
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
84
- $paymentParam->setTotalAmount($totalAmount);
85
- $paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
86
- $this->setPayment($paymentParam);
87
-
88
- $response = $this->_doRapidAPI('AccessCodesShared');
89
- return $response;
90
- }
91
-
92
- /**
93
- * Call Authorisation API (Authorized only)
94
- *
95
- * @param Eway_Rapid31_Model_Response $response
96
- * @return Eway_Rapid31_Model_Response
97
- */
98
- public function doAuthorisation(Eway_Rapid31_Model_Response $response)
99
- {
100
- $this->unsetData();
101
-
102
- $this->_buildRequest();
103
-
104
- $cardData = $response->getCustomer();
105
- if ($cardData['CardNumber'] && $cardData['CardName']) {
106
- $this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
107
- } else {
108
- $this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
109
- }
110
-
111
- $items = $this->_quote->getAllVisibleItems();
112
- $lineItems = array();
113
- foreach ($items as $item) {
114
- /* @var Mage_Sales_Model_Order_Item $item */
115
- $lineItem = Mage::getModel('ewayrapid/field_lineItem');
116
- $lineItem->setSKU($item->getSku());
117
- $lineItem->setDescription(substr($item->getName(), 0, 26));
118
- $lineItem->setQuantity($item->getQty());
119
- $lineItem->setUnitCost(round($item->getBasePrice() * 100));
120
- $lineItem->setTax(round($item->getBaseTaxAmount() * 100));
121
- $lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
122
- $lineItems[] = $lineItem;
123
- }
124
- $this->setItems($lineItems);
125
-
126
- $this->setItems(false);
127
-
128
- // add Payment
129
- $amount = round($this->_quote->getBaseGrandTotal() * 100);
130
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
131
- $paymentParam->setTotalAmount($amount);
132
- $paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
133
- $this->setPayment($paymentParam);
134
-
135
- $customerParam = $this->getCustomer();
136
- $customerParam->setTokenCustomerID($response->getTokenCustomerID());
137
- $this->setCustomer($customerParam);
138
-
139
- $response = $this->_doRapidAPI('Authorisation');
140
- return $response;
141
- }
142
-
143
- /**
144
- * Call Transaction API (Authorized & Capture at the same time)
145
- *
146
- * @param Eway_Rapid31_Model_Response $response
147
- * @return Eway_Rapid31_Model_Response
148
- */
149
- public function doTransaction(Eway_Rapid31_Model_Response $response)
150
- {
151
- $this->unsetData();
152
-
153
- $this->_buildRequest();
154
-
155
- $this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
156
-
157
- $items = $this->_quote->getAllVisibleItems();
158
- $lineItems = array();
159
- foreach ($items as $item) {
160
- /* @var Mage_Sales_Model_Order_Item $item */
161
- $lineItem = Mage::getModel('ewayrapid/field_lineItem');
162
- $lineItem->setSKU($item->getSku());
163
- $lineItem->setDescription(substr($item->getName(), 0, 26));
164
- $lineItem->setQuantity($item->getQty());
165
- $lineItem->setUnitCost(round($item->getBasePrice() * 100));
166
- $lineItem->setTax(round($item->getBaseTaxAmount() * 100));
167
- $lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
168
- $lineItems[] = $lineItem;
169
- }
170
- $this->setItems($lineItems);
171
-
172
- $this->setItems(false);
173
-
174
- // add Payment
175
- $amount = round($this->_quote->getBaseGrandTotal() * 100);
176
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
177
- $paymentParam->setTotalAmount($amount);
178
- $paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
179
- $this->setPayment($paymentParam);
180
-
181
- $customerParam = $this->getCustomer();
182
- $customerParam->setTokenCustomerID($response->getTokenCustomerID());
183
-
184
- $this->setCustomer($customerParam);
185
-
186
- $response = $this->_doRapidAPI('Transaction');
187
- return $response;
188
- }
189
-
190
- /**
191
- * Call Capture API (do the Capture only, must Authorized previously)
192
- *
193
- * @param Eway_Rapid31_Model_Response $response
194
- * @return Eway_Rapid31_Model_Response
195
- */
196
- public function doCapturePayment(Eway_Rapid31_Model_Response $response)
197
- {
198
- $this->setTransactionId($response->getTransactionID());
199
- $this->setMethod(Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT);
200
-
201
- $response = $this->_doRapidAPI('CapturePayment');
202
- return $response;
203
- }
204
-
205
- /**
206
- * Build the request with necessary parameters for doAuthorisation(), doTransaction() and CreateAccessCode()
207
- *
208
- * @return $this
209
- */
210
- protected function _buildRequest()
211
- {
212
- // prepare API
213
- $this->setShippingMethod('Other');
214
- $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
215
- $version = Mage::helper('ewayrapid')->getExtensionVersion();
216
- $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY Official '.$version);
217
- if (Mage::helper('ewayrapid')->isBackendOrder()) {
218
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
219
- } else {
220
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
221
- }
222
- $this->setCustomerReadOnly(true);
223
-
224
- // add Billing Address
225
- $billingAddress = $this->_quote->getBillingAddress();
226
- $customerParam = Mage::getModel('ewayrapid/field_customer');
227
- $customerParam->setTitle($billingAddress->getPrefix() ? $billingAddress->getPrefix() : 'Mr')
228
- ->setFirstName($billingAddress->getFirstname())
229
- ->setLastName($billingAddress->getLastname())
230
- ->setCompanyName($billingAddress->getCompany())
231
- ->setJobDescription($billingAddress->getJobDescription())
232
- ->setStreet1($billingAddress->getStreet1())
233
- ->setStreet2($billingAddress->getStreet2())
234
- ->setCity($billingAddress->getCity())
235
- ->setState($billingAddress->getRegion())
236
- ->setPostalCode($billingAddress->getPostcode())
237
- ->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
238
- ->setEmail($billingAddress->getEmail())
239
- ->setPhone($billingAddress->getTelephone())
240
- ->setMobile($billingAddress->getMobile())
241
- ->setComments('')
242
- ->setFax($billingAddress->getFax())
243
- ->setUrl('');
244
- $this->setCustomer($customerParam);
245
-
246
- // add Shipping Address
247
- $shippingAddress = $this->_quote->getShippingAddress();
248
-
249
- // copy BillingAddress to ShippingAddress if checkout with guest or register
250
- $checkoutMethod = $this->_quote->getCheckoutMethod();
251
- if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
252
- || $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
253
- ) {
254
- $shippingAddress = $billingAddress;
255
- }
256
-
257
- $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
258
- $shippingParam->setFirstName($shippingAddress->getFirstname())
259
- ->setLastName($shippingAddress->getLastname())
260
- ->setStreet1($shippingAddress->getStreet1())
261
- ->setStreet2($shippingAddress->getStreet2())
262
- ->setCity($shippingAddress->getCity())
263
- ->setState($shippingAddress->getRegion())
264
- ->setPostalCode($shippingAddress->getPostcode())
265
- ->setCountry(strtolower($shippingAddress->getCountryModel()->getIso2Code()))
266
- ->setEmail($shippingAddress->getEmail())
267
- ->setPhone($shippingAddress->getTelephone())
268
- ->setFax($shippingAddress->getFax());
269
- $this->setShippingAddress($shippingParam);
270
-
271
- return $this;
272
- }
273
-
274
- /**
275
- * Get customer information by access code
276
- */
277
- public function getInfoByAccessCode($accessCode)
278
- {
279
- $response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
280
- return $response;
281
- }
282
-
283
- /**
284
- * Get customer session object
285
- *
286
- * @return Mage_Customer_Model_Session
287
- */
288
- public function getCustomerSession()
289
- {
290
- return $this->_customerSession;
291
- }
292
-
293
- /**
294
- * check is new token when checkout
295
- *
296
- * @return bool
297
- */
298
- protected function _isNewToken()
299
- {
300
- $info = $this->_quote->getPayment();
301
- Mage::helper('ewayrapid')->unserializeInfoInstace($info);
302
- if ($token = Mage::getSingleton('core/session')->getData('newToken')) {
303
- Mage::getSingleton('core/session')->unsetData('newToken');
304
- return true;
305
- }
306
- return false;
307
- }
308
-
309
- /**
310
- * get TokenCustomerID is selected of customer
311
- *
312
- * @return mixed
313
- */
314
- protected function _editToken()
315
- {
316
- if ($token = Mage::getSingleton('core/session')->getData('editToken')) {
317
- Mage::getSingleton('core/session')->unsetData('editToken');
318
- return $token;
319
- }
320
- return $token;
321
- }
322
-
323
- /**
324
- * check paypal option in eway not saved
325
- *
326
- * @return mixed|null
327
- */
328
- protected function _getPaypalCheckout()
329
- {
330
- if ($paypal = Mage::getSingleton('core/session')->getData('sharedpagePaypal')) {
331
- Mage::getModel('core/session')->unsetData('sharedpagePaypal');
332
- return $paypal;
333
- }
334
- return null;
335
- }
336
-
337
- /**
338
- * update customer when edit shipping address to paypal
339
- *
340
- * @param $accessCode
341
- */
342
- public function updateCustomer($accessCode)
343
- {
344
- $response = $this->_doRapidAPI('Transaction/' . $accessCode, 'GET');
345
- if ($response->isSuccess()) {
346
- $customer = $this->_quote->getCustomer();
347
- $billingAddress = $this->_quote->getBillingAddress();
348
- $shippingAddress = $this->_quote->getShippingAddress();
349
- $trans = $response->getTransactions();
350
-
351
- if (isset($trans[0]['Customer'])) {
352
- $billing = $trans[0]['Customer'];
353
- $billingAddress->setFirstname($billing['FirstName'])
354
- ->setLastName($billing['LastName'])
355
- ->setCompany($billing['CompanyName'])
356
- ->setJobDescription($billing['JobDescription'])
357
- ->setStreet($billing['Street1'])
358
- ->setStreet2($billing['Street2'])
359
- ->setCity($billing['City'])
360
- ->setState($billing['State'])
361
- ->setPostcode($billing['PostalCode'])
362
- ->setCountryId(strtoupper($billing['Country']))
363
- ->setEmail($billing['Email'])
364
- ->setTelephone($billing['Phone'])
365
- ->setMobile($billing['Mobile'])
366
- ->setComments($billing['Comments'])
367
- ->setFax($billing['Fax'])
368
- ->setUrl($billing['Url']);
369
- }
370
- if (isset($trans[0]['ShippingAddress'])) {
371
- $shipping = $trans[0]['ShippingAddress'];
372
- $shippingAddress->setFirstname($shipping['FirstName'])
373
- ->setLastname($shipping['LastName'])
374
- ->setStreet($shipping['Street1'])
375
- ->setStreet2($shipping['Street2'])
376
- ->setCity($shipping['City'])
377
- ->setPostcode($shipping['PostalCode'])
378
- ->setCountryId(strtoupper($shipping['Country']))
379
- ->setEmail($shipping['Email'])
380
- ->setFax($shipping['Fax']);
381
-
382
- if ($shipping['State']
383
- && $shipping['Country']
384
- && $region = Mage::getModel('directory/region')->loadByCode($shipping['State'], $shipping['Country'])
385
- ) {
386
- $shippingAddress->setRegion($region->getName())
387
- ->setRegionId($region->getId());
388
- }
389
- if ($shipping['Phone']) {
390
- $shippingAddress->setTelephone($shipping['Phone']);
391
- }
392
- }
393
- $this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress)->save();
394
- }
395
- }
396
-
397
- /**
398
- * save token when checkout with eway saved
399
- *
400
- * @param Eway_Rapid31_Model_Response $response
401
- * @param null $ccNumber
402
- */
403
- public function saveTokenById(Eway_Rapid31_Model_Response $response, $ccNumber = null)
404
- {
405
- $this->unsetData();
406
-
407
- $customerParam = Mage::getModel('ewayrapid/field_customer');
408
- $customerParam->setTokenCustomerID($response->getTokenCustomerID());
409
- $this->setCustomer($customerParam);
410
- $payment = Mage::getModel('ewayrapid/field_payment');
411
- $payment->setTotalAmount(1);
412
- $this->setPayment($payment);
413
- $this->setRedirectUrl(Mage::getBaseUrl() . '/ewayrapid/sharedpage/saveToken');
414
- $this->setMethod('');
415
-
416
- $response = $this->_doRapidAPI('AccessCodesShared');
417
- $token = true;
418
- if ($response->isSuccess()) {
419
- if (!$ccNumber) {
420
- $token = $this->_createNewToken($response);
421
- } else {
422
- $token = $this->_updateToken($response, $ccNumber);
423
- }
424
-
425
- } else {
426
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while creating new token. Please try again. (Error message: %s)',
427
- $response->getMessage()));
428
- }
429
- if (!$token) {
430
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while process token. Please try again.'));
431
- }
432
- return $response;
433
- }
434
-
435
- /**
436
- * Create new token when checkout
437
- *
438
- * @param Eway_Rapid31_Model_Response $response
439
- * @return $this
440
- */
441
- protected function _createNewToken(Eway_Rapid31_Model_Response $response)
442
- {
443
- try {
444
- $customer = $response->getCustomer();
445
-
446
- $tokenInfo = array(
447
- 'Token' => $response->getTokenCustomerID(),
448
- 'Card' => $customer['CardNumber'] ? substr_replace($customer['CardNumber'], '******', 6, 6) : 'Paypal',
449
- 'Owner' => $customer['CardName'],
450
- 'StartMonth' => $customer['CardStartMonth'],
451
- 'StartYear' => $customer['CardStartYear'],
452
- 'IssueNumber' => $customer['CardIssueNumber'],
453
- 'ExpMonth' => $customer['CardExpiryMonth'],
454
- 'ExpYear' => (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear']),
455
- 'Type' => $this->checkCardType($customer['CardNumber']),
456
- 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customer),
457
- );
458
-
459
- Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
460
- return true;
461
- } catch (Exception $e) {
462
- return false;
463
- }
464
- }
465
-
466
- /**
467
- * Update token when checkout with existing token
468
- *
469
- * @param Eway_Rapid31_Model_Response $response
470
- * @param null $ccNumber
471
- * @return $this
472
- */
473
- protected function _updateToken(Eway_Rapid31_Model_Response $response, $ccNumber = null)
474
- {
475
- try {
476
- $customer = $response->getCustomer();
477
-
478
- $tokenInfo = array(
479
- 'Token' => $response->getTokenCustomerID(),
480
- 'Card' => $customer['CardNumber'] ? substr_replace($customer['CardNumber'], '******', 6, 6) : 'Paypal',
481
- 'Owner' => $customer['CardName'],
482
- 'StartMonth' => $customer['CardStartMonth'],
483
- 'StartYear' => $customer['CardStartYear'],
484
- 'IssueNumber' => $customer['CardIssueNumber'],
485
- 'ExpMonth' => $customer['CardExpiryMonth'],
486
- 'ExpYear' => (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear']),
487
- 'Type' => $this->checkCardType($customer['CardNumber']),
488
- 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customer),
489
- );
490
-
491
- Mage::helper('ewayrapid/customer')->updateToken($ccNumber, $tokenInfo);
492
- return true;
493
- } catch (Exception $e) {
494
- return false;
495
- }
496
- }
497
-
498
- /**
499
- * Get card type name by card number
500
- * @param $num Card number
501
- * @return string Card type name
502
- */
503
- public function checkCardType($num)
504
- {
505
- if ($num == null) {
506
- return Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD;
507
- }
508
- return Mage::getModel('ewayrapid/request_token')->checkCardType($num);
509
- }
510
-
511
- public function getShippingByCode($postalCode)
512
- {
513
- $groups = $this->_quote->getShippingAddress()
514
- ->collectShippingRates()
515
- ->getGroupedAllShippingRates();
516
- // determine current selected code & name
517
- foreach ($groups as $code => $rates) {
518
- foreach ($rates as $rate) {
519
- if (strtoupper($postalCode) == strtoupper($rate->getCode())) {
520
- return $rate;
521
- }
522
- }
523
- }
524
- return false;
525
- }
526
- public function getMethod()
527
- {
528
- return Mage::getSingleton('core/session')->getData('ewayMethod');
529
- }
 
 
 
530
  }
1
+ <?php
2
+
3
+ class Eway_Rapid31_Model_Request_Sharedpage extends Eway_Rapid31_Model_Request_Abstract
4
+ {
5
+ /**
6
+ * @var Mage_Sales_Model_Quote
7
+ */
8
+ protected $_quote = null;
9
+
10
+ /**
11
+ * @var Mage_Customer_Model_Session
12
+ */
13
+ protected $_customerSession;
14
+
15
+ public function __construct($params = array())
16
+ {
17
+ if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
18
+ $this->_quote = $params['quote'];
19
+ } else {
20
+ throw new Exception('Quote instance is required.');
21
+ }
22
+
23
+ $this->_config = Mage::getSingleton('ewayrapid/config');
24
+ $this->_customerSession = Mage::getSingleton('customer/session');
25
+ }
26
+
27
+ /**
28
+ * create AccessCode for process checkout
29
+ *
30
+ * @param null $returnUrl
31
+ * @param null $cancelUrl
32
+ * @return Eway_Rapid31_Model_Response
33
+ */
34
+ public function createAccessCode($returnUrl = null, $cancelUrl = null)
35
+ {
36
+ // Empty Varien_Object's data
37
+ $this->unsetData();
38
+ $token = null;
39
+ $paypal = null;
40
+ $totalAmount = 0;
41
+
42
+ if ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD) {
43
+ if ($this->_isNewToken()) {
44
+ $returnUrl .= '?newToken=1';
45
+ $method = Eway_Rapid31_Model_Config::METHOD_CREATE_TOKEN;
46
+ } elseif ($token = $this->_editToken()) {
47
+ $returnUrl .= '?editToken=' . $token;
48
+ $token = Mage::helper('ewayrapid/customer')->getCustomerTokenId($token);
49
+ $method = Eway_Rapid31_Model_Config::METHOD_UPDATE_TOKEN;
50
+ }
51
+ } else {
52
+ if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
53
+ $method = Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT;
54
+ } else {
55
+ $method = Eway_Rapid31_Model_Config::METHOD_AUTHORISE;
56
+ }
57
+ $totalAmount = round($this->_quote->getBaseGrandTotal() * 100);
58
+ $paypal = $this->_getPaypalCheckout();
59
+ if ($paypal === Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
60
+ $this->setCheckoutPayment(true);
61
+ $this->setCheckoutURL(Mage::getUrl('ewayrapid/sharedpage/review'));
62
+ }
63
+ }
64
+
65
+ $this->_buildRequest();
66
+
67
+ $customer = $this->getCustomer();
68
+ $customer->setTokenCustomerID($token ? $token : '');
69
+ $this->setCustomer($customer);
70
+
71
+ // prepare API
72
+ $this->setRedirectUrl($returnUrl);
73
+ $this->setCancelUrl($cancelUrl);
74
+ $this->setMethod($method);
75
+
76
+ if (Mage::helper('ewayrapid')->getTransferCartLineItems()) {
77
+ // add Shipping item and Line items
78
+ $lineItems = Mage::helper('ewayrapid')->getLineItems();
79
+ $this->setItems($lineItems);
80
+ }
81
+
82
+ // add Payment
83
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
84
+ $paymentParam->setTotalAmount($totalAmount);
85
+ $paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
86
+ $this->setPayment($paymentParam);
87
+
88
+ $response = $this->_doRapidAPI('AccessCodesShared');
89
+ return $response;
90
+ }
91
+
92
+ /**
93
+ * Call Authorisation API (Authorized only)
94
+ *
95
+ * @param Eway_Rapid31_Model_Response $response
96
+ * @return Eway_Rapid31_Model_Response
97
+ */
98
+ public function doAuthorisation(Eway_Rapid31_Model_Response $response)
99
+ {
100
+ $this->unsetData();
101
+
102
+ $this->_buildRequest();
103
+
104
+ $cardData = $response->getCustomer();
105
+ if ($cardData['CardNumber'] && $cardData['CardName']) {
106
+ $this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
107
+ } else {
108
+ $this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
109
+ }
110
+
111
+ $items = $this->_quote->getAllVisibleItems();
112
+ $lineItems = array();
113
+ foreach ($items as $item) {
114
+ /* @var Mage_Sales_Model_Order_Item $item */
115
+ $lineItem = Mage::getModel('ewayrapid/field_lineItem');
116
+ $lineItem->setSKU($item->getSku());
117
+ $lineItem->setDescription(substr($item->getName(), 0, 26));
118
+ $lineItem->setQuantity($item->getQty());
119
+ $lineItem->setUnitCost(round($item->getBasePrice() * 100));
120
+ $lineItem->setTax(round($item->getBaseTaxAmount() * 100));
121
+ $lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
122
+ $lineItems[] = $lineItem;
123
+ }
124
+ $this->setItems($lineItems);
125
+
126
+ $this->setItems(false);
127
+
128
+ // add Payment
129
+ $amount = round($this->_quote->getBaseGrandTotal() * 100);
130
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
131
+ $paymentParam->setTotalAmount($amount);
132
+ $paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
133
+ $this->setPayment($paymentParam);
134
+
135
+ $customerParam = $this->getCustomer();
136
+ $customerParam->setTokenCustomerID($response->getTokenCustomerID());
137
+ $this->setCustomer($customerParam);
138
+
139
+ $response = $this->_doRapidAPI('Authorisation');
140
+ return $response;
141
+ }
142
+
143
+ /**
144
+ * Call Transaction API (Authorized & Capture at the same time)
145
+ *
146
+ * @param Eway_Rapid31_Model_Response $response
147
+ * @return Eway_Rapid31_Model_Response
148
+ */
149
+ public function doTransaction(Eway_Rapid31_Model_Response $response)
150
+ {
151
+ $this->unsetData();
152
+
153
+ $this->_buildRequest();
154
+
155
+ $this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
156
+
157
+ $items = $this->_quote->getAllVisibleItems();
158
+ $lineItems = array();
159
+ foreach ($items as $item) {
160
+ /* @var Mage_Sales_Model_Order_Item $item */
161
+ $lineItem = Mage::getModel('ewayrapid/field_lineItem');
162
+ $lineItem->setSKU($item->getSku());
163
+ $lineItem->setDescription(substr($item->getName(), 0, 26));
164
+ $lineItem->setQuantity($item->getQty());
165
+ $lineItem->setUnitCost(round($item->getBasePrice() * 100));
166
+ $lineItem->setTax(round($item->getBaseTaxAmount() * 100));
167
+ $lineItem->setTotal(round($item->getBaseRowTotalInclTax() * 100));
168
+ $lineItems[] = $lineItem;
169
+ }
170
+ $this->setItems($lineItems);
171
+
172
+ $this->setItems(false);
173
+
174
+ // add Payment
175
+ $amount = round($this->_quote->getBaseGrandTotal() * 100);
176
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
177
+ $paymentParam->setTotalAmount($amount);
178
+ $paymentParam->setCurrencyCode($this->_quote->getBaseCurrencyCode());
179
+ $this->setPayment($paymentParam);
180
+
181
+ $customerParam = $this->getCustomer();
182
+ $customerParam->setTokenCustomerID($response->getTokenCustomerID());
183
+
184
+ $this->setCustomer($customerParam);
185
+
186
+ $response = $this->_doRapidAPI('Transaction');
187
+ return $response;
188
+ }
189
+
190
+ /**
191
+ * Call Capture API (do the Capture only, must Authorized previously)
192
+ *
193
+ * @param Eway_Rapid31_Model_Response $response
194
+ * @return Eway_Rapid31_Model_Response
195
+ */
196
+ public function doCapturePayment(Eway_Rapid31_Model_Response $response)
197
+ {
198
+ $this->setTransactionId($response->getTransactionID());
199
+ $this->setMethod(Eway_Rapid31_Model_Config::METHOD_PROCESS_PAYMENT);
200
+
201
+ $response = $this->_doRapidAPI('CapturePayment');
202
+ return $response;
203
+ }
204
+
205
+ /**
206
+ * Build the request with necessary parameters for doAuthorisation(), doTransaction() and CreateAccessCode()
207
+ *
208
+ * @return $this
209
+ */
210
+ protected function _buildRequest()
211
+ {
212
+ // prepare API
213
+ $this->setShippingMethod('Other');
214
+ $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
215
+ $version = Mage::helper('ewayrapid')->getExtensionVersion();
216
+ $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
217
+ if (Mage::helper('ewayrapid')->isBackendOrder()) {
218
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
219
+ } else {
220
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
221
+ }
222
+ $this->setCustomerReadOnly(true);
223
+
224
+ // add Billing Address
225
+ $billingAddress = $this->_quote->getBillingAddress();
226
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
227
+
228
+ $title = $this->_fixTitle($billingAddress->getPrefix());
229
+
230
+ $customerParam->setTitle($title)
231
+ ->setFirstName($billingAddress->getFirstname())
232
+ ->setLastName($billingAddress->getLastname())
233
+ ->setCompanyName($billingAddress->getCompany())
234
+ ->setJobDescription($billingAddress->getJobDescription())
235
+ ->setStreet1($billingAddress->getStreet1())
236
+ ->setStreet2($billingAddress->getStreet2())
237
+ ->setCity($billingAddress->getCity())
238
+ ->setState($billingAddress->getRegion())
239
+ ->setPostalCode($billingAddress->getPostcode())
240
+ ->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
241
+ ->setEmail($billingAddress->getEmail())
242
+ ->setPhone($billingAddress->getTelephone())
243
+ ->setMobile($billingAddress->getMobile())
244
+ ->setComments('')
245
+ ->setFax($billingAddress->getFax())
246
+ ->setUrl('');
247
+ $this->setCustomer($customerParam);
248
+
249
+ // add Shipping Address
250
+ $shippingAddress = $this->_quote->getShippingAddress();
251
+
252
+ // copy BillingAddress to ShippingAddress if checkout with guest or register
253
+ $checkoutMethod = $this->_quote->getCheckoutMethod();
254
+ if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
255
+ || $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
256
+ ) {
257
+ $shippingAddress = $billingAddress;
258
+ }
259
+
260
+ $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
261
+ $shippingParam->setFirstName($shippingAddress->getFirstname())
262
+ ->setLastName($shippingAddress->getLastname())
263
+ ->setStreet1($shippingAddress->getStreet1())
264
+ ->setStreet2($shippingAddress->getStreet2())
265
+ ->setCity($shippingAddress->getCity())
266
+ ->setState($shippingAddress->getRegion())
267
+ ->setPostalCode($shippingAddress->getPostcode())
268
+ ->setCountry(strtolower($shippingAddress->getCountryModel()->getIso2Code()))
269
+ ->setEmail($shippingAddress->getEmail())
270
+ ->setPhone($shippingAddress->getTelephone())
271
+ ->setFax($shippingAddress->getFax());
272
+ $this->setShippingAddress($shippingParam);
273
+
274
+ return $this;
275
+ }
276
+
277
+ /**
278
+ * Get customer information by access code
279
+ */
280
+ public function getInfoByAccessCode($accessCode)
281
+ {
282
+ $response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
283
+ return $response;
284
+ }
285
+
286
+ /**
287
+ * Get customer session object
288
+ *
289
+ * @return Mage_Customer_Model_Session
290
+ */
291
+ public function getCustomerSession()
292
+ {
293
+ return $this->_customerSession;
294
+ }
295
+
296
+ /**
297
+ * check is new token when checkout
298
+ *
299
+ * @return bool
300
+ */
301
+ protected function _isNewToken()
302
+ {
303
+ $info = $this->_quote->getPayment();
304
+ Mage::helper('ewayrapid')->unserializeInfoInstace($info);
305
+ if ($token = Mage::getSingleton('core/session')->getData('newToken')) {
306
+ Mage::getSingleton('core/session')->unsetData('newToken');
307
+ return true;
308
+ }
309
+ return false;
310
+ }
311
+
312
+ /**
313
+ * get TokenCustomerID is selected of customer
314
+ *
315
+ * @return mixed
316
+ */
317
+ protected function _editToken()
318
+ {
319
+ if ($token = Mage::getSingleton('core/session')->getData('editToken')) {
320
+ Mage::getSingleton('core/session')->unsetData('editToken');
321
+ return $token;
322
+ }
323
+ return $token;
324
+ }
325
+
326
+ /**
327
+ * check paypal option in eway not saved
328
+ *
329
+ * @return mixed|null
330
+ */
331
+ protected function _getPaypalCheckout()
332
+ {
333
+ if ($paypal = Mage::getSingleton('core/session')->getData('sharedpagePaypal')) {
334
+ Mage::getModel('core/session')->unsetData('sharedpagePaypal');
335
+ return $paypal;
336
+ }
337
+ return null;
338
+ }
339
+
340
+ /**
341
+ * update customer when edit shipping address to paypal
342
+ *
343
+ * @param $accessCode
344
+ */
345
+ public function updateCustomer($accessCode)
346
+ {
347
+ $response = $this->_doRapidAPI('Transaction/' . $accessCode, 'GET');
348
+ if ($response->isSuccess()) {
349
+ $customer = $this->_quote->getCustomer();
350
+ $billingAddress = $this->_quote->getBillingAddress();
351
+ $shippingAddress = $this->_quote->getShippingAddress();
352
+ $trans = $response->getTransactions();
353
+
354
+ if (isset($trans[0]['Customer'])) {
355
+ $billing = $trans[0]['Customer'];
356
+ $billingAddress->setFirstname($billing['FirstName'])
357
+ ->setLastName($billing['LastName'])
358
+ ->setCompany($billing['CompanyName'])
359
+ ->setJobDescription($billing['JobDescription'])
360
+ ->setStreet($billing['Street1'])
361
+ ->setStreet2($billing['Street2'])
362
+ ->setCity($billing['City'])
363
+ ->setState($billing['State'])
364
+ ->setPostcode($billing['PostalCode'])
365
+ ->setCountryId(strtoupper($billing['Country']))
366
+ ->setEmail($billing['Email'])
367
+ ->setTelephone($billing['Phone'])
368
+ ->setMobile($billing['Mobile'])
369
+ ->setComments($billing['Comments'])
370
+ ->setFax($billing['Fax'])
371
+ ->setUrl($billing['Url']);
372
+ }
373
+ if (isset($trans[0]['ShippingAddress'])) {
374
+ $shipping = $trans[0]['ShippingAddress'];
375
+ $shippingAddress->setFirstname($shipping['FirstName'])
376
+ ->setLastname($shipping['LastName'])
377
+ ->setStreet($shipping['Street1'])
378
+ ->setStreet2($shipping['Street2'])
379
+ ->setCity($shipping['City'])
380
+ ->setPostcode($shipping['PostalCode'])
381
+ ->setCountryId(strtoupper($shipping['Country']))
382
+ ->setEmail($shipping['Email'])
383
+ ->setFax($shipping['Fax']);
384
+
385
+ if ($shipping['State']
386
+ && $shipping['Country']
387
+ && $region = Mage::getModel('directory/region')->loadByCode($shipping['State'], $shipping['Country'])
388
+ ) {
389
+ $shippingAddress->setRegion($region->getName())
390
+ ->setRegionId($region->getId());
391
+ }
392
+ if ($shipping['Phone']) {
393
+ $shippingAddress->setTelephone($shipping['Phone']);
394
+ }
395
+ }
396
+ $this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress)->save();
397
+ }
398
+ }
399
+
400
+ /**
401
+ * save token when checkout with eway saved
402
+ *
403
+ * @param Eway_Rapid31_Model_Response $response
404
+ * @param null $ccNumber
405
+ */
406
+ public function saveTokenById(Eway_Rapid31_Model_Response $response, $ccNumber = null)
407
+ {
408
+ $this->unsetData();
409
+
410
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
411
+ $customerParam->setTokenCustomerID($response->getTokenCustomerID());
412
+ $this->setCustomer($customerParam);
413
+ $payment = Mage::getModel('ewayrapid/field_payment');
414
+ $payment->setTotalAmount(1);
415
+ $this->setPayment($payment);
416
+ $this->setRedirectUrl(Mage::getBaseUrl() . '/ewayrapid/sharedpage/saveToken');
417
+ $this->setMethod('');
418
+
419
+ $response = $this->_doRapidAPI('AccessCodesShared');
420
+ $token = true;
421
+ if ($response->isSuccess()) {
422
+ if (!$ccNumber) {
423
+ $token = $this->_createNewToken($response);
424
+ } else {
425
+ $token = $this->_updateToken($response, $ccNumber);
426
+ }
427
+
428
+ } else {
429
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while creating new token. Please try again. (Error message: %s)',
430
+ $response->getMessage()));
431
+ }
432
+ if (!$token) {
433
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while process token. Please try again.'));
434
+ }
435
+ return $response;
436
+ }
437
+
438
+ /**
439
+ * Create new token when checkout
440
+ *
441
+ * @param Eway_Rapid31_Model_Response $response
442
+ * @return $this
443
+ */
444
+ protected function _createNewToken(Eway_Rapid31_Model_Response $response)
445
+ {
446
+ try {
447
+ $customer = $response->getCustomer();
448
+
449
+ $tokenInfo = array(
450
+ 'Token' => $response->getTokenCustomerID(),
451
+ 'Card' => $customer['CardNumber'] ? substr_replace($customer['CardNumber'], '******', 6, 6) : 'Paypal',
452
+ 'Owner' => $customer['CardName'],
453
+ 'StartMonth' => $customer['CardStartMonth'],
454
+ 'StartYear' => $customer['CardStartYear'],
455
+ 'IssueNumber' => $customer['CardIssueNumber'],
456
+ 'ExpMonth' => $customer['CardExpiryMonth'],
457
+ 'ExpYear' => (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear']),
458
+ 'Type' => $this->checkCardType($customer['CardNumber']),
459
+ 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customer),
460
+ );
461
+
462
+ Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
463
+ return true;
464
+ } catch (Exception $e) {
465
+ return false;
466
+ }
467
+ }
468
+
469
+ /**
470
+ * Update token when checkout with existing token
471
+ *
472
+ * @param Eway_Rapid31_Model_Response $response
473
+ * @param null $ccNumber
474
+ * @return $this
475
+ */
476
+ protected function _updateToken(Eway_Rapid31_Model_Response $response, $ccNumber = null)
477
+ {
478
+ try {
479
+ $customer = $response->getCustomer();
480
+
481
+ $tokenInfo = array(
482
+ 'Token' => $response->getTokenCustomerID(),
483
+ 'Card' => $customer['CardNumber'] ? substr_replace($customer['CardNumber'], '******', 6, 6) : 'Paypal',
484
+ 'Owner' => $customer['CardName'],
485
+ 'StartMonth' => $customer['CardStartMonth'],
486
+ 'StartYear' => $customer['CardStartYear'],
487
+ 'IssueNumber' => $customer['CardIssueNumber'],
488
+ 'ExpMonth' => $customer['CardExpiryMonth'],
489
+ 'ExpYear' => (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear']),
490
+ 'Type' => $this->checkCardType($customer['CardNumber']),
491
+ 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customer),
492
+ );
493
+
494
+ Mage::helper('ewayrapid/customer')->updateToken($ccNumber, $tokenInfo);
495
+ return true;
496
+ } catch (Exception $e) {
497
+ return false;
498
+ }
499
+ }
500
+
501
+ /**
502
+ * Get card type name by card number
503
+ * @param $num Card number
504
+ * @return string Card type name
505
+ */
506
+ public function checkCardType($num)
507
+ {
508
+ if ($num == null) {
509
+ return Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD;
510
+ }
511
+ return Mage::getModel('ewayrapid/request_token')->checkCardType($num);
512
+ }
513
+
514
+ public function getShippingByCode($postalCode)
515
+ {
516
+ $groups = $this->_quote->getShippingAddress()
517
+ ->collectShippingRates()
518
+ ->getGroupedAllShippingRates();
519
+ // determine current selected code & name
520
+ foreach ($groups as $code => $rates) {
521
+ foreach ($rates as $rate) {
522
+ if (strtoupper($postalCode) == strtoupper($rate->getCode())) {
523
+ return $rate;
524
+ }
525
+ }
526
+ }
527
+ return false;
528
+ }
529
+ public function getMethod()
530
+ {
531
+ return Mage::getSingleton('core/session')->getData('ewayMethod');
532
+ }
533
  }
app/code/community/Eway/Rapid31/Model/Request/Token.php CHANGED
@@ -1,516 +1,525 @@
1
- <?php
2
- class Eway_Rapid31_Model_Request_Token extends Eway_Rapid31_Model_Request_Direct
3
- {
4
- /**
5
- * Call create new customer token API
6
- *
7
- * @param Varien_Object $billing
8
- * @param Varien_Object $infoInstance
9
- * @return Eway_Rapid31_Model_Request_Token
10
- */
11
- public function createNewToken(Varien_Object $billing, Varien_Object $infoInstance)
12
- {
13
- // Empty Varien_Object's data
14
- $this->unsetData();
15
-
16
- $customerParam = Mage::getModel('ewayrapid/field_customer');
17
- $customerParam->setTitle($billing->getPrefix())
18
- ->setFirstName($billing->getFirstname())
19
- ->setLastName($billing->getLastname())
20
- ->setCompanyName($billing->getCompany())
21
- ->setJobDescription($billing->getJobDescription())
22
- ->setStreet1($billing->getStreet1())
23
- ->setStreet2($billing->getStreet2())
24
- ->setCity($billing->getCity())
25
- ->setState($billing->getRegion())
26
- ->setPostalCode($billing->getPostcode())
27
- ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
28
- ->setEmail($billing->getEmail())
29
- ->setPhone($billing->getTelephone())
30
- ->setMobile($billing->getMobile())
31
- ->setComments('')
32
- ->setFax($billing->getFax())
33
- ->setUrl('');
34
-
35
- $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
36
- $cardDetails->setName($infoInstance->getCcOwner())
37
- ->setNumber($infoInstance->getCcNumber())
38
- ->setExpiryMonth($infoInstance->getCcExpMonth())
39
- ->setExpiryYear($infoInstance->getCcExpYear())
40
- ->setCVN($infoInstance->getCcCid())
41
- ->setStartMonth($infoInstance->getStartMonth())
42
- ->setStartYear($infoInstance->getStartYear())
43
- ->setIssueNumber($infoInstance->getIssueNumber());
44
- $customerParam->setCardDetails($cardDetails);
45
- $this->setCustomer($customerParam);
46
-
47
- $response = $this->_doRapidAPI('Customer');
48
- if ($response->isSuccess()) {
49
- $customerReturn = $response->getCustomer();
50
- $cardDetails = $customerReturn['CardDetails'];
51
- unset($customerReturn['CardDetails']);
52
- $customerReturn['RegionId'] = ((!$billing->getRegion() && $billing->getRegionId()) ? $billing->getRegionId() : '');
53
- $tokenInfo = array(
54
- 'Token' => $response->getTokenCustomerID(),
55
- 'Card' => substr_replace($cardDetails['Number'], '******', 6, 6),
56
- 'Owner' => $infoInstance->getCcOwner(),
57
- 'ExpMonth' => $infoInstance->getCcExpMonth(),
58
- 'ExpYear' => $infoInstance->getCcExpYear(),
59
- 'Type' => $infoInstance->getCcType(),
60
- 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customerReturn),
61
- );
62
- Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
63
- return $this;
64
- } else {
65
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while creating new token. Please try again. (Error message: %s)',
66
- $response->getMessage()));
67
- }
68
- }
69
-
70
- /**
71
- * Update current token
72
- *
73
- * @param Varien_Object $billing
74
- * @param Varien_Object $infoInstance
75
- * @return Eway_Rapid31_Model_Request_Token
76
- */
77
- public function updateToken(Varien_Object $billing, Varien_Object $infoInstance)
78
- {
79
- if (!Mage::helper('ewayrapid')->isBackendOrder() && !Mage::getSingleton('ewayrapid/config')->canEditToken()) {
80
- Mage::throwException(Mage::helper('ewayrapid')->__('Customers are not allowed to edit token.'));
81
- }
82
-
83
- // Empty Varien_Object's data
84
- $this->unsetData();
85
-
86
- $customerParam = Mage::getModel('ewayrapid/field_customer');
87
- $customerParam->setTitle($billing->getPrefix())
88
- ->setFirstName($billing->getFirstname())
89
- ->setLastName($billing->getLastname())
90
- ->setCompanyName($billing->getCompany())
91
- ->setJobDescription($billing->getJobDescription())
92
- ->setStreet1($billing->getStreet1())
93
- ->setStreet2($billing->getStreet2())
94
- ->setCity($billing->getCity())
95
- ->setState($billing->getRegion())
96
- ->setPostalCode($billing->getPostcode())
97
- ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
98
- ->setEmail($billing->getEmail())
99
- ->setPhone($billing->getTelephone())
100
- ->setMobile($billing->getMobile())
101
- ->setFax($billing->getFax());
102
-
103
- $customerHelper = Mage::helper('ewayrapid/customer');
104
- $customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken());
105
- if ($customerTokenId) {
106
- $customerParam->setTokenCustomerID($customerTokenId);
107
- } else {
108
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
109
- }
110
-
111
- $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
112
- $cardDetails->setName($infoInstance->getCcOwner())
113
- ->setExpiryMonth($infoInstance->getCcExpMonth())
114
- ->setNumber('444433XXXXXX1111') // Required dummy card number for update to work
115
- ->setExpiryYear($infoInstance->getCcExpYear())
116
- ->setCVN($infoInstance->getCcCid());
117
- $customerParam->setCardDetails($cardDetails);
118
-
119
- $this->setCustomer($customerParam);
120
-
121
- $response = $this->_doRapidAPI('Customer', 'PUT');
122
- if ($response->isSuccess()) {
123
- $customerReturn = $response->getCustomer();
124
- $customerReturn['RegionId'] = ((!$billing->getRegion() && $billing->getRegionId()) ? $billing->getRegionId() : '');
125
- unset($customerReturn['CardDetails']);
126
- $tokenInfo = array(
127
- 'Token' => $response->getTokenCustomerID(),
128
- 'Owner' => $infoInstance->getCcOwner(),
129
- 'ExpMonth' => $infoInstance->getCcExpMonth(),
130
- 'ExpYear' => $infoInstance->getCcExpYear(),
131
- 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customerReturn),
132
- );
133
- Mage::helper('ewayrapid/customer')->updateToken($infoInstance->getSavedToken(), $tokenInfo);
134
- return $this;
135
- } else {
136
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token. Please try again. (Error message: %s)',
137
- $response->getMessage()));
138
- }
139
- }
140
-
141
- protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
142
- {
143
- // Empty Varien_Object's data
144
- $this->unsetData();
145
- // in case recurring profile, $methodInstance is not exist, and $payment->getIsRecurring() is used
146
- if (!$payment->getIsRecurring()) {
147
- $methodInstance = $payment->getMethodInstance();
148
- $infoInstance = $methodInstance->getInfoInstance();
149
- Mage::helper('ewayrapid')->unserializeInfoInstace($infoInstance);
150
- }
151
- $order = $payment->getOrder();
152
- $shipping = $order->getShippingAddress();
153
-
154
- // if item is virtual product
155
- if (!$shipping) {
156
- $quote = Mage::getModel('checkout/cart')->getQuote();
157
- if ($quote->isVirtual()) {
158
- $shipping = $quote->getBillingAddress();
159
- }
160
- }
161
-
162
- if (!$payment->getIsRecurring()) {
163
- $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
164
- }
165
- if (Mage::helper('ewayrapid')->isBackendOrder()) {
166
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
167
- } elseif ($payment->getIsRecurring()) {
168
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_RECURRING);
169
- } else {
170
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
171
- }
172
- $version = Mage::helper('ewayrapid')->getExtensionVersion();
173
- $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY Official '.$version);
174
- $this->setShippingMethod('Other');
175
-
176
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
177
- $paymentParam->setTotalAmount($amount)
178
- ->setCurrencyCode($order->getBaseCurrencyCode());
179
- $this->setPayment($paymentParam);
180
-
181
- $customerParam = Mage::getModel('ewayrapid/field_customer');
182
- $customerTokenId = null;
183
-
184
- /** get $customerTokenId if product is recurring profile */
185
- if ($payment->getIsRecurring()) {
186
- /** @todo save customer id and tokent id into payment when place order */
187
- $customer = Mage::getModel('customer/customer')->load($payment->getCustomerId());
188
- $customerHelper = Mage::helper('ewayrapid/customer');
189
- $customerHelper->setCurrentCustomer($customer);
190
- $customerTokenId = $customerHelper->getCustomerTokenId($payment->getTokenId());
191
- } else {
192
- /** get $customerTokenId if product is normal item */
193
- if ($infoInstance->getSavedToken()) {
194
- $customerHelper = Mage::helper('ewayrapid/customer');
195
- $customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken());
196
- }
197
- else {
198
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
199
- }
200
- }
201
- if ($customerTokenId) {
202
- $customerParam->setTokenCustomerID($customerTokenId);
203
- if ($this->getTransactionType() == Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE) {
204
- $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
205
- $cardDetails->setCVN($infoInstance->getCcCid());
206
- $customerParam->setCardDetails($cardDetails);
207
- }
208
- $this->setCustomer($customerParam);
209
- } else {
210
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
211
- }
212
-
213
- $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
214
- $shippingParam->setFirstName($shipping->getFirstname())
215
- ->setLastName($shipping->getLastname())
216
- ->setStreet1($shipping->getStreet1())
217
- ->setStreet2($shipping->getStreet2())
218
- ->setCity($shipping->getCity())
219
- ->setState($shipping->getRegion())
220
- ->setPostalCode($shipping->getPostcode())
221
- ->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))
222
- ->setEmail($shipping->getEmail())
223
- ->setPhone($shipping->getTelephone())
224
- ->setFax($shipping->getFax());
225
- $this->setShippingAddress($shippingParam);
226
-
227
- if ((isset($methodInstance) && $methodInstance->getConfigData('transfer_cart_items')) || $payment->getIsRecurring() || !$payment->getIsInitialFee()) {
228
- $orderItems = $order->getAllVisibleItems();
229
- $lineItems = array();
230
- foreach ($orderItems as $orderItem) {
231
- /* @var Mage_Sales_Model_Order_Item $orderItem */
232
- $lineItem = Mage::getModel('ewayrapid/field_lineItem');
233
- $lineItem->setSKU($orderItem->getSku());
234
- $lineItem->setDescription(substr($orderItem->getName(), 0, 26));
235
- $lineItem->setQuantity($orderItem->getQtyOrdered());
236
- $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
237
- $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
238
- $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
239
- $lineItems[] = $lineItem;
240
- }
241
- $this->setItems($lineItems);
242
- }
243
-
244
-
245
- return $this;
246
- }
247
-
248
- /**
249
- * Create new AccessCode
250
- * @param Varien_Object $billing
251
- * @param Varien_Object $infoInstance
252
- * @param string $method
253
- * @param null $request
254
- * @return Eway_Rapid31_Model_Response
255
- */
256
- public function createAccessCode(Varien_Object $billing, Varien_Object $infoInstance,
257
- $method = 'AccessCodes', $request = null)
258
- {
259
- // Empty Varien_Object's data
260
- $tokenCustomerID = $request->get('TokenCustomerID');
261
- $this->unsetData();
262
- $customerParam = Mage::getModel('ewayrapid/field_customer');
263
- $customerParam->setTokenCustomerID($tokenCustomerID)
264
- ->setTitle($billing->getPrefix())
265
- ->setFirstName($billing->getFirstname())
266
- ->setLastName($billing->getLastname())
267
- ->setCompanyName($billing->getCompany())
268
- ->setJobDescription($billing->getJobDescription())
269
- ->setStreet1($billing->getStreet1())
270
- ->setStreet2($billing->getStreet2())
271
- ->setCity($billing->getCity())
272
- ->setState($billing->getRegion())
273
- ->setPostalCode($billing->getPostcode())
274
- ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
275
- ->setEmail($billing->getEmail())
276
- ->setPhone($billing->getTelephone())
277
- ->setMobile($billing->getMobile())
278
- ->setComments('')
279
- ->setFax($billing->getFax())
280
- ->setUrl('');
281
-
282
- $returnUrl = Mage::getBaseUrl() . '/ewayrapid/mycards/saveToken?ccType='
283
- . $infoInstance->getCcType() . '&expYear=' . $infoInstance->getCcExpYear();
284
- if ($request->get('is_default') == 'on') {
285
- $returnUrl .= '&is_default=on';
286
- }
287
- if($infoInstance->getCcStartMonth()) {
288
- $returnUrl .= '&startMonth=' . $infoInstance->getCcStartMonth();
289
- }
290
- if($infoInstance->getCcStartYear()) {
291
- $returnUrl .= '&startYear=' . $infoInstance->getCcStartYear();
292
- }
293
- if($infoInstance->getCcIssueNumber()) {
294
- $returnUrl .= '&issueNumber=' . $infoInstance->getCcIssueNumber();
295
- }
296
- // Binding address on url param
297
- $returnUrl .= '&street1=' . base64_encode($billing->getStreet1())
298
- . '&street2=' . base64_encode($billing->getStreet2());
299
- $tokenId = $request->get('token_id');
300
- if (!empty($tokenId)) { // ID token customer will be defined to update
301
- $returnUrl = $returnUrl . '&token_id=' . $tokenId;
302
- }
303
-
304
- $this->setCustomer($customerParam);
305
- $this->setRedirectUrl($returnUrl);
306
- $this->setCancelUrl($returnUrl);
307
- $this->setMethod(!empty($tokenCustomerID) ? 'UpdateTokenCustomer' : 'CreateTokenCustomer');
308
- $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
309
- $version = Mage::helper('ewayrapid')->getExtensionVersion();
310
- $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY Official '.$version);
311
- $this->setTransactionType("Purchase");
312
- $this->setCustomerReadOnly(true);
313
-
314
- // Create new access code
315
- //$formMethod = !empty($tokenCustomerID) ? 'PUT' : 'POST';
316
- $response = $this->_doRapidAPI($method);
317
- return $response;
318
- }
319
-
320
- /*
321
- * Get customer information by access code
322
- */
323
- public function getInfoByAccessCode($accessCode)
324
- {
325
- $response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
326
- return $response;
327
- }
328
-
329
- public function saveInfoByTokenId($cardData)
330
- {
331
- // Empty Varien_Object's data
332
- $this->unsetData();
333
-
334
- $customerParam = Mage::getModel('ewayrapid/field_customer');
335
- $customerParam->setTokenCustomerID($cardData['token']);
336
- $payment = Mage::getModel('ewayrapid/field_payment');
337
- $payment->setTotalAmount(1);
338
- $returnUrl = Mage::getBaseUrl() . '/ewayrapid/mycards';
339
-
340
- $this->setCustomer($customerParam);
341
- $this->setPayment($payment);
342
- $this->setRedirectUrl($returnUrl);
343
- $this->setMethod('');
344
- $this->setTransactionType('');
345
- $version = Mage::helper('ewayrapid')->getExtensionVersion();
346
- $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY Official '.$version);
347
- $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
348
-
349
- $response = $this->_doRapidAPI('AccessCodes');
350
-
351
- if ($cardData['token_id']) {
352
- // Update card
353
- $this->__updateTokenTransparentOrSharedPage($response, $cardData);
354
- } else
355
- // Create new token
356
- $this->__createNewTokenTransparentOrSharedPage($response, $cardData);
357
- return $this;
358
-
359
- }
360
-
361
- private function __createNewTokenTransparentOrSharedPage($response, $cardData)
362
- {
363
- if ($response->isSuccess()) {
364
- $data = $response->getData();
365
- $customer = $data['Customer'];
366
- $address = array(
367
- //'TokenCustomerID' => $customer['TokenCustomerID'],
368
- 'Reference' => $customer['Reference'],
369
- 'Title' => $customer['Title'],
370
- 'FirstName' => $customer['FirstName'],
371
- 'LastName' => $customer['LastName'],
372
- 'CompanyName' => $customer['CompanyName'],
373
- 'JobDescription' => $customer['JobDescription'],
374
- 'Street1' => isset($cardData['street1'])? $cardData['street1'] : $customer['Street1'],
375
- 'Street2' => isset($cardData['street2']) ? $cardData['street2'] : $customer['Street2'],
376
- 'City' => $customer['City'],
377
- 'State' => $customer['State'],
378
- 'PostalCode' => $customer['PostalCode'],
379
- 'Country' => $customer['Country'],
380
- 'Email' => $customer['Email'],
381
- 'Phone' => $customer['Phone'],
382
- 'Mobile' => $customer['Mobile'],
383
- 'Comments' => $customer['Comments'],
384
- 'Fax' => $customer['Fax'],
385
- 'Url' => $customer['Url']
386
- );
387
- $tokenInfo = array(
388
- 'Token' => $response->getTokenCustomerID(),
389
- 'Card' => substr_replace($customer['CardNumber'], '******', 6, 6),
390
- 'Owner' => $customer['CardName'],
391
- 'StartMonth' => $cardData['startMonth'],
392
- 'StartYear' => $cardData['startYear'],
393
- 'IssueNumber' => $cardData['issueNumber'],
394
- 'ExpMonth' => $customer['CardExpiryMonth'],
395
- 'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
396
- (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
397
- 'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
398
- 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
399
- );
400
-
401
- Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
402
- return $this;
403
- } else {
404
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while creating new token. Please try again. (Error message: %s)',
405
- $response->getMessage()));
406
- }
407
- }
408
-
409
- private function __updateTokenTransparentOrSharedPage($res, $cardData)
410
- {
411
- if ($res->isSuccess()) {
412
- $data = $res->getData();
413
- $customer = $data['Customer'];
414
- $address = array(
415
- //'TokenCustomerID' => $customer['TokenCustomerID'],
416
- 'Reference' => $customer['Reference'],
417
- 'Title' => $customer['Title'],
418
- 'FirstName' => $customer['FirstName'],
419
- 'LastName' => $customer['LastName'],
420
- 'CompanyName' => $customer['CompanyName'],
421
- 'JobDescription' => $customer['JobDescription'],
422
- 'Street1' => isset($cardData['street1'])? $cardData['street1'] : $customer['Street1'],
423
- 'Street2' => isset($cardData['street2']) ? $cardData['street2'] : $customer['Street2'],
424
- 'City' => $customer['City'],
425
- 'State' => $customer['State'],
426
- 'PostalCode' => $customer['PostalCode'],
427
- 'Country' => $customer['Country'],
428
- 'Email' => $customer['Email'],
429
- 'Phone' => $customer['Phone'],
430
- 'Mobile' => $customer['Mobile'],
431
- 'Comments' => $customer['Comments'],
432
- 'Fax' => $customer['Fax'],
433
- 'Url' => $customer['Url']
434
- );
435
-
436
- $tokenInfo = array(
437
- 'Token' => $res->getTokenCustomerID(),
438
- 'Owner' => $customer['CardName'],
439
- 'StartMonth' => $cardData['startMonth'],
440
- 'StartYear' => $cardData['startYear'],
441
- 'IssueNumber' => $cardData['issueNumber'],
442
- 'ExpMonth' => $customer['CardExpiryMonth'],
443
- 'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
444
- (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
445
- 'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
446
- 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
447
- );
448
- //edit card number if connection type = shared page
449
- if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
450
- $tokenInfo['Card'] = str_replace('X', '*', $customer['CardNumber']);
451
- $tokenInfo['Card'] = str_replace('x', '*', $tokenInfo['Card']);
452
- }
453
-
454
- Mage::helper('ewayrapid/customer')->updateToken($cardData['token_id'], $tokenInfo);
455
- return $this;
456
- } else {
457
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while creating new token. Please try again. (Error message: %s)',
458
- $res->getMessage()));
459
- }
460
- }
461
-
462
- /**
463
- * Get card type name by card number
464
- * @param $num Card number
465
- * @return string Card type name
466
- */
467
- public function checkCardType($num)
468
- {
469
- if (preg_match('/^(4026|417500|4508|4844|4913|4917)/', $num)) {
470
- return 'VE';
471
- }
472
- if (preg_match('/^4/', $num)) {
473
- return 'VI';
474
- }
475
- if (preg_match('/^(34|37)/', $num)) {
476
- return 'AE';
477
- }
478
- if (preg_match('/^(5[1-5])/', $num)) {
479
- return 'MC';
480
- }
481
- if (preg_match('/^(2131|1800)/', $num)) {
482
- return 'JCB';
483
- }
484
- if (preg_match('/^36/', $num)) {
485
- return 'DC';
486
- }
487
- if (preg_match('/^(5018|5020|5038|5893|6304|6759|6761|6762|6763)/', $num)) {
488
- return 'ME';
489
- }
490
-
491
- return 'Unknown';
492
- }
493
-
494
- public function getTransaction($transaction_number) {
495
-
496
- }
497
-
498
-
499
- /**
500
- * Check Card Name
501
- * @param $card Card Info
502
- * @return string Card name: paypal | masterpass | mastercard
503
- */
504
- public function checkCardName($card)
505
- {
506
- $cardType = strtolower($card->getType());
507
- if (preg_match('/^paypal/', $cardType)) {
508
- return Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD;
509
- }
510
- $ccTypes = Mage::getSingleton('ewayrapid/system_config_source_cctype')->getAllowedTypes();
511
- if (in_array(strtoupper($cardType), $ccTypes)) {
512
- return Eway_Rapid31_Model_Config::CREDITCARD_METHOD;
513
- }
514
- return Eway_Rapid31_Model_Config::MASTERPASS_METHOD;
515
- }
 
 
 
 
 
 
 
 
 
516
  }
1
+ <?php
2
+ class Eway_Rapid31_Model_Request_Token extends Eway_Rapid31_Model_Request_Direct
3
+ {
4
+ /**
5
+ * Call create new customer token API
6
+ *
7
+ * @param Varien_Object $billing
8
+ * @param Varien_Object $infoInstance
9
+ * @return Eway_Rapid31_Model_Request_Token
10
+ */
11
+ public function createNewToken(Varien_Object $billing, Varien_Object $infoInstance)
12
+ {
13
+ // Empty Varien_Object's data
14
+ $this->unsetData();
15
+
16
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
17
+
18
+ $title = $this->_fixTitle($billing->getPrefix());
19
+
20
+ $customerParam->setTitle($title)
21
+ ->setFirstName($billing->getFirstname())
22
+ ->setLastName($billing->getLastname())
23
+ ->setCompanyName($billing->getCompany())
24
+ ->setJobDescription($billing->getJobDescription())
25
+ ->setStreet1($billing->getStreet1())
26
+ ->setStreet2($billing->getStreet2())
27
+ ->setCity($billing->getCity())
28
+ ->setState($billing->getRegion())
29
+ ->setPostalCode($billing->getPostcode())
30
+ ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
31
+ ->setEmail($billing->getEmail())
32
+ ->setPhone($billing->getTelephone())
33
+ ->setMobile($billing->getMobile())
34
+ ->setComments('')
35
+ ->setFax($billing->getFax())
36
+ ->setUrl('');
37
+
38
+ $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
39
+ $cardDetails->setName($infoInstance->getCcOwner())
40
+ ->setNumber($infoInstance->getCcNumber())
41
+ ->setExpiryMonth($infoInstance->getCcExpMonth())
42
+ ->setExpiryYear($infoInstance->getCcExpYear())
43
+ ->setCVN($infoInstance->getCcCid())
44
+ ->setStartMonth($infoInstance->getStartMonth())
45
+ ->setStartYear($infoInstance->getStartYear())
46
+ ->setIssueNumber($infoInstance->getIssueNumber());
47
+ $customerParam->setCardDetails($cardDetails);
48
+ $this->setCustomer($customerParam);
49
+
50
+ $response = $this->_doRapidAPI('Customer');
51
+ if ($response->isSuccess()) {
52
+ $customerReturn = $response->getCustomer();
53
+ $cardDetails = $customerReturn['CardDetails'];
54
+ unset($customerReturn['CardDetails']);
55
+ $customerReturn['RegionId'] = ((!$billing->getRegion() && $billing->getRegionId()) ? $billing->getRegionId() : '');
56
+ $tokenInfo = array(
57
+ 'Token' => $response->getTokenCustomerID(),
58
+ 'Card' => substr_replace($cardDetails['Number'], '******', 6, 6),
59
+ 'Owner' => $infoInstance->getCcOwner(),
60
+ 'ExpMonth' => $infoInstance->getCcExpMonth(),
61
+ 'ExpYear' => $infoInstance->getCcExpYear(),
62
+ 'Type' => $infoInstance->getCcType(),
63
+ 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customerReturn),
64
+ );
65
+ Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
66
+ return $this;
67
+ } else {
68
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while creating new token. Please try again. (Error message: %s)',
69
+ $response->getMessage()));
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Update current token
75
+ *
76
+ * @param Varien_Object $billing
77
+ * @param Varien_Object $infoInstance
78
+ * @return Eway_Rapid31_Model_Request_Token
79
+ */
80
+ public function updateToken(Varien_Object $billing, Varien_Object $infoInstance)
81
+ {
82
+ if (!Mage::helper('ewayrapid')->isBackendOrder() && !Mage::getSingleton('ewayrapid/config')->canEditToken()) {
83
+ Mage::throwException(Mage::helper('ewayrapid')->__('Customers are not allowed to edit token.'));
84
+ }
85
+
86
+ // Empty Varien_Object's data
87
+ $this->unsetData();
88
+
89
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
90
+
91
+ $title = $this->_fixTitle($billing->getPrefix());
92
+
93
+ $customerParam->setTitle($title)
94
+ ->setFirstName($billing->getFirstname())
95
+ ->setLastName($billing->getLastname())
96
+ ->setCompanyName($billing->getCompany())
97
+ ->setJobDescription($billing->getJobDescription())
98
+ ->setStreet1($billing->getStreet1())
99
+ ->setStreet2($billing->getStreet2())
100
+ ->setCity($billing->getCity())
101
+ ->setState($billing->getRegion())
102
+ ->setPostalCode($billing->getPostcode())
103
+ ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
104
+ ->setEmail($billing->getEmail())
105
+ ->setPhone($billing->getTelephone())
106
+ ->setMobile($billing->getMobile())
107
+ ->setFax($billing->getFax());
108
+
109
+ $customerHelper = Mage::helper('ewayrapid/customer');
110
+ $customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken());
111
+ if ($customerTokenId) {
112
+ $customerParam->setTokenCustomerID($customerTokenId);
113
+ } else {
114
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
115
+ }
116
+
117
+ $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
118
+ $cardDetails->setName($infoInstance->getCcOwner())
119
+ ->setExpiryMonth($infoInstance->getCcExpMonth())
120
+ ->setNumber('444433XXXXXX1111') // Required dummy card number for update to work
121
+ ->setExpiryYear($infoInstance->getCcExpYear())
122
+ ->setCVN($infoInstance->getCcCid());
123
+ $customerParam->setCardDetails($cardDetails);
124
+
125
+ $this->setCustomer($customerParam);
126
+
127
+ $response = $this->_doRapidAPI('Customer', 'PUT');
128
+ if ($response->isSuccess()) {
129
+ $customerReturn = $response->getCustomer();
130
+ $customerReturn['RegionId'] = ((!$billing->getRegion() && $billing->getRegionId()) ? $billing->getRegionId() : '');
131
+ unset($customerReturn['CardDetails']);
132
+ $tokenInfo = array(
133
+ 'Token' => $response->getTokenCustomerID(),
134
+ 'Owner' => $infoInstance->getCcOwner(),
135
+ 'ExpMonth' => $infoInstance->getCcExpMonth(),
136
+ 'ExpYear' => $infoInstance->getCcExpYear(),
137
+ 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customerReturn),
138
+ );
139
+ Mage::helper('ewayrapid/customer')->updateToken($infoInstance->getSavedToken(), $tokenInfo);
140
+ return $this;
141
+ } else {
142
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token. Please try again. (Error message: %s)',
143
+ $response->getMessage()));
144
+ }
145
+ }
146
+
147
+ protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
148
+ {
149
+ // Empty Varien_Object's data
150
+ $this->unsetData();
151
+ // in case recurring profile, $methodInstance is not exist, and $payment->getIsRecurring() is used
152
+ if (!$payment->getIsRecurring()) {
153
+ $methodInstance = $payment->getMethodInstance();
154
+ $infoInstance = $methodInstance->getInfoInstance();
155
+ Mage::helper('ewayrapid')->unserializeInfoInstace($infoInstance);
156
+ }
157
+ $order = $payment->getOrder();
158
+ $shipping = $order->getShippingAddress();
159
+
160
+ // if item is virtual product
161
+ if (!$shipping) {
162
+ $quote = Mage::getModel('checkout/cart')->getQuote();
163
+ if ($quote->isVirtual()) {
164
+ $shipping = $quote->getBillingAddress();
165
+ }
166
+ }
167
+
168
+ if (!$payment->getIsRecurring()) {
169
+ $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
170
+ }
171
+ if (Mage::helper('ewayrapid')->isBackendOrder()) {
172
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
173
+ } elseif ($payment->getIsRecurring()) {
174
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_RECURRING);
175
+ } else {
176
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
177
+ }
178
+ $version = Mage::helper('ewayrapid')->getExtensionVersion();
179
+ $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
180
+ $this->setShippingMethod('Other');
181
+
182
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
183
+ $paymentParam->setTotalAmount($amount)
184
+ ->setCurrencyCode($order->getBaseCurrencyCode());
185
+ $this->setPayment($paymentParam);
186
+
187
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
188
+ $customerTokenId = null;
189
+
190
+ /** get $customerTokenId if product is recurring profile */
191
+ if ($payment->getIsRecurring()) {
192
+ /** @todo save customer id and tokent id into payment when place order */
193
+ $customer = Mage::getModel('customer/customer')->load($payment->getCustomerId());
194
+ $customerHelper = Mage::helper('ewayrapid/customer');
195
+ $customerHelper->setCurrentCustomer($customer);
196
+ $customerTokenId = $customerHelper->getCustomerTokenId($payment->getTokenId());
197
+ } else {
198
+ /** get $customerTokenId if product is normal item */
199
+ if ($infoInstance->getSavedToken()) {
200
+ $customerHelper = Mage::helper('ewayrapid/customer');
201
+ $customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken());
202
+ }
203
+ else {
204
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
205
+ }
206
+ }
207
+ if ($customerTokenId) {
208
+ $customerParam->setTokenCustomerID($customerTokenId);
209
+ if ($this->getTransactionType() == Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE) {
210
+ $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
211
+ $cardDetails->setCVN($infoInstance->getCcCid());
212
+ $customerParam->setCardDetails($cardDetails);
213
+ }
214
+ $this->setCustomer($customerParam);
215
+ } else {
216
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
217
+ }
218
+
219
+ $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
220
+ $shippingParam->setFirstName($shipping->getFirstname())
221
+ ->setLastName($shipping->getLastname())
222
+ ->setStreet1($shipping->getStreet1())
223
+ ->setStreet2($shipping->getStreet2())
224
+ ->setCity($shipping->getCity())
225
+ ->setState($shipping->getRegion())
226
+ ->setPostalCode($shipping->getPostcode())
227
+ ->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))
228
+ ->setEmail($shipping->getEmail())
229
+ ->setPhone($shipping->getTelephone())
230
+ ->setFax($shipping->getFax());
231
+ $this->setShippingAddress($shippingParam);
232
+
233
+ if ((isset($methodInstance) && $methodInstance->getConfigData('transfer_cart_items')) || $payment->getIsRecurring() || !$payment->getIsInitialFee()) {
234
+ $orderItems = $order->getAllVisibleItems();
235
+ $lineItems = array();
236
+ foreach ($orderItems as $orderItem) {
237
+ /* @var Mage_Sales_Model_Order_Item $orderItem */
238
+ $lineItem = Mage::getModel('ewayrapid/field_lineItem');
239
+ $lineItem->setSKU($orderItem->getSku());
240
+ $lineItem->setDescription(substr($orderItem->getName(), 0, 26));
241
+ $lineItem->setQuantity($orderItem->getQtyOrdered());
242
+ $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
243
+ $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
244
+ $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
245
+ $lineItems[] = $lineItem;
246
+ }
247
+ $this->setItems($lineItems);
248
+ }
249
+
250
+
251
+ return $this;
252
+ }
253
+
254
+ /**
255
+ * Create new AccessCode
256
+ * @param Varien_Object $billing
257
+ * @param Varien_Object $infoInstance
258
+ * @param string $method
259
+ * @param null $request
260
+ * @return Eway_Rapid31_Model_Response
261
+ */
262
+ public function createAccessCode(Varien_Object $billing, Varien_Object $infoInstance,
263
+ $method = 'AccessCodes', $request = null)
264
+ {
265
+ // Empty Varien_Object's data
266
+ $tokenCustomerID = $request->get('TokenCustomerID');
267
+ $this->unsetData();
268
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
269
+
270
+ $title = $this->_fixTitle($billing->getPrefix());
271
+
272
+ $customerParam->setTokenCustomerID($tokenCustomerID)
273
+ ->setTitle($title)
274
+ ->setFirstName($billing->getFirstname())
275
+ ->setLastName($billing->getLastname())
276
+ ->setCompanyName($billing->getCompany())
277
+ ->setJobDescription($billing->getJobDescription())
278
+ ->setStreet1($billing->getStreet1())
279
+ ->setStreet2($billing->getStreet2())
280
+ ->setCity($billing->getCity())
281
+ ->setState($billing->getRegion())
282
+ ->setPostalCode($billing->getPostcode())
283
+ ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
284
+ ->setEmail($billing->getEmail())
285
+ ->setPhone($billing->getTelephone())
286
+ ->setMobile($billing->getMobile())
287
+ ->setComments('')
288
+ ->setFax($billing->getFax())
289
+ ->setUrl('');
290
+
291
+ $returnUrl = Mage::getBaseUrl() . '/ewayrapid/mycards/saveToken?ccType='
292
+ . $infoInstance->getCcType() . '&expYear=' . $infoInstance->getCcExpYear();
293
+ if ($request->get('is_default') == 'on') {
294
+ $returnUrl .= '&is_default=on';
295
+ }
296
+ if($infoInstance->getCcStartMonth()) {
297
+ $returnUrl .= '&startMonth=' . $infoInstance->getCcStartMonth();
298
+ }
299
+ if($infoInstance->getCcStartYear()) {
300
+ $returnUrl .= '&startYear=' . $infoInstance->getCcStartYear();
301
+ }
302
+ if($infoInstance->getCcIssueNumber()) {
303
+ $returnUrl .= '&issueNumber=' . $infoInstance->getCcIssueNumber();
304
+ }
305
+ // Binding address on url param
306
+ $returnUrl .= '&street1=' . base64_encode($billing->getStreet1())
307
+ . '&street2=' . base64_encode($billing->getStreet2());
308
+ $tokenId = $request->get('token_id');
309
+ if (!empty($tokenId)) { // ID token customer will be defined to update
310
+ $returnUrl = $returnUrl . '&token_id=' . $tokenId;
311
+ }
312
+
313
+ $this->setCustomer($customerParam);
314
+ $this->setRedirectUrl($returnUrl);
315
+ $this->setCancelUrl($returnUrl);
316
+ $this->setMethod(!empty($tokenCustomerID) ? 'UpdateTokenCustomer' : 'CreateTokenCustomer');
317
+ $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
318
+ $version = Mage::helper('ewayrapid')->getExtensionVersion();
319
+ $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
320
+ $this->setTransactionType("Purchase");
321
+ $this->setCustomerReadOnly(true);
322
+
323
+ // Create new access code
324
+ //$formMethod = !empty($tokenCustomerID) ? 'PUT' : 'POST';
325
+ $response = $this->_doRapidAPI($method);
326
+ return $response;
327
+ }
328
+
329
+ /*
330
+ * Get customer information by access code
331
+ */
332
+ public function getInfoByAccessCode($accessCode)
333
+ {
334
+ $response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
335
+ return $response;
336
+ }
337
+
338
+ public function saveInfoByTokenId($cardData)
339
+ {
340
+ // Empty Varien_Object's data
341
+ $this->unsetData();
342
+
343
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
344
+ $customerParam->setTokenCustomerID($cardData['token']);
345
+ $payment = Mage::getModel('ewayrapid/field_payment');
346
+ $payment->setTotalAmount(1);
347
+ $returnUrl = Mage::getBaseUrl() . '/ewayrapid/mycards';
348
+
349
+ $this->setCustomer($customerParam);
350
+ $this->setPayment($payment);
351
+ $this->setRedirectUrl($returnUrl);
352
+ $this->setMethod('');
353
+ $this->setTransactionType('');
354
+ $version = Mage::helper('ewayrapid')->getExtensionVersion();
355
+ $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
356
+ $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
357
+
358
+ $response = $this->_doRapidAPI('AccessCodes');
359
+
360
+ if ($cardData['token_id']) {
361
+ // Update card
362
+ $this->__updateTokenTransparentOrSharedPage($response, $cardData);
363
+ } else
364
+ // Create new token
365
+ $this->__createNewTokenTransparentOrSharedPage($response, $cardData);
366
+ return $this;
367
+
368
+ }
369
+
370
+ private function __createNewTokenTransparentOrSharedPage($response, $cardData)
371
+ {
372
+ if ($response->isSuccess()) {
373
+ $data = $response->getData();
374
+ $customer = $data['Customer'];
375
+ $address = array(
376
+ //'TokenCustomerID' => $customer['TokenCustomerID'],
377
+ 'Reference' => $customer['Reference'],
378
+ 'Title' => $customer['Title'],
379
+ 'FirstName' => $customer['FirstName'],
380
+ 'LastName' => $customer['LastName'],
381
+ 'CompanyName' => $customer['CompanyName'],
382
+ 'JobDescription' => $customer['JobDescription'],
383
+ 'Street1' => isset($cardData['street1'])? $cardData['street1'] : $customer['Street1'],
384
+ 'Street2' => isset($cardData['street2']) ? $cardData['street2'] : $customer['Street2'],
385
+ 'City' => $customer['City'],
386
+ 'State' => $customer['State'],
387
+ 'PostalCode' => $customer['PostalCode'],
388
+ 'Country' => $customer['Country'],
389
+ 'Email' => $customer['Email'],
390
+ 'Phone' => $customer['Phone'],
391
+ 'Mobile' => $customer['Mobile'],
392
+ 'Comments' => $customer['Comments'],
393
+ 'Fax' => $customer['Fax'],
394
+ 'Url' => $customer['Url']
395
+ );
396
+ $tokenInfo = array(
397
+ 'Token' => $response->getTokenCustomerID(),
398
+ 'Card' => substr_replace($customer['CardNumber'], '******', 6, 6),
399
+ 'Owner' => $customer['CardName'],
400
+ 'StartMonth' => $cardData['startMonth'],
401
+ 'StartYear' => $cardData['startYear'],
402
+ 'IssueNumber' => $cardData['issueNumber'],
403
+ 'ExpMonth' => $customer['CardExpiryMonth'],
404
+ 'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
405
+ (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
406
+ 'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
407
+ 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
408
+ );
409
+
410
+ Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
411
+ return $this;
412
+ } else {
413
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while creating new token. Please try again. (Error message: %s)',
414
+ $response->getMessage()));
415
+ }
416
+ }
417
+
418
+ private function __updateTokenTransparentOrSharedPage($res, $cardData)
419
+ {
420
+ if ($res->isSuccess()) {
421
+ $data = $res->getData();
422
+ $customer = $data['Customer'];
423
+ $address = array(
424
+ //'TokenCustomerID' => $customer['TokenCustomerID'],
425
+ 'Reference' => $customer['Reference'],
426
+ 'Title' => $customer['Title'],
427
+ 'FirstName' => $customer['FirstName'],
428
+ 'LastName' => $customer['LastName'],
429
+ 'CompanyName' => $customer['CompanyName'],
430
+ 'JobDescription' => $customer['JobDescription'],
431
+ 'Street1' => isset($cardData['street1'])? $cardData['street1'] : $customer['Street1'],
432
+ 'Street2' => isset($cardData['street2']) ? $cardData['street2'] : $customer['Street2'],
433
+ 'City' => $customer['City'],
434
+ 'State' => $customer['State'],
435
+ 'PostalCode' => $customer['PostalCode'],
436
+ 'Country' => $customer['Country'],
437
+ 'Email' => $customer['Email'],
438
+ 'Phone' => $customer['Phone'],
439
+ 'Mobile' => $customer['Mobile'],
440
+ 'Comments' => $customer['Comments'],
441
+ 'Fax' => $customer['Fax'],
442
+ 'Url' => $customer['Url']
443
+ );
444
+
445
+ $tokenInfo = array(
446
+ 'Token' => $res->getTokenCustomerID(),
447
+ 'Owner' => $customer['CardName'],
448
+ 'StartMonth' => $cardData['startMonth'],
449
+ 'StartYear' => $cardData['startYear'],
450
+ 'IssueNumber' => $cardData['issueNumber'],
451
+ 'ExpMonth' => $customer['CardExpiryMonth'],
452
+ 'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
453
+ (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
454
+ 'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
455
+ 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
456
+ );
457
+ //edit card number if connection type = shared page
458
+ if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type') === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
459
+ $tokenInfo['Card'] = str_replace('X', '*', $customer['CardNumber']);
460
+ $tokenInfo['Card'] = str_replace('x', '*', $tokenInfo['Card']);
461
+ }
462
+
463
+ Mage::helper('ewayrapid/customer')->updateToken($cardData['token_id'], $tokenInfo);
464
+ return $this;
465
+ } else {
466
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while creating new token. Please try again. (Error message: %s)',
467
+ $res->getMessage()));
468
+ }
469
+ }
470
+
471
+ /**
472
+ * Get card type name by card number
473
+ * @param $num Card number
474
+ * @return string Card type name
475
+ */
476
+ public function checkCardType($num)
477
+ {
478
+ if (preg_match('/^(4026|417500|4508|4844|4913|4917)/', $num)) {
479
+ return 'VE';
480
+ }
481
+ if (preg_match('/^4/', $num)) {
482
+ return 'VI';
483
+ }
484
+ if (preg_match('/^(34|37)/', $num)) {
485
+ return 'AE';
486
+ }
487
+ if (preg_match('/^(5[1-5])/', $num)) {
488
+ return 'MC';
489
+ }
490
+ if (preg_match('/^(2131|1800)/', $num)) {
491
+ return 'JCB';
492
+ }
493
+ if (preg_match('/^36/', $num)) {
494
+ return 'DC';
495
+ }
496
+ if (preg_match('/^(5018|5020|5038|5893|6304|6759|6761|6762|6763)/', $num)) {
497
+ return 'ME';
498
+ }
499
+
500
+ return 'Unknown';
501
+ }
502
+
503
+ public function getTransaction($transaction_number) {
504
+
505
+ }
506
+
507
+
508
+ /**
509
+ * Check Card Name
510
+ * @param $card Card Info
511
+ * @return string Card name: paypal | masterpass | mastercard
512
+ */
513
+ public function checkCardName($card)
514
+ {
515
+ $cardType = strtolower($card->getType());
516
+ if (preg_match('/^paypal/', $cardType)) {
517
+ return Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD;
518
+ }
519
+ $ccTypes = Mage::getSingleton('ewayrapid/system_config_source_cctype')->getAllowedTypes();
520
+ if (in_array(strtoupper($cardType), $ccTypes)) {
521
+ return Eway_Rapid31_Model_Config::CREDITCARD_METHOD;
522
+ }
523
+ return Eway_Rapid31_Model_Config::MASTERPASS_METHOD;
524
+ }
525
  }
app/code/community/Eway/Rapid31/Model/Request/Transparent.php CHANGED
@@ -1,686 +1,694 @@
1
- <?php
2
-
3
- class Eway_Rapid31_Model_Request_Transparent extends Eway_Rapid31_Model_Request_Abstract
4
- {
5
- /**
6
- * Get AccessCode
7
- *
8
- * @param Mage_Sales_Model_Quote $quote
9
- * @return Eway_Rapid31_Model_Response
10
- */
11
- public function createAccessCode(Mage_Sales_Model_Quote $quote, $method = 'ProcessPayment', $action = 'AccessCodes')
12
- {
13
- // Empty Varien_Object's data
14
- $this->unsetData();
15
-
16
- $billingAddress = $quote->getBillingAddress();
17
- $customerParam = Mage::getModel('ewayrapid/field_customer');
18
- $customerParam->setTitle($billingAddress->getPrefix() ? $billingAddress->getPrefix() : 'Mr')
19
- ->setFirstName($billingAddress->getFirstname())
20
- ->setLastName($billingAddress->getLastname())
21
- ->setCompanyName($billingAddress->getCompany())
22
- ->setJobDescription($billingAddress->getJobDescription())
23
- ->setStreet1($billingAddress->getStreet1())
24
- ->setStreet2($billingAddress->getStreet2())
25
- ->setCity($billingAddress->getCity())
26
- ->setState($billingAddress->getRegion())
27
- ->setPostalCode($billingAddress->getPostcode())
28
- ->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
29
- ->setEmail($billingAddress->getEmail())
30
- ->setPhone($billingAddress->getTelephone())
31
- ->setMobile($billingAddress->getMobile())
32
- ->setComments('')
33
- ->setFax($billingAddress->getFax())
34
- ->setUrl('');
35
-
36
- if ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD) {
37
- $customerTokenId = Mage::getSingleton('core/session')->getSavedToken();
38
- if (!$customerTokenId) {
39
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
40
- } elseif (is_numeric($customerTokenId)) {
41
- $customerHelper = Mage::helper('ewayrapid/customer');
42
- $customerTokenId = $customerHelper->getCustomerTokenId($customerTokenId);
43
- if ($customerTokenId) {
44
- $customerParam->setTokenCustomerID($customerTokenId);
45
- } else {
46
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
47
- }
48
- }
49
- }
50
-
51
- $this->setCustomer($customerParam);
52
-
53
- $shippingAddress = $quote->getShippingAddress();
54
-
55
- // copy BillingAddress to ShippingAddress if checkout with guest or register
56
- $checkoutMethod = $quote->getCheckoutMethod();
57
- if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
58
- || $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
59
- ) {
60
- $shippingAddress = $billingAddress;
61
- }
62
-
63
- $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
64
- $shippingParam->setFirstName($shippingAddress->getFirstname())
65
- ->setLastName($shippingAddress->getLastname())
66
- ->setStreet1($shippingAddress->getStreet1())
67
- ->setStreet2($shippingAddress->getStreet2())
68
- ->setCity($shippingAddress->getCity())
69
- ->setState($shippingAddress->getRegion())
70
- ->setPostalCode($shippingAddress->getPostcode())
71
- ->setCountry(strtolower($shippingAddress->getCountryModel()->getIso2Code()))
72
- ->setEmail($shippingAddress->getEmail())
73
- ->setPhone($shippingAddress->getTelephone())
74
- ->setFax($shippingAddress->getFax());
75
- $this->setShippingAddress($shippingParam);
76
-
77
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
78
- $paymentParam->setTotalAmount(round($quote->getBaseGrandTotal() * 100));
79
- if ($method == 'CreateTokenCustomer' || $method == 'UpdateTokenCustomer') {
80
- $paymentParam->setTotalAmount(0);
81
- }
82
- $paymentParam->setCurrencyCode($quote->getBaseCurrencyCode());
83
- $this->setPayment($paymentParam);
84
-
85
- $returnUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/callBack';
86
- $cancelUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/cancel';
87
-
88
- $this->setRedirectUrl($returnUrl);
89
-
90
- //CheckOutUrl if using PayPal
91
- $checkOutUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/review';
92
-
93
- if (Mage::helper('ewayrapid/data')->getTransferCartLineItems()) {
94
- // add Shipping item and Line items
95
- $lineItems = Mage::helper('ewayrapid')->getLineItems();
96
- $this->setItems($lineItems);
97
- }
98
-
99
- /*if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
100
- $this->setItems(false);
101
- }*/
102
-
103
- if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
104
- $this->setCheckoutPayment(true);
105
- $this->setCheckoutURL($checkOutUrl);
106
- $this->setItems(false);
107
- }
108
-
109
- $this->setCancelUrl($cancelUrl);
110
- $this->setMethod($method);
111
- $this->setShippingMethod('Other');
112
- $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
113
- $version = Mage::helper('ewayrapid')->getExtensionVersion();
114
- $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY Official '.$version);
115
- if (Mage::helper('ewayrapid')->isBackendOrder()) {
116
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
117
- } else {
118
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
119
- }
120
- $this->setCustomerReadOnly(true);
121
-
122
- $response = $this->_doRapidAPI($action);
123
- if ($response->isSuccess()) {
124
- return $response;
125
- } else {
126
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
127
- $response->getMessage()));
128
- }
129
- }
130
-
131
- /**
132
- * Get customer information by access code
133
- * @param $accessCode
134
- * @throws Mage_Core_Exception
135
- */
136
- public function getInfoByAccessCode($accessCode)
137
- {
138
- $response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
139
- if ($response->isSuccess()) {
140
- return $response;
141
- } else {
142
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. Please try again. (Error message: %s)',
143
- $response->getMessage()));
144
- return false;
145
- }
146
- }
147
-
148
- public function getTransaction($accessCode)
149
- {
150
- try {
151
- $results = $this->_doRapidAPI("Transaction/$accessCode", 'GET');
152
- if ($results->isSuccess()) {
153
- return $results->getTransactions();
154
- }
155
- } catch (Exception $e) {
156
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
157
- $results->getMessage()));
158
- return false;
159
- }
160
- }
161
-
162
- /**
163
- * Update customer info
164
- * @param $transId
165
- * @return mixed
166
- */
167
- public function updateCustomer($accessCode, Mage_Sales_Model_Quote $quote)
168
- {
169
- try {
170
- $results = $this->_doRapidAPI("Transaction/$accessCode", 'GET');
171
- if (!$results->isSuccess()) {
172
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
173
- $results->getMessage()));
174
- }
175
-
176
- $customer = $quote->getCustomer();
177
- $billingAddress = $quote->getBillingAddress();
178
- $shippingAddress = $quote->getShippingAddress();
179
-
180
- if ($results->isSuccess()) {
181
- $trans = $results->getTransactions();
182
-
183
- if (isset($trans[0]['Customer'])) {
184
- $billing = $trans[0]['Customer'];
185
- $billingAddress->setFirstname($billing['FirstName'])
186
- ->setLastName($billing['LastName'])
187
- ->setCompany($billing['CompanyName'])
188
- ->setJobDescription($billing['JobDescription'])
189
- ->setStreet($billing['Street1'])
190
- ->setStreet2($billing['Street2'])
191
- ->setCity($billing['City'])
192
- ->setState($billing['State'])
193
- ->setPostcode($billing['PostalCode'])
194
- ->setCountryId(strtoupper($billing['Country']))
195
- ->setEmail($billing['Email'])
196
- ->setTelephone($billing['Phone'])
197
- ->setMobile($billing['Mobile'])
198
- ->setComments($billing['Comments'])
199
- ->setFax($billing['Fax'])
200
- ->setUrl($billing['Url']);
201
- }
202
- if (isset($trans[0]['ShippingAddress'])) {
203
- $shipping = $trans[0]['ShippingAddress'];
204
- $shippingAddress->setFirstname($shipping['FirstName'])
205
- ->setLastname($shipping['LastName'])
206
- ->setStreet($shipping['Street1'])
207
- ->setStreet2($shipping['Street2'])
208
- ->setCity($shipping['City'])
209
- ->setPostcode($shipping['PostalCode'])
210
- ->setCountryId(strtoupper($shipping['Country']))
211
- ->setEmail($shipping['Email'])
212
- ->setFax($shipping['Fax']);
213
-
214
- if ($shipping['State']
215
- && $shipping['Country']
216
- && $region = Mage::getModel('directory/region')->loadByCode($shipping['State'], $shipping['Country'])
217
- ) {
218
- $shippingAddress->setRegion($region->getName())
219
- ->setRegionId($region->getId());
220
- }
221
- if ($shipping['Phone']) {
222
- $shippingAddress->setTelephone($shipping['Phone']);
223
- }
224
- }
225
- return $quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress)->save();
226
- }
227
- return false;
228
- } catch (Exception $e) {
229
- Mage::throwException($e->getMessage());
230
- return false;
231
- }
232
- }
233
-
234
- /**
235
- * @param Mage_Sales_Model_Quote $quote
236
- * @param $tokenInfo
237
- * @param $tokenCustomerID
238
- * @return bool
239
- */
240
- public function addToken(Mage_Sales_Model_Quote $quote, $tokenInfo, $tokenCustomerID = 0)
241
- {
242
- try {
243
- if (!$tokenCustomerID)
244
- return false;
245
-
246
- //Get Customer Card Info
247
- $customerCard = $this->getCustomerCard($tokenCustomerID);
248
- $cardetail = null;
249
- if ($customerCard) {
250
- $customer = $customerCard->getCustomer();
251
- $cardetail = $customer && isset($customer['CardDetails']) ? $customer['CardDetails'] : null;
252
- unset($customer);
253
- }
254
-
255
- $billingAddress = $quote->getBillingAddress();
256
- $customerParam = Mage::getModel('ewayrapid/field_customer');
257
- $customerParam->setTitle($billingAddress->getPrefix() ? $billingAddress->getPrefix() : 'Mr')
258
- ->setFirstName($billingAddress->getFirstname())
259
- ->setLastName($billingAddress->getLastname())
260
- ->setCompanyName($billingAddress->getCompany())
261
- ->setJobDescription($billingAddress->getJobDescription())
262
- ->setStreet1($billingAddress->getStreet1())
263
- ->setStreet2($billingAddress->getStreet2())
264
- ->setCity($billingAddress->getCity())
265
- ->setState($billingAddress->getRegion())
266
- ->setPostalCode($billingAddress->getPostcode())
267
- ->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
268
- ->setEmail($billingAddress->getEmail())
269
- ->setPhone($billingAddress->getTelephone())
270
- ->setMobile($billingAddress->getMobile())
271
- ->setComments('')
272
- ->setFax($billingAddress->getFax())
273
- ->setUrl('');
274
- $config = Mage::getSingleton('ewayrapid/config');
275
- $cardNumber = null;
276
-
277
- if ($tokenInfo['SavedType'] == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
278
- $tokenInfo['ccType'] = "PayPal";
279
- $cardNumber = "PayPal";
280
- $tokenInfo['EWAY_CARDNAME'] = "PayPal";
281
- $tokenInfo['EWAY_CARDEXPIRYMONTH'] = $tokenInfo['EWAY_CARDEXPIRYYEAR'] = '';
282
- } elseif ($tokenInfo['SavedType'] == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
283
- //$tokenInfo['ccType'] = "MC";
284
- $cardNumber = $cardetail && isset($cardetail['Number']) ? substr_replace($cardetail['Number'], '******', 6, 6) : "MasterPass";
285
- $cardNumber = substr_replace($cardNumber, '******', 6, 6);
286
- $tokenInfo['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "MasterPass";
287
- $tokenInfo['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : "";
288
- $tokenInfo['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : "";
289
- } else {
290
- $cardNumber = $cardetail && isset($cardetail['Number']) ? $cardetail['Number'] : @Mage::helper('ewayrapid/data')->decryptSha256($tokenInfo['EWAY_CARDNUMBER'], $config->getBasicAuthenticationHeader());
291
- $cardNumber = substr_replace($cardNumber, '******', 6, 6);
292
- $tokenInfo['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "creditcard";
293
- $tokenInfo['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : "";
294
- $tokenInfo['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : "";
295
- }
296
- $type = isset($tokenInfo['ccType']) ? $tokenInfo['ccType'] : $this->checkCardType($cardNumber);
297
- if($type == 'Unknown') {
298
- $type = $tokenInfo['SavedType'] == Eway_Rapid31_Model_Config::MASTERPASS_METHOD ? 'MasterPass' : 'CreditCard';
299
- }
300
-
301
- $tokenInfo['EWAY_CARDEXPIRYYEAR'] = $tokenInfo['EWAY_CARDEXPIRYYEAR'] && strlen($tokenInfo['EWAY_CARDEXPIRYYEAR']) == 2 ? '20' . $tokenInfo['EWAY_CARDEXPIRYYEAR'] : $cardetail['EWAY_CARDEXPIRYYEAR'];
302
- $cardInfo = array(
303
- 'Token' => $tokenCustomerID,
304
- 'TokenCustomerID' => $tokenCustomerID,
305
- 'Card' => $cardNumber,
306
- 'Owner' => $tokenInfo['EWAY_CARDNAME'],
307
- 'StartMonth' => '',
308
- 'StartYear' => '',
309
- 'IssueNumber' => '',
310
- 'ExpMonth' => (int)$tokenInfo['EWAY_CARDEXPIRYMONTH'],
311
- 'ExpYear' => (int)$tokenInfo['EWAY_CARDEXPIRYYEAR'],
312
- 'Type' => $type,
313
- 'Address' => $customerParam,
314
- );
315
-
316
- Mage::helper('ewayrapid/customer')->addToken($cardInfo);
317
- return true;
318
- } catch (Exception $e) {
319
- return false;
320
- }
321
- }
322
-
323
- /**
324
- * @param $id
325
- * @param $info
326
- * @return bool
327
- */
328
- public function updateToken($id, $info = null)
329
- {
330
- try {
331
- //Get Customer Card Info
332
- $customerCard = $this->getCustomerCard($id);
333
- $cardetail = null;
334
- if ($customerCard) {
335
- $customer = $customerCard->getCustomer();
336
- $cardetail = $customer && isset($customer['CardDetails']) ? $customer['CardDetails'] : null;
337
- unset($customer);
338
- }
339
- $cardetail['ExpiryYear'] = $cardetail['ExpiryYear'] && strlen($cardetail['ExpiryYear']) == 2 ? '20' . $cardetail['ExpiryYear'] : $cardetail['ExpiryYear'];
340
-
341
- if ($info['SavedType'] == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
342
- $tokenInfo['EWAY_CARDNAME'] = "PayPal";
343
- } elseif ($info['SavedType'] == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
344
- $info['ccType'] = "MC";
345
- $info['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "MasterPass";
346
- $info['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : "";
347
- $info['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : "";
348
- } else {
349
- $info['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "PayPal";
350
- $info['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : $info['EWAY_CARDEXPIRYMONTH'];
351
- $info['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : $info['EWAY_CARDEXPIRYYEAR'];
352
- }
353
-
354
- $cardInfo = array(
355
- 'Owner' => $info['EWAY_CARDNAME'],
356
- 'StartMonth' => '',
357
- 'StartYear' => '',
358
- 'IssueNumber' => '',
359
- 'ExpMonth' => $info ? (int)$info['EWAY_CARDEXPIRYMONTH'] : '',
360
- 'ExpYear' => $info ? (int)$info['EWAY_CARDEXPIRYYEAR'] : '',
361
- );
362
-
363
- if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
364
- $uid = Mage::getSingleton('core/session')->getPaypalSavedToken();
365
- } elseif ($this->getTransMethod() == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
366
- $uid = Mage::getSingleton('core/session')->getMasterpassSavedToken();
367
- } else {
368
- $uid = Mage::getSingleton('core/session')->getSavedToken();
369
- }
370
-
371
- Mage::helper('ewayrapid/customer')->updateToken($uid, $cardInfo);
372
- return true;
373
- } catch (Exception $e) {
374
- return false;
375
- }
376
- }
377
-
378
- /**
379
- * Get card type name by card number
380
- * @param $num Card number
381
- * @return string Card type name
382
- */
383
- public function checkCardType($num)
384
- {
385
- return Mage::getModel('ewayrapid/request_token')->checkCardType($num);
386
- }
387
-
388
- /**
389
- * @param Mage_Sales_Model_Order_Payment $payment
390
- * @return bool
391
- */
392
- public function setTransaction(Mage_Sales_Model_Order_Payment $payment)
393
- {
394
- $payment->setTransactionId(Mage::getSingleton('core/session')->getTransactionId());
395
- $payment->setIsTransactionClosed(0);
396
- return $payment;
397
- }
398
-
399
- /**
400
- * Get shipping by code
401
- *
402
- * @param Mage_Sales_Model_Quote $quote
403
- * @param $postalCode
404
- * @return bool
405
- */
406
- public function getShippingByCode(Mage_Sales_Model_Quote $quote, $postalCode)
407
- {
408
- $groups = $quote->getShippingAddress()->collectShippingRates()->getGroupedAllShippingRates();
409
- // determine current selected code & name
410
- foreach ($groups as $code => $rates) {
411
- foreach ($rates as $rate) {
412
- if (strtoupper($postalCode) == strtoupper($rate->getCode())) {
413
- return $rate;
414
- }
415
- }
416
- }
417
- return false;
418
- }
419
-
420
- /**
421
- * Call Transaction API (Authorized & Capture at the same time)
422
- *
423
- * @param Mage_Sales_Model_Order_Payment $payment
424
- * @param float $amount
425
- * @return Eway_Rapid31_Model_Request_Direct $this
426
- */
427
- public function doTransaction(Mage_Sales_Model_Quote $quote, $amount)
428
- {
429
- $this->_buildRequest($quote, $amount);
430
- $this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
431
- $response = $this->_doRapidAPI('Transaction');
432
-
433
- if ($response->isSuccess()) {
434
- $quote->setTransactionId($response->getTransactionID());
435
- $quote->setCcLast4($response->getCcLast4());
436
- $quote->save();
437
- return $quote;
438
- } else {
439
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. Please try again. (Error message: %s)',
440
- $response->getMessage()));
441
- }
442
- }
443
-
444
- /**
445
- * Call Authorisation API (Authorized only)
446
- *
447
- * @param Mage_Sales_Model_Order_Payment $payment
448
- * @param $amount
449
- * @return Eway_Rapid31_Model_Request_Direct
450
- */
451
- public function doAuthorisation(Mage_Sales_Model_Quote $quote, $amount)
452
- {
453
- $this->_buildRequest($quote, $amount);
454
- $this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
455
- $response = $this->_doRapidAPI('Authorisation');
456
- if ($response->isSuccess()) {
457
- $quote->setTransactionId($response->getTransactionID());
458
- $quote->setIsTransactionClosed(0);
459
- $quote->setCcLast4($response->getCcLast4());
460
- $quote->save();
461
- return $quote;
462
- } else {
463
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the authorisation. Please try again. (Error message: %s)',
464
- $response->getMessage()));
465
- }
466
- }
467
-
468
- /**
469
- * Call Capture API (do the Capture only, must Authorized previously)
470
- *
471
- * @param Mage_Sales_Model_Order_Payment $payment
472
- * @param $amount
473
- * @return Eway_Rapid31_Model_Request_Direct
474
- */
475
- public function doCapturePayment(Mage_Sales_Model_Quote $quote, $amount)
476
- {
477
- // Empty Varien_Object's data
478
- $this->unsetData();
479
-
480
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
481
- $paymentParam->setTotalAmount($amount)
482
- ->setCurrencyCode($quote->getBaseCurrencyCode());
483
-
484
- $this->setPayment($paymentParam);
485
- $this->setTransactionId($quote->getTransactionId());
486
- $this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
487
- $response = $this->_doRapidAPI('CapturePayment');
488
-
489
- if ($response->isSuccess()) {
490
- $quote->setTransactionId($response->getTransactionID());
491
- $quote->save();
492
- return $quote;
493
- } else {
494
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the capture. Please try again. (Error message: %s)',
495
- $response->getMessage()));
496
- }
497
- }
498
-
499
- /**
500
- * Build the request with necessary parameters for doAuthorisation() and doTransaction()
501
- *
502
- * @param Mage_Sales_Model_Order_Payment $payment
503
- * @param $amount
504
- * @return Eway_Rapid31_Model_Request_Direct
505
- */
506
- protected function _buildRequest(Mage_Sales_Model_Quote $quote, $amount)
507
- {
508
- // Empty Varien_Object's data
509
- $this->unsetData();
510
-
511
- $billing = $quote->getBillingAddress();
512
- $shipping = $quote->getShippingAddress();
513
-
514
- // copy BillingAddress to ShippingAddress if checkout with guest or register
515
- $checkoutMethod = $quote->getCheckoutMethod();
516
- if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
517
- || $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
518
- ) {
519
- $shipping = $billing;
520
- }
521
-
522
- $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
523
- if (Mage::helper('ewayrapid')->isBackendOrder()) {
524
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
525
- } else {
526
- $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
527
- }
528
- $version = Mage::helper('ewayrapid')->getExtensionVersion();
529
- $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY Official '.$version);
530
- $this->setShippingMethod('Other');
531
-
532
- $paymentParam = Mage::getModel('ewayrapid/field_payment');
533
- $paymentParam->setTotalAmount($amount);
534
- $paymentParam->setCurrencyCode($quote->getBaseCurrencyCode());
535
- $this->setPayment($paymentParam);
536
-
537
- $customerParam = Mage::getModel('ewayrapid/field_customer');
538
- $customerParam->setTitle($billing->getPrefix())
539
- ->setFirstName($billing->getFirstname())
540
- ->setLastName($billing->getLastname())
541
- ->setCompanyName($billing->getCompany())
542
- ->setJobDescription('')
543
- ->setStreet1($billing->getStreet1())
544
- ->setStreet2($billing->getStreet2())
545
- ->setCity($billing->getCity())
546
- ->setState($billing->getRegion())
547
- ->setPostalCode($billing->getPostcode())
548
- ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
549
- ->setEmail($billing->getEmail())
550
- ->setPhone($billing->getTelephone())
551
- ->setMobile('')
552
- ->setComments('')
553
- ->setFax($billing->getFax())
554
- ->setUrl('');
555
-
556
- $infoCard = Mage::getSingleton('core/session')->getInfoCard();
557
- if ($infoCard && $infoCard->getCard() && $infoCard->getOwner() && !$this->getTokenInfo()) {
558
- $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
559
- $cardDetails->setName($infoCard->getOwner())
560
- ->setNumber($infoCard->getCard())
561
- ->setExpiryMonth($infoCard->getExpMonth())
562
- ->setExpiryYear($infoCard->getExpYear())
563
- ->setCVN($infoCard->getCid());
564
- $customerParam->setCardDetails($cardDetails);
565
- }
566
-
567
- if ($quote->getTokenCustomerID()) {
568
- $customerParam->setTokenCustomerID($quote->getTokenCustomerID());
569
- } elseif ($token = $this->getTokenInfo()) {
570
- $customerParam->setTokenCustomerID($token->getToken() ? $token->getToken() : $token->getTokenCustomerID());
571
- }
572
-
573
- $this->setCustomer($customerParam);
574
-
575
- $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
576
- $shippingParam->setFirstName($shipping->getFirstname())
577
- ->setLastName($shipping->getLastname())
578
- ->setStreet1($shipping->getStreet1())
579
- ->setStreet2($shipping->getStreet2())
580
- ->setCity($shipping->getCity())
581
- ->setState($shipping->getRegion())
582
- ->setPostalCode($shipping->getPostcode())
583
- ->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))
584
- ->setEmail($shipping->getEmail())
585
- ->setPhone($shipping->getTelephone())
586
- ->setFax($shipping->getFax());
587
- $this->setShippingAddress($shippingParam);
588
-
589
- $orderItems = $quote->getAllVisibleItems();
590
- $lineItems = array();
591
- foreach ($orderItems as $orderItem) {
592
- /* @var Mage_Sales_Model_Order_Item $orderItem */
593
- $lineItem = Mage::getModel('ewayrapid/field_lineItem');
594
- $lineItem->setSKU($orderItem->getSku());
595
- $lineItem->setDescription(substr($orderItem->getName(), 0, 26));
596
- $lineItem->setQuantity($orderItem->getQtyOrdered());
597
- $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
598
- $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
599
- $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
600
- $lineItems[] = $lineItem;
601
- }
602
- $this->setItems($lineItems);
603
- if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
604
- $this->setItems(false);
605
- }
606
-
607
- return $this;
608
- }
609
-
610
- /**
611
- * @param $tokenCustomerID
612
- * @throws Mage_Core_Exception
613
- */
614
- public function getCustomerCard($tokenCustomerID)
615
- {
616
- // Empty Varien_Object's data
617
- $this->unsetData();
618
-
619
- $customerParam = Mage::getModel('ewayrapid/field_customer');
620
-
621
- if ($tokenCustomerID) {
622
- $customerParam->setTokenCustomerID($tokenCustomerID);
623
- } else {
624
- Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
625
- }
626
- $this->setCustomer($customerParam);
627
-
628
- $response = $this->_doRapidAPI('Customer', 'PUT');
629
- if ($response->isSuccess()) {
630
- return $response;
631
- } else {
632
- return false;
633
- }
634
- }
635
-
636
- public function getMethod()
637
- {
638
- return Mage::getSingleton('core/session')->getMethod();
639
- }
640
-
641
- /**
642
- * @return mixed
643
- */
644
- public function getTransMethod()
645
- {
646
- $transMethod = Mage::getSingleton('core/session')->getTransparentNotsaved();
647
- if (!$transMethod) {
648
- $transMethod = Mage::getSingleton('core/session')->getTransparentSaved();
649
- }
650
- return $transMethod;
651
- }
652
-
653
- /**
654
- * @return mixed
655
- */
656
- public function getTokenInfo()
657
- {
658
- if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
659
- $uid = Mage::getSingleton('core/session')->getPaypalSavedToken();
660
- } elseif ($this->getTransMethod() == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
661
- $uid = Mage::getSingleton('core/session')->getMasterpassSavedToken();
662
- } else {
663
- $uid = Mage::getSingleton('core/session')->getSavedToken();
664
- }
665
- if ($uid && $uid != Eway_Rapid31_Model_Config::TOKEN_NEW)
666
- return Mage::helper('ewayrapid/customer')->getTokenById($uid);
667
- return false;
668
- }
669
-
670
- /**
671
- *
672
- */
673
- public function unsetSessionData()
674
- {
675
- Mage::getSingleton('core/session')->unsTransparentNotsaved();
676
- Mage::getSingleton('core/session')->unsTransparentSaved();
677
- Mage::getSingleton('core/session')->unsSavedToken();
678
- Mage::getSingleton('core/session')->unsTransactionId();
679
- Mage::getSingleton('core/session')->unsFormActionUrl();
680
- Mage::getSingleton('core/session')->unsPaypalSavedToken();
681
- Mage::getSingleton('core/session')->unsMethod();
682
- Mage::getSingleton('core/session')->unsCompleteCheckoutURL();
683
- Mage::getSingleton('core/session')->unsMasterPassSavedToken();
684
- Mage::getSingleton('core/session')->unsInfoCard();
685
- }
 
 
 
 
 
 
 
 
686
  }
1
+ <?php
2
+
3
+ class Eway_Rapid31_Model_Request_Transparent extends Eway_Rapid31_Model_Request_Abstract
4
+ {
5
+ /**
6
+ * Get AccessCode
7
+ *
8
+ * @param Mage_Sales_Model_Quote $quote
9
+ * @return Eway_Rapid31_Model_Response
10
+ */
11
+ public function createAccessCode(Mage_Sales_Model_Quote $quote, $method = 'ProcessPayment', $action = 'AccessCodes')
12
+ {
13
+ // Empty Varien_Object's data
14
+ $this->unsetData();
15
+
16
+ $billingAddress = $quote->getBillingAddress();
17
+
18
+ $title = $this->_fixTitle($billingAddress->getPrefix());
19
+
20
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
21
+ $customerParam->setTitle($title)
22
+ ->setFirstName($billingAddress->getFirstname())
23
+ ->setLastName($billingAddress->getLastname())
24
+ ->setCompanyName($billingAddress->getCompany())
25
+ ->setJobDescription($billingAddress->getJobDescription())
26
+ ->setStreet1($billingAddress->getStreet1())
27
+ ->setStreet2($billingAddress->getStreet2())
28
+ ->setCity($billingAddress->getCity())
29
+ ->setState($billingAddress->getRegion())
30
+ ->setPostalCode($billingAddress->getPostcode())
31
+ ->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
32
+ ->setEmail($billingAddress->getEmail())
33
+ ->setPhone($billingAddress->getTelephone())
34
+ ->setMobile($billingAddress->getMobile())
35
+ ->setComments('')
36
+ ->setFax($billingAddress->getFax())
37
+ ->setUrl('');
38
+
39
+ if ($this->getMethod() == Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD) {
40
+ $customerTokenId = Mage::getSingleton('core/session')->getSavedToken();
41
+ if (!$customerTokenId) {
42
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
43
+ } elseif (is_numeric($customerTokenId)) {
44
+ $customerHelper = Mage::helper('ewayrapid/customer');
45
+ $customerTokenId = $customerHelper->getCustomerTokenId($customerTokenId);
46
+ if ($customerTokenId) {
47
+ $customerParam->setTokenCustomerID($customerTokenId);
48
+ } else {
49
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
50
+ }
51
+ }
52
+ }
53
+
54
+ $this->setCustomer($customerParam);
55
+
56
+ $shippingAddress = $quote->getShippingAddress();
57
+
58
+ // copy BillingAddress to ShippingAddress if checkout with guest or register
59
+ $checkoutMethod = $quote->getCheckoutMethod();
60
+ if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
61
+ || $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
62
+ ) {
63
+ $shippingAddress = $billingAddress;
64
+ }
65
+
66
+ $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
67
+ $shippingParam->setFirstName($shippingAddress->getFirstname())
68
+ ->setLastName($shippingAddress->getLastname())
69
+ ->setStreet1($shippingAddress->getStreet1())
70
+ ->setStreet2($shippingAddress->getStreet2())
71
+ ->setCity($shippingAddress->getCity())
72
+ ->setState($shippingAddress->getRegion())
73
+ ->setPostalCode($shippingAddress->getPostcode())
74
+ ->setCountry(strtolower($shippingAddress->getCountryModel()->getIso2Code()))
75
+ ->setEmail($shippingAddress->getEmail())
76
+ ->setPhone($shippingAddress->getTelephone())
77
+ ->setFax($shippingAddress->getFax());
78
+ $this->setShippingAddress($shippingParam);
79
+
80
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
81
+ $paymentParam->setTotalAmount(round($quote->getBaseGrandTotal() * 100));
82
+ if ($method == 'CreateTokenCustomer' || $method == 'UpdateTokenCustomer') {
83
+ $paymentParam->setTotalAmount(0);
84
+ }
85
+ $paymentParam->setCurrencyCode($quote->getBaseCurrencyCode());
86
+ $this->setPayment($paymentParam);
87
+
88
+ $returnUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/callBack';
89
+ $cancelUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/cancel';
90
+
91
+ $this->setRedirectUrl($returnUrl);
92
+
93
+ //CheckOutUrl if using PayPal
94
+ $checkOutUrl = Mage::getBaseUrl() . '/ewayrapid/transparent/review';
95
+
96
+ if (Mage::helper('ewayrapid/data')->getTransferCartLineItems()) {
97
+ // add Shipping item and Line items
98
+ $lineItems = Mage::helper('ewayrapid')->getLineItems();
99
+ $this->setItems($lineItems);
100
+ }
101
+
102
+ /*if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
103
+ $this->setItems(false);
104
+ }*/
105
+
106
+ if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD) {
107
+ $this->setCheckoutPayment(true);
108
+ $this->setCheckoutURL($checkOutUrl);
109
+ $this->setItems(false);
110
+ }
111
+
112
+ $this->setCancelUrl($cancelUrl);
113
+ $this->setMethod($method);
114
+ $this->setShippingMethod('Other');
115
+ $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
116
+ $version = Mage::helper('ewayrapid')->getExtensionVersion();
117
+ $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
118
+ if (Mage::helper('ewayrapid')->isBackendOrder()) {
119
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
120
+ } else {
121
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
122
+ }
123
+ $this->setCustomerReadOnly(true);
124
+
125
+ $response = $this->_doRapidAPI($action);
126
+ if ($response->isSuccess()) {
127
+ return $response;
128
+ } else {
129
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
130
+ $response->getMessage()));
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Get customer information by access code
136
+ * @param $accessCode
137
+ * @throws Mage_Core_Exception
138
+ */
139
+ public function getInfoByAccessCode($accessCode)
140
+ {
141
+ $response = $this->_doRapidAPI('AccessCode/' . $accessCode, false);
142
+ if ($response->isSuccess()) {
143
+ return $response;
144
+ } else {
145
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. Please try again. (Error message: %s)',
146
+ $response->getMessage()));
147
+ return false;
148
+ }
149
+ }
150
+
151
+ public function getTransaction($accessCode)
152
+ {
153
+ try {
154
+ $results = $this->_doRapidAPI("Transaction/$accessCode", 'GET');
155
+ if ($results->isSuccess()) {
156
+ return $results->getTransactions();
157
+ }
158
+ } catch (Exception $e) {
159
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
160
+ $results->getMessage()));
161
+ return false;
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Update customer info
167
+ * @param $transId
168
+ * @return mixed
169
+ */
170
+ public function updateCustomer($accessCode, Mage_Sales_Model_Quote $quote)
171
+ {
172
+ try {
173
+ $results = $this->_doRapidAPI("Transaction/$accessCode", 'GET');
174
+ if (!$results->isSuccess()) {
175
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: %s)',
176
+ $results->getMessage()));
177
+ }
178
+
179
+ $customer = $quote->getCustomer();
180
+ $billingAddress = $quote->getBillingAddress();
181
+ $shippingAddress = $quote->getShippingAddress();
182
+
183
+ if ($results->isSuccess()) {
184
+ $trans = $results->getTransactions();
185
+
186
+ if (isset($trans[0]['Customer'])) {
187
+ $billing = $trans[0]['Customer'];
188
+ $billingAddress->setFirstname($billing['FirstName'])
189
+ ->setLastName($billing['LastName'])
190
+ ->setCompany($billing['CompanyName'])
191
+ ->setJobDescription($billing['JobDescription'])
192
+ ->setStreet($billing['Street1'])
193
+ ->setStreet2($billing['Street2'])
194
+ ->setCity($billing['City'])
195
+ ->setState($billing['State'])
196
+ ->setPostcode($billing['PostalCode'])
197
+ ->setCountryId(strtoupper($billing['Country']))
198
+ ->setEmail($billing['Email'])
199
+ ->setTelephone($billing['Phone'])
200
+ ->setMobile($billing['Mobile'])
201
+ ->setComments($billing['Comments'])
202
+ ->setFax($billing['Fax'])
203
+ ->setUrl($billing['Url']);
204
+ }
205
+ if (isset($trans[0]['ShippingAddress'])) {
206
+ $shipping = $trans[0]['ShippingAddress'];
207
+ $shippingAddress->setFirstname($shipping['FirstName'])
208
+ ->setLastname($shipping['LastName'])
209
+ ->setStreet($shipping['Street1'])
210
+ ->setStreet2($shipping['Street2'])
211
+ ->setCity($shipping['City'])
212
+ ->setPostcode($shipping['PostalCode'])
213
+ ->setCountryId(strtoupper($shipping['Country']))
214
+ ->setEmail($shipping['Email'])
215
+ ->setFax($shipping['Fax']);
216
+
217
+ if ($shipping['State']
218
+ && $shipping['Country']
219
+ && $region = Mage::getModel('directory/region')->loadByCode($shipping['State'], $shipping['Country'])
220
+ ) {
221
+ $shippingAddress->setRegion($region->getName())
222
+ ->setRegionId($region->getId());
223
+ }
224
+ if ($shipping['Phone']) {
225
+ $shippingAddress->setTelephone($shipping['Phone']);
226
+ }
227
+ }
228
+ return $quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress)->save();
229
+ }
230
+ return false;
231
+ } catch (Exception $e) {
232
+ Mage::throwException($e->getMessage());
233
+ return false;
234
+ }
235
+ }
236
+
237
+ /**
238
+ * @param Mage_Sales_Model_Quote $quote
239
+ * @param $tokenInfo
240
+ * @param $tokenCustomerID
241
+ * @return bool
242
+ */
243
+ public function addToken(Mage_Sales_Model_Quote $quote, $tokenInfo, $tokenCustomerID = 0)
244
+ {
245
+ try {
246
+ if (!$tokenCustomerID)
247
+ return false;
248
+
249
+ //Get Customer Card Info
250
+ $customerCard = $this->getCustomerCard($tokenCustomerID);
251
+ $cardetail = null;
252
+ if ($customerCard) {
253
+ $customer = $customerCard->getCustomer();
254
+ $cardetail = $customer && isset($customer['CardDetails']) ? $customer['CardDetails'] : null;
255
+ unset($customer);
256
+ }
257
+
258
+ $billingAddress = $quote->getBillingAddress();
259
+
260
+ $title = $this->_fixTitle($billingAddress->getPrefix());
261
+
262
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
263
+ $customerParam->setTitle($title)
264
+ ->setFirstName($billingAddress->getFirstname())
265
+ ->setLastName($billingAddress->getLastname())
266
+ ->setCompanyName($billingAddress->getCompany())
267
+ ->setJobDescription($billingAddress->getJobDescription())
268
+ ->setStreet1($billingAddress->getStreet1())
269
+ ->setStreet2($billingAddress->getStreet2())
270
+ ->setCity($billingAddress->getCity())
271
+ ->setState($billingAddress->getRegion())
272
+ ->setPostalCode($billingAddress->getPostcode())
273
+ ->setCountry(strtolower($billingAddress->getCountryModel()->getIso2Code()))
274
+ ->setEmail($billingAddress->getEmail())
275
+ ->setPhone($billingAddress->getTelephone())
276
+ ->setMobile($billingAddress->getMobile())
277
+ ->setComments('')
278
+ ->setFax($billingAddress->getFax())
279
+ ->setUrl('');
280
+ $config = Mage::getSingleton('ewayrapid/config');
281
+ $cardNumber = null;
282
+
283
+ if ($tokenInfo['SavedType'] == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
284
+ $tokenInfo['ccType'] = "PayPal";
285
+ $cardNumber = "PayPal";
286
+ $tokenInfo['EWAY_CARDNAME'] = "PayPal";
287
+ $tokenInfo['EWAY_CARDEXPIRYMONTH'] = $tokenInfo['EWAY_CARDEXPIRYYEAR'] = '';
288
+ } elseif ($tokenInfo['SavedType'] == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
289
+ //$tokenInfo['ccType'] = "MC";
290
+ $cardNumber = $cardetail && isset($cardetail['Number']) ? substr_replace($cardetail['Number'], '******', 6, 6) : "MasterPass";
291
+ $cardNumber = substr_replace($cardNumber, '******', 6, 6);
292
+ $tokenInfo['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "MasterPass";
293
+ $tokenInfo['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : "";
294
+ $tokenInfo['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : "";
295
+ } else {
296
+ $cardNumber = $cardetail && isset($cardetail['Number']) ? $cardetail['Number'] : @Mage::helper('ewayrapid/data')->decryptSha256($tokenInfo['EWAY_CARDNUMBER'], $config->getBasicAuthenticationHeader());
297
+ $cardNumber = substr_replace($cardNumber, '******', 6, 6);
298
+ $tokenInfo['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "creditcard";
299
+ $tokenInfo['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : "";
300
+ $tokenInfo['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : "";
301
+ }
302
+ $type = isset($tokenInfo['ccType']) ? $tokenInfo['ccType'] : $this->checkCardType($cardNumber);
303
+ if($type == 'Unknown') {
304
+ $type = $tokenInfo['SavedType'] == Eway_Rapid31_Model_Config::MASTERPASS_METHOD ? 'MasterPass' : 'CreditCard';
305
+ }
306
+
307
+ $tokenInfo['EWAY_CARDEXPIRYYEAR'] = $tokenInfo['EWAY_CARDEXPIRYYEAR'] && strlen($tokenInfo['EWAY_CARDEXPIRYYEAR']) == 2 ? '20' . $tokenInfo['EWAY_CARDEXPIRYYEAR'] : $cardetail['EWAY_CARDEXPIRYYEAR'];
308
+ $cardInfo = array(
309
+ 'Token' => $tokenCustomerID,
310
+ 'TokenCustomerID' => $tokenCustomerID,
311
+ 'Card' => $cardNumber,
312
+ 'Owner' => $tokenInfo['EWAY_CARDNAME'],
313
+ 'StartMonth' => '',
314
+ 'StartYear' => '',
315
+ 'IssueNumber' => '',
316
+ 'ExpMonth' => (int)$tokenInfo['EWAY_CARDEXPIRYMONTH'],
317
+ 'ExpYear' => (int)$tokenInfo['EWAY_CARDEXPIRYYEAR'],
318
+ 'Type' => $type,
319
+ 'Address' => $customerParam,
320
+ );
321
+
322
+ Mage::helper('ewayrapid/customer')->addToken($cardInfo);
323
+ return true;
324
+ } catch (Exception $e) {
325
+ return false;
326
+ }
327
+ }
328
+
329
+ /**
330
+ * @param $id
331
+ * @param $info
332
+ * @return bool
333
+ */
334
+ public function updateToken($id, $info = null)
335
+ {
336
+ try {
337
+ //Get Customer Card Info
338
+ $customerCard = $this->getCustomerCard($id);
339
+ $cardetail = null;
340
+ if ($customerCard) {
341
+ $customer = $customerCard->getCustomer();
342
+ $cardetail = $customer && isset($customer['CardDetails']) ? $customer['CardDetails'] : null;
343
+ unset($customer);
344
+ }
345
+ $cardetail['ExpiryYear'] = $cardetail['ExpiryYear'] && strlen($cardetail['ExpiryYear']) == 2 ? '20' . $cardetail['ExpiryYear'] : $cardetail['ExpiryYear'];
346
+
347
+ if ($info['SavedType'] == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
348
+ $tokenInfo['EWAY_CARDNAME'] = "PayPal";
349
+ } elseif ($info['SavedType'] == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
350
+ $info['ccType'] = "MC";
351
+ $info['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "MasterPass";
352
+ $info['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : "";
353
+ $info['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : "";
354
+ } else {
355
+ $info['EWAY_CARDNAME'] = $cardetail && isset($cardetail['Name']) ? $cardetail['Name'] : "PayPal";
356
+ $info['EWAY_CARDEXPIRYMONTH'] = $cardetail && isset($cardetail['ExpiryMonth']) ? $cardetail['ExpiryMonth'] : $info['EWAY_CARDEXPIRYMONTH'];
357
+ $info['EWAY_CARDEXPIRYYEAR'] = $cardetail && isset($cardetail['ExpiryYear']) ? $cardetail['ExpiryYear'] : $info['EWAY_CARDEXPIRYYEAR'];
358
+ }
359
+
360
+ $cardInfo = array(
361
+ 'Owner' => $info['EWAY_CARDNAME'],
362
+ 'StartMonth' => '',
363
+ 'StartYear' => '',
364
+ 'IssueNumber' => '',
365
+ 'ExpMonth' => $info ? (int)$info['EWAY_CARDEXPIRYMONTH'] : '',
366
+ 'ExpYear' => $info ? (int)$info['EWAY_CARDEXPIRYYEAR'] : '',
367
+ );
368
+
369
+ if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
370
+ $uid = Mage::getSingleton('core/session')->getPaypalSavedToken();
371
+ } elseif ($this->getTransMethod() == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
372
+ $uid = Mage::getSingleton('core/session')->getMasterpassSavedToken();
373
+ } else {
374
+ $uid = Mage::getSingleton('core/session')->getSavedToken();
375
+ }
376
+
377
+ Mage::helper('ewayrapid/customer')->updateToken($uid, $cardInfo);
378
+ return true;
379
+ } catch (Exception $e) {
380
+ return false;
381
+ }
382
+ }
383
+
384
+ /**
385
+ * Get card type name by card number
386
+ * @param $num Card number
387
+ * @return string Card type name
388
+ */
389
+ public function checkCardType($num)
390
+ {
391
+ return Mage::getModel('ewayrapid/request_token')->checkCardType($num);
392
+ }
393
+
394
+ /**
395
+ * @param Mage_Sales_Model_Order_Payment $payment
396
+ * @return bool
397
+ */
398
+ public function setTransaction(Mage_Sales_Model_Order_Payment $payment)
399
+ {
400
+ $payment->setTransactionId(Mage::getSingleton('core/session')->getTransactionId());
401
+ $payment->setIsTransactionClosed(0);
402
+ return $payment;
403
+ }
404
+
405
+ /**
406
+ * Get shipping by code
407
+ *
408
+ * @param Mage_Sales_Model_Quote $quote
409
+ * @param $postalCode
410
+ * @return bool
411
+ */
412
+ public function getShippingByCode(Mage_Sales_Model_Quote $quote, $postalCode)
413
+ {
414
+ $groups = $quote->getShippingAddress()->collectShippingRates()->getGroupedAllShippingRates();
415
+ // determine current selected code & name
416
+ foreach ($groups as $code => $rates) {
417
+ foreach ($rates as $rate) {
418
+ if (strtoupper($postalCode) == strtoupper($rate->getCode())) {
419
+ return $rate;
420
+ }
421
+ }
422
+ }
423
+ return false;
424
+ }
425
+
426
+ /**
427
+ * Call Transaction API (Authorized & Capture at the same time)
428
+ *
429
+ * @param Mage_Sales_Model_Order_Payment $payment
430
+ * @param float $amount
431
+ * @return Eway_Rapid31_Model_Request_Direct $this
432
+ */
433
+ public function doTransaction(Mage_Sales_Model_Quote $quote, $amount)
434
+ {
435
+ $this->_buildRequest($quote, $amount);
436
+ $this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
437
+ $response = $this->_doRapidAPI('Transaction');
438
+
439
+ if ($response->isSuccess()) {
440
+ $quote->setTransactionId($response->getTransactionID());
441
+ $quote->setCcLast4($response->getCcLast4());
442
+ $quote->save();
443
+ return $quote;
444
+ } else {
445
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. Please try again. (Error message: %s)',
446
+ $response->getMessage()));
447
+ }
448
+ }
449
+
450
+ /**
451
+ * Call Authorisation API (Authorized only)
452
+ *
453
+ * @param Mage_Sales_Model_Order_Payment $payment
454
+ * @param $amount
455
+ * @return Eway_Rapid31_Model_Request_Direct
456
+ */
457
+ public function doAuthorisation(Mage_Sales_Model_Quote $quote, $amount)
458
+ {
459
+ $this->_buildRequest($quote, $amount);
460
+ $this->setMethod(Eway_Rapid31_Model_Config::METHOD_AUTHORISE);
461
+ $response = $this->_doRapidAPI('Authorisation');
462
+ if ($response->isSuccess()) {
463
+ $quote->setTransactionId($response->getTransactionID());
464
+ $quote->setIsTransactionClosed(0);
465
+ $quote->setCcLast4($response->getCcLast4());
466
+ $quote->save();
467
+ return $quote;
468
+ } else {
469
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the authorisation. Please try again. (Error message: %s)',
470
+ $response->getMessage()));
471
+ }
472
+ }
473
+
474
+ /**
475
+ * Call Capture API (do the Capture only, must Authorized previously)
476
+ *
477
+ * @param Mage_Sales_Model_Order_Payment $payment
478
+ * @param $amount
479
+ * @return Eway_Rapid31_Model_Request_Direct
480
+ */
481
+ public function doCapturePayment(Mage_Sales_Model_Quote $quote, $amount)
482
+ {
483
+ // Empty Varien_Object's data
484
+ $this->unsetData();
485
+
486
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
487
+ $paymentParam->setTotalAmount($amount)
488
+ ->setCurrencyCode($quote->getBaseCurrencyCode());
489
+
490
+ $this->setPayment($paymentParam);
491
+ $this->setTransactionId($quote->getTransactionId());
492
+ $this->setMethod(Eway_Rapid31_Model_Config::METHOD_TOKEN_PAYMENT);
493
+ $response = $this->_doRapidAPI('CapturePayment');
494
+
495
+ if ($response->isSuccess()) {
496
+ $quote->setTransactionId($response->getTransactionID());
497
+ $quote->save();
498
+ return $quote;
499
+ } else {
500
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the capture. Please try again. (Error message: %s)',
501
+ $response->getMessage()));
502
+ }
503
+ }
504
+
505
+ /**
506
+ * Build the request with necessary parameters for doAuthorisation() and doTransaction()
507
+ *
508
+ * @param Mage_Sales_Model_Order_Payment $payment
509
+ * @param $amount
510
+ * @return Eway_Rapid31_Model_Request_Direct
511
+ */
512
+ protected function _buildRequest(Mage_Sales_Model_Quote $quote, $amount)
513
+ {
514
+ // Empty Varien_Object's data
515
+ $this->unsetData();
516
+
517
+ $billing = $quote->getBillingAddress();
518
+ $shipping = $quote->getShippingAddress();
519
+
520
+ // copy BillingAddress to ShippingAddress if checkout with guest or register
521
+ $checkoutMethod = $quote->getCheckoutMethod();
522
+ if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
523
+ || $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
524
+ ) {
525
+ $shipping = $billing;
526
+ }
527
+
528
+ $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
529
+ if (Mage::helper('ewayrapid')->isBackendOrder()) {
530
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
531
+ } else {
532
+ $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
533
+ }
534
+ $version = Mage::helper('ewayrapid')->getExtensionVersion();
535
+ $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion().' - eWAY '.$version);
536
+ $this->setShippingMethod('Other');
537
+
538
+ $paymentParam = Mage::getModel('ewayrapid/field_payment');
539
+ $paymentParam->setTotalAmount($amount);
540
+ $paymentParam->setCurrencyCode($quote->getBaseCurrencyCode());
541
+ $this->setPayment($paymentParam);
542
+
543
+ $title = $this->_fixTitle($billing->getPrefix());
544
+
545
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
546
+ $customerParam->setTitle($title)
547
+ ->setFirstName($billing->getFirstname())
548
+ ->setLastName($billing->getLastname())
549
+ ->setCompanyName($billing->getCompany())
550
+ ->setJobDescription('')
551
+ ->setStreet1($billing->getStreet1())
552
+ ->setStreet2($billing->getStreet2())
553
+ ->setCity($billing->getCity())
554
+ ->setState($billing->getRegion())
555
+ ->setPostalCode($billing->getPostcode())
556
+ ->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))
557
+ ->setEmail($billing->getEmail())
558
+ ->setPhone($billing->getTelephone())
559
+ ->setMobile('')
560
+ ->setComments('')
561
+ ->setFax($billing->getFax())
562
+ ->setUrl('');
563
+
564
+ $infoCard = Mage::getSingleton('core/session')->getInfoCard();
565
+ if ($infoCard && $infoCard->getCard() && $infoCard->getOwner() && !$this->getTokenInfo()) {
566
+ $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
567
+ $cardDetails->setName($infoCard->getOwner())
568
+ ->setNumber($infoCard->getCard())
569
+ ->setExpiryMonth($infoCard->getExpMonth())
570
+ ->setExpiryYear($infoCard->getExpYear())
571
+ ->setCVN($infoCard->getCid());
572
+ $customerParam->setCardDetails($cardDetails);
573
+ }
574
+
575
+ if ($quote->getTokenCustomerID()) {
576
+ $customerParam->setTokenCustomerID($quote->getTokenCustomerID());
577
+ } elseif ($token = $this->getTokenInfo()) {
578
+ $customerParam->setTokenCustomerID($token->getToken() ? $token->getToken() : $token->getTokenCustomerID());
579
+ }
580
+
581
+ $this->setCustomer($customerParam);
582
+
583
+ $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
584
+ $shippingParam->setFirstName($shipping->getFirstname())
585
+ ->setLastName($shipping->getLastname())
586
+ ->setStreet1($shipping->getStreet1())
587
+ ->setStreet2($shipping->getStreet2())
588
+ ->setCity($shipping->getCity())
589
+ ->setState($shipping->getRegion())
590
+ ->setPostalCode($shipping->getPostcode())
591
+ ->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))
592
+ ->setEmail($shipping->getEmail())
593
+ ->setPhone($shipping->getTelephone())
594
+ ->setFax($shipping->getFax());
595
+ $this->setShippingAddress($shippingParam);
596
+
597
+ $orderItems = $quote->getAllVisibleItems();
598
+ $lineItems = array();
599
+ foreach ($orderItems as $orderItem) {
600
+ /* @var Mage_Sales_Model_Order_Item $orderItem */
601
+ $lineItem = Mage::getModel('ewayrapid/field_lineItem');
602
+ $lineItem->setSKU($orderItem->getSku());
603
+ $lineItem->setDescription(substr($orderItem->getName(), 0, 26));
604
+ $lineItem->setQuantity($orderItem->getQtyOrdered());
605
+ $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
606
+ $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
607
+ $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
608
+ $lineItems[] = $lineItem;
609
+ }
610
+ $this->setItems($lineItems);
611
+ if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
612
+ $this->setItems(false);
613
+ }
614
+
615
+ return $this;
616
+ }
617
+
618
+ /**
619
+ * @param $tokenCustomerID
620
+ * @throws Mage_Core_Exception
621
+ */
622
+ public function getCustomerCard($tokenCustomerID)
623
+ {
624
+ // Empty Varien_Object's data
625
+ $this->unsetData();
626
+
627
+ $customerParam = Mage::getModel('ewayrapid/field_customer');
628
+
629
+ if ($tokenCustomerID) {
630
+ $customerParam->setTokenCustomerID($tokenCustomerID);
631
+ } else {
632
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while updating token: Token info does not exist.'));
633
+ }
634
+ $this->setCustomer($customerParam);
635
+
636
+ $response = $this->_doRapidAPI('Customer', 'PUT');
637
+ if ($response->isSuccess()) {
638
+ return $response;
639
+ } else {
640
+ return false;
641
+ }
642
+ }
643
+
644
+ public function getMethod()
645
+ {
646
+ return Mage::getSingleton('core/session')->getMethod();
647
+ }
648
+
649
+ /**
650
+ * @return mixed
651
+ */
652
+ public function getTransMethod()
653
+ {
654
+ $transMethod = Mage::getSingleton('core/session')->getTransparentNotsaved();
655
+ if (!$transMethod) {
656
+ $transMethod = Mage::getSingleton('core/session')->getTransparentSaved();
657
+ }
658
+ return $transMethod;
659
+ }
660
+
661
+ /**
662
+ * @return mixed
663
+ */
664
+ public function getTokenInfo()
665
+ {
666
+ if ($this->getTransMethod() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD) {
667
+ $uid = Mage::getSingleton('core/session')->getPaypalSavedToken();
668
+ } elseif ($this->getTransMethod() == Eway_Rapid31_Model_Config::MASTERPASS_METHOD) {
669
+ $uid = Mage::getSingleton('core/session')->getMasterpassSavedToken();
670
+ } else {
671
+ $uid = Mage::getSingleton('core/session')->getSavedToken();
672
+ }
673
+ if ($uid && $uid != Eway_Rapid31_Model_Config::TOKEN_NEW)
674
+ return Mage::helper('ewayrapid/customer')->getTokenById($uid);
675
+ return false;
676
+ }
677
+
678
+ /**
679
+ *
680
+ */
681
+ public function unsetSessionData()
682
+ {
683
+ Mage::getSingleton('core/session')->unsTransparentNotsaved();
684
+ Mage::getSingleton('core/session')->unsTransparentSaved();
685
+ Mage::getSingleton('core/session')->unsSavedToken();
686
+ Mage::getSingleton('core/session')->unsTransactionId();
687
+ Mage::getSingleton('core/session')->unsFormActionUrl();
688
+ Mage::getSingleton('core/session')->unsPaypalSavedToken();
689
+ Mage::getSingleton('core/session')->unsMethod();
690
+ Mage::getSingleton('core/session')->unsCompleteCheckoutURL();
691
+ Mage::getSingleton('core/session')->unsMasterPassSavedToken();
692
+ Mage::getSingleton('core/session')->unsInfoCard();
693
+ }
694
  }
app/code/community/Eway/Rapid31/controllers/Adminhtml/IndexController.php CHANGED
@@ -1,9 +1,6 @@
1
  <?php
2
  /**
3
- * Created by PhpStorm.
4
- * User: Administrator PC
5
- * Date: 7/22/14
6
- * Time: 9:07 AM
7
  */
8
  class Eway_Rapid31_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
9
  public function indexAction() {
1
  <?php
2
  /**
3
+ *
 
 
 
4
  */
5
  class Eway_Rapid31_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
6
  public function indexAction() {
app/code/community/Eway/Rapid31/controllers/TestController.php CHANGED
@@ -1,9 +1,6 @@
1
  <?php
2
  /**
3
- * Created by PhpStorm.
4
- * User: Administrator PC
5
- * Date: 8/7/14
6
- * Time: 10:05 AM
7
  */
8
  class Eway_Rapid31_TestController extends Mage_Core_Controller_Front_Action
9
  {
1
  <?php
2
  /**
3
+ *
 
 
 
4
  */
5
  class Eway_Rapid31_TestController extends Mage_Core_Controller_Front_Action
6
  {
app/code/community/Eway/Rapid31/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Eway_Rapid31>
5
- <version>1.3.0</version>
6
  </Eway_Rapid31>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Eway_Rapid31>
5
+ <version>1.3.1</version>
6
  </Eway_Rapid31>
7
  </modules>
8
  <global>
app/code/community/Eway/Rapid31/etc/system.xml CHANGED
@@ -65,7 +65,7 @@
65
  <sort_order>50</sort_order>
66
  <comment>
67
  <![CDATA[
68
- <a href="https://myeway.force.com/success/s/article/How-do-I-setup-my-Live-eWAY-API-Key-and-Password" target="_blank">How to generate Live Rapid 3.1 API Key and Password</a>
69
  ]]>
70
  </comment>
71
  </live_api_password>
@@ -96,7 +96,7 @@
96
  <sort_order>70</sort_order>
97
  <comment>
98
  <![CDATA[
99
- <a href="https://myeway.force.com/success/s/article/How-do-I-set-up-my-Sandbox-API-Key-and-password" target="_blank">How to generate Sandbox Rapid 3.1 API Key and Password</a>
100
  ]]>
101
  </comment>
102
  </sandbox_api_password>
65
  <sort_order>50</sort_order>
66
  <comment>
67
  <![CDATA[
68
+ <a href="https://go.eway.io/s/article/How-do-I-setup-my-Live-eWAY-API-Key-and-Password" target="_blank">How to generate Live Rapid 3.1 API Key and Password</a>
69
  ]]>
70
  </comment>
71
  </live_api_password>
96
  <sort_order>70</sort_order>
97
  <comment>
98
  <![CDATA[
99
+ <a href="https://go.eway.io/s/article/How-do-I-set-up-my-Sandbox-API-Key-and-password" target="_blank">How to generate Sandbox Rapid 3.1 API Key and Password</a>
100
  ]]>
101
  </comment>
102
  </sandbox_api_password>
app/code/community/Eway/Rapid31/sql/ewayrapid_setup/install-0.1.0.php CHANGED
@@ -1,22 +1,19 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- /* @var $installer Mage_Core_Model_Resource_Setup */
6
- $installer = $this;
7
-
8
- $installer->startSetup();
9
-
10
- $setup = Mage::getResourceModel('customer/setup', 'core_setup');
11
-
12
- $setup->addAttribute('customer', 'saved_tokens_json', array(
13
- 'input' => '',
14
- 'type' => 'text',
15
- 'label' => '',
16
- 'visible' => '0',
17
- 'required' => '0',
18
- 'user_defined' => '0',
19
- 'backend' => 'ewayrapid/backend_savedtokens',
20
- ));
21
-
22
  $installer->endSetup();
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $setup = Mage::getResourceModel('customer/setup', 'core_setup');
8
+
9
+ $setup->addAttribute('customer', 'saved_tokens_json', array(
10
+ 'input' => '',
11
+ 'type' => 'text',
12
+ 'label' => '',
13
+ 'visible' => '0',
14
+ 'required' => '0',
15
+ 'user_defined' => '0',
16
+ 'backend' => 'ewayrapid/backend_savedtokens',
17
+ ));
18
+
 
 
 
19
  $installer->endSetup();
app/code/community/Eway/Rapid31/sql/ewayrapid_setup/upgrade-0.1.0-1.0.0.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- /* @var $installer Mage_Core_Model_Resource_Setup */
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- Mage::getModel('sales/order_status')
8
- ->setStatus(Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED)
9
- ->setLabel('eWAY Authorised')
10
- ->assignState('processing')
11
- ->save();
12
-
13
- Mage::getModel('sales/order_status')
14
- ->setStatus(Eway_Rapid31_Model_Config::ORDER_STATUS_CAPTURED)
15
- ->setLabel('eWAY Captured')
16
- ->assignState('processing')
17
- ->save();
18
-
19
  $installer->endSetup();
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ Mage::getModel('sales/order_status')
8
+ ->setStatus(Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED)
9
+ ->setLabel('eWAY Authorised')
10
+ ->assignState('processing')
11
+ ->save();
12
+
13
+ Mage::getModel('sales/order_status')
14
+ ->setStatus(Eway_Rapid31_Model_Config::ORDER_STATUS_CAPTURED)
15
+ ->setLabel('eWAY Captured')
16
+ ->assignState('processing')
17
+ ->save();
18
+
19
  $installer->endSetup();
app/code/community/Eway/Rapid31/sql/ewayrapid_setup/upgrade-1.0.0-1.0.1.php CHANGED
@@ -1,26 +1,41 @@
1
- <?php
2
- /* @var $installer Mage_Core_Model_Resource_Setup */
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
- try {
7
- $installer->run("
8
- ALTER IGNORE TABLE sales_flat_order ADD COLUMN eway_transaction_id char(50) NULL;
9
- ALTER TABLE sales_flat_quote ADD IGNORE COLUMN transaction_id char(50) NULL;
10
- ");
11
- } catch (Exception $e) {
12
- }
13
-
14
- $setup = Mage::getResourceModel('customer/setup', 'core_setup');
15
-
16
- $setup->addAttribute('customer', 'mark_fraud', array(
17
- 'input' => '',
18
- 'type' => 'int',
19
- 'label' => '',
20
- 'visible' => '0',
21
- 'required' => '0',
22
- 'user_defined' => '0',
23
- 'backend' => '',
24
- ));
25
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  $installer->endSetup();
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->getConnection()
8
+ ->addColumn($installer->getTable('sales/order'),
9
+ 'eway_transaction_id',
10
+ array(
11
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
12
+ 'length' => 50,
13
+ 'nullable' => true,
14
+ 'comment' => 'eWAY Transaction ID'
15
+ )
16
+ );
17
+
18
+ $installer->getConnection()
19
+ ->addColumn($installer->getTable('sales/quote'),
20
+ 'transaction_id',
21
+ array(
22
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
23
+ 'length' => 50,
24
+ 'nullable' => true,
25
+ 'comment' => 'eWAY Transaction ID'
26
+ )
27
+ );
28
+
29
+ $setup = Mage::getResourceModel('customer/setup', 'core_setup');
30
+
31
+ $setup->addAttribute('customer', 'mark_fraud', array(
32
+ 'input' => '',
33
+ 'type' => 'int',
34
+ 'label' => '',
35
+ 'visible' => '0',
36
+ 'required' => '0',
37
+ 'user_defined' => '0',
38
+ 'backend' => '',
39
+ ));
40
+
41
  $installer->endSetup();
app/code/community/Eway/Rapid31/sql/ewayrapid_setup/upgrade-1.0.1-1.0.3.php CHANGED
@@ -1,33 +1,32 @@
1
- <?php
2
-
3
- /* @var $installer Mage_Core_Model_Resource_Setup */
4
- $installer = $this;
5
- $installer->startSetup();
6
-
7
- $setup = Mage::getResourceModel('customer/setup', 'core_setup');
8
-
9
- $setup->addAttribute('customer', 'block_fraud_customer', array(
10
- 'input' => 'select',
11
- 'type' => 'int',
12
- 'label' => 'Unblock Fraud Customer',
13
- 'visible' => '0',
14
- 'required' => '0',
15
- 'user_defined' => '0',
16
- 'default' => '0',
17
- 'source' => 'eav/entity_attribute_source_boolean'
18
- ));
19
-
20
- try {
21
- $attributeId = $setup->getAttributeId('customer', 'block_fraud_customer');
22
- Mage::getModel('customer/attribute')->load($attributeId)
23
- ->setSortOrder(999)
24
- ->save();
25
-
26
- $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'block_fraud_customer');
27
- $oAttribute->setData('used_in_forms', array('adminhtml_customer'));
28
- $oAttribute->save();
29
-
30
- $installer->endSetup();
31
- } catch (Exception $e) {
32
-
33
- }
1
+ <?php
2
+
3
+ /* @var $installer Mage_Core_Model_Resource_Setup */
4
+ $installer = $this;
5
+ $installer->startSetup();
6
+
7
+ $setup = Mage::getResourceModel('customer/setup', 'core_setup');
8
+
9
+ $setup->addAttribute('customer', 'block_fraud_customer', array(
10
+ 'input' => 'select',
11
+ 'type' => 'int',
12
+ 'label' => 'Unblock Fraud Customer',
13
+ 'visible' => '0',
14
+ 'required' => '0',
15
+ 'user_defined' => '0',
16
+ 'default' => '0',
17
+ 'source' => 'eav/entity_attribute_source_boolean'
18
+ ));
19
+
20
+ try {
21
+ $attributeId = $setup->getAttributeId('customer', 'block_fraud_customer');
22
+ Mage::getModel('customer/attribute')->load($attributeId)
23
+ ->setSortOrder(999)
24
+ ->save();
25
+
26
+ $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'block_fraud_customer');
27
+ $oAttribute->setData('used_in_forms', array('adminhtml_customer'));
28
+ $oAttribute->save();
29
+ } catch (Exception $e) {
30
+ }
31
+
32
+ $installer->endSetup();
 
app/design/frontend/base/default/template/ewayrapid/js.phtml CHANGED
@@ -1,243 +1,307 @@
1
- <?php $_config = Mage::getSingleton('ewayrapid/config'); ?>
2
- <?php $_backend = Mage::helper('ewayrapid')->isBackendOrder(); ?>
3
- <?php $_checkoutExtension = $this->getCheckoutExtension(); ?>
4
- <?php if ($_config->isDirectConnection() || $_backend): ?>
5
- <script type="text/javascript">
6
- EwayPayment.supportCardTypes = <?php echo json_encode($_config->getSupportedCardTypes()) ?>;
7
- <?php if(Mage::helper('ewayrapid')->isBackendOrder()): ?>
8
- var ewayPayment = new EwayPayment($('edit_form'), '<?php echo $_config->getEncryptionKey() ?>');
9
- AdminOrder.prototype.submit = ewayPayment.submitAdminOrder;
10
- <?php else: ?>
11
- <?php switch($_checkoutExtension):
12
- case 'OneStepCheckout': // OneStepCheckout extension ?>
13
- document.observe("dom:loaded", function () {
14
-
15
- <?php if(Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')): ?>
16
- var ewayPayment = new EwayPayment($('onestepcheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
17
- if (ewayPayment && $('onestepcheckout-form')) {
18
- Payment.prototype.switchMethod = ewayPayment.OneStepCheckout.switchMethod;
19
- if (payment.currentMethod) {
20
- payment.switchMethod(payment.currentMethod);
21
- }
22
- }
23
-
24
- $('onestepcheckout-form') && ($('onestepcheckout-form').submit = function () {
25
- form = eCrypt.doEncrypt();
26
- form.submit();
27
- });
28
- <?php endif; ?>
29
-
30
- <?php if(Mage::getStoreConfig('onestepcheckout/general/active')): ?>
31
- var ewayPayment2 = new EwayPayment($('one-step-checkout-form'), '<?php echo $_config->getEncryptionKey() ?>');
32
- if (ewayPayment2 && $('one-step-checkout-form'))
33
- Payment.prototype.switchMethod = ewayPayment2.OneStepCheckout.switchMethod;
34
-
35
- $('one-step-checkout-form') && ($('one-step-checkout-form').submit = function () {
36
- form = eCrypt.doEncrypt();
37
- form.submit();
38
- });
39
- <?php endif; ?>
40
-
41
- });
42
- <?php break; ?>
43
-
44
- <?php case 'LightCheckout': ?>
45
- document.observe("dom:loaded", function () {
46
- var ewayPayment = new EwayPayment($('gcheckout-onepage-form'), '<?php echo $_config->getEncryptionKey() ?>');
47
- if (typeof checkout.LightcheckoutSubmitOld == "undefined") {
48
- checkout.LightcheckoutSubmitOld = checkout.LightcheckoutSubmit;
49
- checkout.LightcheckoutSubmit = ewayPayment.Lightcheckout.LightcheckoutSubmit;
50
- checkout.getFormData = ewayPayment.Lightcheckout.getFormData;
51
- }
52
- });
53
- <?php break; ?>
54
-
55
- <?php case 'FireCheckout': // FireCheckout extension ?>
56
- document.observe("dom:loaded", function () {
57
- var ewayPayment = new EwayPayment($('firecheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
58
- if (typeof FireCheckout.prototype.ewayOldSave == "undefined") {
59
- FireCheckout.prototype.ewayOldSave = FireCheckout.prototype.save;
60
- FireCheckout.prototype.save = ewayPayment.FireCheckout.save;
61
- }
62
- });
63
- <?php break; ?>
64
- <?php case 'IWDOnePageCheckout': // FireCheckout extension ?>
65
- document.observe("dom:loaded", function () {
66
- var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
67
- if (typeof IWD.OPC.ewayOldSavePayment == "undefined") {
68
- IWD.OPC.ewayOldSavePayment = IWD.OPC.savePayment;
69
- IWD.OPC.ewayOldSaveOrder = IWD.OPC.saveOrder;
70
- IWD.OPC.savePayment = ewayPayment.IWDOnePageCheckout.savePayment;
71
- IWD.OPC.saveOrder = ewayPayment.IWDOnePageCheckout.saveOrder;
72
- }
73
- });
74
- <?php break; ?>
75
- <?php case 'MultiShippingAddress': // Magento default multi shipping address ?>
76
- var ewayPayment = new EwayPayment($('multishipping-billing-form'), '<?php echo $_config->getEncryptionKey() ?>');
77
- <?php break; ?>
78
- <?php default: // Magento default one page checkout ?>
79
- var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
80
- Payment.prototype.save = ewayPayment.savePaymentWithEncryption;
81
- Review.prototype.save = ewayPayment.saveReviewWithEncryption;
82
- <?php endswitch; ?>
83
- <?php endif; ?>
84
- </script>
85
- <?php endif; ?>
86
-
87
- <?php if ($_config->isTransparentConnection() && !$_backend): ?>
88
- <?php if($_checkoutExtension) {
89
- Mage::getSingleton('core/session')->setCheckoutExtension($_checkoutExtension);
90
- } else {
91
- Mage::getSingleton('core/session')->unsCheckoutExtension();
92
- }?>
93
- <script type="text/javascript">
94
- var creditcard = '<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>';
95
-
96
- <?php switch($_checkoutExtension):
97
- case 'OneStepCheckout': // OneStepCheckout extension ?>
98
- document.observe("dom:loaded", function () {
99
- <?php if(Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')): ?>
100
- var ewayPayment = new EwayPayment($('onestepcheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
101
- Payment.prototype.switchMethod = ewayPayment.OneStepCheckout.switchMethod;
102
- if (payment.currentMethod) {
103
- payment.switchMethod(payment.currentMethod);
104
- }
105
-
106
- $('onestepcheckout-form') && ($('onestepcheckout-form').submit = function () {
107
- form = eCrypt.doEncrypt();
108
- form.submit();
109
- });
110
-
111
- if ($('onestepcheckout-form')) {
112
- $('ewayrapid_notsaved_expiration') && $('ewayrapid_notsaved_expiration').writeAttribute('style', 'width:103px !important;');
113
- $('ewayrapid_saved_expiration') && $('ewayrapid_saved_expiration').writeAttribute('style', 'width:103px !important;');
114
- $('ewayrapid_saved_token') && $('ewayrapid_saved_token').writeAttribute('style', 'width:128px !important;');
115
- $('v-fix-change') && $('v-fix-change').writeAttribute('style', 'width:60px !important;');
116
- $('v-fix-cvn-id') && $('v-fix-cvn-id').writeAttribute('style', 'width:60px !important;');
117
-
118
- $('ul_payment_form_ewayrapid_notsaved') && $('ul_payment_form_ewayrapid_notsaved').setStyle({'margin-left': '-2px'});
119
- $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
120
- $('ul-eway-saved-div-box') && $('ul-eway-saved-div-box').setStyle({'margin-left': '-2px'});
121
- $$('#container_payment_method_ewayrapid_notsaved ul li').each(function (element) {
122
- element.writeAttribute('style', 'float: left; width: 100%');
123
- });
124
- }
125
- <?php endif; ?>
126
-
127
- <?php if(Mage::getStoreConfig('onestepcheckout/general/active')): ?>
128
- var ewayPayment2 = new EwayPayment($('one-step-checkout-form'), '<?php echo $_config->getEncryptionKey() ?>');
129
- if (ewayPayment2 && $('one-step-checkout-form'))
130
- Payment.prototype.switchMethod = ewayPayment2.OneStepCheckout.switchMethod;
131
-
132
- $('one-step-checkout-form') && ($('one-step-checkout-form').submit = function () {
133
- form = eCrypt.doEncrypt();
134
- form.submit();
135
- });
136
-
137
- if ($('one-step-checkout-form')) {
138
- $('payment_form_ewayrapid_notsaved') && $('payment_form_ewayrapid_notsaved').setStyle({'width': '95%'});
139
- $('payment_form_ewayrapid_saved') && $('payment_form_ewayrapid_saved').setStyle({'width': '95%'});
140
- $('ul_payment_form_ewayrapid_notsaved') && $('ul_payment_form_ewayrapid_notsaved').setStyle({'margin-left': '-2px'});
141
- $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
142
- $('payment_form_ewayrapid_saved') && $('payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
143
- $('ul-eway-saved-div-box') && $('ul-eway-saved-div-box').setStyle({'margin-left': '-2px'});
144
-
145
- $('ewayrapid_notsaved_cc_type_cvv_div') && $$('#ewayrapid_notsaved_cc_type_cvv_div div.v-fix')[0].writeAttribute('style', 'width: 35% !important');
146
- $('ewayrapid_saved_cc_type_cvv_div') && $$('#ewayrapid_saved_cc_type_cvv_div div.v-fix')[0].writeAttribute('style', 'width: 35% !important');
147
-
148
- $$('#ul_payment_form_ewayrapid_notsaved input[type=text]').each(function (element) {
149
- element.writeAttribute('style', 'width: 97% !important;');
150
- });
151
-
152
- $('ul_payment_form_ewayrapid_saved') && $$('#ul_payment_form_ewayrapid_saved input[type=text]').each(function (element) {
153
- element.writeAttribute('style', 'width: 97% !important;');
154
- });
155
-
156
- $$('#container_payment_method_ewayrapid_notsaved ul li').each(function (element) {
157
- element.writeAttribute('style', 'float: left; width: 100%');
158
- });
159
- $('container_payment_method_ewayrapid_saved') && $$('#container_payment_method_ewayrapid_saved ul li').each(function (element) {
160
- element.writeAttribute('style', 'float: left; width: 100%');
161
- });
162
-
163
- $$('.eway-saved-div-box')[0].writeAttribute('style', 'margin-left:-26px');
164
- $('ewayrapid_saved_cc_cid') && $('ewayrapid_saved_cc_cid').removeAttribute('disabled');
165
- $('eway_save_paypal') && $('eway_save_paypal').hide();
166
- $('eway_save_masterpass') && $('eway_save_masterpass').hide();
167
- var _ctype = $('ewayrapid_saved_token')[0].readAttribute('rel');
168
- if (_ctype == 'paypal') {
169
- $('ewayrapid_saved_cc_type_cvv_div') && $('ewayrapid_saved_cc_type_cvv_div').hide();
170
- $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
171
- $$('.element_save_creditcard').each(function (el) {
172
- el.hide();
173
- });
174
- } else if ((_ctype == "" || _ctype == null || $('ewayrapid_saved_token').getValue() == 'new')) {
175
- $('<?php echo $_code ?>_cc_number') && $('<?php echo $_code ?>_cc_number').writeAttribute('disabled', false);
176
- $('eway_save_masterpass') && $('eway_save_masterpass').show(150);
177
- $('eway_save_paypal') && $('eway_save_paypal').show(150);
178
- $('ul_payment_form_<?php echo $_code ?>') && $('ul_payment_form_<?php echo $_code ?>').show(150);
179
-
180
- $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
181
-
182
- $$('.element_save_creditcard').each(function (el) {
183
- el.show();
184
- });
185
- $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').show();
186
- $('ewayrapid_saved_cc_type_cvv_div') && $('ewayrapid_saved_cc_type_cvv_div').show();
187
- } else {
188
- $$('.element_save_creditcard').each(function (el) {
189
- el.hide();
190
- });
191
- }
192
- }
193
- <?php endif; ?>
194
- });
195
- <?php break; ?>
196
-
197
- <?php case 'LightCheckout': ?>
198
- document.observe("dom:loaded", function () {
199
- var ewayPayment = new EwayPayment($('gcheckout-onepage-form'), '<?php echo $_config->getEncryptionKey() ?>');
200
- if (typeof checkout.LightcheckoutSubmitOld == "undefined") {
201
- checkout.LightcheckoutSubmitOld = checkout.LightcheckoutSubmit;
202
- checkout.LightcheckoutSubmit = ewayPayment.Lightcheckout.LightcheckoutSubmit;
203
- checkout.getFormData = ewayPayment.Lightcheckout.getFormData;
204
- }
205
- });
206
- <?php break; ?>
207
-
208
-
209
- <?php case 'FireCheckout': // FireCheckout extension ?>
210
- document.observe("dom:loaded", function () {
211
- var ewayPayment = new EwayPayment($('firecheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
212
- if (typeof FireCheckout.prototype.ewayOldSave == "undefined") {
213
- FireCheckout.prototype.ewayOldSave = FireCheckout.prototype.save;
214
- FireCheckout.prototype.save = ewayPayment.FireCheckout.savePayment;
215
- }
216
- });
217
- <?php break; ?>
218
- <?php case 'IWDOnePageCheckout': // FireCheckout extension ?>
219
- document.observe("dom:loaded", function () {
220
- var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
221
- if (typeof IWD.OPC.ewayOldSavePayment == "undefined") {
222
- IWD.OPC.ewayOldSavePayment = IWD.OPC.savePayment;
223
- IWD.OPC.savePayment = ewayPayment.IWDOnePageCheckout.savePaymentTrans;
224
- }
225
- });
226
- <?php break; ?>
227
- <?php case 'MultiShippingAddress': // Magento default multi shipping address ?>
228
- var ewayPayment = new EwayPayment($('multishipping-billing-form'), '<?php echo $_config->getEncryptionKey() ?>');
229
- <?php break; ?>
230
-
231
- <?php default: // Magento default one page checkout ?>
232
- var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
233
- Payment.prototype.save = ewayPayment.savePaymentWithTransEncryption;
234
-
235
- if (typeof (ewayPayment.ewaysavedOldOrder) == "undefined") {
236
- ewayPayment.ewaysavedOldOrder = Review.prototype.save;
237
- }
238
- ewayPayment.paymentUrl = "<?php echo Mage::getUrl('ewayrapid/transparent/build', array('_secure'=>true)); ?>";
239
- Review.prototype.save = ewayPayment.saveReviewWithEncryptionTrans;
240
- <?php endswitch; ?>
241
-
242
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  <?php endif; ?>
1
+ <?php $_config = Mage::getSingleton('ewayrapid/config'); ?>
2
+ <?php $_backend = Mage::helper('ewayrapid')->isBackendOrder(); ?>
3
+ <?php $_checkoutExtension = $this->getCheckoutExtension(); ?>
4
+ <?php $_mageworld = Mage::helper('core')->isModuleEnabled('MW_Onestepcheckout'); ?>
5
+ <?php if ($_config->isDirectConnection() || $_backend): ?>
6
+ <script type="text/javascript">
7
+ EwayPayment.supportCardTypes = <?php echo json_encode($_config->getSupportedCardTypes()) ?>;
8
+ <?php if(Mage::helper('ewayrapid')->isBackendOrder()): ?>
9
+ var ewayPayment = new EwayPayment($('edit_form'), '<?php echo $_config->getEncryptionKey() ?>');
10
+ AdminOrder.prototype.submit = ewayPayment.submitAdminOrder;
11
+ <?php else: ?>
12
+ <?php switch($_checkoutExtension):
13
+ case 'OneStepCheckout': // OneStepCheckout extension ?>
14
+ document.observe("dom:loaded", function () {
15
+
16
+ <?php if(Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')): ?>
17
+ var ewayPayment = new EwayPayment($('onestepcheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
18
+ if (ewayPayment && $('onestepcheckout-form')) {
19
+ Payment.prototype.switchMethod = ewayPayment.OneStepCheckout.switchMethod;
20
+ if (payment.currentMethod) {
21
+ payment.switchMethod(payment.currentMethod);
22
+ }
23
+ }
24
+
25
+ $('onestepcheckout-form') && ($('onestepcheckout-form').submit = function () {
26
+ form = eCrypt.doEncrypt();
27
+ form.submit();
28
+ });
29
+ <?php endif; ?>
30
+
31
+ <?php if(Mage::getStoreConfig('onestepcheckout/general/active')): ?>
32
+ var ewayPayment2 = new EwayPayment($('one-step-checkout-form'), '<?php echo $_config->getEncryptionKey() ?>');
33
+ if (ewayPayment2 && $('one-step-checkout-form'))
34
+ Payment.prototype.switchMethod = ewayPayment2.OneStepCheckout.switchMethod;
35
+
36
+ $('one-step-checkout-form') && ($('one-step-checkout-form').submit = function () {
37
+ form = eCrypt.doEncrypt();
38
+ form.submit();
39
+ });
40
+ <?php endif; ?>
41
+
42
+ });
43
+ <?php break; ?>
44
+
45
+ <?php case 'LightCheckout': ?>
46
+ document.observe("dom:loaded", function () {
47
+ var ewayPayment = new EwayPayment($('gcheckout-onepage-form'), '<?php echo $_config->getEncryptionKey() ?>');
48
+ if (typeof checkout.LightcheckoutSubmitOld == "undefined") {
49
+ checkout.LightcheckoutSubmitOld = checkout.LightcheckoutSubmit;
50
+ checkout.LightcheckoutSubmit = ewayPayment.Lightcheckout.LightcheckoutSubmit;
51
+ checkout.getFormData = ewayPayment.Lightcheckout.getFormData;
52
+ }
53
+ });
54
+ <?php break; ?>
55
+
56
+ <?php case 'FireCheckout': // FireCheckout extension ?>
57
+ document.observe("dom:loaded", function () {
58
+ var ewayPayment = new EwayPayment($('firecheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
59
+ if (typeof FireCheckout.prototype.ewayOldSave == "undefined") {
60
+ FireCheckout.prototype.ewayOldSave = FireCheckout.prototype.save;
61
+ FireCheckout.prototype.save = ewayPayment.FireCheckout.save;
62
+ }
63
+ });
64
+ <?php break; ?>
65
+ <?php case 'IWDOnePageCheckout': // IWD OnePageCheckout extension ?>
66
+ document.observe("dom:loaded", function () {
67
+ var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
68
+ if (typeof IWD.OPC.ewayOldSavePayment == "undefined") {
69
+ IWD.OPC.ewayOldSavePayment = IWD.OPC.savePayment;
70
+ IWD.OPC.ewayOldSaveOrder = IWD.OPC.saveOrder;
71
+ IWD.OPC.savePayment = ewayPayment.IWDOnePageCheckout.savePayment;
72
+ IWD.OPC.saveOrder = ewayPayment.IWDOnePageCheckout.saveOrder;
73
+ }
74
+ });
75
+ <?php break; ?>
76
+ <?php case 'MultiShippingAddress': // Magento default multi shipping address ?>
77
+ var ewayPayment = new EwayPayment($('multishipping-billing-form'), '<?php echo $_config->getEncryptionKey() ?>');
78
+ <?php break; ?>
79
+ <?php default: // Magento default one page checkout ?>
80
+ var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
81
+ Payment.prototype.save = ewayPayment.savePaymentWithEncryption;
82
+ Review.prototype.save = ewayPayment.saveReviewWithEncryption;
83
+
84
+ document.observe("dom:loaded", function () {
85
+ window.onload = function(){
86
+ // MageWorld One Step Checkout Pro
87
+ if(typeof $MW_Onestepcheckout != 'undefined') {
88
+ $MW_Onestepcheckout('.btn-checkout').die('click');
89
+ $MW_Onestepcheckout('.btn-checkout').live("click",function(e){
90
+ var ewayPayment = new EwayPayment($('onestep_form'), '<?php echo $_config->getEncryptionKey() ?>');
91
+ <?php if($_mageworld && Mage::helper('onestepcheckout')->onlyProductDownloadable()):?>
92
+ var notshipmethod=1;
93
+ <?php else:?>
94
+ var notshipmethod=$MW_Onestepcheckout("input[name=shipping_method]:checked").val();
95
+ <?php endif?>
96
+ ewayPayment.MageWorld.submit(e, notshipmethod, false);
97
+ });
98
+ }
99
+ }
100
+ });
101
+ <?php endswitch; ?>
102
+ <?php endif; ?>
103
+ </script>
104
+ <?php endif; ?>
105
+
106
+ <?php if ($_config->isTransparentConnection() && !$_backend): ?>
107
+ <?php if($_checkoutExtension) {
108
+ Mage::getSingleton('core/session')->setCheckoutExtension($_checkoutExtension);
109
+ } else {
110
+ Mage::getSingleton('core/session')->unsCheckoutExtension();
111
+ }?>
112
+ <script type="text/javascript">
113
+ var creditcard = '<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>';
114
+
115
+ <?php switch($_checkoutExtension):
116
+ case 'OneStepCheckout': // OneStepCheckout extension ?>
117
+ document.observe("dom:loaded", function () {
118
+ <?php if(Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')): ?>
119
+ var ewayPayment = new EwayPayment($('onestepcheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
120
+ Payment.prototype.switchMethod = ewayPayment.OneStepCheckout.switchMethod;
121
+ if (payment.currentMethod) {
122
+ payment.switchMethod(payment.currentMethod);
123
+ }
124
+
125
+ $('onestepcheckout-form') && ($('onestepcheckout-form').submit = function () {
126
+ form = eCrypt.doEncrypt();
127
+ form.submit();
128
+ });
129
+
130
+ if ($('onestepcheckout-form')) {
131
+ $('ewayrapid_notsaved_expiration') && $('ewayrapid_notsaved_expiration').writeAttribute('style', 'width:103px !important;');
132
+ $('ewayrapid_saved_expiration') && $('ewayrapid_saved_expiration').writeAttribute('style', 'width:103px !important;');
133
+ $('ewayrapid_saved_token') && $('ewayrapid_saved_token').writeAttribute('style', 'width:128px !important;');
134
+ $('v-fix-change') && $('v-fix-change').writeAttribute('style', 'width:60px !important;');
135
+ $('v-fix-cvn-id') && $('v-fix-cvn-id').writeAttribute('style', 'width:60px !important;');
136
+
137
+ $('ul_payment_form_ewayrapid_notsaved') && $('ul_payment_form_ewayrapid_notsaved').setStyle({'margin-left': '-2px'});
138
+ $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
139
+ $('ul-eway-saved-div-box') && $('ul-eway-saved-div-box').setStyle({'margin-left': '-2px'});
140
+ $$('#container_payment_method_ewayrapid_notsaved ul li').each(function (element) {
141
+ element.writeAttribute('style', 'float: left; width: 100%');
142
+ });
143
+ }
144
+ <?php endif; ?>
145
+
146
+ <?php if(Mage::getStoreConfig('onestepcheckout/general/active')): ?>
147
+ var ewayPayment2 = new EwayPayment($('one-step-checkout-form'), '<?php echo $_config->getEncryptionKey() ?>');
148
+ if (ewayPayment2 && $('one-step-checkout-form'))
149
+ Payment.prototype.switchMethod = ewayPayment2.OneStepCheckout.switchMethod;
150
+
151
+ $('one-step-checkout-form') && ($('one-step-checkout-form').submit = function () {
152
+ form = eCrypt.doEncrypt();
153
+ form.submit();
154
+ });
155
+
156
+ if ($('one-step-checkout-form')) {
157
+ $('payment_form_ewayrapid_notsaved') && $('payment_form_ewayrapid_notsaved').setStyle({'width': '95%'});
158
+ $('payment_form_ewayrapid_saved') && $('payment_form_ewayrapid_saved').setStyle({'width': '95%'});
159
+ $('ul_payment_form_ewayrapid_notsaved') && $('ul_payment_form_ewayrapid_notsaved').setStyle({'margin-left': '-2px'});
160
+ $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
161
+ $('payment_form_ewayrapid_saved') && $('payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
162
+ $('ul-eway-saved-div-box') && $('ul-eway-saved-div-box').setStyle({'margin-left': '-2px'});
163
+
164
+ $('ewayrapid_notsaved_cc_type_cvv_div') && $$('#ewayrapid_notsaved_cc_type_cvv_div div.v-fix')[0].writeAttribute('style', 'width: 35% !important');
165
+ $('ewayrapid_saved_cc_type_cvv_div') && $$('#ewayrapid_saved_cc_type_cvv_div div.v-fix')[0].writeAttribute('style', 'width: 35% !important');
166
+
167
+ $$('#ul_payment_form_ewayrapid_notsaved input[type=text]').each(function (element) {
168
+ element.writeAttribute('style', 'width: 97% !important;');
169
+ });
170
+
171
+ $('ul_payment_form_ewayrapid_saved') && $$('#ul_payment_form_ewayrapid_saved input[type=text]').each(function (element) {
172
+ element.writeAttribute('style', 'width: 97% !important;');
173
+ });
174
+
175
+ $$('#container_payment_method_ewayrapid_notsaved ul li').each(function (element) {
176
+ element.writeAttribute('style', 'float: left; width: 100%');
177
+ });
178
+ $('container_payment_method_ewayrapid_saved') && $$('#container_payment_method_ewayrapid_saved ul li').each(function (element) {
179
+ element.writeAttribute('style', 'float: left; width: 100%');
180
+ });
181
+
182
+ $$('.eway-saved-div-box')[0].writeAttribute('style', 'margin-left:-26px');
183
+ $('ewayrapid_saved_cc_cid') && $('ewayrapid_saved_cc_cid').removeAttribute('disabled');
184
+ $('eway_save_paypal') && $('eway_save_paypal').hide();
185
+ $('eway_save_masterpass') && $('eway_save_masterpass').hide();
186
+ var _ctype = $('ewayrapid_saved_token')[0].readAttribute('rel');
187
+ if (_ctype == 'paypal') {
188
+ $('ewayrapid_saved_cc_type_cvv_div') && $('ewayrapid_saved_cc_type_cvv_div').hide();
189
+ $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
190
+ $$('.element_save_creditcard').each(function (el) {
191
+ el.hide();
192
+ });
193
+ } else if ((_ctype == "" || _ctype == null || $('ewayrapid_saved_token').getValue() == 'new')) {
194
+ $('<?php echo $_code ?>_cc_number') && $('<?php echo $_code ?>_cc_number').writeAttribute('disabled', false);
195
+ $('eway_save_masterpass') && $('eway_save_masterpass').show(150);
196
+ $('eway_save_paypal') && $('eway_save_paypal').show(150);
197
+ $('ul_payment_form_<?php echo $_code ?>') && $('ul_payment_form_<?php echo $_code ?>').show(150);
198
+
199
+ $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
200
+
201
+ $$('.element_save_creditcard').each(function (el) {
202
+ el.show();
203
+ });
204
+ $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').show();
205
+ $('ewayrapid_saved_cc_type_cvv_div') && $('ewayrapid_saved_cc_type_cvv_div').show();
206
+ } else {
207
+ $$('.element_save_creditcard').each(function (el) {
208
+ el.hide();
209
+ });
210
+ }
211
+ }
212
+ <?php endif; ?>
213
+ });
214
+ <?php break; ?>
215
+
216
+ <?php case 'LightCheckout': ?>
217
+ document.observe("dom:loaded", function () {
218
+ var ewayPayment = new EwayPayment($('gcheckout-onepage-form'), '<?php echo $_config->getEncryptionKey() ?>');
219
+ if (typeof checkout.LightcheckoutSubmitOld == "undefined") {
220
+ checkout.LightcheckoutSubmitOld = checkout.LightcheckoutSubmit;
221
+ checkout.LightcheckoutSubmit = ewayPayment.Lightcheckout.LightcheckoutSubmit;
222
+ checkout.getFormData = ewayPayment.Lightcheckout.getFormData;
223
+ }
224
+ });
225
+ <?php break; ?>
226
+
227
+
228
+ <?php case 'FireCheckout': // FireCheckout extension ?>
229
+ document.observe("dom:loaded", function () {
230
+ var ewayPayment = new EwayPayment($('firecheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
231
+ if (typeof FireCheckout.prototype.ewayOldSave == "undefined") {
232
+ FireCheckout.prototype.ewayOldSave = FireCheckout.prototype.save;
233
+ FireCheckout.prototype.save = ewayPayment.FireCheckout.savePayment;
234
+ }
235
+ });
236
+ <?php break; ?>
237
+ <?php case 'IWDOnePageCheckout': // FireCheckout extension ?>
238
+ document.observe("dom:loaded", function () {
239
+ var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
240
+ if (typeof IWD.OPC.ewayOldSavePayment == "undefined") {
241
+ IWD.OPC.ewayOldSavePayment = IWD.OPC.savePayment;
242
+ IWD.OPC.savePayment = ewayPayment.IWDOnePageCheckout.savePaymentTrans;
243
+ }
244
+ });
245
+ <?php break; ?>
246
+ <?php case 'MultiShippingAddress': // Magento default multi shipping address ?>
247
+ var ewayPayment = new EwayPayment($('multishipping-billing-form'), '<?php echo $_config->getEncryptionKey() ?>');
248
+ <?php break; ?>
249
+
250
+ <?php default: // Magento default one page checkout ?>
251
+ var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
252
+ Payment.prototype.save = ewayPayment.savePaymentWithTransEncryption;
253
+
254
+ if (typeof (ewayPayment.ewaysavedOldOrder) == "undefined") {
255
+ ewayPayment.ewaysavedOldOrder = Review.prototype.save;
256
+ }
257
+ ewayPayment.paymentUrl = "<?php echo Mage::getUrl('ewayrapid/transparent/build', array('_secure'=>true)); ?>";
258
+ Review.prototype.save = ewayPayment.saveReviewWithEncryptionTrans;
259
+
260
+ document.observe("dom:loaded", function () {
261
+ window.onload = function(){
262
+ // MageWorld One Step Checkout Pro
263
+ if(typeof $MW_Onestepcheckout != 'undefined') {
264
+
265
+ $('payment_form_ewayrapid_notsaved') && $('payment_form_ewayrapid_notsaved').setStyle({'width': '90%'});
266
+ $('payment_form_ewayrapid_saved') && $('payment_form_ewayrapid_saved').setStyle({'width': '90%'});
267
+ $('ul_payment_form_ewayrapid_notsaved') && $('ul_payment_form_ewayrapid_notsaved').setStyle({'margin-left': '-2px'});
268
+ $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
269
+ $('payment_form_ewayrapid_saved') && $('payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
270
+ $('ul-eway-saved-div-box') && $('ul-eway-saved-div-box').setStyle({'margin-left': '-2px'});
271
+
272
+ $('ewayrapid_notsaved_expiration') && $('ewayrapid_notsaved_expiration').writeAttribute('style', 'width:103px !important;');
273
+ $('ewayrapid_saved_expiration') && $('ewayrapid_saved_expiration').writeAttribute('style', 'width:103px !important;');
274
+ $('ewayrapid_saved_token') && $('ewayrapid_saved_token').writeAttribute('style', 'width:128px !important;');
275
+
276
+ $('ewayrapid_notsaved_cc_type_cvv_div') && $$('#ewayrapid_notsaved_cc_type_cvv_div div.v-fix')[0].writeAttribute('style', 'width: 35% !important');
277
+ $('ewayrapid_saved_cc_type_cvv_div') && $$('#ewayrapid_saved_cc_type_cvv_div div.v-fix')[0].writeAttribute('style', 'width: 35% !important');
278
+
279
+ $$('#ul_payment_form_ewayrapid_notsaved input[type=text]').each(function (element) {
280
+ element.writeAttribute('style', 'width: 80% !important;');
281
+ });
282
+
283
+ $('ul_payment_form_ewayrapid_saved') && $$('#ul_payment_form_ewayrapid_saved input[type=text]').each(function (element) {
284
+ element.writeAttribute('style', 'width: 80% !important;');
285
+ });
286
+
287
+ $MW_Onestepcheckout('.btn-checkout').die('click');
288
+ $MW_Onestepcheckout('.btn-checkout').live("click",function(e){
289
+ alert('Transparent Redirect is not supported with MageWorld One Step Checkout Pro.');
290
+ return false;
291
+ var ewayPayment = new EwayPayment($('onestep_form'), '<?php echo $_config->getEncryptionKey() ?>');
292
+ ewayPayment.paymentUrl = "<?php echo Mage::getUrl('ewayrapid/transparent/build', array('_secure'=>true)); ?>";
293
+ <?php if($_mageworld && Mage::helper('onestepcheckout')->onlyProductDownloadable()):?>
294
+ var notshipmethod=1;
295
+ <?php else:?>
296
+ var notshipmethod=$MW_Onestepcheckout("input[name=shipping_method]:checked").val();
297
+ <?php endif?>
298
+ ewayPayment.MageWorld.submit(e, notshipmethod, true);
299
+ });
300
+ }
301
+ }
302
+ });
303
+
304
+ <?php endswitch; ?>
305
+
306
+ </script>
307
  <?php endif; ?>
js/ewayrapid/eWAY_Payment_Rapid31.xml ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <_>
2
+ <form_key>zlEmYI88Nf5v0PME</form_key>
3
+ <name>eWAY_Payment_Rapid31</name>
4
+ <channel>community</channel>
5
+ <version_ids>
6
+ <version_ids>2</version_ids>
7
+ </version_ids>
8
+ <summary>The eWAY payment module - accept credit card payments, save cards, process refunds with eWAY&apos;s Rapid 3.1 Payment Gateway.</summary>
9
+ <description>The eWAY Rapid 3.1 payments module - made by eWAY for eWAY merchants:
10
+
11
+ - It&apos;s free!
12
+ - Fast and easy to set up and integrate
13
+ - Smash chargebacks with global fraud protection
14
+ - More options for your customers - more payment methods
15
+ - Improve basket conversion with faster checkout features
16
+ - Full Magento back-office integration, including manual orders and refunds
17
+ - Supports eWAY&apos;s Sandbox for testing
18
+ - Your customers can save their card details using eWAY&apos;s secure servers for faster checkout
19
+ - Get help when and where you need it with 24/7 support
20
+
21
+ Discover more at http://www.eway.com.au - payments made smarter!</description>
22
+ <license>OSL v3.0</license>
23
+ <license_uri/>
24
+ <version>1.3.1</version>
25
+ <stability>stable</stability>
26
+ <notes>Minor fixes:
27
+
28
+ - Fix for stores with custom DB table prefixes
29
+ - Improved recurring initial fee handling
30
+ - Fix for manual payments not submitting for some stores
31
+ - Fix for update token with Direct sometimes failing</notes>
32
+ <authors>
33
+ <name>
34
+ <name>eWAY Payments</name>
35
+ </name>
36
+ <user>
37
+ <user>eWAYPayments</user>
38
+ </user>
39
+ <email>
40
+ <email>partner@eway.com.au</email>
41
+ </email>
42
+ </authors>
43
+ <depends_php_min>5.2.0</depends_php_min>
44
+ <depends_php_max>6.0.0</depends_php_max>
45
+ <depends>
46
+ <package>
47
+ <name>
48
+ <name/>
49
+ </name>
50
+ <channel>
51
+ <channel/>
52
+ </channel>
53
+ <min>
54
+ <min/>
55
+ </min>
56
+ <max>
57
+ <max/>
58
+ </max>
59
+ <files>
60
+ <files> </files>
61
+ </files>
62
+ </package>
63
+ <extension>
64
+ <name>
65
+ <name>Core</name>
66
+ <name>curl</name>
67
+ </name>
68
+ <min>
69
+ <min/>
70
+ <min/>
71
+ </min>
72
+ <max>
73
+ <max/>
74
+ <max/>
75
+ </max>
76
+ </extension>
77
+ </depends>
78
+ <contents>
79
+ <target>
80
+ <target>magelocal</target>
81
+ <target>magecommunity</target>
82
+ <target>magedesign</target>
83
+ <target>magedesign</target>
84
+ <target>mageetc</target>
85
+ <target>magelocale</target>
86
+ <target>mageskin</target>
87
+ <target>mageskin</target>
88
+ <target>mageweb</target>
89
+ <target>magedesign</target>
90
+ <target>magedesign</target>
91
+ </target>
92
+ <path>
93
+ <path/>
94
+ <path>Eway</path>
95
+ <path>adminhtml/default/default/layout/ewayrapid/</path>
96
+ <path>frontend/base/default/layout/ewayrapid</path>
97
+ <path>modules/Eway_Rapid31.xml</path>
98
+ <path>en_US/Eway_Rapid31.csv</path>
99
+ <path>adminhtml/default/default/ewayrapid.css</path>
100
+ <path>frontend/base/default/css/ewayrapid.css</path>
101
+ <path>js/ewayrapid</path>
102
+ <path>adminhtml/default/default/template/ewayrapid</path>
103
+ <path>frontend/base/default/template/ewayrapid</path>
104
+ </path>
105
+ <type>
106
+ <type>file</type>
107
+ <type>dir</type>
108
+ <type>dir</type>
109
+ <type>dir</type>
110
+ <type>file</type>
111
+ <type>file</type>
112
+ <type>file</type>
113
+ <type>file</type>
114
+ <type>dir</type>
115
+ <type>dir</type>
116
+ <type>dir</type>
117
+ </type>
118
+ <include>
119
+ <include/>
120
+ <include/>
121
+ <include/>
122
+ <include/>
123
+ <include/>
124
+ <include/>
125
+ <include/>
126
+ <include/>
127
+ <include/>
128
+ <include/>
129
+ <include/>
130
+ </include>
131
+ <ignore>
132
+ <ignore/>
133
+ <ignore/>
134
+ <ignore/>
135
+ <ignore/>
136
+ <ignore/>
137
+ <ignore/>
138
+ <ignore/>
139
+ <ignore/>
140
+ <ignore/>
141
+ <ignore/>
142
+ <ignore/>
143
+ </ignore>
144
+ </contents>
145
+ </_>
js/ewayrapid/ewayrapid.js CHANGED
@@ -1,1012 +1,764 @@
1
- var EwayPayment = Class.create();
2
- EwayPayment.isEwayRapidMethod = function(method) {
3
- return ("ewayrapid_saved" === method || "ewayrapid_notsaved" === method);
4
- };
5
- EwayPayment.supportCardTypes = ['AE', 'VI', 'MC', 'JCB', 'DC', 'VE', 'ME'];
6
- EwayPayment.prototype = {
7
- paymentUrl : null,
8
- ewayPayment: this,
9
- initialize: function(form, encryptionKey) {
10
- if(form) {
11
- // Init client-side encryption
12
- if(typeof eCrypt == 'function') {
13
- form.writeAttribute('data-eway-encrypt-key', encryptionKey);
14
- eCrypt && eCrypt.init();
15
- }
16
- }
17
- },
18
-
19
- savePaymentWithEncryption: function() {
20
- if (checkout.loadWaiting!=false) return;
21
- var validator = new Validation(this.form);
22
- if (this.validate() && validator.validate()) {
23
- checkout.setLoadWaiting('payment');
24
- var form = $(this.form);
25
- if($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
26
- form = eCrypt.doEncrypt();
27
- }
28
- this.ewayForm = form;
29
- var request = new Ajax.Request(
30
- this.saveUrl,
31
- {
32
- method:'post',
33
- onComplete: this.onComplete,
34
- onSuccess: this.onSave,
35
- onFailure: checkout.ajaxFailure.bind(checkout),
36
- parameters: $(form.id).serialize()
37
- }
38
- );
39
- }
40
- },
41
-
42
- savePaymentWithTransEncryption: function() {
43
- if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
44
- if (checkout.loadWaiting != false) return;
45
- var validator = new Validation(this.form);
46
- if (this.validate() && validator.validate()) {
47
- checkout.setLoadWaiting('payment');
48
- var form = $(this.form);
49
- var _method = $$("input[name='payment[method]']:checked")[0].getValue();
50
- var _transparent_method = '';
51
-
52
- if (_method == 'ewayrapid_notsaved' && $$("input[name='payment[transparent_notsaved]']:checked").length > 0) {
53
- _transparent_method = $$("input[name='payment[transparent_notsaved]']:checked")[0];
54
- } else if (_method == 'ewayrapid_saved' && $$("input[name='payment[transparent_saved]']:checked").length > 0) {
55
- _transparent_method = $$("input[name='payment[transparent_saved]']:checked")[0];
56
- }
57
-
58
- if (_transparent_method != '' && $(_transparent_method.id).getValue() == creditcard) {
59
- if ($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
60
- form = eCrypt.doEncrypt();
61
- }
62
- }
63
-
64
- this.ewayForm = form;
65
- var request = new Ajax.Request(
66
- this.saveUrl,
67
- {
68
- method: 'post',
69
- onComplete: this.onComplete,
70
- onSuccess: this.onSave,
71
- onFailure: checkout.ajaxFailure.bind(checkout),
72
- parameters: $(form.id).serialize()
73
- }
74
- );
75
- }
76
- }
77
- },
78
-
79
- saveReviewWithEncryption: function() {
80
- if (checkout.loadWaiting!=false) return;
81
- checkout.setLoadWaiting('review');
82
- //var params = Form.serialize(payment.form);
83
- var params = payment.ewayForm.serialize();
84
- if (this.agreementsForm) {
85
- params += '&'+Form.serialize(this.agreementsForm);
86
- }
87
- params.save = true;
88
- var request = new Ajax.Request(
89
- this.saveUrl,
90
- {
91
- method:'post',
92
- parameters:params,
93
- onComplete: this.onComplete,
94
- onSuccess: this.onSave,
95
- onFailure: checkout.ajaxFailure.bind(checkout)
96
- }
97
- );
98
- },
99
- saveReviewWithEncryptionTrans: function () {
100
- if (EwayPayment.isEwayRapidMethod(payment.currentMethod) && ewayPayment.paymentUrl != null) {
101
- $('review-please-wait') && $('review-please-wait').show();
102
- $('review-buttons-container') && $('review-buttons-container').down('button').hide();
103
-
104
- var request = new Ajax.Request(
105
- ewayPayment.paymentUrl,
106
- {
107
- method: 'post',
108
- onComplete: {},
109
- onSuccess: function (response) {
110
- if (response.responseText != '0') {
111
- window.location = response.responseText;
112
- }
113
- return false;
114
- },
115
- onFailure: {}
116
- }
117
- );
118
- } else {
119
- this.prototype.ewaysavedOldOrder();
120
- }
121
- },
122
- subMitForm: function () {
123
- form = eCrypt.doEncrypt();
124
- form.submit();
125
- },
126
-
127
- submitAdminOrder: function() {
128
- if(editForm.validator && editForm.validator.validate()) {
129
- if($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
130
- editForm = eCrypt.doEncrypt();
131
- }
132
- if (this.orderItemChanged) {
133
- if (confirm('You have item changes')) {
134
- if (editForm.submit()) {
135
- disableElements('save');
136
- }
137
- } else {
138
- this.itemsUpdate();
139
- }
140
- } else {
141
- if (editForm.submit()) {
142
- disableElements('save');
143
- }
144
- }
145
- }
146
- },
147
-
148
- OneStepCheckout: {
149
- switchMethod: function(method) {
150
- $$('.payment-method .form-list').each(function(form) {
151
- form.style.display = 'none';
152
- var elements = form.select('input').concat(form.select('select')).concat(form.select('textarea'));
153
- for (var i=0; i<elements.length; i++) elements[i].disabled = true;
154
- });
155
-
156
- if ($('payment_form_'+method)){
157
- var form = $('payment_form_'+method);
158
- form.style.display = '';
159
- var elements = form.select('input').concat(form.select('select')).concat(form.select('textarea'));
160
- for (var i=0; i<elements.length; i++) elements[i].disabled = false;
161
- this.currentMethod = method;
162
- if ($('ul_payment_form_'+method)) {
163
- $('ul_payment_form_'+method).show();
164
- }
165
- }
166
- }
167
- },
168
-
169
- FireCheckout: {
170
- save: function(urlSuffix, forceSave) {
171
- var currentMethod = payment.currentMethod ? payment.currentMethod : '';
172
- if(EwayPayment.isEwayRapidMethod(currentMethod)) {
173
- if (this.loadWaiting != false) {
174
- return;
175
- }
176
-
177
- if (!this.validate()) {
178
- return;
179
- }
180
-
181
- // infostrates tnt
182
- if (!forceSave && (typeof shippingMethod === 'object')
183
- && shippingMethod.getCurrentMethod().indexOf("tnt_") === 0) {
184
-
185
- shippingMethodTnt(shippingMethodTntUrl);
186
- return;
187
- }
188
- // infostrates tnt
189
-
190
- checkout.setLoadWaiting(true);
191
-
192
- var params = Form.serialize(this.form, true);
193
- $('review-please-wait').show();
194
-
195
- encryptedForm = eCrypt.doEncrypt();
196
- params = Form.serialize(encryptedForm, true);
197
-
198
- urlSuffix = urlSuffix || '';
199
- var request = new Ajax.Request(this.urls.save + urlSuffix, {
200
- method:'post',
201
- parameters:params,
202
- onSuccess: this.setResponse.bind(this),
203
- onFailure: this.ajaxFailure.bind(this)
204
- });
205
- } else if(typeof this.ewayOldSave == 'function') {
206
- this.ewayOldSave(urlSuffix, forceSave);
207
- }
208
- },
209
- savePayment: function(urlSuffix, forceSave) {
210
- var currentMethod = payment.currentMethod ? payment.currentMethod : '';
211
- if(EwayPayment.isEwayRapidMethod(currentMethod)) {
212
- if (this.loadWaiting != false) {
213
- return;
214
- }
215
-
216
- if (!this.validate()) {
217
- return;
218
- }
219
-
220
- // infostrates tnt
221
- if (!forceSave && (typeof shippingMethod === 'object')
222
- && shippingMethod.getCurrentMethod().indexOf("tnt_") === 0) {
223
-
224
- shippingMethodTnt(shippingMethodTntUrl);
225
- return;
226
- }
227
- // infostrates tnt
228
-
229
- checkout.setLoadWaiting(true);
230
-
231
- var params = Form.serialize(this.form, true);
232
- $('review-please-wait').show();
233
-
234
- var _method = $$("input[name='payment[method]']:checked")[0].getValue();
235
- var _transparent_method = '';
236
- if (_method == 'ewayrapid_notsaved' && $$("input[name='payment[transparent_notsaved]']:checked").length > 0) {
237
- _transparent_method = $$("input[name='payment[transparent_notsaved]']:checked")[0];
238
- } else if (_method == 'ewayrapid_saved' && $$("input[name='payment[transparent_saved]']:checked").length > 0) {
239
- _transparent_method = $$("input[name='payment[transparent_saved]']:checked")[0];
240
- }
241
-
242
- if (_transparent_method != '' && $(_transparent_method.id).getValue() == creditcard) {
243
- if ($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
244
- encryptedForm = eCrypt.doEncrypt();
245
- }
246
- }
247
-
248
- params = Form.serialize(encryptedForm, true);
249
-
250
- urlSuffix = urlSuffix || '';
251
- var request = new Ajax.Request(this.urls.save + urlSuffix, {
252
- method:'post',
253
- parameters:params,
254
- onSuccess: this.setResponse.bind(this),
255
- onFailure: this.ajaxFailure.bind(this)
256
- });
257
- } else if(typeof this.ewayOldSave == 'function') {
258
- this.ewayOldSave(urlSuffix, forceSave);
259
- }
260
- }
261
- },
262
-
263
- IWDOnePageCheckout: {
264
- savePayment: function() {
265
- if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
266
- if (IWD.OPC.Checkout.xhr!=null){
267
- IWD.OPC.Checkout.xhr.abort();
268
- }
269
- IWD.OPC.Checkout.showLoader();
270
- var ewayForm = eCrypt.doEncrypt();
271
- form = $j(ewayForm).serializeArray();
272
- IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.config.baseUrl + 'onepage/json/savePayment',form, IWD.OPC.preparePaymentResponse,'json');
273
- } else if(typeof IWD.OPC.ewayOldSavePayment == 'function') {
274
- IWD.OPC.ewayOldSavePayment();
275
- }
276
- },
277
- savePaymentTrans: function() {
278
- if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
279
- /*var ewayForm = $(this.form);
280
- if (IWD.OPC.Checkout.xhr!=null){
281
- IWD.OPC.Checkout.xhr.abort();
282
- }
283
- IWD.OPC.Checkout.showLoader();
284
- var _method = $$("input[name='payment[method]']:checked")[0].getValue();
285
- var _transparent_method = '';
286
- if (_method == 'ewayrapid_notsaved' && $$("input[name='payment[transparent_notsaved]']:checked").length > 0) {
287
- _transparent_method = $$("input[name='payment[transparent_notsaved]']:checked")[0];
288
- } else if (_method == 'ewayrapid_saved' && $$("input[name='payment[transparent_saved]']:checked").length > 0) {
289
- _transparent_method = $$("input[name='payment[transparent_saved]']:checked")[0];
290
- }
291
-
292
- if (_transparent_method != '' && $(_transparent_method.id).getValue() == creditcard) {
293
- if ($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
294
- ewayForm = eCrypt.doEncrypt();
295
- }
296
- }*/
297
- var ewayForm = eCrypt.doEncrypt();
298
- form = $j(ewayForm).serializeArray();
299
- IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.config.baseUrl + 'onepage/json/savePayment',form, IWD.OPC.preparePaymentResponse,'json');
300
- } else if(typeof IWD.OPC.ewayOldSavePayment == 'function') {
301
- IWD.OPC.ewayOldSavePayment();
302
- }
303
- },
304
- saveOrder: function() {
305
- if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
306
- var ewayForm = eCrypt.doEncrypt();
307
- form = $j(ewayForm).serializeArray();
308
- form = IWD.OPC.checkAgreement(form);
309
- IWD.OPC.Checkout.showLoader();
310
- if (IWD.OPC.Checkout.config.comment!=="0"){
311
- IWD.OPC.saveCustomerComment();
312
- }
313
-
314
- IWD.OPC.Plugin.dispatch('saveOrder');
315
- IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.saveOrderUrl ,form, IWD.OPC.prepareOrderResponse,'json');
316
- } else if(typeof IWD.OPC.ewayOldSaveOrder == 'function') {
317
- IWD.OPC.ewayOldSaveOrder();
318
- }
319
- }
320
- },
321
- Lightcheckout : {
322
- LightcheckoutSubmit: function() {
323
- if (payment.currentMethod && (payment.currentMethod.indexOf('sagepay') == 0) &&
324
- (SageServer != undefined) && (review != undefined)) {
325
- if (checkoutForm.validator.validate()) {
326
- review.preparedata();
327
- }
328
- }
329
- else {
330
- if (checkoutForm.validator.validate()) {
331
- this.submit(this.getFormData(), 'save_payment_methods');
332
- }
333
- }
334
- },
335
- submit: function (params, action) {
336
-
337
- this.showLoadinfo();
338
-
339
- params.action = action;
340
-
341
- var request = new Ajax.Request(this.url,
342
- {
343
- method: 'post',
344
- parameters: params,
345
- onSuccess: function (transport) {
346
-
347
- eval('var response = ' + transport.responseText);
348
-
349
- if (response.messages_block) {
350
- var gcheckout_onepage_wrap = $$('div.gcheckout-onepage-wrap')[0];
351
- if (gcheckout_onepage_wrap) {
352
- new Insertion.Before(gcheckout_onepage_wrap, response.messages_block);
353
- }
354
- this.disable_place_order = true;
355
- } else {
356
- this.disable_place_order = false;
357
- }
358
-
359
- if (response.url) {
360
-
361
- this.existsreview = false;
362
- setLocation(response.url);
363
-
364
- } else {
365
-
366
- if (response.error) {
367
- if (response.message) {
368
- alert(response.message);
369
- }
370
- this.existsreview = false;
371
- this.hideLoadinfo();
372
- } else {
373
-
374
- var process_save_order = false;
375
-
376
- if (response.methods) {
377
- // Quote isVirtual
378
- this.innerHTMLwithScripts($('gcheckout-onepage-methods'), response.methods);
379
- var wrap = $$('div.gcheckout-onepage-wrap')[0];
380
- if (wrap && !wrap.hasClassName('not_shipping_mode')) {
381
- wrap.addClassName('not_shipping_mode');
382
- }
383
- if ($('billing_use_for_shipping_yes') && $('billing_use_for_shipping_yes').up('li.control')) {
384
- $('billing_use_for_shipping_yes').up('li.control').remove();
385
- }
386
- if ($('gcheckout-shipping-address')) {
387
- $('gcheckout-shipping-address').remove();
388
- }
389
- payment.init();
390
- this.observeMethods();
391
- }
392
-
393
- if (response.shippings) {
394
- if (shipping_rates_block = $('gcheckout-shipping-method-available')) {
395
- this.innerHTMLwithScripts(shipping_rates_block, response.shippings);
396
- this.observeShippingMethods();
397
- }
398
- }
399
-
400
- if (response.payments) {
401
- this.innerHTMLwithScripts($('gcheckout-payment-methods-available'), response.payments);
402
- payment.init();
403
- this.observePaymentMethods();
404
- }
405
-
406
- if (response.gift_message) {
407
- if (giftmessage_block = $('gomage-lightcheckout-giftmessage')) {
408
- this.innerHTMLwithScripts(giftmessage_block, response.gift_message);
409
- }
410
- }
411
-
412
- if (response.toplinks) {
413
- this.replaceTopLinks(response.toplinks);
414
- }
415
-
416
- if (response.minicart) {
417
- this.replaceMiniCart(response);
418
- }
419
-
420
- if (response.cart_sidebar && typeof(GomageProcartConfig) != 'undefined') {
421
- GomageProcartConfig._replaceEnterpriseTopCart(response.cart_sidebar, ($('topCartContent') && $('topCartContent').visible()));
422
- }
423
-
424
- if (response.review) {
425
- this.innerHTMLwithScripts($$('#gcheckout-onepage-review div.totals')[0], response.review);
426
- }
427
-
428
- if (response.content_billing) {
429
- var div_billing = document.createElement('div');
430
- div_billing.innerHTML = response.content_billing;
431
- $('gcheckout-onepage-address').replaceChild(div_billing.firstChild, $('gcheckout-billing-address'));
432
- }
433
-
434
- if (response.content_shipping && $('gcheckout-shipping-address')) {
435
- var div_shipping = document.createElement('div');
436
- div_shipping.innerHTML = response.content_shipping;
437
- $('gcheckout-onepage-address').replaceChild(div_shipping.firstChild, $('gcheckout-shipping-address'));
438
- }
439
-
440
- if (response.content_billing || response.content_shipping) {
441
- this.observeAddresses();
442
- initAddresses();
443
- }
444
-
445
- if (response.section == 'varify_taxvat') {
446
-
447
- if ($('billing_taxvat_verified')) {
448
- $('billing_taxvat_verified').remove();
449
- }
450
-
451
- if ($('shipping_taxvat_verified')) {
452
- $('shipping_taxvat_verified').remove();
453
- }
454
-
455
- this.taxvat_verify_result = response.verify_result;
456
-
457
- if ($('billing_taxvat') && $('billing_taxvat').value) {
458
- if (response.verify_result.billing) {
459
- if (label = $('billing_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
460
- label.innerHTML += '<strong id="billing_taxvat_verified" style="margin-left:5px;">(<span style="color:green;">Verified</span>)</strong>';
461
- $('billing_taxvat').removeClassName('validation-failed');
462
- }
463
- } else if ($('billing_taxvat').value) {
464
- if (label = $('billing_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
465
- label.innerHTML += '<strong id="billing_taxvat_verified" style="margin-left:5px;">(<span style="color:red;">Not Verified</span>)</strong>';
466
- }
467
- }
468
- }
469
-
470
- if ($('shipping_taxvat') && $('shipping_taxvat').value) {
471
- if (response.verify_result.shipping) {
472
- if (label = $('shipping_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
473
- label.innerHTML += '<strong id="shipping_taxvat_verified" style="margin-left:5px;">(<span style="color:green;">Verified</span>)</strong>';
474
- $('shipping_taxvat').removeClassName('validation-failed');
475
- }
476
- } else if ($('shipping_taxvat').value) {
477
- if (label = $('shipping_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
478
- label.innerHTML += '<strong id="shipping_taxvat_verified" style="margin-left:5px;">(<span style="color:red;">Not Verified</span>)</strong>';
479
- }
480
- }
481
- }
482
-
483
- }
484
-
485
- if (response.section == 'centinel') {
486
-
487
- if (response.centinel) {
488
- this.showCentinel(response.centinel);
489
- } else {
490
- process_save_order = true;
491
- if ((payment.currentMethod == 'authorizenet_directpost') && ((typeof directPostModel != 'undefined'))) {
492
- directPostModel.saveOnepageOrder();
493
- } else {
494
- this.saveorder();
495
- }
496
- }
497
- }
498
-
499
- this.setBlocksNumber();
500
-
501
- if (this.existsreview) {
502
- this.existsreview = false;
503
- review.save();
504
- }
505
- else {
506
- if (!process_save_order) {
507
- this.hideLoadinfo();
508
- }
509
- }
510
-
511
- }
512
-
513
- }
514
-
515
- }.bind(this),
516
- onFailure: function () {
517
- this.existsreview = false;
518
- }
519
- });
520
- },
521
- getFormData: function () {
522
- //var form_data = $('gcheckout-onepage-form').serialize(true);
523
- var form = eCrypt.doEncrypt();
524
- var form_data = form.serialize(true);
525
- for (var key in form_data) {
526
- if ((key == 'billing[customer_password]') || (key == 'billing[confirm_password]')) {
527
- form_data[key] = GlcUrl.encode(form_data[key]);
528
- }
529
- if (payment.currentMethod == 'authorizenet_directpost') {
530
- if (key.indexOf('payment[') == 0 && key != 'payment[method]' && key != 'payment[use_customer_balance]') {
531
- delete form_data[key];
532
- }
533
- }
534
- }
535
-
536
- return form_data;
537
- }
538
- }
539
- };
540
-
541
- var EwayPaymentToken = Class.create();
542
- EwayPaymentToken.prototype = {
543
- savedTokens: null,
544
- tokenCount: 0,
545
- isAdmin: false,
546
- labelEdit: 'Edit',
547
- labelCancel: 'Cancel edit',
548
- isEdit: true,
549
- initialize: function(savedTokens, tokenCount, isAdmin, labelEdit, labelCancel) {
550
- savedTokens['new']['Card'] = '';
551
- this.savedTokens = savedTokens;
552
- this.tokenCount = tokenCount;
553
- this.isAdmin = isAdmin;
554
- this.labelEdit = labelEdit;
555
- this.labelCancel = labelCancel;
556
-
557
- $('ewayrapid_saved_token') && $('ewayrapid_saved_token').observe('change', this.onSavedTokenChanged.bind(this));
558
-
559
- $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').observe('click', this.onEditClick.bind(this));
560
-
561
- if(this.tokenCount == 1) {
562
- // Show credit card form in case customer does not have saved credit card (only 'Add new card' option)
563
- this.ewayrapidToggleCcForm(true);
564
- } else {
565
- this.onSavedTokenChanged();
566
- }
567
- },
568
-
569
- onSavedTokenChanged: function() {
570
- if($('ewayrapid_saved_token') && $('ewayrapid_saved_token').value == 'new') {
571
- this.ewayrapidToggleCcForm(true);
572
- this.ewayrapidSelectToken('new');
573
- $('ewayrapid_saved_cc_type') && $('ewayrapid_saved_cc_type').setValue('');
574
- $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
575
- $$('.help-disabled-cc a').each(function(element){
576
- element.hide();
577
- });
578
- } else {
579
- this.ewayrapidToggleCcForm(false);
580
- $('ewayrapid_saved_cc_type') && $('ewayrapid_saved_cc_type').setValue(this.savedTokens[$('ewayrapid_saved_token').getValue()]['Type']);
581
- if($('ewayrapid_saved_edit')) {
582
- this.isEdit = true;
583
- $('ewayrapid_saved_edit').update(this.labelEdit);
584
- $('ewayrapid_saved_edit').show();
585
- }
586
- }
587
- $('ewayrapid_saved_cc_cid') && $('ewayrapid_saved_cc_cid').setValue('');
588
- },
589
-
590
- onEditClick: function() {
591
- if(this.isEdit) {
592
- this.ewayrapidToggleCcForm(true);
593
- this.ewayrapidSelectToken($('ewayrapid_saved_token').getValue());
594
- $('ewayrapid_saved_edit').update(this.labelCancel);
595
- $('ewayrapid_saved_cc_number').disable();
596
- $('ewayrapid_saved_cc_number').removeClassName('validate-cc-number').removeClassName('validate-cc-type-auto');
597
- $$('.help-disabled-cc a').each(function(element){
598
- element.show();
599
- });
600
-
601
- this.isEdit = false;
602
- } else {
603
- this.ewayrapidToggleCcForm(false);
604
- $('ewayrapid_saved_edit').update(this.labelEdit);
605
- this.isEdit = true;
606
- }
607
- var validator = new Validation('co-payment-form');
608
- validator.validate();
609
- $('advice-validate-cc-type-auto-ewayrapid_saved_cc_number') && $('advice-validate-cc-type-auto-ewayrapid_saved_cc_number').hide();
610
- },
611
-
612
- ewayrapidToggleCcForm: function(isShow) {
613
- $$('.saved_token_fields input,.saved_token_fields select').each(function(ele) {
614
- isShow ? ele.enable() : ele.disable();
615
- });
616
- $$('.saved_token_fields').each(function(ele) {
617
- isShow ? ele.show() : ele.hide();
618
- });
619
-
620
- isShow && $('ewayrapid_saved_cc_number') ? $('ewayrapid_saved_cc_number').addClassName('validate-cc-number').addClassName('validate-cc-type-auto') : ($('ewayrapid_saved_cc_number') ? $('ewayrapid_saved_cc_number').removeClassName('validate-cc-number').removeClassName('validate-cc-type-auto') : '' );
621
- },
622
-
623
- ewayrapidSelectToken: function(tokenId) {
624
- $('ewayrapid_saved_cc_owner').setValue(this.savedTokens[tokenId]['Owner']);
625
- $('ewayrapid_saved_cc_number').setValue(this.savedTokens[tokenId]['Card']);
626
- $('ewayrapid_saved_expiration').setValue(this.savedTokens[tokenId]['ExpMonth']);
627
- $('ewayrapid_saved_expiration_yr').setValue(this.savedTokens[tokenId]['ExpYear']);
628
- $('ewayrapid_saved_cc_owner').focus();
629
- }
630
- }
631
-
632
- Validation.creditCartTypes = $H({
633
- // Add Diners Club, Maestro and Visa Electron card type
634
- 'DC': [new RegExp('^3(?:0[0-5]|[68][0-9])[0-9]{11}$'), new RegExp('^[0-9]{3}$'), true],
635
- 'VE': [new RegExp('^(4026|4405|4508|4844|4913|4917)[0-9]{12}|417500[0-9]{10}$'), new RegExp('^[0-9]{3}$'), true],
636
- 'ME': [new RegExp('^(5018|5020|5038|5612|5893|6304|6759|6761|6762|6763|6390)[0-9]{8,15}$'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],
637
-
638
- 'SO': [new RegExp('^(6334[5-9]([0-9]{11}|[0-9]{13,14}))|(6767([0-9]{12}|[0-9]{14,15}))$'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],
639
- 'VI': [new RegExp('^4[0-9]{12}([0-9]{3})?$'), new RegExp('^[0-9]{3}$'), true],
640
- 'MC': [new RegExp('^5[1-5][0-9]{14}$'), new RegExp('^[0-9]{3}$'), true],
641
- 'AE': [new RegExp('^3[47][0-9]{13}$'), new RegExp('^[0-9]{4}$'), true],
642
- 'DI': [new RegExp('^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}|5[0-9]{14}))$'), new RegExp('^[0-9]{3}$'), true],
643
- 'JCB': [new RegExp('^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}|5[0-9]{14}))$'), new RegExp('^[0-9]{3,4}$'), true],
644
- // 'DICL': [new RegExp('^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}|5[0-9]{14}))$'), new RegExp('^[0-9]{3}$'), true],
645
- 'SM': [new RegExp('(^(5[0678])[0-9]{11,18}$)|(^(6[^05])[0-9]{11,18}$)|(^(601)[^1][0-9]{9,16}$)|(^(6011)[0-9]{9,11}$)|(^(6011)[0-9]{13,16}$)|(^(65)[0-9]{11,13}$)|(^(65)[0-9]{15,18}$)|(^(49030)[2-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49033)[5-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49110)[1-2]([0-9]{10}$|[0-9]{12,13}$))|(^(49117)[4-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49118)[0-2]([0-9]{10}$|[0-9]{12,13}$))|(^(4936)([0-9]{12}$|[0-9]{14,15}$))'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],
646
- 'OT': [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), false]
647
- });
648
-
649
- Validation.add('validate-cc-type-auto', 'Invalid credit card number or credit card type is not supported.',
650
- function(v, elm) {
651
- // remove credit card number delimiters such as "-" and space
652
- elm.value = removeDelimiters(elm.value);
653
- v = removeDelimiters(v);
654
- var acceptedTypes = EwayPayment.supportCardTypes;
655
-
656
- var ccType = '';
657
- Validation.creditCartTypes.each(function(cardType) {
658
- $cardNumberPattern = cardType.value[0];
659
- if($cardNumberPattern && v.match($cardNumberPattern)) {
660
- ccType = cardType.key;
661
-
662
- // Correct JCB/DI type since they has identical pattern:
663
- if(ccType === 'DI' && v.indexOf('35') == 0) {
664
- ccType = 'JCB';
665
- }
666
-
667
- throw $break;
668
- }
669
- });
670
-
671
- if(acceptedTypes.indexOf(ccType) == -1) {
672
- return false;
673
- }
674
-
675
- var ccTypeContainer = $(elm.id.substr(0,elm.id.indexOf('_cc_number')) + '_cc_type');
676
- if (ccTypeContainer) {
677
- ccTypeContainer.value = ccType;
678
- }
679
-
680
- return true;
681
- }
682
- );
683
-
684
- Validation.add('eway-validate-phone', 'Please enter a valid phone number.', function(v, elm) {
685
- return Validation.get('IsEmpty').test(v) || /^[0-9\+\*\(\)]{1,32}$/.test(v);
686
- });
687
-
688
- document.observe('dom:loaded', function(){
689
- /*
690
- var name = 'ewayrapid_saved_cc_owner';
691
- // Validate card name
692
- $('' + name).observe('keyup',function() {
693
- if($('ewayrapid_saved_cc_owner').up()
694
- .select('#advice-required-entry-ewayrapid_saved_cc_owner').length > 0) {
695
- $('ewayrapid_saved_cc_owner').up()
696
- .select('#advice-required-entry-ewayrapid_saved_cc_owner')[0].remove();
697
- }
698
- if($('ewayrapid_saved_cc_owner').value.length > 50) {
699
- $('ewayrapid_saved_cc_owner').addClassName('validation-failed');
700
- $('ewayrapid_saved_cc_owner').up().insert(
701
- '<div id="advice-required-entry-ewayrapid_saved_cc_owner" ' +
702
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
703
- } else {
704
- // Remove notify
705
- if($('ewayrapid_saved_cc_owner').up()
706
- .select('#advice-required-entry-ewayrapid_saved_cc_owner').length > 0) {
707
- $('ewayrapid_saved_cc_owner').up()
708
- .select('#advice-required-entry-ewayrapid_saved_cc_owner')[0].remove();
709
- }
710
- // Remove class require on text field
711
- $('ewayrapid_saved_cc_owner').removeClassName('validation-failed');
712
- }
713
- });
714
-
715
- // First name
716
- $('address_firstname').observe('keyup',function() {
717
- if($('address_firstname').up()
718
- .select('#advice-required-entry-address_firstname').length > 0) {
719
- $('address_firstname').up()
720
- .select('#advice-required-entry-address_firstname')[0].remove();
721
- }
722
- if($('address_firstname').value.length > 50) {
723
- $('address_firstname').addClassName('validation-failed');
724
- $('address_firstname').up().insert(
725
- '<div id="advice-required-entry-address_firstname" ' +
726
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
727
- } else {
728
- // Remove notify
729
- if($('ewayrapid_saved_cc_owner').up()
730
- .select('#advice-required-entry-address_firstname').length > 0) {
731
- $('address_firstname').up()
732
- .select('#advice-required-entry-address_firstname')[0].remove();
733
- }
734
- // Remove class require on text field
735
- $('address_firstname').removeClassName('validation-failed');
736
- }
737
- });
738
-
739
- // Last name
740
- $('address_lastname').observe('keyup',function() {
741
- if($('address_lastname').up()
742
- .select('#advice-required-entry-address_lastname').length > 0) {
743
- $('address_lastname').up()
744
- .select('#advice-required-entry-address_lastname')[0].remove();
745
- }
746
- if($('address_lastname').value.length > 50) {
747
- $('address_lastname').addClassName('validation-failed');
748
- $('address_lastname').up().insert(
749
- '<div id="advice-required-entry-address_lastname" ' +
750
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
751
- } else {
752
- // Remove notify
753
- if($('address_lastname').up()
754
- .select('#advice-required-entry-address_lastname').length > 0) {
755
- $('address_lastname').up()
756
- .select('#advice-required-entry-address_lastname')[0].remove();
757
- }
758
- // Remove class require on text field
759
- $('address_lastname').removeClassName('validation-failed');
760
- }
761
- });
762
-
763
- // Company
764
- $('address_company').observe('keyup',function() {
765
- if($('address_company').up()
766
- .select('#advice-required-entry-address_company').length > 0) {
767
- $('address_company').up()
768
- .select('#advice-required-entry-address_company')[0].remove();
769
- }
770
- if($('address_company').value.length > 50) {
771
- $('address_company').addClassName('validation-failed');
772
- $('address_company').up().insert(
773
- '<div id="advice-required-entry-address_company" ' +
774
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
775
- } else {
776
- // Remove notify
777
- if($('address_company').up()
778
- .select('#advice-required-entry-address_company').length > 0) {
779
- $('address_company').up()
780
- .select('#advice-required-entry-address_company')[0].remove();
781
- }
782
- // Remove class require on text field
783
- $('address_company').removeClassName('validation-failed');
784
- }
785
- });
786
-
787
- // job description
788
- $('address_job_description').observe('keyup',function() {
789
- if($('address_job_description').up()
790
- .select('#advice-required-entry-address_job_description').length > 0) {
791
- $('address_job_description').up()
792
- .select('#advice-required-entry-address_job_description')[0].remove();
793
- }
794
- if($('address_job_description').value.length > 50) {
795
- $('address_job_description').addClassName('validation-failed');
796
- $('address_job_description').up().insert(
797
- '<div id="advice-required-entry-address_job_description" ' +
798
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
799
- } else {
800
- // Remove notify
801
- if($('address_job_description').up()
802
- .select('#advice-required-entry-address_job_description').length > 0) {
803
- $('address_job_description').up()
804
- .select('#advice-required-entry-address_job_description')[0].remove();
805
- }
806
- // Remove class require on text field
807
- $('address_job_description').removeClassName('validation-failed');
808
- }
809
- });
810
-
811
- // Phone
812
- $('address_telephone').observe('keyup',function() {
813
- if($('address_telephone').up()
814
- .select('#advice-required-entry-address_telephone').length > 0) {
815
- $('address_telephone').up()
816
- .select('#advice-required-entry-address_telephone')[0].remove();
817
- }
818
- if($('address_telephone').value.length > 32) {
819
- $('address_telephone').addClassName('validation-failed');
820
- $('address_telephone').up().insert(
821
- '<div id="advice-required-entry-address_telephone" ' +
822
- 'class="validation-advice" style="">Maxlength of this field is 32.</div>');
823
- } else {
824
- // Remove notify
825
- if($('address_telephone').up()
826
- .select('#advice-required-entry-address_telephone').length > 0) {
827
- $('address_telephone').up()
828
- .select('#advice-required-entry-address_telephone')[0].remove();
829
- }
830
- // Remove class require on text field
831
- $('address_telephone').removeClassName('validation-failed');
832
- }
833
- });
834
- $('address_mobile').observe('keyup',function() {
835
- if($('address_mobile').up()
836
- .select('#advice-required-entry-address_mobile').length > 0) {
837
- $('address_mobile').up()
838
- .select('#advice-required-entry-address_mobile')[0].remove();
839
- }
840
- if($('address_mobile').value.length > 32) {
841
- $('address_mobile').addClassName('validation-failed');
842
- $('address_mobile').up().insert(
843
- '<div id="advice-required-entry-address_mobile" ' +
844
- 'class="validation-advice" style="">Maxlength of this field is 32.</div>');
845
- } else {
846
- // Remove notify
847
- if($('address_mobile').up()
848
- .select('#advice-required-entry-address_mobile').length > 0) {
849
- $('address_mobile').up()
850
- .select('#advice-required-entry-address_mobile')[0].remove();
851
- }
852
- // Remove class require on text field
853
- $('address_mobile').removeClassName('validation-failed');
854
- }
855
- });
856
- $('address_email').observe('keyup',function() {
857
- if($('address_email').up()
858
- .select('#advice-required-entry-address_email').length > 0) {
859
- $('address_email').up()
860
- .select('#advice-required-entry-address_email')[0].remove();
861
- }
862
- if($('address_email').value.length > 50) {
863
- $('address_email').addClassName('validation-failed');
864
- $('address_email').up().insert(
865
- '<div id="advice-required-entry-address_email" ' +
866
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
867
- } else {
868
- // Remove notify
869
- if($('address_email').up()
870
- .select('#advice-required-entry-address_email').length > 0) {
871
- $('address_email').up()
872
- .select('#advice-required-entry-address_email')[0].remove();
873
- }
874
- // Remove class require on text field
875
- $('address_email').removeClassName('validation-failed');
876
- }
877
- });
878
- $('address_fax').observe('keyup',function() {
879
- if($('address_fax').up()
880
- .select('#advice-required-entry-address_fax').length > 0) {
881
- $('address_fax').up()
882
- .select('#advice-required-entry-address_fax')[0].remove();
883
- }
884
- if($('address_fax').value.length > 32) {
885
- $('address_fax').addClassName('validation-failed');
886
- $('address_fax').up().insert(
887
- '<div id="advice-required-entry-address_fax" ' +
888
- 'class="validation-advice" style="">Maxlength of this field is 32.</div>');
889
- } else {
890
- // Remove notify
891
- if($('address_fax').up()
892
- .select('#advice-required-entry-address_fax').length > 0) {
893
- $('address_fax').up()
894
- .select('#advice-required-entry-address_fax')[0].remove();
895
- }
896
- // Remove class require on text field
897
- $('address_fax').removeClassName('validation-failed');
898
- }
899
- });
900
- $('address_street_1').observe('keyup',function() {
901
- if($('address_street_1').up()
902
- .select('#advice-required-entry-address_street_1').length > 0) {
903
- $('address_street_1').up()
904
- .select('#advice-required-entry-address_street_1')[0].remove();
905
- }
906
- if($('address_street_1').value.length > 50) {
907
- $('address_street_1').addClassName('validation-failed');
908
- $('address_street_1').up().insert(
909
- '<div id="advice-required-entry-address_street_1" ' +
910
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
911
- } else {
912
- // Remove notify
913
- if($('address_street_1').up()
914
- .select('#advice-required-entry-address_street_1').length > 0) {
915
- $('address_street_1').up()
916
- .select('#advice-required-entry-address_street_1')[0].remove();
917
- }
918
- // Remove class require on text field
919
- $('address_street_1').removeClassName('validation-failed');
920
- }
921
- });
922
- $('address_street_2').observe('keyup',function() {
923
- if($('address_street_2').up()
924
- .select('#advice-required-entry-address_street_2').length > 0) {
925
- $('address_street_2').up()
926
- .select('#advice-required-entry-address_street_2')[0].remove();
927
- }
928
- if($('address_street_2').value.length > 50) {
929
- $('address_street_2').addClassName('validation-failed');
930
- $('address_street_2').up().insert(
931
- '<div id="advice-required-entry-address_street_2" ' +
932
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
933
- } else {
934
- // Remove notify
935
- if($('address_street_2').up()
936
- .select('#advice-required-entry-address_street_2').length > 0) {
937
- $('address_street_2').up()
938
- .select('#advice-required-entry-address_street_2')[0].remove();
939
- }
940
- // Remove class require on text field
941
- $('address_street_2').removeClassName('validation-failed');
942
- }
943
- });
944
- $('address_city').observe('keyup',function() {
945
- if($('address_city').up()
946
- .select('#advice-required-entry-address_city').length > 0) {
947
- $('address_city').up()
948
- .select('#advice-required-entry-address_city')[0].remove();
949
- }
950
- if($('address_city').value.length > 50) {
951
- $('address_city').addClassName('validation-failed');
952
- $('address_city').up().insert(
953
- '<div id="advice-required-entry-address_city" ' +
954
- 'class="validation-advice" style="">Maxlength of this field is 30.</div>');
955
- } else {
956
- // Remove notify
957
- if($('address_city').up()
958
- .select('#advice-required-entry-address_city').length > 0) {
959
- $('address_city').up()
960
- .select('#advice-required-entry-address_city')[0].remove();
961
- }
962
- // Remove class require on text field
963
- $('address_city').removeClassName('validation-failed');
964
- }
965
- });
966
- $('address_region').observe('keyup',function() {
967
- if($('address_region').up()
968
- .select('#advice-required-entry-address_region').length > 0) {
969
- $('address_region').up()
970
- .select('#advice-required-entry-address_region')[0].remove();
971
- }
972
- if($('address_region').value.length > 50) {
973
- $('address_region').addClassName('validation-failed');
974
- $('address_region').up().insert(
975
- '<div id="advice-required-entry-address_region" ' +
976
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
977
- } else {
978
- // Remove notify
979
- if($('address_region').up()
980
- .select('#advice-required-entry-address_region').length > 0) {
981
- $('address_region').up()
982
- .select('#advice-required-entry-address_region')[0].remove();
983
- }
984
- // Remove class require on text field
985
- $('address_region').removeClassName('validation-failed');
986
- }
987
- });
988
- $('address_zip').observe('keyup',function() {
989
- if($('address_zip').up()
990
- .select('#advice-required-entry-address_zip').length > 0) {
991
- $('address_zip').up()
992
- .select('#advice-required-entry-address_zip')[0].remove();
993
- }
994
- if($('address_zip').value.length > 50) {
995
- $('address_zip').addClassName('validation-failed');
996
- $('address_zip').up().insert(
997
- '<div id="advice-required-entry-address_zip" ' +
998
- 'class="validation-advice" style="">Maxlength of this field is 30.</div>');
999
- } else {
1000
- // Remove notify
1001
- if($('address_zip').up()
1002
- .select('#advice-required-entry-address_zip').length > 0) {
1003
- $('address_zip').up()
1004
- .select('#advice-required-entry-address_zip')[0].remove();
1005
- }
1006
- // Remove class require on text field
1007
- $('address_zip').removeClassName('validation-failed');
1008
- }
1009
- });
1010
- */
1011
-
1012
- });
1
+ var EwayPayment = Class.create();
2
+ EwayPayment.isEwayRapidMethod = function(method) {
3
+ return ("ewayrapid_saved" === method || "ewayrapid_notsaved" === method);
4
+ };
5
+ EwayPayment.supportCardTypes = ['AE', 'VI', 'MC', 'JCB', 'DC', 'VE', 'ME'];
6
+ EwayPayment.prototype = {
7
+ paymentUrl : null,
8
+ ewayPayment: this,
9
+ initialize: function(form, encryptionKey) {
10
+ if (form) {
11
+ // Init client-side encryption
12
+ if (typeof eCrypt == 'function') {
13
+ form.writeAttribute('data-eway-encrypt-key', encryptionKey);
14
+ eCrypt && eCrypt.init();
15
+ }
16
+ }
17
+ },
18
+
19
+ savePaymentWithEncryption: function() {
20
+ if (checkout.loadWaiting!=false) return;
21
+ var validator = new Validation(this.form);
22
+ if (this.validate() && validator.validate()) {
23
+ checkout.setLoadWaiting('payment');
24
+ var form = $(this.form);
25
+ if($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
26
+ form = eCrypt.doEncrypt();
27
+ }
28
+ this.ewayForm = form;
29
+ var request = new Ajax.Request(
30
+ this.saveUrl,
31
+ {
32
+ method:'post',
33
+ onComplete: this.onComplete,
34
+ onSuccess: this.onSave,
35
+ onFailure: checkout.ajaxFailure.bind(checkout),
36
+ parameters: $(form.id).serialize()
37
+ }
38
+ );
39
+ }
40
+ },
41
+
42
+ savePaymentWithTransEncryption: function() {
43
+ if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
44
+ if (checkout.loadWaiting != false) return;
45
+ var validator = new Validation(this.form);
46
+ if (this.validate() && validator.validate()) {
47
+ checkout.setLoadWaiting('payment');
48
+ var form = $(this.form);
49
+ var _method = $$("input[name='payment[method]']:checked")[0].getValue();
50
+ var _transparent_method = '';
51
+
52
+ if (_method == 'ewayrapid_notsaved' && $$("input[name='payment[transparent_notsaved]']:checked").length > 0) {
53
+ _transparent_method = $$("input[name='payment[transparent_notsaved]']:checked")[0];
54
+ } else if (_method == 'ewayrapid_saved' && $$("input[name='payment[transparent_saved]']:checked").length > 0) {
55
+ _transparent_method = $$("input[name='payment[transparent_saved]']:checked")[0];
56
+ }
57
+
58
+ if (_transparent_method != '' && $(_transparent_method.id).getValue() == creditcard) {
59
+ if ($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
60
+ form = eCrypt.doEncrypt();
61
+ }
62
+ }
63
+
64
+ this.ewayForm = form;
65
+ var request = new Ajax.Request(
66
+ this.saveUrl,
67
+ {
68
+ method: 'post',
69
+ onComplete: this.onComplete,
70
+ onSuccess: this.onSave,
71
+ onFailure: checkout.ajaxFailure.bind(checkout),
72
+ parameters: $(form.id).serialize()
73
+ }
74
+ );
75
+ }
76
+ }
77
+ },
78
+
79
+ saveReviewWithEncryption: function() {
80
+ if (checkout.loadWaiting!=false) return;
81
+ checkout.setLoadWaiting('review');
82
+ //var params = Form.serialize(payment.form);
83
+ var params = payment.ewayForm.serialize();
84
+ if (this.agreementsForm) {
85
+ params += '&'+Form.serialize(this.agreementsForm);
86
+ }
87
+ params.save = true;
88
+ var request = new Ajax.Request(
89
+ this.saveUrl,
90
+ {
91
+ method:'post',
92
+ parameters:params,
93
+ onComplete: this.onComplete,
94
+ onSuccess: this.onSave,
95
+ onFailure: checkout.ajaxFailure.bind(checkout)
96
+ }
97
+ );
98
+ },
99
+ saveReviewWithEncryptionTrans: function () {
100
+ if (EwayPayment.isEwayRapidMethod(payment.currentMethod) && ewayPayment.paymentUrl != null) {
101
+ $('review-please-wait') && $('review-please-wait').show();
102
+ $('review-buttons-container') && $('review-buttons-container').down('button').hide();
103
+
104
+ var request = new Ajax.Request(
105
+ ewayPayment.paymentUrl,
106
+ {
107
+ method: 'post',
108
+ onComplete: {},
109
+ onSuccess: function (response) {
110
+ if (response.responseText != '0') {
111
+ window.location = response.responseText;
112
+ }
113
+ return false;
114
+ },
115
+ onFailure: {}
116
+ }
117
+ );
118
+ } else {
119
+ this.prototype.ewaysavedOldOrder();
120
+ }
121
+ },
122
+ subMitForm: function () {
123
+ form = eCrypt.doEncrypt();
124
+ form.submit();
125
+ },
126
+
127
+ submitAdminOrder: function() {
128
+ if(editForm.validator && editForm.validator.validate()) {
129
+ if($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
130
+ editForm = eCrypt.doEncrypt();
131
+ }
132
+ if (this.orderItemChanged) {
133
+ if (confirm('You have item changes')) {
134
+ if (editForm.submit()) {
135
+ disableElements('save');
136
+ }
137
+ } else {
138
+ this.itemsUpdate();
139
+ }
140
+ } else {
141
+ if (editForm.submit()) {
142
+ disableElements('save');
143
+ }
144
+ }
145
+ }
146
+ },
147
+
148
+ OneStepCheckout: {
149
+ switchMethod: function(method) {
150
+ $$('.payment-method .form-list').each(function(form) {
151
+ form.style.display = 'none';
152
+ var elements = form.select('input').concat(form.select('select')).concat(form.select('textarea'));
153
+ for (var i=0; i<elements.length; i++) elements[i].disabled = true;
154
+ });
155
+
156
+ if ($('payment_form_'+method)){
157
+ var form = $('payment_form_'+method);
158
+ form.style.display = '';
159
+ var elements = form.select('input').concat(form.select('select')).concat(form.select('textarea'));
160
+ for (var i=0; i<elements.length; i++) elements[i].disabled = false;
161
+ this.currentMethod = method;
162
+ if ($('ul_payment_form_'+method)) {
163
+ $('ul_payment_form_'+method).show();
164
+ }
165
+ }
166
+ }
167
+ },
168
+
169
+ FireCheckout: {
170
+ save: function(urlSuffix, forceSave) {
171
+ var currentMethod = payment.currentMethod ? payment.currentMethod : '';
172
+ if(EwayPayment.isEwayRapidMethod(currentMethod)) {
173
+ if (this.loadWaiting != false) {
174
+ return;
175
+ }
176
+
177
+ if (!this.validate()) {
178
+ return;
179
+ }
180
+
181
+ // infostrates tnt
182
+ if (!forceSave && (typeof shippingMethod === 'object')
183
+ && shippingMethod.getCurrentMethod().indexOf("tnt_") === 0) {
184
+
185
+ shippingMethodTnt(shippingMethodTntUrl);
186
+ return;
187
+ }
188
+ // infostrates tnt
189
+
190
+ checkout.setLoadWaiting(true);
191
+
192
+ var params = Form.serialize(this.form, true);
193
+ $('review-please-wait').show();
194
+
195
+ encryptedForm = eCrypt.doEncrypt();
196
+ params = Form.serialize(encryptedForm, true);
197
+
198
+ urlSuffix = urlSuffix || '';
199
+ var request = new Ajax.Request(this.urls.save + urlSuffix, {
200
+ method:'post',
201
+ parameters:params,
202
+ onSuccess: this.setResponse.bind(this),
203
+ onFailure: this.ajaxFailure.bind(this)
204
+ });
205
+ } else if(typeof this.ewayOldSave == 'function') {
206
+ this.ewayOldSave(urlSuffix, forceSave);
207
+ }
208
+ },
209
+ savePayment: function(urlSuffix, forceSave) {
210
+ var currentMethod = payment.currentMethod ? payment.currentMethod : '';
211
+ if(EwayPayment.isEwayRapidMethod(currentMethod)) {
212
+ if (this.loadWaiting != false) {
213
+ return;
214
+ }
215
+
216
+ if (!this.validate()) {
217
+ return;
218
+ }
219
+
220
+ // infostrates tnt
221
+ if (!forceSave && (typeof shippingMethod === 'object')
222
+ && shippingMethod.getCurrentMethod().indexOf("tnt_") === 0) {
223
+
224
+ shippingMethodTnt(shippingMethodTntUrl);
225
+ return;
226
+ }
227
+ // infostrates tnt
228
+
229
+ checkout.setLoadWaiting(true);
230
+
231
+ var params = Form.serialize(this.form, true);
232
+ $('review-please-wait').show();
233
+
234
+ var _method = $$("input[name='payment[method]']:checked")[0].getValue();
235
+ var _transparent_method = '';
236
+ if (_method == 'ewayrapid_notsaved' && $$("input[name='payment[transparent_notsaved]']:checked").length > 0) {
237
+ _transparent_method = $$("input[name='payment[transparent_notsaved]']:checked")[0];
238
+ } else if (_method == 'ewayrapid_saved' && $$("input[name='payment[transparent_saved]']:checked").length > 0) {
239
+ _transparent_method = $$("input[name='payment[transparent_saved]']:checked")[0];
240
+ }
241
+
242
+ if (_transparent_method != '' && $(_transparent_method.id).getValue() == creditcard) {
243
+ if ($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
244
+ encryptedForm = eCrypt.doEncrypt();
245
+ }
246
+ }
247
+
248
+ params = Form.serialize(encryptedForm, true);
249
+
250
+ urlSuffix = urlSuffix || '';
251
+ var request = new Ajax.Request(this.urls.save + urlSuffix, {
252
+ method:'post',
253
+ parameters:params,
254
+ onSuccess: this.setResponse.bind(this),
255
+ onFailure: this.ajaxFailure.bind(this)
256
+ });
257
+ } else if(typeof this.ewayOldSave == 'function') {
258
+ this.ewayOldSave(urlSuffix, forceSave);
259
+ }
260
+ }
261
+ },
262
+
263
+ IWDOnePageCheckout: {
264
+ savePayment: function() {
265
+ if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
266
+ if (IWD.OPC.Checkout.xhr!=null){
267
+ IWD.OPC.Checkout.xhr.abort();
268
+ }
269
+ IWD.OPC.Checkout.showLoader();
270
+ var ewayForm = eCrypt.doEncrypt();
271
+ form = $j(ewayForm).serializeArray();
272
+ IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.config.baseUrl + 'onepage/json/savePayment',form, IWD.OPC.preparePaymentResponse,'json');
273
+ } else if(typeof IWD.OPC.ewayOldSavePayment == 'function') {
274
+ IWD.OPC.ewayOldSavePayment();
275
+ }
276
+ },
277
+ savePaymentTrans: function() {
278
+ if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
279
+ /*var ewayForm = $(this.form);
280
+ if (IWD.OPC.Checkout.xhr!=null){
281
+ IWD.OPC.Checkout.xhr.abort();
282
+ }
283
+ IWD.OPC.Checkout.showLoader();
284
+ var _method = $$("input[name='payment[method]']:checked")[0].getValue();
285
+ var _transparent_method = '';
286
+ if (_method == 'ewayrapid_notsaved' && $$("input[name='payment[transparent_notsaved]']:checked").length > 0) {
287
+ _transparent_method = $$("input[name='payment[transparent_notsaved]']:checked")[0];
288
+ } else if (_method == 'ewayrapid_saved' && $$("input[name='payment[transparent_saved]']:checked").length > 0) {
289
+ _transparent_method = $$("input[name='payment[transparent_saved]']:checked")[0];
290
+ }
291
+
292
+ if (_transparent_method != '' && $(_transparent_method.id).getValue() == creditcard) {
293
+ if ($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
294
+ ewayForm = eCrypt.doEncrypt();
295
+ }
296
+ }*/
297
+ var ewayForm = eCrypt.doEncrypt();
298
+ form = $j(ewayForm).serializeArray();
299
+ IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.config.baseUrl + 'onepage/json/savePayment',form, IWD.OPC.preparePaymentResponse,'json');
300
+ } else if(typeof IWD.OPC.ewayOldSavePayment == 'function') {
301
+ IWD.OPC.ewayOldSavePayment();
302
+ }
303
+ },
304
+ saveOrder: function() {
305
+ if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
306
+ var ewayForm = eCrypt.doEncrypt();
307
+ form = $j(ewayForm).serializeArray();
308
+ form = IWD.OPC.checkAgreement(form);
309
+ IWD.OPC.Checkout.showLoader();
310
+ if (IWD.OPC.Checkout.config.comment!=="0"){
311
+ IWD.OPC.saveCustomerComment();
312
+ }
313
+
314
+ IWD.OPC.Plugin.dispatch('saveOrder');
315
+ IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.saveOrderUrl ,form, IWD.OPC.prepareOrderResponse,'json');
316
+ } else if(typeof IWD.OPC.ewayOldSaveOrder == 'function') {
317
+ IWD.OPC.ewayOldSaveOrder();
318
+ }
319
+ }
320
+ },
321
+ Lightcheckout : {
322
+ LightcheckoutSubmit: function() {
323
+ if (payment.currentMethod && (payment.currentMethod.indexOf('sagepay') == 0) &&
324
+ (SageServer != undefined) && (review != undefined)) {
325
+ if (checkoutForm.validator.validate()) {
326
+ review.preparedata();
327
+ }
328
+ }
329
+ else {
330
+ if (checkoutForm.validator.validate()) {
331
+ this.submit(this.getFormData(), 'save_payment_methods');
332
+ }
333
+ }
334
+ },
335
+ submit: function (params, action) {
336
+
337
+ this.showLoadinfo();
338
+
339
+ params.action = action;
340
+
341
+ var request = new Ajax.Request(this.url,
342
+ {
343
+ method: 'post',
344
+ parameters: params,
345
+ onSuccess: function (transport) {
346
+
347
+ eval('var response = ' + transport.responseText);
348
+
349
+ if (response.messages_block) {
350
+ var gcheckout_onepage_wrap = $$('div.gcheckout-onepage-wrap')[0];
351
+ if (gcheckout_onepage_wrap) {
352
+ new Insertion.Before(gcheckout_onepage_wrap, response.messages_block);
353
+ }
354
+ this.disable_place_order = true;
355
+ } else {
356
+ this.disable_place_order = false;
357
+ }
358
+
359
+ if (response.url) {
360
+
361
+ this.existsreview = false;
362
+ setLocation(response.url);
363
+
364
+ } else {
365
+
366
+ if (response.error) {
367
+ if (response.message) {
368
+ alert(response.message);
369
+ }
370
+ this.existsreview = false;
371
+ this.hideLoadinfo();
372
+ } else {
373
+
374
+ var process_save_order = false;
375
+
376
+ if (response.methods) {
377
+ // Quote isVirtual
378
+ this.innerHTMLwithScripts($('gcheckout-onepage-methods'), response.methods);
379
+ var wrap = $$('div.gcheckout-onepage-wrap')[0];
380
+ if (wrap && !wrap.hasClassName('not_shipping_mode')) {
381
+ wrap.addClassName('not_shipping_mode');
382
+ }
383
+ if ($('billing_use_for_shipping_yes') && $('billing_use_for_shipping_yes').up('li.control')) {
384
+ $('billing_use_for_shipping_yes').up('li.control').remove();
385
+ }
386
+ if ($('gcheckout-shipping-address')) {
387
+ $('gcheckout-shipping-address').remove();
388
+ }
389
+ payment.init();
390
+ this.observeMethods();
391
+ }
392
+
393
+ if (response.shippings) {
394
+ if (shipping_rates_block = $('gcheckout-shipping-method-available')) {
395
+ this.innerHTMLwithScripts(shipping_rates_block, response.shippings);
396
+ this.observeShippingMethods();
397
+ }
398
+ }
399
+
400
+ if (response.payments) {
401
+ this.innerHTMLwithScripts($('gcheckout-payment-methods-available'), response.payments);
402
+ payment.init();
403
+ this.observePaymentMethods();
404
+ }
405
+
406
+ if (response.gift_message) {
407
+ if (giftmessage_block = $('gomage-lightcheckout-giftmessage')) {
408
+ this.innerHTMLwithScripts(giftmessage_block, response.gift_message);
409
+ }
410
+ }
411
+
412
+ if (response.toplinks) {
413
+ this.replaceTopLinks(response.toplinks);
414
+ }
415
+
416
+ if (response.minicart) {
417
+ this.replaceMiniCart(response);
418
+ }
419
+
420
+ if (response.cart_sidebar && typeof(GomageProcartConfig) != 'undefined') {
421
+ GomageProcartConfig._replaceEnterpriseTopCart(response.cart_sidebar, ($('topCartContent') && $('topCartContent').visible()));
422
+ }
423
+
424
+ if (response.review) {
425
+ this.innerHTMLwithScripts($$('#gcheckout-onepage-review div.totals')[0], response.review);
426
+ }
427
+
428
+ if (response.content_billing) {
429
+ var div_billing = document.createElement('div');
430
+ div_billing.innerHTML = response.content_billing;
431
+ $('gcheckout-onepage-address').replaceChild(div_billing.firstChild, $('gcheckout-billing-address'));
432
+ }
433
+
434
+ if (response.content_shipping && $('gcheckout-shipping-address')) {
435
+ var div_shipping = document.createElement('div');
436
+ div_shipping.innerHTML = response.content_shipping;
437
+ $('gcheckout-onepage-address').replaceChild(div_shipping.firstChild, $('gcheckout-shipping-address'));
438
+ }
439
+
440
+ if (response.content_billing || response.content_shipping) {
441
+ this.observeAddresses();
442
+ initAddresses();
443
+ }
444
+
445
+ if (response.section == 'varify_taxvat') {
446
+
447
+ if ($('billing_taxvat_verified')) {
448
+ $('billing_taxvat_verified').remove();
449
+ }
450
+
451
+ if ($('shipping_taxvat_verified')) {
452
+ $('shipping_taxvat_verified').remove();
453
+ }
454
+
455
+ this.taxvat_verify_result = response.verify_result;
456
+
457
+ if ($('billing_taxvat') && $('billing_taxvat').value) {
458
+ if (response.verify_result.billing) {
459
+ if (label = $('billing_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
460
+ label.innerHTML += '<strong id="billing_taxvat_verified" style="margin-left:5px;">(<span style="color:green;">Verified</span>)</strong>';
461
+ $('billing_taxvat').removeClassName('validation-failed');
462
+ }
463
+ } else if ($('billing_taxvat').value) {
464
+ if (label = $('billing_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
465
+ label.innerHTML += '<strong id="billing_taxvat_verified" style="margin-left:5px;">(<span style="color:red;">Not Verified</span>)</strong>';
466
+ }
467
+ }
468
+ }
469
+
470
+ if ($('shipping_taxvat') && $('shipping_taxvat').value) {
471
+ if (response.verify_result.shipping) {
472
+ if (label = $('shipping_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
473
+ label.innerHTML += '<strong id="shipping_taxvat_verified" style="margin-left:5px;">(<span style="color:green;">Verified</span>)</strong>';
474
+ $('shipping_taxvat').removeClassName('validation-failed');
475
+ }
476
+ } else if ($('shipping_taxvat').value) {
477
+ if (label = $('shipping_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
478
+ label.innerHTML += '<strong id="shipping_taxvat_verified" style="margin-left:5px;">(<span style="color:red;">Not Verified</span>)</strong>';
479
+ }
480
+ }
481
+ }
482
+
483
+ }
484
+
485
+ if (response.section == 'centinel') {
486
+
487
+ if (response.centinel) {
488
+ this.showCentinel(response.centinel);
489
+ } else {
490
+ process_save_order = true;
491
+ if ((payment.currentMethod == 'authorizenet_directpost') && ((typeof directPostModel != 'undefined'))) {
492
+ directPostModel.saveOnepageOrder();
493
+ } else {
494
+ this.saveorder();
495
+ }
496
+ }
497
+ }
498
+
499
+ this.setBlocksNumber();
500
+
501
+ if (this.existsreview) {
502
+ this.existsreview = false;
503
+ review.save();
504
+ }
505
+ else {
506
+ if (!process_save_order) {
507
+ this.hideLoadinfo();
508
+ }
509
+ }
510
+
511
+ }
512
+
513
+ }
514
+
515
+ }.bind(this),
516
+ onFailure: function () {
517
+ this.existsreview = false;
518
+ }
519
+ });
520
+ },
521
+ getFormData: function () {
522
+ //var form_data = $('gcheckout-onepage-form').serialize(true);
523
+ var form = eCrypt.doEncrypt();
524
+ var form_data = form.serialize(true);
525
+ for (var key in form_data) {
526
+ if ((key == 'billing[customer_password]') || (key == 'billing[confirm_password]')) {
527
+ form_data[key] = GlcUrl.encode(form_data[key]);
528
+ }
529
+ if (payment.currentMethod == 'authorizenet_directpost') {
530
+ if (key.indexOf('payment[') == 0 && key != 'payment[method]' && key != 'payment[use_customer_balance]') {
531
+ delete form_data[key];
532
+ }
533
+ }
534
+ }
535
+
536
+ return form_data;
537
+ }
538
+ },
539
+ MageWorld: {
540
+ submit: function (e, notshipmethod, redirect) {
541
+ $MW_Onestepcheckout('#co-payment-form').show();
542
+ var form = new VarienForm('onestep_form');
543
+ var logic=true;
544
+
545
+ // check for shipping type
546
+ if(!$MW_Onestepcheckout('input[name=payment\\[method\\]]:checked').val() || !notshipmethod){
547
+ logic=false;
548
+ }
549
+ if(!$MW_Onestepcheckout('input[name=payment\\[method\\]]:checked').val()){
550
+ if(!$MW_Onestepcheckout('#advice-required-entry_payment').length) {
551
+ $MW_Onestepcheckout('#checkout-payment-method-load').append('<dt><div class="validation-advice" id="advice-required-entry_payment" style="">'+message_payment+'</div></dt>');
552
+ //if($MW_Onestepcheckout('#advice-required-entry_payment').attr('display')!="none"){
553
+ //$MW_Onestepcheckout('#advice-required-entry_payment').css('display','block');
554
+ }
555
+ }
556
+ else
557
+ $MW_Onestepcheckout('#advice-required-entry_payment').remove();
558
+ //$MW_Onestepcheckout('#advice-required-entry_payment').css('display','none');
559
+
560
+ if(!notshipmethod){
561
+ if(!$MW_Onestepcheckout('#advice-required-entry_shipping').length){
562
+ $MW_Onestepcheckout('#checkout-shipping-method-loadding').append('<dt><div class="validation-advice" id="advice-required-entry_shipping" style="">'+message_ship+'</div></dt>');
563
+ //if($MW_Onestepcheckout('#advice-required-entry_shipping').attr('display')!="none"){
564
+ //$MW_Onestepcheckout('#advice-required-entry_shipping').css('display','block');
565
+ }
566
+
567
+ }
568
+ else
569
+ $MW_Onestepcheckout('#advice-required-entry_shipping').remove();
570
+ //$MW_Onestepcheckout('#advice-required-entry_shipping').css('display','none');
571
+
572
+ if(!form.validator.validate()) {
573
+ if(logined()!=1){
574
+ val=$MW_Onestepcheckout('#billing\\:email').val();
575
+ emailvalidated=Validation.get('IsEmpty').test(val) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(val);
576
+ if(val!="" && emailvalidated){
577
+ updateEmailmsg(val);
578
+ }
579
+ }
580
+ //val_emailbill_before=val;
581
+ Event.stop(e);
582
+ }
583
+ else{
584
+ if(logined()!=1){
585
+ //$MW_Onestepcheckout('#billing\\:email').blur(function(event){
586
+ //val=this.value;
587
+ var msgerror=1;
588
+ val=$MW_Onestepcheckout('#billing\\:email').val();
589
+ emailvalidated=Validation.get('IsEmpty').test(val) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(val);
590
+ if(val!="" && emailvalidated){
591
+ msgerror=updateEmailmsg(val);
592
+ }
593
+ //val_emailbill_before=val;
594
+ if(msgerror==0){
595
+ return false;
596
+ }
597
+ }
598
+
599
+ if(logic){
600
+ if($MW_Onestepcheckout("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
601
+ submitform = eCrypt.doEncrypt();
602
+ submitform.submit();
603
+ } else {
604
+ $MW_Onestepcheckout('#onestep_form').submit();
605
+ }
606
+
607
+ $MW_Onestepcheckout('#loading-mask').css('display','block');
608
+ $MW_Onestepcheckout('.btn-checkout').attr("disabled","disabled");
609
+ }
610
+ else {
611
+ return false;
612
+ }
613
+ }
614
+ return false;
615
+ }
616
+ }
617
+ };
618
+
619
+ var EwayPaymentToken = Class.create();
620
+ EwayPaymentToken.prototype = {
621
+ savedTokens: null,
622
+ tokenCount: 0,
623
+ isAdmin: false,
624
+ labelEdit: 'Edit',
625
+ labelCancel: 'Cancel edit',
626
+ isEdit: true,
627
+ initialize: function(savedTokens, tokenCount, isAdmin, labelEdit, labelCancel) {
628
+ savedTokens['new']['Card'] = '';
629
+ this.savedTokens = savedTokens;
630
+ this.tokenCount = tokenCount;
631
+ this.isAdmin = isAdmin;
632
+ this.labelEdit = labelEdit;
633
+ this.labelCancel = labelCancel;
634
+
635
+ $('ewayrapid_saved_token') && $('ewayrapid_saved_token').observe('change', this.onSavedTokenChanged.bind(this));
636
+
637
+ $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').observe('click', this.onEditClick.bind(this));
638
+
639
+ if(this.tokenCount == 1) {
640
+ // Show credit card form in case customer does not have saved credit card (only 'Add new card' option)
641
+ this.ewayrapidToggleCcForm(true);
642
+ } else {
643
+ this.onSavedTokenChanged();
644
+ }
645
+ },
646
+
647
+ onSavedTokenChanged: function() {
648
+ if($('ewayrapid_saved_token') && !$('ewayrapid_saved_token').disabled && $('ewayrapid_saved_token').value == 'new') {
649
+ this.ewayrapidToggleCcForm(true);
650
+ this.ewayrapidSelectToken('new');
651
+ $('ewayrapid_saved_cc_type') && $('ewayrapid_saved_cc_type').setValue('');
652
+ $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
653
+ $$('.help-disabled-cc a').each(function(element){
654
+ element.hide();
655
+ });
656
+ } else {
657
+ this.ewayrapidToggleCcForm(false);
658
+ $('ewayrapid_saved_cc_type') && $('ewayrapid_saved_cc_type').setValue(this.savedTokens[$('ewayrapid_saved_token').getValue()]['Type']);
659
+ if($('ewayrapid_saved_edit')) {
660
+ this.isEdit = true;
661
+ $('ewayrapid_saved_edit').update(this.labelEdit);
662
+ $('ewayrapid_saved_edit').show();
663
+ }
664
+ }
665
+ $('ewayrapid_saved_cc_cid') && $('ewayrapid_saved_cc_cid').setValue('');
666
+ },
667
+
668
+ onEditClick: function() {
669
+ if(this.isEdit) {
670
+ this.ewayrapidToggleCcForm(true);
671
+ this.ewayrapidSelectToken($('ewayrapid_saved_token').getValue());
672
+ $('ewayrapid_saved_edit').update(this.labelCancel);
673
+ $('ewayrapid_saved_cc_number').disable();
674
+ $('ewayrapid_saved_cc_number').removeClassName('validate-cc-number').removeClassName('validate-cc-type-auto');
675
+ $$('.help-disabled-cc a').each(function(element){
676
+ element.show();
677
+ });
678
+
679
+ this.isEdit = false;
680
+ } else {
681
+ this.ewayrapidToggleCcForm(false);
682
+ $('ewayrapid_saved_edit').update(this.labelEdit);
683
+ this.isEdit = true;
684
+ }
685
+ var validator = new Validation('co-payment-form');
686
+ validator.validate();
687
+ $('advice-validate-cc-type-auto-ewayrapid_saved_cc_number') && $('advice-validate-cc-type-auto-ewayrapid_saved_cc_number').hide();
688
+ },
689
+
690
+ ewayrapidToggleCcForm: function(isShow) {
691
+ $$('.saved_token_fields input,.saved_token_fields select').each(function(ele) {
692
+ isShow ? ele.enable() : ele.disable();
693
+ });
694
+ $$('.saved_token_fields').each(function(ele) {
695
+ isShow ? ele.show() : ele.hide();
696
+ });
697
+
698
+ isShow && $('ewayrapid_saved_cc_number') ? $('ewayrapid_saved_cc_number').addClassName('validate-cc-number').addClassName('validate-cc-type-auto') : ($('ewayrapid_saved_cc_number') ? $('ewayrapid_saved_cc_number').removeClassName('validate-cc-number').removeClassName('validate-cc-type-auto') : '' );
699
+ },
700
+
701
+ ewayrapidSelectToken: function(tokenId) {
702
+ $('ewayrapid_saved_cc_owner').setValue(this.savedTokens[tokenId]['Owner']);
703
+ $('ewayrapid_saved_cc_number').setValue(this.savedTokens[tokenId]['Card']);
704
+ $('ewayrapid_saved_expiration').setValue(this.savedTokens[tokenId]['ExpMonth']);
705
+ $('ewayrapid_saved_expiration_yr').setValue(this.savedTokens[tokenId]['ExpYear']);
706
+ $('ewayrapid_saved_cc_owner').focus();
707
+ }
708
+ }
709
+
710
+ Validation.creditCartTypes = $H({
711
+ // Add Diners Club, Maestro and Visa Electron card type
712
+ 'DC': [new RegExp('^3(?:0[0-5]|[68][0-9])[0-9]{11}$'), new RegExp('^[0-9]{3}$'), true],
713
+ 'VE': [new RegExp('^(4026|4405|4508|4844|4913|4917)[0-9]{12}|417500[0-9]{10}$'), new RegExp('^[0-9]{3}$'), true],
714
+ 'ME': [new RegExp('^(5018|5020|5038|5612|5893|6304|6759|6761|6762|6763|6390)[0-9]{8,15}$'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],
715
+
716
+ 'SO': [new RegExp('^(6334[5-9]([0-9]{11}|[0-9]{13,14}))|(6767([0-9]{12}|[0-9]{14,15}))$'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],
717
+ 'VI': [new RegExp('^4[0-9]{12}([0-9]{3})?$'), new RegExp('^[0-9]{3}$'), true],
718
+ 'MC': [new RegExp('^5[1-5][0-9]{14}$'), new RegExp('^[0-9]{3}$'), true],
719
+ 'AE': [new RegExp('^3[47][0-9]{13}$'), new RegExp('^[0-9]{4}$'), true],
720
+ 'DI': [new RegExp('^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}|5[0-9]{14}))$'), new RegExp('^[0-9]{3}$'), true],
721
+ 'JCB': [new RegExp('^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}|5[0-9]{14}))$'), new RegExp('^[0-9]{3,4}$'), true],
722
+ // 'DICL': [new RegExp('^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}|5[0-9]{14}))$'), new RegExp('^[0-9]{3}$'), true],
723
+ 'SM': [new RegExp('(^(5[0678])[0-9]{11,18}$)|(^(6[^05])[0-9]{11,18}$)|(^(601)[^1][0-9]{9,16}$)|(^(6011)[0-9]{9,11}$)|(^(6011)[0-9]{13,16}$)|(^(65)[0-9]{11,13}$)|(^(65)[0-9]{15,18}$)|(^(49030)[2-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49033)[5-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49110)[1-2]([0-9]{10}$|[0-9]{12,13}$))|(^(49117)[4-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49118)[0-2]([0-9]{10}$|[0-9]{12,13}$))|(^(4936)([0-9]{12}$|[0-9]{14,15}$))'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],
724
+ 'OT': [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), false]
725
+ });
726
+
727
+ Validation.add('validate-cc-type-auto', 'Invalid credit card number or credit card type is not supported.',
728
+ function(v, elm) {
729
+ // remove credit card number delimiters such as "-" and space
730
+ elm.value = removeDelimiters(elm.value);
731
+ v = removeDelimiters(v);
732
+ var acceptedTypes = EwayPayment.supportCardTypes;
733
+
734
+ var ccType = '';
735
+ Validation.creditCartTypes.each(function(cardType) {
736
+ $cardNumberPattern = cardType.value[0];
737
+ if($cardNumberPattern && v.match($cardNumberPattern)) {
738
+ ccType = cardType.key;
739
+
740
+ // Correct JCB/DI type since they has identical pattern:
741
+ if(ccType === 'DI' && v.indexOf('35') == 0) {
742
+ ccType = 'JCB';
743
+ }
744
+
745
+ throw $break;
746
+ }
747
+ });
748
+
749
+ if(acceptedTypes.indexOf(ccType) == -1) {
750
+ return false;
751
+ }
752
+
753
+ var ccTypeContainer = $(elm.id.substr(0,elm.id.indexOf('_cc_number')) + '_cc_type');
754
+ if (ccTypeContainer) {
755
+ ccTypeContainer.value = ccType;
756
+ }
757
+
758
+ return true;
759
+ }
760
+ );
761
+
762
+ Validation.add('eway-validate-phone', 'Please enter a valid phone number.', function(v, elm) {
763
+ return Validation.get('IsEmpty').test(v) || /^[0-9\+\*\(\)]{1,32}$/.test(v);
764
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eWAY_Payment_Rapid31</name>
4
- <version>1.3.0</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
@@ -19,18 +19,18 @@
19
  - Your customers can save their card details using eWAY's secure servers for faster checkout&#xD;
20
  - Get help when and where you need it with 24/7 support&#xD;
21
  &#xD;
22
- Discover more at http://www.eway.com.au - payments made smarter!</description>
23
- <notes>Fixes and updates:&#xD;
 
24
  &#xD;
25
- - Fix for using Transparent Redirect with OneStepCheckout.com&#xD;
26
- - Fix for not sending invoice emails&#xD;
27
- - Minor fix for recurring orders &#xD;
28
- - Fix for new fraud codes not processing correctly&#xD;
29
- - Improved transaction failure handling</notes>
30
  <authors><author><name>eWAY Payments</name><user>eWAYPayments</user><email>partner@eway.com.au</email></author></authors>
31
- <date>2015-04-08</date>
32
- <time>03:51:26</time>
33
- <contents><target name="magecommunity"><dir name="Eway"><dir name="Rapid31"><dir name="Block"><dir name="Admin"><file name="Version.php" hash="7b5b41f31c14413c87e4e16cefab5748"/></dir><dir name="Customer"><file name="Edit.php" hash="d7b1373e21796578ff7b6be9d0bf051d"/><file name="Mycards.php" hash="34df399b9c3e8a2752cf2989b188ae80"/></dir><dir name="Form"><dir name="Direct"><file name="Notsaved.php" hash="82a649f61fb2c4cc1d02a492aed401a2"/><file name="Saved.php" hash="1ce47a1e6edb31dda3388a9d0966f80d"/></dir><dir name="Sharedpage"><file name="Notsaved.php" hash="8b8dc22e210f8d812c879cd0f0b85a03"/><file name="Saved.php" hash="af30582c5260c6edef41ac13daad6da0"/></dir><dir name="Transparent"><file name="Notsaved.php" hash="be64d2e56a205f2e2005770b92d294dd"/><file name="Saved.php" hash="4489ebedf0fd6a7c22311e6d01ca6a47"/></dir></dir><dir name="Info"><dir name="Direct"><file name="Notsaved.php" hash="76857a644cafc5b880a8a6930e9c8246"/><file name="Saved.php" hash="a9b1a08db461a9875cb67c24ec0d341d"/></dir><dir name="Sharedpage"><file name="Notsaved.php" hash="64fbfb7ad75b2eaec7cc55ca0189d4dc"/><file name="Saved.php" hash="6122e7f28b5086e5944e825dc50fd191"/></dir><dir name="Transparent"><file name="Notsaved.php" hash="743f4227532db7a4bcc706260b552e99"/><file name="Saved.php" hash="31de55ee9e7a015662b112d3c77bcd99"/></dir></dir><dir name="Redirect"><file name="PaypalReview.php" hash="bdfff05cf75ce9739a5022ce9fd553ed"/><file name="Transparent.php" hash="d0f589b3e1d19ec02fbea141ff0aaa2e"/><file name="TransparentCheckout.php" hash="458b1b10da66953fe38a82af8832f136"/></dir><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="aa7b83ca6d666a9fe34a1d762bd10eae"/></dir></dir></dir><dir name="Helper"><file name="Customer.php" hash="c056f18f4dd474e94a10d066a56f6bf3"/><file name="Data.php" hash="17145883a7fe7434271e625ea53952a1"/></dir><dir name="Model"><dir name="Backend"><file name="Savedtokens.php" hash="55c209484a4ee56caadcde3633cb68dc"/></dir><file name="Config.php" hash="070d408e0e6f7b2c654c70d73b63714a"/><dir name="Customer"><file name="Savedtokens.php" hash="fec7133470f1c26cb284c12fd56e7991"/><file name="Token.php" hash="698166a7b2f9906a08842d15f01dc86c"/></dir><file name="EwayCron.php" hash="ea9d865930b880f77e11e3e8d1567bcc"/><dir name="Field"><file name="CardDetails.php" hash="15d10ff8dec0590335b5c576df00554b"/><file name="Customer.php" hash="a5c32b1f06070ec3fe419ff9bc1a298a"/><file name="LineItem.php" hash="0ba66e9b1ecd1acb95c91d6192f9a8df"/><file name="Payment.php" hash="5226334c0d5fe39f27466b6113e8c091"/><file name="ShippingAddress.php" hash="3e46233fa343875dd061a158b3363c32"/></dir><file name="JsonSerializable.php" hash="630af4fb2b90d9e7808615bcca2b968a"/><file name="JsonSerializableAbstract.php" hash="15f72821079c02efe2f31ce52be22193"/><dir name="Method"><file name="Notsaved.php" hash="f23183119533925cae5eb79e73a3fdfe"/><file name="Saved.php" hash="8b0772ea5731ec3c21b6e23968d59c85"/></dir><file name="Observer.php" hash="fa01d269218f6ee5e77d608829d3a357"/><file name="RecurringProfile.php" hash="66bf152dadaa09aeeb875fb92e66b543"/><dir name="Request"><file name="Abstract.php" hash="90ae6a7b39ca934749a32a75a5402f3f"/><file name="Direct.php" hash="8a5584acf0c717bb56eec30b8d6a5421"/><file name="Sharedpage.php" hash="aea0b6dcfd888410d2e32a6c244bd7be"/><file name="Token.php" hash="73a5f6273fc80887ccda4fca11b765a8"/><file name="Transparent.php" hash="188996608883bc28356cbb1e5aa3997e"/></dir><file name="Response.php" hash="03977513b56c2698d44ac578756f9c8e"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Orderstatus.php" hash="26a90ac9556ba210a73685a2b6edc5cd"/><file name="Validation.php" hash="39a895e6083f47872425e1616e75bee5"/></dir><dir name="Source"><file name="Cctype.php" hash="1b31bfaae980669c5ac0ba7e644ea515"/><file name="ConnectionType.php" hash="9060bb5013246eaf08c8ebf215b70a7d"/><file name="Mode.php" hash="a3f1dffc58540b31c5ab43a32452cce5"/><file name="Orderstatus.php" hash="75524debbd930498e278abd74c635fb9"/><file name="PaymentAction.php" hash="eaca860975abf97aa3ca49ba5f57d21b"/><file name="VerifyStatus.php" hash="28ff5c7c66c6b70c3923379ce3b82671"/></dir></dir></dir></dir><dir name="Test"><dir name="Model"><file name="Abstract.php" hash="5683575f264336a8c5f4c71768883b73"/><file name="Config.php" hash="98cc66555893a2a29a2ac093795dde17"/><file name="CustomerToken.php" hash="ed2f390b4579a33da70835356a718a79"/><file name="JsonSerializable.php" hash="d0735fda26a7461885c3cf8a5afcca2a"/><dir name="Request"><dir name="fixtures"><file name="default.yaml" hash="51c7dc1c509fcd1e4cf8dc0c49c9126a"/></dir></dir><file name="Request.php" hash="e19218a48cfd0fe5c8abaa0a99d5da08"/><file name="Response.php" hash="fd7b02d0e0f7a4a50862b6649d9faf41"/><dir name="TokenRequest"><dir name="fixtures"><file name="default.yaml" hash="51c7dc1c509fcd1e4cf8dc0c49c9126a"/></dir></dir><file name="TokenRequest.php" hash="965cc4efc952fd9d612d0a6dc924e43e"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="58cfc001c2e14938e5232cae17ae9cf0"/></dir><file name="MycardsController.php" hash="6f91776f56decab5beedda246c54437f"/><file name="SharedpageController.php" hash="69629e3f89512f2b8c70a5aa2dcfb04d"/><file name="TestController.php" hash="68c0eed4d6142f00e6d67c719cd08abc"/><file name="TransparentController.php" hash="38c5a81509ab91153784bde0be27dc22"/></dir><dir name="etc"><file name="config.xml" hash="378faf81bf9d6b85ba9dc0dc84f2b455"/><file name="system.xml" hash="4d968adda6fbdba3460814c7cc47d1d7"/></dir><dir name="sql"><dir name="ewayrapid_setup"><file name="install-0.1.0.php" hash="ca019c7e662566d1e4e8c5e844f85247"/><file name="upgrade-0.1.0-1.0.0.php" hash="5183123b924cd233ee739c710da05bc2"/><file name="upgrade-1.0.0-1.0.1.php" hash="78aa6c5bf4704f65b0ced6d007539d0c"/><file name="upgrade-1.0.1-1.0.3.php" hash="9b7d1892e813b70bf82a79cd9a16ed29"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="ewayrapid"><file name="layout.xml" hash="b5ce2f60041814eb192c75deec216647"/></dir></dir><dir name="template"><dir name="ewayrapid"><dir name="form"><file name="direct_notsaved.phtml" hash="5a3aac5acc635e03083773b706330b4f"/><file name="direct_saved.phtml" hash="8c7516529ace83e8d177a5fc9a8e9cd9"/></dir><dir name="info"><file name="direct_notsaved.phtml" hash="7378da27e6fc9432317686c5b05c52e3"/><file name="direct_saved.phtml" hash="fe943996b2eff65e72f594d34a2ddc89"/></dir><dir name="pdf"><file name="direct_notsaved.phtml" hash="bf22201062b76225e130323584646238"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="ewayrapid"><file name="layout.xml" hash="b95b4baa764c5cb65c4c9ec91065ce17"/></dir></dir><dir name="template"><dir name="ewayrapid"><dir name="customer"><file name="edit.phtml" hash="b34376162df56abcdbbe81fdd78e75d7"/><file name="mycards.phtml" hash="edef4b70420c7225e9ee0e8098a686e0"/></dir><dir name="form"><file name="direct_notsaved.phtml" hash="c1bbc7f299e8ba2166256146f568320b"/><file name="direct_saved.phtml" hash="989b05758da7db9f51875e5e29145053"/><file name="sharedpage_notsaved.phtml" hash="84bcdff59da4888fde3d68b0e0044854"/><file name="sharedpage_saved.phtml" hash="08963dc603cef32fba9fb48d01536f5f"/><file name="transparent_notsaved.phtml" hash="8d5263c29c5d799f5f6aa10990a85fdc"/><file name="transparent_saved.phtml" hash="db8446efcca8fdef0fc65ecbaa1679e1"/></dir><dir name="info"><file name="direct_notsaved.phtml" hash="e3e6de0f60921687690a5c6225ddf8b6"/><file name="direct_saved.phtml" hash="e3e6de0f60921687690a5c6225ddf8b6"/><file name="sharedpage_notsaved.phtml" hash="e3e6de0f60921687690a5c6225ddf8b6"/><file name="sharedpage_saved.phtml" hash="b14f24a69d19129b34e5369dc075298d"/><file name="transparent_notsaved.phtml" hash="3b7c42bfbf960a89ebb5988c8c3f0e2d"/></dir><file name="js.phtml" hash="c9284649181f10838b982e956e506fc0"/><dir name="redirect"><file name="review.phtml" hash="8f64dfebe347f45cc9cfa6be3554d7e7"/><file name="transparent.phtml" hash="23813476dc656d857efe6f2b50b5e710"/><file name="transparent_checkout.phtml" hash="20ae7dc582a9c430c84b381c9be8148d"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eway_Rapid31.xml" hash="2c1fefb7319ecbd86d3904afd35ac4c7"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Eway_Rapid31.csv" hash="4cecdb8c8152a113467fb2ca48b5062f"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="ewayrapid.css" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="ewayrapid.css" hash="b8dda3f195eb10b86f1ebd5d349ac0db"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="ewayrapid"><file name="eCrypt.js" hash="b79ff8bbb306e667872ae5862f82058c"/><file name="ewayrapid.js" hash="70de77639398b4745594de1933115752"/></dir></dir></target></contents>
34
  <compatible/>
35
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
36
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eWAY_Payment_Rapid31</name>
4
+ <version>1.3.1</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
19
  - Your customers can save their card details using eWAY's secure servers for faster checkout&#xD;
20
  - Get help when and where you need it with 24/7 support&#xD;
21
  &#xD;
22
+ Discover more at https://www.eway.com.au - payments made smarter!</description>
23
+ <notes>Upgrade&#xD;
24
+ - Support for MageWorld One Step Checkout Pro&#xD;
25
  &#xD;
26
+ Minor fixes:&#xD;
27
+ &#xD;
28
+ - Fix for stores with custom DB table prefixes&#xD;
29
+ - Fix for manual payments not submitting for some stores</notes>
 
30
  <authors><author><name>eWAY Payments</name><user>eWAYPayments</user><email>partner@eway.com.au</email></author></authors>
31
+ <date>2015-10-13</date>
32
+ <time>04:05:40</time>
33
+ <contents><target name="magecommunity"><dir name="Eway"><dir name="Rapid31"><dir name="Block"><dir name="Admin"><file name="Version.php" hash="7b5b41f31c14413c87e4e16cefab5748"/></dir><dir name="Customer"><file name="Edit.php" hash="d7b1373e21796578ff7b6be9d0bf051d"/><file name="Mycards.php" hash="34df399b9c3e8a2752cf2989b188ae80"/></dir><dir name="Form"><dir name="Direct"><file name="Notsaved.php" hash="82a649f61fb2c4cc1d02a492aed401a2"/><file name="Saved.php" hash="1ce47a1e6edb31dda3388a9d0966f80d"/></dir><dir name="Sharedpage"><file name="Notsaved.php" hash="8b8dc22e210f8d812c879cd0f0b85a03"/><file name="Saved.php" hash="af30582c5260c6edef41ac13daad6da0"/></dir><dir name="Transparent"><file name="Notsaved.php" hash="be64d2e56a205f2e2005770b92d294dd"/><file name="Saved.php" hash="4489ebedf0fd6a7c22311e6d01ca6a47"/></dir></dir><dir name="Info"><dir name="Direct"><file name="Notsaved.php" hash="76857a644cafc5b880a8a6930e9c8246"/><file name="Saved.php" hash="a9b1a08db461a9875cb67c24ec0d341d"/></dir><dir name="Sharedpage"><file name="Notsaved.php" hash="64fbfb7ad75b2eaec7cc55ca0189d4dc"/><file name="Saved.php" hash="6122e7f28b5086e5944e825dc50fd191"/></dir><dir name="Transparent"><file name="Notsaved.php" hash="743f4227532db7a4bcc706260b552e99"/><file name="Saved.php" hash="31de55ee9e7a015662b112d3c77bcd99"/></dir></dir><dir name="Redirect"><file name="PaypalReview.php" hash="bdfff05cf75ce9739a5022ce9fd553ed"/><file name="Transparent.php" hash="d0f589b3e1d19ec02fbea141ff0aaa2e"/><file name="TransparentCheckout.php" hash="458b1b10da66953fe38a82af8832f136"/></dir><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="6af2cdc17e4b785a9caeeb8853c9ec88"/></dir></dir></dir><dir name="Helper"><file name="Customer.php" hash="c056f18f4dd474e94a10d066a56f6bf3"/><file name="Data.php" hash="2fdaf7c015a22caa53ee27cfd5becfc1"/></dir><dir name="Model"><dir name="Backend"><file name="Savedtokens.php" hash="55c209484a4ee56caadcde3633cb68dc"/></dir><file name="Config.php" hash="2d082fdbfa6ec184ea7b92686834726e"/><dir name="Customer"><file name="Savedtokens.php" hash="fec7133470f1c26cb284c12fd56e7991"/><file name="Token.php" hash="698166a7b2f9906a08842d15f01dc86c"/></dir><file name="EwayCron.php" hash="95b813adf22a0d1acf65a2677bcf1a59"/><dir name="Field"><file name="CardDetails.php" hash="15d10ff8dec0590335b5c576df00554b"/><file name="Customer.php" hash="a5c32b1f06070ec3fe419ff9bc1a298a"/><file name="LineItem.php" hash="0ba66e9b1ecd1acb95c91d6192f9a8df"/><file name="Payment.php" hash="5226334c0d5fe39f27466b6113e8c091"/><file name="ShippingAddress.php" hash="3e46233fa343875dd061a158b3363c32"/></dir><file name="JsonSerializable.php" hash="630af4fb2b90d9e7808615bcca2b968a"/><file name="JsonSerializableAbstract.php" hash="15f72821079c02efe2f31ce52be22193"/><dir name="Method"><file name="Notsaved.php" hash="f23183119533925cae5eb79e73a3fdfe"/><file name="Saved.php" hash="8b0772ea5731ec3c21b6e23968d59c85"/></dir><file name="Observer.php" hash="4ecba6f46d4ac2c129dce6fcf3a848e6"/><file name="RecurringProfile.php" hash="fc1f34e29edbca79ec8bab93887dbda7"/><dir name="Request"><file name="Abstract.php" hash="d0bdc1f5c76b974c44f116d9124b11b7"/><file name="Direct.php" hash="a1a5d56ddee61cf34f7ed0c3731df7ae"/><file name="Sharedpage.php" hash="d1b7bc02737862d203a8a40ce82e7971"/><file name="Token.php" hash="a73d105b824ea3c7783516fbc85a192a"/><file name="Transparent.php" hash="ee4b8062d0939aa69921043fe2a2aa2f"/></dir><file name="Response.php" hash="03977513b56c2698d44ac578756f9c8e"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Orderstatus.php" hash="26a90ac9556ba210a73685a2b6edc5cd"/><file name="Validation.php" hash="39a895e6083f47872425e1616e75bee5"/></dir><dir name="Source"><file name="Cctype.php" hash="1b31bfaae980669c5ac0ba7e644ea515"/><file name="ConnectionType.php" hash="9060bb5013246eaf08c8ebf215b70a7d"/><file name="Mode.php" hash="a3f1dffc58540b31c5ab43a32452cce5"/><file name="Orderstatus.php" hash="75524debbd930498e278abd74c635fb9"/><file name="PaymentAction.php" hash="eaca860975abf97aa3ca49ba5f57d21b"/><file name="VerifyStatus.php" hash="28ff5c7c66c6b70c3923379ce3b82671"/></dir></dir></dir></dir><dir name="Test"><dir name="Model"><file name="Abstract.php" hash="5683575f264336a8c5f4c71768883b73"/><file name="Config.php" hash="98cc66555893a2a29a2ac093795dde17"/><file name="CustomerToken.php" hash="ed2f390b4579a33da70835356a718a79"/><file name="JsonSerializable.php" hash="d0735fda26a7461885c3cf8a5afcca2a"/><dir name="Request"><dir name="fixtures"><file name="default.yaml" hash="51c7dc1c509fcd1e4cf8dc0c49c9126a"/></dir></dir><file name="Request.php" hash="e19218a48cfd0fe5c8abaa0a99d5da08"/><file name="Response.php" hash="fd7b02d0e0f7a4a50862b6649d9faf41"/><dir name="TokenRequest"><dir name="fixtures"><file name="default.yaml" hash="51c7dc1c509fcd1e4cf8dc0c49c9126a"/></dir></dir><file name="TokenRequest.php" hash="965cc4efc952fd9d612d0a6dc924e43e"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="bcbc9f9462908777ca60f7af3f7018b1"/></dir><file name="MycardsController.php" hash="6f91776f56decab5beedda246c54437f"/><file name="SharedpageController.php" hash="69629e3f89512f2b8c70a5aa2dcfb04d"/><file name="TestController.php" hash="4d6bac6b37f8da9bf803ddf8cee7addb"/><file name="TransparentController.php" hash="38c5a81509ab91153784bde0be27dc22"/></dir><dir name="etc"><file name="config.xml" hash="77656289beba05351fc2ffe1f76fa56d"/><file name="system.xml" hash="02ed01ae6ea79dbcb899926b802dd6aa"/></dir><dir name="sql"><dir name="ewayrapid_setup"><file name="install-0.1.0.php" hash="25c8318a51545d2685388370b0bd87be"/><file name="upgrade-0.1.0-1.0.0.php" hash="9823e00ab55115dfa5da99d067ad1924"/><file name="upgrade-1.0.0-1.0.1.php" hash="7e68e66ec1273400fc35f796b1d3565e"/><file name="upgrade-1.0.1-1.0.3.php" hash="21fde70ea184fe2b0667f942d63e0280"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="ewayrapid"><file name="layout.xml" hash="b5ce2f60041814eb192c75deec216647"/></dir></dir><dir name="template"><dir name="ewayrapid"><dir name="form"><file name="direct_notsaved.phtml" hash="5a3aac5acc635e03083773b706330b4f"/><file name="direct_saved.phtml" hash="8c7516529ace83e8d177a5fc9a8e9cd9"/></dir><dir name="info"><file name="direct_notsaved.phtml" hash="7378da27e6fc9432317686c5b05c52e3"/><file name="direct_saved.phtml" hash="fe943996b2eff65e72f594d34a2ddc89"/></dir><dir name="pdf"><file name="direct_notsaved.phtml" hash="bf22201062b76225e130323584646238"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="ewayrapid"><file name="layout.xml" hash="b95b4baa764c5cb65c4c9ec91065ce17"/></dir></dir><dir name="template"><dir name="ewayrapid"><dir name="customer"><file name="edit.phtml" hash="b34376162df56abcdbbe81fdd78e75d7"/><file name="mycards.phtml" hash="edef4b70420c7225e9ee0e8098a686e0"/></dir><dir name="form"><file name="direct_notsaved.phtml" hash="c1bbc7f299e8ba2166256146f568320b"/><file name="direct_saved.phtml" hash="989b05758da7db9f51875e5e29145053"/><file name="sharedpage_notsaved.phtml" hash="84bcdff59da4888fde3d68b0e0044854"/><file name="sharedpage_saved.phtml" hash="08963dc603cef32fba9fb48d01536f5f"/><file name="transparent_notsaved.phtml" hash="8d5263c29c5d799f5f6aa10990a85fdc"/><file name="transparent_saved.phtml" hash="db8446efcca8fdef0fc65ecbaa1679e1"/></dir><dir name="info"><file name="direct_notsaved.phtml" hash="e3e6de0f60921687690a5c6225ddf8b6"/><file name="direct_saved.phtml" hash="e3e6de0f60921687690a5c6225ddf8b6"/><file name="sharedpage_notsaved.phtml" hash="e3e6de0f60921687690a5c6225ddf8b6"/><file name="sharedpage_saved.phtml" hash="b14f24a69d19129b34e5369dc075298d"/><file name="transparent_notsaved.phtml" hash="3b7c42bfbf960a89ebb5988c8c3f0e2d"/></dir><file name="js.phtml" hash="d3c363cf2c7ac0a6a822f1919fc9383a"/><dir name="redirect"><file name="review.phtml" hash="8f64dfebe347f45cc9cfa6be3554d7e7"/><file name="transparent.phtml" hash="23813476dc656d857efe6f2b50b5e710"/><file name="transparent_checkout.phtml" hash="20ae7dc582a9c430c84b381c9be8148d"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eway_Rapid31.xml" hash="2c1fefb7319ecbd86d3904afd35ac4c7"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Eway_Rapid31.csv" hash="4cecdb8c8152a113467fb2ca48b5062f"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="ewayrapid.css" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="ewayrapid.css" hash="b8dda3f195eb10b86f1ebd5d349ac0db"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="ewayrapid"><file name="eCrypt.js" hash="b79ff8bbb306e667872ae5862f82058c"/><file name="eWAY_Payment_Rapid31.xml" hash="03c6728b4c2b7dde8ab537a5b229f3aa"/><file name="ewayrapid.js" hash="563c82a82c017987ad282f04075ffcf3"/></dir></dir></target></contents>
34
  <compatible/>
35
+ <dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
36
  </package>