eWAY_Payment_Rapid31 - Version 1.2.0

Version Notes

Fixes and updates:

- Fixed virtual products causing errors in checkout
- Fixed customer comments sometimes not being added to orders
- Transparent Redirect now works with the Fire Checkout one page checkout extension
- Transparent Redirect now works with the IWD One Page Checkout extension
- Added support for MageStore One Step Checkout
- Added support for GoMage LightCheckout
- Added payment details to the invoice print format

Download this release

Release Info

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


Code changes from version 1.1.0 to 1.2.0

Files changed (39) hide show
  1. app/code/community/Eway/Rapid31/Block/Info/Sharedpage/Notsaved.php +1 -1
  2. app/code/community/Eway/Rapid31/Block/Info/Sharedpage/Saved.php +1 -1
  3. app/code/community/Eway/Rapid31/Block/Info/Transparent/Notsaved.php +1 -1
  4. app/code/community/Eway/Rapid31/Block/Info/Transparent/Saved.php +1 -1
  5. app/code/community/Eway/Rapid31/Helper/Customer.php +1 -1
  6. app/code/community/Eway/Rapid31/Helper/Data.php +9 -1
  7. app/code/community/Eway/Rapid31/Model/EwayCron.php +1 -1
  8. app/code/community/Eway/Rapid31/Model/Method/Notsaved.php +14 -3
  9. app/code/community/Eway/Rapid31/Model/Method/Saved.php +1 -0
  10. app/code/community/Eway/Rapid31/Model/Observer.php +1 -1
  11. app/code/community/Eway/Rapid31/Model/RecurringProfile.php +525 -525
  12. app/code/community/Eway/Rapid31/Model/Request/Abstract.php +4 -2
  13. app/code/community/Eway/Rapid31/Model/Request/Direct.php +8 -0
  14. app/code/community/Eway/Rapid31/Model/Request/Sharedpage.php +9 -0
  15. app/code/community/Eway/Rapid31/Model/Request/Token.php +11 -4
  16. app/code/community/Eway/Rapid31/Model/Request/Transparent.php +17 -0
  17. app/code/community/Eway/Rapid31/controllers/Adminhtml/IndexController.php +176 -176
  18. app/code/community/Eway/Rapid31/controllers/SharedpageController.php +271 -271
  19. app/code/community/Eway/Rapid31/controllers/TransparentController.php +65 -6
  20. app/code/community/Eway/Rapid31/etc/config.xml +1 -1
  21. app/code/community/Eway/Rapid31/etc/system.xml +2 -2
  22. app/code/community/Eway/Rapid31/sql/ewayrapid_setup/install-0.1.0.php +24 -24
  23. app/design/adminhtml/default/default/template/ewayrapid/form/direct_saved.phtml +2 -2
  24. app/design/adminhtml/default/default/template/ewayrapid/info/direct_notsaved.phtml +25 -11
  25. app/design/adminhtml/default/default/template/ewayrapid/info/direct_saved.phtml +19 -11
  26. app/design/adminhtml/default/default/template/ewayrapid/pdf/direct_notsaved.phtml +26 -4
  27. app/design/frontend/base/default/layout/ewayrapid/layout.xml +18 -0
  28. app/design/frontend/base/default/template/ewayrapid/customer/edit.phtml +615 -615
  29. app/design/frontend/base/default/template/ewayrapid/form/direct_notsaved.phtml +97 -87
  30. app/design/frontend/base/default/template/ewayrapid/form/direct_saved.phtml +162 -152
  31. app/design/frontend/base/default/template/ewayrapid/form/sharedpage_saved.phtml +1 -1
  32. app/design/frontend/base/default/template/ewayrapid/form/transparent_notsaved.phtml +96 -73
  33. app/design/frontend/base/default/template/ewayrapid/form/transparent_saved.phtml +35 -13
  34. app/design/frontend/base/default/template/ewayrapid/js.phtml +184 -33
  35. app/etc/modules/Eway_Rapid31.xml +8 -8
  36. js/ewayrapid/eCrypt.js +1023 -1000
  37. js/ewayrapid/ewayrapid.js +1009 -682
  38. package.xml +13 -12
  39. skin/frontend/base/default/css/ewayrapid.css +28 -1
app/code/community/Eway/Rapid31/Block/Info/Sharedpage/Notsaved.php CHANGED
@@ -14,7 +14,7 @@ class Eway_Rapid31_Block_Info_Sharedpage_Notsaved extends Mage_Payment_Block_Inf
14
  */
15
  public function toPdf()
16
  {
17
- $this->setTemplate('ewayrapid/pdf/sharedpage_notsaved.phtml');
18
  return $this->toHtml();
19
  }
20
 
14
  */
15
  public function toPdf()
16
  {
17
+ $this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
18
  return $this->toHtml();
19
  }
20
 
app/code/community/Eway/Rapid31/Block/Info/Sharedpage/Saved.php CHANGED
@@ -14,7 +14,7 @@ class Eway_Rapid31_Block_Info_Sharedpage_Saved extends Mage_Payment_Block_Info
14
  */
15
  public function toPdf()
16
  {
17
- $this->setTemplate('ewayrapid/pdf/sharedpage_saved.phtml');
18
  return $this->toHtml();
19
  }
20
 
14
  */
15
  public function toPdf()
16
  {
17
+ $this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
18
  return $this->toHtml();
19
  }
20
 
app/code/community/Eway/Rapid31/Block/Info/Transparent/Notsaved.php CHANGED
@@ -15,7 +15,7 @@ class Eway_Rapid31_Block_Info_Transparent_Notsaved extends Mage_Payment_Block_In
15
  */
16
  public function toPdf()
17
  {
18
- $this->setTemplate('ewayrapid/pdf/transparent_notsaved.phtml');
19
  return $this->toHtml();
20
  }
21
 
15
  */
16
  public function toPdf()
17
  {
18
+ $this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
19
  return $this->toHtml();
20
  }
21
 
app/code/community/Eway/Rapid31/Block/Info/Transparent/Saved.php CHANGED
@@ -15,7 +15,7 @@ class Eway_Rapid31_Block_Info_Transparent_Saved extends Mage_Payment_Block_Info
15
  */
16
  public function toPdf()
17
  {
18
- $this->setTemplate('ewayrapid/pdf/transparent_notsaved.phtml');
19
  return $this->toHtml();
20
  }
21
 
15
  */
16
  public function toPdf()
17
  {
18
+ $this->setTemplate('ewayrapid/pdf/direct_notsaved.phtml');
19
  return $this->toHtml();
20
  }
21
 
app/code/community/Eway/Rapid31/Helper/Customer.php CHANGED
@@ -177,7 +177,7 @@ class Eway_Rapid31_Helper_Customer extends Mage_Core_Helper_Abstract
177
  {
178
  $customer = $this->getCurrentCustomer();
179
  if($customer && $customer->getSavedTokens()) {
180
- $tokens = $customer->getSavedTokens()->getTokens();
181
  if(is_array($tokens)) {
182
  foreach($tokens as $key => $token) {
183
  /* @var Eway_Rapid31_Model_Customer_Token $token */
177
  {
178
  $customer = $this->getCurrentCustomer();
179
  if($customer && $customer->getSavedTokens()) {
180
+ $tokens = $customer->getSavedTokens()->getTokens();
181
  if(is_array($tokens)) {
182
  foreach($tokens as $key => $token) {
183
  /* @var Eway_Rapid31_Model_Customer_Token $token */
app/code/community/Eway/Rapid31/Helper/Data.php CHANGED
@@ -1,10 +1,11 @@
1
  <?php
 
2
  /**
3
  * Created by PhpStorm.
4
  * User: hiephm
5
  * Date: 4/23/14
6
  * Time: 5:30 PM
7
- */
8
  class Eway_Rapid31_Helper_Data extends Mage_Core_Helper_Abstract
9
  {
10
  private $_ccTypeNames = null;
@@ -144,4 +145,11 @@ class Eway_Rapid31_Helper_Data extends Mage_Core_Helper_Abstract
144
  $model = Mage::getModel('ewayrapid/request_token');
145
  return $model->checkCardName($card);
146
  }
 
 
 
 
 
 
 
147
  }
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
  {
11
  private $_ccTypeNames = null;
145
  $model = Mage::getModel('ewayrapid/request_token');
146
  return $model->checkCardName($card);
147
  }
148
+
149
+ public function clearSessionSharedpage()
150
+ {
151
+ Mage::getSingleton('core/session')->unsetData('editToken');
152
+ Mage::getSingleton('core/session')->unsetData('newToken');
153
+ Mage::getSingleton('core/session')->unsetData('sharedpagePaypal');
154
+ }
155
  }
app/code/community/Eway/Rapid31/Model/EwayCron.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
  /**
3
  * Created by PhpStorm.
4
  * User: Administrator PC
1
+ <?php
2
  /**
3
  * Created by PhpStorm.
4
  * User: Administrator PC
app/code/community/Eway/Rapid31/Model/Method/Notsaved.php CHANGED
@@ -88,6 +88,7 @@ class Eway_Rapid31_Model_Method_Notsaved extends Mage_Payment_Model_Method_Abstr
88
  $info = $this->getInfoInstance();
89
 
90
  if (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
 
91
  //Mage::getSingleton('core/session')->setData('sharedpagePaypal', $data->getSharedpageNotsaved());
92
  Mage::getSingleton('core/session')->setData('sharedpagePaypal', 'paypal');
93
  } elseif (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
@@ -141,7 +142,7 @@ class Eway_Rapid31_Model_Method_Notsaved extends Mage_Payment_Model_Method_Abstr
141
  ->setCid($data->getCcCid())
142
  ->setExpMonth($data->getCcExpMonth())
143
  ->setExpYear($data->getCcExpYear()
144
- ));
145
 
146
  } else {
147
  $info->setCcType($data->getCcType())
@@ -224,7 +225,7 @@ class Eway_Rapid31_Model_Method_Notsaved extends Mage_Payment_Model_Method_Abstr
224
  }
225
 
226
  if ($ccType!=$info->getCcType()) {
227
- $errorMsg = Mage::helper('payment')->__('Credit card number mismatch with credit card type.');
228
  }
229
  } else {
230
  $errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number');
@@ -464,7 +465,17 @@ class Eway_Rapid31_Model_Method_Notsaved extends Mage_Payment_Model_Method_Abstr
464
  if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
465
  === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
466
  ) {
467
- return Mage::getUrl('ewayrapid/sharedpage/start');
 
 
 
 
 
 
 
 
 
 
468
  }
469
  return null;
470
  }
88
  $info = $this->getInfoInstance();
89
 
90
  if (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
91
+ Mage::helper('ewayrapid')->clearSessionSharedpage();
92
  //Mage::getSingleton('core/session')->setData('sharedpagePaypal', $data->getSharedpageNotsaved());
93
  Mage::getSingleton('core/session')->setData('sharedpagePaypal', 'paypal');
94
  } elseif (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
142
  ->setCid($data->getCcCid())
143
  ->setExpMonth($data->getCcExpMonth())
144
  ->setExpYear($data->getCcExpYear()
145
+ ));
146
 
147
  } else {
148
  $info->setCcType($data->getCcType())
225
  }
226
 
227
  if ($ccType!=$info->getCcType()) {
228
+ $errorMsg = Mage::helper('payment')->__('Please enter a valid credit card number.');
229
  }
230
  } else {
231
  $errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number');
465
  if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
466
  === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
467
  ) {
468
+ return Mage::getUrl('ewayrapid/sharedpage/start', array('_secure'=>true));
469
+ }
470
+ elseif (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
471
+ === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
472
+ && (Mage::getStoreConfig('onestepcheckout/general/active')
473
+ || Mage::getStoreConfig('opc/global/status')
474
+ || Mage::getStoreConfig('firecheckout/general/enabled')
475
+ || Mage::getStoreConfig('gomage_checkout/general/enabled')
476
+ || Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links'))
477
+ ) {
478
+ return Mage::getUrl('ewayrapid/transparent/build', array('_secure'=>true));
479
  }
480
  return null;
481
  }
app/code/community/Eway/Rapid31/Model/Method/Saved.php CHANGED
@@ -53,6 +53,7 @@ class Eway_Rapid31_Model_Method_Saved extends Eway_Rapid31_Model_Method_Notsaved
53
  }
54
 
55
  if($data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW) {
 
56
  if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
57
  && !$this->_isBackendOrder
58
  ) {
53
  }
54
 
55
  if($data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW) {
56
+ Mage::helper('ewayrapid')->clearSessionSharedpage();
57
  if ($this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE
58
  && !$this->_isBackendOrder
59
  ) {
app/code/community/Eway/Rapid31/Model/Observer.php CHANGED
@@ -146,7 +146,7 @@ class Eway_Rapid31_Model_Observer {
146
  $profile->save();
147
 
148
  // charge Initial Fee if It is greater than 0 and is numeric
149
- if ($profile->getInitAmount()
150
  && (int) $profile->getInitAmount() > 0
151
  && (string)(int) $profile->getInitAmount() === ltrim($profile->getInitAmount(), '0')
152
  ) {
146
  $profile->save();
147
 
148
  // charge Initial Fee if It is greater than 0 and is numeric
149
+ if ($profile->getInitAmount()
150
  && (int) $profile->getInitAmount() > 0
151
  && (string)(int) $profile->getInitAmount() === ltrim($profile->getInitAmount(), '0')
152
  ) {
app/code/community/Eway/Rapid31/Model/RecurringProfile.php CHANGED
@@ -1,526 +1,526 @@
1
- <?php
2
-
3
- class Eway_Rapid31_Model_RecurringProfile
4
- {
5
-
6
- /**
7
- * @var Mage_Sales_Model_Recurring_Profile
8
- */
9
- protected $_recurringProfile;
10
- /**
11
- * eway transaction id
12
- * @var string
13
- */
14
- protected $_txdId;
15
- /**
16
- * total price of all nominal items. i.e $10*5 = $50
17
- * @var float
18
- */
19
- protected $_price;
20
- /**
21
- * shipping fee
22
- * @var float
23
- */
24
- protected $_shippingAmount;
25
- /**
26
- * tax amount
27
- * @var float
28
- */
29
- protected $_taxAmount;
30
- /**
31
- * grand total
32
- * @var float
33
- */
34
- protected $_amount;
35
-
36
- /**
37
- * period type
38
- *
39
- * @var string
40
- */
41
- protected $_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR;
42
-
43
- /**
44
- * @param Mage_Sales_Model_Recurring_Profile $profile
45
- * @throws Exception
46
- */
47
- public function processRequest(Mage_Sales_Model_Recurring_Profile $profile)
48
- {
49
- $this->_recurringProfile = $profile;
50
- try {
51
- $this->_checkRecurringProfile();
52
- $this->_checkoutRecurring();
53
- $this->_processRecurringProfile();
54
- } catch (Exception $e) {
55
- throw $e;
56
- }
57
- $this->updateBeforeDate();
58
- $this->nextDate();
59
- $this->updatePeriodMaxCycles();
60
- }
61
-
62
- /**
63
- * check eway active, check whether method code is eway
64
- */
65
- protected function _checkRecurringProfile()
66
- {
67
- $methodCode = $this->_recurringProfile->getMethodCode();
68
- if ($methodCode != 'ewayrapid_saved') {
69
- throw new Exception(sprintf('Method "%s" is not eWAY Rapid (Saved).', $methodCode));
70
- }
71
- if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
72
- throw new Exception(sprintf('Method "%s" is not available.', $methodCode));
73
- }
74
- }
75
-
76
- /**
77
- * charge money for recurring item
78
- */
79
- protected function _checkoutRecurring()
80
- {
81
- /** @var Mage_Sales_Model_Order $order */
82
- $order = Mage::getModel('sales/order');
83
-
84
- $item = new Varien_Object($this->_recurringProfile->getOrderItemInfo());
85
-
86
- $this->_price = $item->getBasePrice() * $item->getQty();
87
-
88
- $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
89
-
90
- // check isset TrialBilling
91
- // Trial Billing Frequency <= 0 or isn't numeric => failure
92
- if ($this->_recurringProfile->getTrialBillingAmount()
93
- && $this->_recurringProfile->getTrialPeriodFrequency()
94
- && $this->_recurringProfile->getTrialPeriodMaxCycles()
95
- && $this->_recurringProfile->getTrialPeriodUnit()
96
- && (string)(int) $this->_recurringProfile->getTrialPeriodFrequency() === ltrim($this->_recurringProfile->getTrialPeriodFrequency(), '0')
97
- && (int) $this->_recurringProfile->getTrialPeriodFrequency() > 0
98
- ) {
99
- $trialPeriodMaxCycles = (int)$this->_recurringProfile->getTrialPeriodMaxCycles();
100
- if (!isset($additionalInfo['trialPeriodMaxCycles'])) {
101
- $additionalInfo['trialPeriodMaxCycles'] = $trialPeriodMaxCycles;
102
- $this->_recurringProfile->setAdditionalInfo($additionalInfo);
103
- $this->_price = $this->_recurringProfile->getTrialBillingAmount();
104
- $this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
105
- }
106
- elseif (isset($additionalInfo['trialPeriodMaxCycles']) && $additionalInfo['trialPeriodMaxCycles'] > 0) {
107
- $this->_price = $this->_recurringProfile->getTrialBillingAmount();
108
- $this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
109
- }
110
- }
111
-
112
- // calculate total amount
113
- $this->_shippingAmount = $item->getBaseShippingAmount();
114
- $this->_taxAmount = $item->getBaseTaxAmount();
115
- $this->_amount = $this->_price + $this->_shippingAmount + $this->_taxAmount;
116
-
117
- // init order
118
- /** @var Mage_Sales_Model_Order_Item $orderItem */
119
- $orderItem = Mage::getModel('sales/order_item')
120
- ->setName($item->getName())
121
- ->setSku($item->getSku())
122
- ->setDescription($item->getDescription())
123
- ->setQtyOrdered($item->getQty())
124
- ->setBasePrice($item->getBasePrice())
125
- ->setBaseTaxAmount($item->getBaseTaxAmount())
126
- ->setBaseRowTotalInclTax($item->getBaseRowTotalInclTax());
127
-
128
- $order->addItem($orderItem);
129
-
130
- $shippingInfo = $this->_recurringProfile->getShippingAddressInfo();
131
- $shippingAddress = Mage::getModel('sales/order_address')
132
- ->setData($shippingInfo)
133
- ->setId(null);
134
-
135
- // get base currency code
136
- $orderInfo = new Varien_Object($this->_recurringProfile->getOrderInfo());
137
- $currencyCode = $orderInfo->getBaseCurrencyCode();
138
-
139
- $order->setShippingAddress($shippingAddress);
140
- $order->setBaseCurrencyCode($currencyCode);
141
-
142
- /** @var Mage_Sales_Model_Order_Payment $payment */
143
- $payment = Mage::getModel('sales/order_payment');
144
- $payment->setOrder($order);
145
- $payment->setIsRecurring(true);
146
- $payment->setIsInitialFee(true);
147
-
148
- $customerId = $this->_recurringProfile->getCustomerId();
149
- $payment->setCustomerId($customerId);
150
-
151
- $tokenId = $additionalInfo['token']['saved_token'];
152
- $payment->setTokenId($tokenId);
153
-
154
- /** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
155
- $ewaySave = Mage::getModel('ewayrapid/method_saved');
156
-
157
- $paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
158
- if ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
159
- $ewaySave->authorize($payment, $this->_amount);
160
- } elseif ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
161
- $ewaySave->capture($payment, $this->_amount);
162
- }
163
- if (!$payment->getTransactionId()) {
164
- throw new Exception('Transaction is not available');
165
- } else {
166
- $this->_txdId = $payment->getTransactionId();
167
- }
168
- /** @todo: change status of order = "eWAY Authorised"
169
- * now status order = "processing"
170
- */
171
- }
172
-
173
- /**
174
- * Process notification from recurring profile payments
175
- *
176
- * @throws Exception
177
- * @throws Mage_Core_Exception
178
- */
179
- protected function _processRecurringProfile()
180
- {
181
- try {
182
- $this->_registerRecurringProfilePaymentCapture();
183
- if ($this->_periodType == Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL) {
184
- $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
185
- $additionalInfo['trialPeriodMaxCycles'] -= 1;
186
- $this->_recurringProfile->setAdditionalInfo($additionalInfo);
187
- $this->_recurringProfile->save();
188
- }
189
- } catch (Mage_Core_Exception $e) {
190
- throw $e;
191
- }
192
- }
193
-
194
- /**
195
- * Register recurring payment notification, create and process order
196
- */
197
- protected function _registerRecurringProfilePaymentCapture()
198
- {
199
- $price = $this->_price;
200
- $tax = $this->_taxAmount;
201
- $shipping = $this->_shippingAmount;
202
- $grandTotal = $this->_amount;
203
- $periodType = $this->_periodType;
204
- $transactionId = $this->_txdId;
205
- $ewayMessage = '';
206
-
207
- $productItemInfo = new Varien_Object;
208
- /** @todo: response doesn't contain period type / payment type */
209
- $productItemInfo->setPaymentType($periodType);
210
- $productItemInfo->setTaxAmount($tax);
211
- $productItemInfo->setShippingAmount($shipping);
212
- $productItemInfo->setPrice($price);
213
-
214
-
215
- /** @var Mage_Sales_Model_Recurring_Profile $recurringProfile */
216
- $recurringProfile = $this->_recurringProfile;
217
- $order = $recurringProfile->createOrder($productItemInfo);
218
- $payment = $order->getPayment();
219
- $payment->setTransactionId($transactionId)
220
- ->setPreparedMessage($ewayMessage)
221
- ->setIsTransactionClosed(0);
222
- $order->save();
223
- $this->_recurringProfile->addOrderRelation($order->getId());
224
- $payment->registerCaptureNotification($grandTotal);
225
- $order->save();
226
-
227
- // notify customer
228
- if ($invoice = $payment->getCreatedInvoice()) {
229
- $message = Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
230
- $comment = $order->sendNewOrderEmail()->addStatusHistoryComment($message)
231
- ->setIsCustomerNotified(true)
232
- ->save();
233
- }
234
-
235
- if (!$recurringProfile->getIsCronJob()) {
236
- $session = Mage::getSingleton('checkout/type_onepage')->getCheckout();
237
- $session->setLastOrderId($order->getId());
238
- }
239
- }
240
-
241
- /**
242
- * process token if customer create and edit token when checkout with recurring profile
243
- *
244
- * @param Mage_Sales_Model_Quote $quote
245
- * @return string
246
- * @throws Exception
247
- */
248
- public function processToken(Mage_Sales_Model_Quote $quote)
249
- {
250
- try {
251
- $billing = $quote->getBillingAddress();
252
- $payment = $quote->getPayment();
253
-
254
- /** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
255
- $ewaySave = Mage::getModel('ewayrapid/method_saved');
256
- $ewaySave->setData('info_instance', $payment);
257
-
258
- /** @var Mage_Sales_Model_Order $order */
259
- $order = Mage::getModel('sales/order');
260
- /*$order->setBillingAddress($billing);*/
261
-
262
- /** @var Mage_Sales_Model_Order_Payment $paymentObj */
263
- $paymentObj = Mage::getModel('sales/order_payment');
264
- $paymentObj->setOrder($order);
265
-
266
- $request = Mage::getModel('ewayrapid/request_token');
267
-
268
- $ewaySave->_setBilling($billing);
269
- $ewaySave->_shouldCreateOrUpdateToken($paymentObj, $request);
270
- return $payment->getAdditionalData();
271
- } catch (Exception $e) {
272
- throw $e;
273
- }
274
- }
275
-
276
- /**
277
- * update day was run of recurring profile when cron job create order
278
- */
279
- public function updateBeforeDate()
280
- {
281
- // timezone used as store's timezone
282
- $currentDate = date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));
283
- $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
284
- $additionalInfo['beforeDate'] = $currentDate;
285
- $this->_recurringProfile->setAdditionalInfo($additionalInfo);
286
- $this->_recurringProfile->save();
287
- }
288
-
289
-
290
- /**
291
- * @param null $startDate
292
- *
293
- * calculate the next date create order of recurring profile
294
- * Timezone of startDate is store's timezone
295
- * Timezone of startDatetime load into recurring profile is store's timezone
296
- */
297
- public function nextDate($startDate = null)
298
- {
299
- // when recurring profile loaded, startDate updated by currentDate
300
- // timezone used as store's timezone
301
- if ($startDate == null) {
302
- $startDate = $this->_recurringProfile->getStartDatetime();
303
- $date = new DateTime($startDate, new DateTimeZone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE));
304
- $timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
305
- $date->setTimezone(new DateTimeZone($timezone));
306
- $startDate = $date->format('Y-m-d');
307
- }
308
-
309
- $frequency = (int)$this->_recurringProfile->getPeriodFrequency();
310
- $unit = $this->_recurringProfile->getPeriodUnit();
311
-
312
- if ($unit === 'week') {
313
- $unit = 'day';
314
- $frequency = $frequency * 7;
315
- }
316
- if ($unit === 'two weeks') {
317
- $unit = 'day';
318
- $frequency = $frequency * 14;
319
- }
320
-
321
- $newDate = date('Y-m-d', strtotime('+' . $frequency . $unit, strtotime($startDate)));
322
-
323
- if (!$this->_checkDate($unit, $frequency, $startDate, $newDate)) {
324
- $newDate = date('Y-m-d', strtotime('-1day', strtotime(date('Y-m-1', strtotime('+1month', strtotime($newDate))))));
325
- }
326
-
327
- $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
328
- $additionalInfo['nextDate'] = $newDate;
329
- $this->_recurringProfile->setAdditionalInfo($additionalInfo);
330
- $this->_recurringProfile->save();
331
- }
332
-
333
- /**
334
- * update period max cycles of recurring profile when cron job create order
335
- */
336
- public function updatePeriodMaxCycles()
337
- {
338
- // edit period max cycles if It is greater than or equal 0 and is numeric
339
- // If period max cycles <= 0 or null, recurring profile will run forever
340
- if ($periodMaxCycles = $this->_recurringProfile->getPeriodMaxCycles()) {
341
- if ((string)(int) $periodMaxCycles === ltrim($periodMaxCycles, '0') && $periodMaxCycles > 0) {
342
- $periodMaxCycles = (int) $periodMaxCycles - 1;
343
- $this->_recurringProfile->setPeriodMaxCycles($periodMaxCycles);
344
- $this->_recurringProfile->save();
345
- }
346
- }
347
- }
348
-
349
- /**
350
- * check date valid
351
- *
352
- * @param $unit
353
- * @param $frequency
354
- * @param $startDate
355
- * @param $newDate
356
- * @return bool
357
- */
358
- protected function _checkDate($unit, $frequency, $startDate, $newDate)
359
- {
360
- if('day' === $unit) {
361
- return true;
362
- }
363
-
364
- list($oldYear, $oldMonth, $oldDay) = explode('-', date('Y-m-d', strtotime($startDate)));
365
- list($newYear, $newMonth, $newDay) = explode('-', date('Y-m-d', strtotime($newDate)));
366
-
367
- if(($oldDay + (int)('day' == $unit ? $frequency : 0)) == $newDay && ($oldMonth + (int)('month' == $unit ? $frequency : 0)) == $newMonth && ($oldYear + (int)('year' == $unit ? $frequency : 0)) == $newYear) {
368
- return true;
369
- }
370
- return false;
371
- }
372
-
373
- /**
374
- * check run cron job conditions
375
- *
376
- * @param Mage_Sales_Model_Recurring_Profile $profile
377
- * @return bool
378
- */
379
- public function checkRecurringProfileRunCronJob(Mage_Sales_Model_Recurring_Profile $profile)
380
- {
381
- $additionalInfo = $profile->getAdditionalInfo();
382
- $timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
383
- // timezone used as store's timezone
384
- $nextDate = new DateTime(date("Y-m-d", strtotime($additionalInfo['nextDate'])), new DateTimeZone($timezone));
385
- $currentDate = new DateTime(date("Y-m-d", Mage::getModel('core/date')->timestamp(time())), new DateTimeZone($timezone));
386
- if (!isset($additionalInfo['beforeDate']) || $additionalInfo['beforeDate'] == null) {
387
- if($nextDate == $currentDate) {
388
- return true;
389
- }
390
- } else {
391
- $beforeDate = new DateTime(date("Y-m-d", strtotime($additionalInfo['beforeDate'])), new DateTimeZone($timezone));
392
- if ($beforeDate < $currentDate && $nextDate == $currentDate) {
393
- return true;
394
- }
395
- }
396
- return false;
397
- }
398
-
399
- /**
400
- * check current time >= started time
401
- *
402
- * @param null $startDate
403
- * @return bool
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
- }
410
-
411
- /**
412
- * process Initial Fee
413
- *
414
- * @param Mage_Sales_Model_Recurring_Profile $profile
415
- */
416
- public function processInitialFee(Mage_Sales_Model_Recurring_Profile $profile)
417
- {
418
- // charge Initial Fee
419
- /** @var Mage_Sales_Model_Order $order */
420
- $order = Mage::getModel('sales/order');
421
- $amount = $profile->getInitAmount();
422
- $shippingInfo = $profile->getShippingAddressInfo();
423
- $shippingAddress = Mage::getModel('sales/order_address')
424
- ->setData($shippingInfo)
425
- ->setId(null);
426
-
427
- $orderInfo = new Varien_Object($profile->getOrderInfo());
428
- $currencyCode = $orderInfo->getBaseCurrencyCode();
429
-
430
- $order->setShippingAddress($shippingAddress);
431
- $order->setBaseCurrencyCode($currencyCode);
432
-
433
- /** @var Mage_Sales_Model_Order_Payment $payment */
434
- $payment = Mage::getModel('sales/order_payment');
435
- $payment->setOrder($order);
436
- $payment->setIsRecurring(true);
437
- $payment->setIsInitialFee(true);
438
-
439
- $customerId = $profile->getCustomerId();
440
- $payment->setCustomerId($customerId);
441
-
442
- $additionalInfo = $profile->getAdditionalInfo();
443
- $tokenId = $additionalInfo['token']['saved_token'];
444
- $payment->setTokenId($tokenId);
445
-
446
- /** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
447
- $ewaySave = Mage::getModel('ewayrapid/method_saved');
448
- $paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
449
- if ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
450
- $ewaySave->authorize($payment, $amount);
451
- } elseif ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
452
- $ewaySave->capture($payment, $amount);
453
- }
454
- /** @todo: change status of order = "eWAY Authorised"
455
- * now status order = "processing"
456
- */
457
- }
458
-
459
- /**
460
- * @param Mage_Sales_Model_Recurring_Profile $profile
461
- */
462
- public function updateNextDate(Mage_Sales_Model_Recurring_Profile $profile)
463
- {
464
- $timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
465
- $additionalInfo = $profile->getAdditionalInfo();
466
- // timezone used as store's timezone
467
- $nextDate = new DateTime(date("Y-m-d", strtotime($additionalInfo['nextDate'])), new DateTimeZone($timezone));
468
- // timezone used as store's timezone
469
- $currentDate = new DateTime(date("Y-m-d", Mage::getModel('core/date')->timestamp(time())), new DateTimeZone($timezone));
470
- if ($nextDate < $currentDate) {
471
- $this->_recurringProfile = $profile;
472
- $startDate = $nextDate->format('Y-m-d');
473
- $this->nextDate($startDate);
474
- }
475
- }
476
-
477
- /**
478
- * @param Mage_Sales_Model_Recurring_Profile $profile
479
- * @param bool $bool
480
- * @return bool
481
- *
482
- * check Maximum Payment Failures
483
- * Maximum Payment Failures <= 0 -> run forever
484
- * Maximum Payment Failures > 0 -> save countFailures into additional Info
485
- * if isset countFailures -> countFailures - 1
486
- * if countFailures = 0 -> profile is suspended
487
- * if Maximum Payment Failures = null -> run forever
488
- */
489
- public function checkMaxPaymentFailures(Mage_Sales_Model_Recurring_Profile $profile, $bool = true)
490
- {
491
- $additional = $profile->getAdditionalInfo();
492
- switch (true) {
493
- // Maximum Payment Failures <= 0 or = null -> run forever
494
- case (int) $profile->getSuspensionThreshold() <= 0:
495
- break;
496
- // Maximum Payment Failures > 0 -> save countFailures into additional Info
497
- // if countFailures = 0 -> profile is suspended
498
- case $profile->getSuspensionThreshold() && !isset($additional['paymentFailures']):
499
- $additional['paymentFailures'] = (int) $profile->getSuspensionThreshold() - 1;
500
- $profile->setAdditionalInfo($additional);
501
- $profile->save();
502
- if ($additional['paymentFailures'] == 0) {
503
- $profile->suspend();
504
- $bool = false;
505
- }
506
- break;
507
- // Maximum Payment Failures > 0 -> save countFailures into additional Info
508
- // if isset countFailures -> countFailures - 1
509
- // if countFailures = 0 -> profile is suspended
510
- case $profile->getSuspensionThreshold() && $additional['paymentFailures'] > 0:
511
- $additional['paymentFailures'] -= 1;
512
- $profile->setAdditionalInfo($additional);
513
- $profile->save();
514
- if ($additional['paymentFailures'] == 0) {
515
- $profile->suspend();
516
- $bool = false;
517
- }
518
- break;
519
- default:
520
- $profile->suspend();
521
- $bool = false;
522
- break;
523
- }
524
- return $bool;
525
- }
526
  }
1
+ <?php
2
+
3
+ class Eway_Rapid31_Model_RecurringProfile
4
+ {
5
+
6
+ /**
7
+ * @var Mage_Sales_Model_Recurring_Profile
8
+ */
9
+ protected $_recurringProfile;
10
+ /**
11
+ * eway transaction id
12
+ * @var string
13
+ */
14
+ protected $_txdId;
15
+ /**
16
+ * total price of all nominal items. i.e $10*5 = $50
17
+ * @var float
18
+ */
19
+ protected $_price;
20
+ /**
21
+ * shipping fee
22
+ * @var float
23
+ */
24
+ protected $_shippingAmount;
25
+ /**
26
+ * tax amount
27
+ * @var float
28
+ */
29
+ protected $_taxAmount;
30
+ /**
31
+ * grand total
32
+ * @var float
33
+ */
34
+ protected $_amount;
35
+
36
+ /**
37
+ * period type
38
+ *
39
+ * @var string
40
+ */
41
+ protected $_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR;
42
+
43
+ /**
44
+ * @param Mage_Sales_Model_Recurring_Profile $profile
45
+ * @throws Exception
46
+ */
47
+ public function processRequest(Mage_Sales_Model_Recurring_Profile $profile)
48
+ {
49
+ $this->_recurringProfile = $profile;
50
+ try {
51
+ $this->_checkRecurringProfile();
52
+ $this->_checkoutRecurring();
53
+ $this->_processRecurringProfile();
54
+ } catch (Exception $e) {
55
+ throw $e;
56
+ }
57
+ $this->updateBeforeDate();
58
+ $this->nextDate();
59
+ $this->updatePeriodMaxCycles();
60
+ }
61
+
62
+ /**
63
+ * check eway active, check whether method code is eway
64
+ */
65
+ protected function _checkRecurringProfile()
66
+ {
67
+ $methodCode = $this->_recurringProfile->getMethodCode();
68
+ if ($methodCode != 'ewayrapid_saved') {
69
+ throw new Exception(sprintf('Method "%s" is not eWAY Rapid (Saved).', $methodCode));
70
+ }
71
+ if (!Mage::helper('ewayrapid')->isSavedMethodEnabled()) {
72
+ throw new Exception(sprintf('Method "%s" is not available.', $methodCode));
73
+ }
74
+ }
75
+
76
+ /**
77
+ * charge money for recurring item
78
+ */
79
+ protected function _checkoutRecurring()
80
+ {
81
+ /** @var Mage_Sales_Model_Order $order */
82
+ $order = Mage::getModel('sales/order');
83
+
84
+ $item = new Varien_Object($this->_recurringProfile->getOrderItemInfo());
85
+
86
+ $this->_price = $item->getBasePrice() * $item->getQty();
87
+
88
+ $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
89
+
90
+ // check isset TrialBilling
91
+ // Trial Billing Frequency <= 0 or isn't numeric => failure
92
+ if ($this->_recurringProfile->getTrialBillingAmount()
93
+ && $this->_recurringProfile->getTrialPeriodFrequency()
94
+ && $this->_recurringProfile->getTrialPeriodMaxCycles()
95
+ && $this->_recurringProfile->getTrialPeriodUnit()
96
+ && (string)(int) $this->_recurringProfile->getTrialPeriodFrequency() === ltrim($this->_recurringProfile->getTrialPeriodFrequency(), '0')
97
+ && (int) $this->_recurringProfile->getTrialPeriodFrequency() > 0
98
+ ) {
99
+ $trialPeriodMaxCycles = (int)$this->_recurringProfile->getTrialPeriodMaxCycles();
100
+ if (!isset($additionalInfo['trialPeriodMaxCycles'])) {
101
+ $additionalInfo['trialPeriodMaxCycles'] = $trialPeriodMaxCycles;
102
+ $this->_recurringProfile->setAdditionalInfo($additionalInfo);
103
+ $this->_price = $this->_recurringProfile->getTrialBillingAmount();
104
+ $this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
105
+ }
106
+ elseif (isset($additionalInfo['trialPeriodMaxCycles']) && $additionalInfo['trialPeriodMaxCycles'] > 0) {
107
+ $this->_price = $this->_recurringProfile->getTrialBillingAmount();
108
+ $this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
109
+ }
110
+ }
111
+
112
+ // calculate total amount
113
+ $this->_shippingAmount = $item->getBaseShippingAmount();
114
+ $this->_taxAmount = $item->getBaseTaxAmount();
115
+ $this->_amount = $this->_price + $this->_shippingAmount + $this->_taxAmount;
116
+
117
+ // init order
118
+ /** @var Mage_Sales_Model_Order_Item $orderItem */
119
+ $orderItem = Mage::getModel('sales/order_item')
120
+ ->setName($item->getName())
121
+ ->setSku($item->getSku())
122
+ ->setDescription($item->getDescription())
123
+ ->setQtyOrdered($item->getQty())
124
+ ->setBasePrice($item->getBasePrice())
125
+ ->setBaseTaxAmount($item->getBaseTaxAmount())
126
+ ->setBaseRowTotalInclTax($item->getBaseRowTotalInclTax());
127
+
128
+ $order->addItem($orderItem);
129
+
130
+ $shippingInfo = $this->_recurringProfile->getShippingAddressInfo();
131
+ $shippingAddress = Mage::getModel('sales/order_address')
132
+ ->setData($shippingInfo)
133
+ ->setId(null);
134
+
135
+ // get base currency code
136
+ $orderInfo = new Varien_Object($this->_recurringProfile->getOrderInfo());
137
+ $currencyCode = $orderInfo->getBaseCurrencyCode();
138
+
139
+ $order->setShippingAddress($shippingAddress);
140
+ $order->setBaseCurrencyCode($currencyCode);
141
+
142
+ /** @var Mage_Sales_Model_Order_Payment $payment */
143
+ $payment = Mage::getModel('sales/order_payment');
144
+ $payment->setOrder($order);
145
+ $payment->setIsRecurring(true);
146
+ $payment->setIsInitialFee(true);
147
+
148
+ $customerId = $this->_recurringProfile->getCustomerId();
149
+ $payment->setCustomerId($customerId);
150
+
151
+ $tokenId = $additionalInfo['token']['saved_token'];
152
+ $payment->setTokenId($tokenId);
153
+
154
+ /** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
155
+ $ewaySave = Mage::getModel('ewayrapid/method_saved');
156
+
157
+ $paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
158
+ if ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
159
+ $ewaySave->authorize($payment, $this->_amount);
160
+ } elseif ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
161
+ $ewaySave->capture($payment, $this->_amount);
162
+ }
163
+ if (!$payment->getTransactionId()) {
164
+ throw new Exception('Transaction is not available');
165
+ } else {
166
+ $this->_txdId = $payment->getTransactionId();
167
+ }
168
+ /** @todo: change status of order = "eWAY Authorised"
169
+ * now status order = "processing"
170
+ */
171
+ }
172
+
173
+ /**
174
+ * Process notification from recurring profile payments
175
+ *
176
+ * @throws Exception
177
+ * @throws Mage_Core_Exception
178
+ */
179
+ protected function _processRecurringProfile()
180
+ {
181
+ try {
182
+ $this->_registerRecurringProfilePaymentCapture();
183
+ if ($this->_periodType == Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL) {
184
+ $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
185
+ $additionalInfo['trialPeriodMaxCycles'] -= 1;
186
+ $this->_recurringProfile->setAdditionalInfo($additionalInfo);
187
+ $this->_recurringProfile->save();
188
+ }
189
+ } catch (Mage_Core_Exception $e) {
190
+ throw $e;
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Register recurring payment notification, create and process order
196
+ */
197
+ protected function _registerRecurringProfilePaymentCapture()
198
+ {
199
+ $price = $this->_price;
200
+ $tax = $this->_taxAmount;
201
+ $shipping = $this->_shippingAmount;
202
+ $grandTotal = $this->_amount;
203
+ $periodType = $this->_periodType;
204
+ $transactionId = $this->_txdId;
205
+ $ewayMessage = '';
206
+
207
+ $productItemInfo = new Varien_Object;
208
+ /** @todo: response doesn't contain period type / payment type */
209
+ $productItemInfo->setPaymentType($periodType);
210
+ $productItemInfo->setTaxAmount($tax);
211
+ $productItemInfo->setShippingAmount($shipping);
212
+ $productItemInfo->setPrice($price);
213
+
214
+
215
+ /** @var Mage_Sales_Model_Recurring_Profile $recurringProfile */
216
+ $recurringProfile = $this->_recurringProfile;
217
+ $order = $recurringProfile->createOrder($productItemInfo);
218
+ $payment = $order->getPayment();
219
+ $payment->setTransactionId($transactionId)
220
+ ->setPreparedMessage($ewayMessage)
221
+ ->setIsTransactionClosed(0);
222
+ $order->save();
223
+ $this->_recurringProfile->addOrderRelation($order->getId());
224
+ $payment->registerCaptureNotification($grandTotal);
225
+ $order->save();
226
+
227
+ // notify customer
228
+ if ($invoice = $payment->getCreatedInvoice()) {
229
+ $message = Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
230
+ $comment = $order->sendNewOrderEmail()->addStatusHistoryComment($message)
231
+ ->setIsCustomerNotified(true)
232
+ ->save();
233
+ }
234
+
235
+ if (!$recurringProfile->getIsCronJob()) {
236
+ $session = Mage::getSingleton('checkout/type_onepage')->getCheckout();
237
+ $session->setLastOrderId($order->getId());
238
+ }
239
+ }
240
+
241
+ /**
242
+ * process token if customer create and edit token when checkout with recurring profile
243
+ *
244
+ * @param Mage_Sales_Model_Quote $quote
245
+ * @return string
246
+ * @throws Exception
247
+ */
248
+ public function processToken(Mage_Sales_Model_Quote $quote)
249
+ {
250
+ try {
251
+ $billing = $quote->getBillingAddress();
252
+ $payment = $quote->getPayment();
253
+
254
+ /** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
255
+ $ewaySave = Mage::getModel('ewayrapid/method_saved');
256
+ $ewaySave->setData('info_instance', $payment);
257
+
258
+ /** @var Mage_Sales_Model_Order $order */
259
+ $order = Mage::getModel('sales/order');
260
+ /*$order->setBillingAddress($billing);*/
261
+
262
+ /** @var Mage_Sales_Model_Order_Payment $paymentObj */
263
+ $paymentObj = Mage::getModel('sales/order_payment');
264
+ $paymentObj->setOrder($order);
265
+
266
+ $request = Mage::getModel('ewayrapid/request_token');
267
+
268
+ $ewaySave->_setBilling($billing);
269
+ $ewaySave->_shouldCreateOrUpdateToken($paymentObj, $request);
270
+ return $payment->getAdditionalData();
271
+ } catch (Exception $e) {
272
+ throw $e;
273
+ }
274
+ }
275
+
276
+ /**
277
+ * update day was run of recurring profile when cron job create order
278
+ */
279
+ public function updateBeforeDate()
280
+ {
281
+ // timezone used as store's timezone
282
+ $currentDate = date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));
283
+ $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
284
+ $additionalInfo['beforeDate'] = $currentDate;
285
+ $this->_recurringProfile->setAdditionalInfo($additionalInfo);
286
+ $this->_recurringProfile->save();
287
+ }
288
+
289
+
290
+ /**
291
+ * @param null $startDate
292
+ *
293
+ * calculate the next date create order of recurring profile
294
+ * Timezone of startDate is store's timezone
295
+ * Timezone of startDatetime load into recurring profile is store's timezone
296
+ */
297
+ public function nextDate($startDate = null)
298
+ {
299
+ // when recurring profile loaded, startDate updated by currentDate
300
+ // timezone used as store's timezone
301
+ if ($startDate == null) {
302
+ $startDate = $this->_recurringProfile->getStartDatetime();
303
+ $date = new DateTime($startDate, new DateTimeZone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE));
304
+ $timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
305
+ $date->setTimezone(new DateTimeZone($timezone));
306
+ $startDate = $date->format('Y-m-d');
307
+ }
308
+
309
+ $frequency = (int)$this->_recurringProfile->getPeriodFrequency();
310
+ $unit = $this->_recurringProfile->getPeriodUnit();
311
+
312
+ if ($unit === 'week') {
313
+ $unit = 'day';
314
+ $frequency = $frequency * 7;
315
+ }
316
+ if ($unit === 'two weeks') {
317
+ $unit = 'day';
318
+ $frequency = $frequency * 14;
319
+ }
320
+
321
+ $newDate = date('Y-m-d', strtotime('+' . $frequency . $unit, strtotime($startDate)));
322
+
323
+ if (!$this->_checkDate($unit, $frequency, $startDate, $newDate)) {
324
+ $newDate = date('Y-m-d', strtotime('-1day', strtotime(date('Y-m-1', strtotime('+1month', strtotime($newDate))))));
325
+ }
326
+
327
+ $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
328
+ $additionalInfo['nextDate'] = $newDate;
329
+ $this->_recurringProfile->setAdditionalInfo($additionalInfo);
330
+ $this->_recurringProfile->save();
331
+ }
332
+
333
+ /**
334
+ * update period max cycles of recurring profile when cron job create order
335
+ */
336
+ public function updatePeriodMaxCycles()
337
+ {
338
+ // edit period max cycles if It is greater than or equal 0 and is numeric
339
+ // If period max cycles <= 0 or null, recurring profile will run forever
340
+ if ($periodMaxCycles = $this->_recurringProfile->getPeriodMaxCycles()) {
341
+ if ((string)(int) $periodMaxCycles === ltrim($periodMaxCycles, '0') && $periodMaxCycles > 0) {
342
+ $periodMaxCycles = (int) $periodMaxCycles - 1;
343
+ $this->_recurringProfile->setPeriodMaxCycles($periodMaxCycles);
344
+ $this->_recurringProfile->save();
345
+ }
346
+ }
347
+ }
348
+
349
+ /**
350
+ * check date valid
351
+ *
352
+ * @param $unit
353
+ * @param $frequency
354
+ * @param $startDate
355
+ * @param $newDate
356
+ * @return bool
357
+ */
358
+ protected function _checkDate($unit, $frequency, $startDate, $newDate)
359
+ {
360
+ if('day' === $unit) {
361
+ return true;
362
+ }
363
+
364
+ list($oldYear, $oldMonth, $oldDay) = explode('-', date('Y-m-d', strtotime($startDate)));
365
+ list($newYear, $newMonth, $newDay) = explode('-', date('Y-m-d', strtotime($newDate)));
366
+
367
+ if(($oldDay + (int)('day' == $unit ? $frequency : 0)) == $newDay && ($oldMonth + (int)('month' == $unit ? $frequency : 0)) == $newMonth && ($oldYear + (int)('year' == $unit ? $frequency : 0)) == $newYear) {
368
+ return true;
369
+ }
370
+ return false;
371
+ }
372
+
373
+ /**
374
+ * check run cron job conditions
375
+ *
376
+ * @param Mage_Sales_Model_Recurring_Profile $profile
377
+ * @return bool
378
+ */
379
+ public function checkRecurringProfileRunCronJob(Mage_Sales_Model_Recurring_Profile $profile)
380
+ {
381
+ $additionalInfo = $profile->getAdditionalInfo();
382
+ $timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
383
+ // timezone used as store's timezone
384
+ $nextDate = new DateTime(date("Y-m-d", strtotime($additionalInfo['nextDate'])), new DateTimeZone($timezone));
385
+ $currentDate = new DateTime(date("Y-m-d", Mage::getModel('core/date')->timestamp(time())), new DateTimeZone($timezone));
386
+ if (!isset($additionalInfo['beforeDate']) || $additionalInfo['beforeDate'] == null) {
387
+ if($nextDate == $currentDate) {
388
+ return true;
389
+ }
390
+ } else {
391
+ $beforeDate = new DateTime(date("Y-m-d", strtotime($additionalInfo['beforeDate'])), new DateTimeZone($timezone));
392
+ if ($beforeDate < $currentDate && $nextDate == $currentDate) {
393
+ return true;
394
+ }
395
+ }
396
+ return false;
397
+ }
398
+
399
+ /**
400
+ * check current time >= started time
401
+ *
402
+ * @param null $startDate
403
+ * @return bool
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
+ }
410
+
411
+ /**
412
+ * process Initial Fee
413
+ *
414
+ * @param Mage_Sales_Model_Recurring_Profile $profile
415
+ */
416
+ public function processInitialFee(Mage_Sales_Model_Recurring_Profile $profile)
417
+ {
418
+ // charge Initial Fee
419
+ /** @var Mage_Sales_Model_Order $order */
420
+ $order = Mage::getModel('sales/order');
421
+ $amount = $profile->getInitAmount();
422
+ $shippingInfo = $profile->getShippingAddressInfo();
423
+ $shippingAddress = Mage::getModel('sales/order_address')
424
+ ->setData($shippingInfo)
425
+ ->setId(null);
426
+
427
+ $orderInfo = new Varien_Object($profile->getOrderInfo());
428
+ $currencyCode = $orderInfo->getBaseCurrencyCode();
429
+
430
+ $order->setShippingAddress($shippingAddress);
431
+ $order->setBaseCurrencyCode($currencyCode);
432
+
433
+ /** @var Mage_Sales_Model_Order_Payment $payment */
434
+ $payment = Mage::getModel('sales/order_payment');
435
+ $payment->setOrder($order);
436
+ $payment->setIsRecurring(true);
437
+ $payment->setIsInitialFee(true);
438
+
439
+ $customerId = $profile->getCustomerId();
440
+ $payment->setCustomerId($customerId);
441
+
442
+ $additionalInfo = $profile->getAdditionalInfo();
443
+ $tokenId = $additionalInfo['token']['saved_token'];
444
+ $payment->setTokenId($tokenId);
445
+
446
+ /** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
447
+ $ewaySave = Mage::getModel('ewayrapid/method_saved');
448
+ $paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
449
+ if ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
450
+ $ewaySave->authorize($payment, $amount);
451
+ } elseif ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
452
+ $ewaySave->capture($payment, $amount);
453
+ }
454
+ /** @todo: change status of order = "eWAY Authorised"
455
+ * now status order = "processing"
456
+ */
457
+ }
458
+
459
+ /**
460
+ * @param Mage_Sales_Model_Recurring_Profile $profile
461
+ */
462
+ public function updateNextDate(Mage_Sales_Model_Recurring_Profile $profile)
463
+ {
464
+ $timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
465
+ $additionalInfo = $profile->getAdditionalInfo();
466
+ // timezone used as store's timezone
467
+ $nextDate = new DateTime(date("Y-m-d", strtotime($additionalInfo['nextDate'])), new DateTimeZone($timezone));
468
+ // timezone used as store's timezone
469
+ $currentDate = new DateTime(date("Y-m-d", Mage::getModel('core/date')->timestamp(time())), new DateTimeZone($timezone));
470
+ if ($nextDate < $currentDate) {
471
+ $this->_recurringProfile = $profile;
472
+ $startDate = $nextDate->format('Y-m-d');
473
+ $this->nextDate($startDate);
474
+ }
475
+ }
476
+
477
+ /**
478
+ * @param Mage_Sales_Model_Recurring_Profile $profile
479
+ * @param bool $bool
480
+ * @return bool
481
+ *
482
+ * check Maximum Payment Failures
483
+ * Maximum Payment Failures <= 0 -> run forever
484
+ * Maximum Payment Failures > 0 -> save countFailures into additional Info
485
+ * if isset countFailures -> countFailures - 1
486
+ * if countFailures = 0 -> profile is suspended
487
+ * if Maximum Payment Failures = null -> run forever
488
+ */
489
+ public function checkMaxPaymentFailures(Mage_Sales_Model_Recurring_Profile $profile, $bool = true)
490
+ {
491
+ $additional = $profile->getAdditionalInfo();
492
+ switch (true) {
493
+ // Maximum Payment Failures <= 0 or = null -> run forever
494
+ case (int) $profile->getSuspensionThreshold() <= 0:
495
+ break;
496
+ // Maximum Payment Failures > 0 -> save countFailures into additional Info
497
+ // if countFailures = 0 -> profile is suspended
498
+ case $profile->getSuspensionThreshold() && !isset($additional['paymentFailures']):
499
+ $additional['paymentFailures'] = (int) $profile->getSuspensionThreshold() - 1;
500
+ $profile->setAdditionalInfo($additional);
501
+ $profile->save();
502
+ if ($additional['paymentFailures'] == 0) {
503
+ $profile->suspend();
504
+ $bool = false;
505
+ }
506
+ break;
507
+ // Maximum Payment Failures > 0 -> save countFailures into additional Info
508
+ // if isset countFailures -> countFailures - 1
509
+ // if countFailures = 0 -> profile is suspended
510
+ case $profile->getSuspensionThreshold() && $additional['paymentFailures'] > 0:
511
+ $additional['paymentFailures'] -= 1;
512
+ $profile->setAdditionalInfo($additional);
513
+ $profile->save();
514
+ if ($additional['paymentFailures'] == 0) {
515
+ $profile->suspend();
516
+ $bool = false;
517
+ }
518
+ break;
519
+ default:
520
+ $profile->suspend();
521
+ $bool = false;
522
+ break;
523
+ }
524
+ return $bool;
525
+ }
526
  }
app/code/community/Eway/Rapid31/Model/Request/Abstract.php CHANGED
@@ -99,7 +99,8 @@ abstract class Eway_Rapid31_Model_Request_Abstract extends Eway_Rapid31_Model_Js
99
  $this->_log("There is an error in making API request: %s", curl_error($ch));
100
  } else {
101
  $info = curl_getinfo($ch);
102
- if ($info['http_code'] == 401 || $info['http_code'] == 404) {
 
103
  $response->isSuccess(false);
104
  $response->setMessage(Mage::helper('ewayrapid')->__("Please check the API Key and Password %s", $mode));
105
  $this->_log('Access denied. HTTP_CODE = ' . $info['http_code']);
@@ -107,9 +108,10 @@ abstract class Eway_Rapid31_Model_Request_Abstract extends Eway_Rapid31_Model_Js
107
  $response->isSuccess(true);
108
  $response->decodeJSON($result);
109
  if($this->_config->isDebug()) {
110
- $this->_log('SUCCESS. Response body:');
111
  $this->_log(print_r(json_decode($result, true), true));
112
  }
 
113
  }
114
  curl_close($ch);
115
  }
99
  $this->_log("There is an error in making API request: %s", 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']);
108
  $response->isSuccess(true);
109
  $response->decodeJSON($result);
110
  if($this->_config->isDebug()) {
111
+ $this->_log('SUCCESS. Response body: ');
112
  $this->_log(print_r(json_decode($result, true), true));
113
  }
114
+ $this->_log('SUCCESS. HTTP_CODE = ' . $info['http_code']);
115
  }
116
  curl_close($ch);
117
  }
app/code/community/Eway/Rapid31/Model/Request/Direct.php CHANGED
@@ -182,6 +182,14 @@ class Eway_Rapid31_Model_Request_Direct extends Eway_Rapid31_Model_Request_Abstr
182
  $billing = $order->getBillingAddress();
183
  $shipping = $order->getShippingAddress();
184
 
 
 
 
 
 
 
 
 
185
  $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
186
  if(Mage::helper('ewayrapid')->isBackendOrder()) {
187
  $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
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);
app/code/community/Eway/Rapid31/Model/Request/Sharedpage.php CHANGED
@@ -242,6 +242,15 @@ class Eway_Rapid31_Model_Request_Sharedpage extends Eway_Rapid31_Model_Request_A
242
 
243
  // add Shipping Address
244
  $shippingAddress = $this->_quote->getShippingAddress();
 
 
 
 
 
 
 
 
 
245
  $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
246
  $shippingParam->setFirstName($shippingAddress->getFirstname())
247
  ->setLastName($shippingAddress->getLastname())
242
 
243
  // add Shipping Address
244
  $shippingAddress = $this->_quote->getShippingAddress();
245
+
246
+ // copy BillingAddress to ShippingAddress if checkout with guest or register
247
+ $checkoutMethod = $this->_quote->getCheckoutMethod();
248
+ if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
249
+ || $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
250
+ ) {
251
+ $shippingAddress = $billingAddress;
252
+ }
253
+
254
  $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
255
  $shippingParam->setFirstName($shippingAddress->getFirstname())
256
  ->setLastName($shippingAddress->getLastname())
app/code/community/Eway/Rapid31/Model/Request/Token.php CHANGED
@@ -151,6 +151,13 @@ class Eway_Rapid31_Model_Request_Token extends Eway_Rapid31_Model_Request_Direct
151
  $order = $payment->getOrder();
152
  $shipping = $order->getShippingAddress();
153
 
 
 
 
 
 
 
 
154
 
155
  $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
156
  if (Mage::helper('ewayrapid')->isBackendOrder()) {
@@ -381,7 +388,7 @@ class Eway_Rapid31_Model_Request_Token extends Eway_Rapid31_Model_Request_Direct
381
  'IssueNumber' => $cardData['issueNumber'],
382
  'ExpMonth' => $customer['CardExpiryMonth'],
383
  'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
384
- (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
385
  'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
386
  'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
387
  );
@@ -429,7 +436,7 @@ class Eway_Rapid31_Model_Request_Token extends Eway_Rapid31_Model_Request_Direct
429
  'IssueNumber' => $cardData['issueNumber'],
430
  'ExpMonth' => $customer['CardExpiryMonth'],
431
  'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
432
- (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
433
  'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
434
  'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
435
  );
@@ -467,8 +474,8 @@ class Eway_Rapid31_Model_Request_Token extends Eway_Rapid31_Model_Request_Direct
467
  return 'MC';
468
  }
469
  if (preg_match('/^(2131|1800)/', $num)) {
470
- return 'JCB';
471
- }
472
  if (preg_match('/^36/', $num)) {
473
  return 'DC';
474
  }
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
  $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
163
  if (Mage::helper('ewayrapid')->isBackendOrder()) {
388
  'IssueNumber' => $cardData['issueNumber'],
389
  'ExpMonth' => $customer['CardExpiryMonth'],
390
  'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
391
+ (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
392
  'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
393
  'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
394
  );
436
  'IssueNumber' => $cardData['issueNumber'],
437
  'ExpMonth' => $customer['CardExpiryMonth'],
438
  'ExpYear' => (!empty($cardData['expYear']) ? $cardData['expYear'] :
439
+ (strlen($customer['CardExpiryYear']) == 2 ? '20' . $customer['CardExpiryYear'] : $customer['CardExpiryYear'])),
440
  'Type' => $cardData['ccType'] ? $cardData['ccType'] : $this->checkCardType($customer['CardNumber']),
441
  'Address' => Mage::getModel('ewayrapid/field_customer')->addData($address),
442
  );
474
  return 'MC';
475
  }
476
  if (preg_match('/^(2131|1800)/', $num)) {
477
+ return 'JCB';
478
+ }
479
  if (preg_match('/^36/', $num)) {
480
  return 'DC';
481
  }
app/code/community/Eway/Rapid31/Model/Request/Transparent.php CHANGED
@@ -51,6 +51,15 @@ class Eway_Rapid31_Model_Request_Transparent extends Eway_Rapid31_Model_Request_
51
  $this->setCustomer($customerParam);
52
 
53
  $shippingAddress = $quote->getShippingAddress();
 
 
 
 
 
 
 
 
 
54
  $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
55
  $shippingParam->setFirstName($shippingAddress->getFirstname())
56
  ->setLastName($shippingAddress->getLastname())
@@ -501,6 +510,14 @@ class Eway_Rapid31_Model_Request_Transparent extends Eway_Rapid31_Model_Request_
501
  $billing = $quote->getBillingAddress();
502
  $shipping = $quote->getShippingAddress();
503
 
 
 
 
 
 
 
 
 
504
  $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
505
  if (Mage::helper('ewayrapid')->isBackendOrder()) {
506
  $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
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())
510
  $billing = $quote->getBillingAddress();
511
  $shipping = $quote->getShippingAddress();
512
 
513
+ // copy BillingAddress to ShippingAddress if checkout with guest or register
514
+ $checkoutMethod = $quote->getCheckoutMethod();
515
+ if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
516
+ || $checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
517
+ ) {
518
+ $shipping = $billing;
519
+ }
520
+
521
  $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
522
  if (Mage::helper('ewayrapid')->isBackendOrder()) {
523
  $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
app/code/community/Eway/Rapid31/controllers/Adminhtml/IndexController.php CHANGED
@@ -1,177 +1,177 @@
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() {
10
-
11
- }
12
-
13
- public function massEwayAuthorisedAction() {
14
- $data = Mage::app()->getRequest()->getPost();
15
- if(is_array($data) & isset($data['order_ids'])) {
16
- foreach($data['order_ids'] as $id) {
17
- $order = Mage::getModel('sales/order')->load($id);
18
- $order->setData('state', 'processing');
19
- $order->setData('status', Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED);
20
- $order->save();
21
-
22
- // Update user fraud status
23
- $customer_data = Mage::getModel('customer/customer')->load($order->getCustomerId());
24
- $customer_data->setData('mark_fraud', 0);
25
- $customer_data->save();
26
-
27
- // Re-order current order
28
- // ...
29
- }
30
- }
31
- // Redirect form
32
- $this->_redirectUrl(Mage::helper("adminhtml")->getUrl("adminhtml/sales_order/index"));
33
- }
34
-
35
- public function massProcessingAction() {
36
- $data = Mage::app()->getRequest()->getPost();
37
- if(is_array($data) & isset($data['order_ids'])) {
38
- foreach($data['order_ids'] as $id) {
39
- $order = Mage::getModel('sales/order')->load($id);
40
- $order->setData('state', 'processing');
41
- $order->setData('status', 'processing');
42
- $order->save();
43
-
44
- // Update user fraud status
45
- $customer_data = Mage::getModel('customer/customer')->load($order->getCustomerId());
46
- $customer_data->setData('mark_fraud', 0);
47
- $customer_data->save();
48
-
49
- // Re-order current order
50
- // ...
51
- }
52
- }
53
- // Redirect form
54
- $this->_redirectUrl(Mage::helper("adminhtml")->getUrl("adminhtml/sales_order/index"));
55
- }
56
-
57
- public function massVerifyEwayOrderAction() {
58
- $data = Mage::app()->getRequest()->getPost();
59
- if(is_array($data) & isset($data['order_ids'])) {
60
-
61
- foreach($data['order_ids'] as $id) {
62
-
63
- $order = Mage::getModel('sales/order')->load($id);
64
-
65
- $result = $this->__getTransaction($order->getEwayTransactionId());
66
-
67
- // Check return data
68
- $result_decode = json_decode($result);
69
-
70
- $trans = $result_decode->Transactions;
71
- if(!isset($trans[0])) {
72
- continue; // go to next cycle when no element is exist
73
- }
74
- $tranId = $trans[0]->TransactionID;
75
-
76
- if($trans[0]->ResponseMessage == 'A2000') { // Success - Fraud order has been approved
77
- // Create new transaction
78
- $this->__createNewTransaction($order, $tranId);
79
- // Update order status
80
- $this->__updateStatusOrder($order);
81
- // Un-mark fraud customer
82
- $this->__unMarkFraudUser($order);
83
- }
84
- }
85
- }
86
- // Redirect form
87
- $this->_redirectUrl(Mage::helper("adminhtml")->getUrl("adminhtml/sales_order/index"));
88
- }
89
- private function __getTransaction($transId) {
90
- $ewayConfig = Mage::getSingleton('ewayrapid/config');
91
- $url = $ewayConfig->getRapidAPIUrl('Transaction') . '/' . $transId;
92
- $ch = curl_init($url);
93
- curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));
94
- curl_setopt($ch, CURLOPT_USERPWD, $ewayConfig->getBasicAuthenticationHeader());
95
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
96
-
97
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
98
- curl_setopt($ch, CURLOPT_TIMEOUT, 60);
99
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $ewayConfig->isEnableSSLVerification());
100
-
101
- $result = curl_exec($ch);
102
- return $result;
103
- }
104
-
105
- /**
106
- * Create new transaction with base order
107
- * @param $data
108
- */
109
- private function __createNewTransaction(Mage_Sales_Model_Order $order, $transId) {
110
-
111
- // Load transaction
112
- $currentTrans = Mage::getModel('sales/order_payment_transaction')
113
- ->getCollection()
114
- ->addFieldToFilter('order_id', array('eq' => $order->getEntityId()));
115
- foreach($currentTrans as $t) { }
116
- if($t == null) {
117
- $t = new Mage_Sales_Model_Order_Payment_Transaction();
118
- }
119
-
120
- $trans = new Mage_Sales_Model_Order_Payment_Transaction();
121
- // Load payment object
122
- $payment = Mage::getModel('sales/order_payment')->load($t->getPaymentId());
123
-
124
- $trans->setOrderPaymentObject($payment);
125
- $trans->setOrder($order);
126
-
127
- $trans->setParentId($t->getTransactionId());
128
- $trans->setOrderId($order->getEntityId());
129
- $trans->setPaymentId($t->getPaymentId());
130
- // Get new TxnId
131
- $break = true;
132
- for($i = 0; $i < 100; $i++) {
133
- $transId += 1;
134
- $newTrans = Mage::getModel('sales/order_payment_transaction')
135
- ->getCollection()
136
- ->addFieldToFilter('txn_id', array('eq' => $transId));
137
- if(count($newTrans) == 0) {
138
- $break = false;
139
- break;
140
- }
141
- }
142
- if($break) {
143
- return false;
144
- }
145
- $trans->setTxnId($transId);
146
-
147
- $trans->setParentTxnId($t->getTxnId());
148
- $trans->setTxnType($t->getTxnType());
149
- $trans->setIsClosed($t->getIsClosed());
150
- $trans->setCreatedAt(date('Y-m-d H:i:s'));
151
-
152
- try {
153
- $trans->save();
154
- } catch(Exception $e) {
155
- // Do something
156
- }
157
- return true;
158
-
159
- }
160
-
161
- private function __updateStatusOrder(Mage_Sales_Model_Order $order) {
162
- $state_config = Mage::getStoreConfig('payment/ewayrapid_general/verify_eway_order');
163
-
164
- $order->setState($state_config);
165
- $order->setStatus($state_config);
166
- $order->save();
167
- }
168
-
169
- private function __unMarkFraudUser(Mage_Sales_Model_Order $order) {
170
- if ($uid = $order->getCustomerId()) {
171
- $customer = Mage::getModel('customer/customer')->load($uid);
172
- $customer->setMarkFraud(0);
173
- $customer->save();
174
- }
175
- }
176
-
177
  }
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() {
10
+
11
+ }
12
+
13
+ public function massEwayAuthorisedAction() {
14
+ $data = Mage::app()->getRequest()->getPost();
15
+ if(is_array($data) & isset($data['order_ids'])) {
16
+ foreach($data['order_ids'] as $id) {
17
+ $order = Mage::getModel('sales/order')->load($id);
18
+ $order->setData('state', 'processing');
19
+ $order->setData('status', Eway_Rapid31_Model_Config::ORDER_STATUS_AUTHORISED);
20
+ $order->save();
21
+
22
+ // Update user fraud status
23
+ $customer_data = Mage::getModel('customer/customer')->load($order->getCustomerId());
24
+ $customer_data->setData('mark_fraud', 0);
25
+ $customer_data->save();
26
+
27
+ // Re-order current order
28
+ // ...
29
+ }
30
+ }
31
+ // Redirect form
32
+ $this->_redirectUrl(Mage::helper("adminhtml")->getUrl("adminhtml/sales_order/index"));
33
+ }
34
+
35
+ public function massProcessingAction() {
36
+ $data = Mage::app()->getRequest()->getPost();
37
+ if(is_array($data) & isset($data['order_ids'])) {
38
+ foreach($data['order_ids'] as $id) {
39
+ $order = Mage::getModel('sales/order')->load($id);
40
+ $order->setData('state', 'processing');
41
+ $order->setData('status', 'processing');
42
+ $order->save();
43
+
44
+ // Update user fraud status
45
+ $customer_data = Mage::getModel('customer/customer')->load($order->getCustomerId());
46
+ $customer_data->setData('mark_fraud', 0);
47
+ $customer_data->save();
48
+
49
+ // Re-order current order
50
+ // ...
51
+ }
52
+ }
53
+ // Redirect form
54
+ $this->_redirectUrl(Mage::helper("adminhtml")->getUrl("adminhtml/sales_order/index"));
55
+ }
56
+
57
+ public function massVerifyEwayOrderAction() {
58
+ $data = Mage::app()->getRequest()->getPost();
59
+ if(is_array($data) & isset($data['order_ids'])) {
60
+
61
+ foreach($data['order_ids'] as $id) {
62
+
63
+ $order = Mage::getModel('sales/order')->load($id);
64
+
65
+ $result = $this->__getTransaction($order->getEwayTransactionId());
66
+
67
+ // Check return data
68
+ $result_decode = json_decode($result);
69
+
70
+ $trans = $result_decode->Transactions;
71
+ if(!isset($trans[0])) {
72
+ continue; // go to next cycle when no element is exist
73
+ }
74
+ $tranId = $trans[0]->TransactionID;
75
+
76
+ if($trans[0]->ResponseMessage == 'A2000') { // Success - Fraud order has been approved
77
+ // Create new transaction
78
+ $this->__createNewTransaction($order, $tranId);
79
+ // Update order status
80
+ $this->__updateStatusOrder($order);
81
+ // Un-mark fraud customer
82
+ $this->__unMarkFraudUser($order);
83
+ }
84
+ }
85
+ }
86
+ // Redirect form
87
+ $this->_redirectUrl(Mage::helper("adminhtml")->getUrl("adminhtml/sales_order/index"));
88
+ }
89
+ private function __getTransaction($transId) {
90
+ $ewayConfig = Mage::getSingleton('ewayrapid/config');
91
+ $url = $ewayConfig->getRapidAPIUrl('Transaction') . '/' . $transId;
92
+ $ch = curl_init($url);
93
+ curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));
94
+ curl_setopt($ch, CURLOPT_USERPWD, $ewayConfig->getBasicAuthenticationHeader());
95
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
96
+
97
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
98
+ curl_setopt($ch, CURLOPT_TIMEOUT, 60);
99
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $ewayConfig->isEnableSSLVerification());
100
+
101
+ $result = curl_exec($ch);
102
+ return $result;
103
+ }
104
+
105
+ /**
106
+ * Create new transaction with base order
107
+ * @param $data
108
+ */
109
+ private function __createNewTransaction(Mage_Sales_Model_Order $order, $transId) {
110
+
111
+ // Load transaction
112
+ $currentTrans = Mage::getModel('sales/order_payment_transaction')
113
+ ->getCollection()
114
+ ->addFieldToFilter('order_id', array('eq' => $order->getEntityId()));
115
+ foreach($currentTrans as $t) { }
116
+ if($t == null) {
117
+ $t = new Mage_Sales_Model_Order_Payment_Transaction();
118
+ }
119
+
120
+ $trans = new Mage_Sales_Model_Order_Payment_Transaction();
121
+ // Load payment object
122
+ $payment = Mage::getModel('sales/order_payment')->load($t->getPaymentId());
123
+
124
+ $trans->setOrderPaymentObject($payment);
125
+ $trans->setOrder($order);
126
+
127
+ $trans->setParentId($t->getTransactionId());
128
+ $trans->setOrderId($order->getEntityId());
129
+ $trans->setPaymentId($t->getPaymentId());
130
+ // Get new TxnId
131
+ $break = true;
132
+ for($i = 0; $i < 100; $i++) {
133
+ $transId += 1;
134
+ $newTrans = Mage::getModel('sales/order_payment_transaction')
135
+ ->getCollection()
136
+ ->addFieldToFilter('txn_id', array('eq' => $transId));
137
+ if(count($newTrans) == 0) {
138
+ $break = false;
139
+ break;
140
+ }
141
+ }
142
+ if($break) {
143
+ return false;
144
+ }
145
+ $trans->setTxnId($transId);
146
+
147
+ $trans->setParentTxnId($t->getTxnId());
148
+ $trans->setTxnType($t->getTxnType());
149
+ $trans->setIsClosed($t->getIsClosed());
150
+ $trans->setCreatedAt(date('Y-m-d H:i:s'));
151
+
152
+ try {
153
+ $trans->save();
154
+ } catch(Exception $e) {
155
+ // Do something
156
+ }
157
+ return true;
158
+
159
+ }
160
+
161
+ private function __updateStatusOrder(Mage_Sales_Model_Order $order) {
162
+ $state_config = Mage::getStoreConfig('payment/ewayrapid_general/verify_eway_order');
163
+
164
+ $order->setState($state_config);
165
+ $order->setStatus($state_config);
166
+ $order->save();
167
+ }
168
+
169
+ private function __unMarkFraudUser(Mage_Sales_Model_Order $order) {
170
+ if ($uid = $order->getCustomerId()) {
171
+ $customer = Mage::getModel('customer/customer')->load($uid);
172
+ $customer->setMarkFraud(0);
173
+ $customer->save();
174
+ }
175
+ }
176
+
177
  }
app/code/community/Eway/Rapid31/controllers/SharedpageController.php CHANGED
@@ -1,272 +1,272 @@
1
- <?php
2
-
3
- require_once "Mage" . DS . "Checkout" . DS . "controllers" . DS . "OnepageController.php";
4
-
5
- class Eway_Rapid31_SharedpageController extends Mage_Checkout_OnepageController
6
- {
7
- /**
8
- * @var Mage_Sales_Model_Quote
9
- */
10
- protected $_quote = null;
11
-
12
- /**
13
- * @var Eway_Rapid31_Model_Request_Sharedpage
14
- */
15
- protected $_checkout = null;
16
-
17
- protected $_checkoutType = 'ewayrapid/request_sharedpage';
18
-
19
- /**
20
- * process checkout with eway Responsive Shared Page
21
- */
22
- public function startAction()
23
- {
24
- // check method available
25
- $method = $this->_getQuote()->getPayment()->getMethod();
26
- if ($method !== Eway_Rapid31_Model_Config::PAYMENT_NOT_SAVED_METHOD
27
- && $method !== Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
28
- ) {
29
- Mage::getSingleton('core/session')->addError($this->__('Payment method ' . $method . ' not available'));
30
- $this->_redirect('checkout/cart');
31
- return;
32
- }
33
- if ($method === Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
34
- && !Mage::helper('ewayrapid')->isSavedMethodEnabled()
35
- ) {
36
- Mage::getSingleton('core/session')->addError($this->__('This feature has been disabled. Please contact site owner.'));
37
- $this->_redirect('checkout/cart');
38
- return;
39
- }
40
-
41
- try {
42
- $this->_initCheckout();
43
- $data = $this->_checkout->createAccessCode(Mage::getUrl('*/*/return'), Mage::getUrl('*/*/cancel'));
44
- if ($data->isSuccess()) {
45
- Mage::getSingleton('core/session')->setData('FormActionURL', $data->getFormActionURL());
46
- if ($data->getSharedPaymentUrl()) {
47
- $this->_redirectUrl($data->getSharedPaymentUrl());
48
- return;
49
- }
50
- } else {
51
- Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: ' . $data->getMessage() . ')'));
52
- $this->_redirect('checkout/cart');
53
- return;
54
- }
55
-
56
- } catch (Exception $e) {
57
- Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__($e->getMessage()));
58
- $this->_redirect('checkout/cart');
59
- }
60
- }
61
-
62
- public function cancelAction()
63
- {
64
- $this->_redirect('checkout/cart');
65
- }
66
-
67
- /**
68
- * process payment when eway callback
69
- */
70
- public function returnAction()
71
- {
72
- try {
73
- $this->_initCheckout();
74
-
75
- $newToken = $this->getRequest()->getParam('newToken');
76
- $editToken = $this->getRequest()->getParam('editToken');
77
- $accessCode = $this->getRequest()->getParam('AccessCode');
78
-
79
- $response = $this->_checkout->getInfoByAccessCode($accessCode);
80
- if ($newToken || $editToken) {
81
- if ($response->getTokenCustomerID()) {
82
- $response = $this->_checkout->saveTokenById($response, $editToken);
83
- $response = $this->_processPayment($response);
84
- } else {
85
- Mage::throwException(Mage::helper('ewayrapid')->__('Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.',
86
- $response->getMessage()));
87
- }
88
- }
89
-
90
- $orderId = null;
91
- if ($response->isSuccess()) {
92
- $orderId = $this->storeOrder($response);
93
- } else {
94
- Mage::throwException(Mage::helper('ewayrapid')->__('Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.',
95
- $response->getMessage()));
96
- }
97
- if ($orderId) {
98
- $this->_redirect('checkout/onepage/success');
99
- return;
100
- }
101
- } catch (Exception $e) {
102
- Mage::getSingleton('checkout/session')->addError($e->getMessage());
103
- Mage::logException($e);
104
- $this->_redirect('checkout/cart');
105
- return;
106
- }
107
- }
108
-
109
- /**
110
- * save order
111
- *
112
- * @param Eway_Rapid31_Model_Response $response
113
- * @param string $successType
114
- * @return string
115
- */
116
- private function storeOrder($response, $successType = 'success')
117
- {
118
- try {
119
- // Clear the basket and save the order (including some info about how the payment went)
120
- $this->getOnepage()->getQuote()->collectTotals();
121
- $payment = $this->getOnepage()->getQuote()->getPayment();
122
- $payment->setAdditionalInformation('successType', $successType);
123
- Mage::getSingleton('core/session')->setData('ewayTransactionID', $response->getTransactionID());
124
- $orderId = $this->getOnepage()->saveOrder()->getLastOrderId();
125
- $this->getOnepage()->getQuote()->save();
126
- return $orderId;
127
- } catch (Exception $e) {
128
- Mage::throwException(Mage::helper('ewayrapid')->__($e->getMessage()));
129
- }
130
-
131
- }
132
-
133
- /**
134
- * Get one page checkout model
135
- *
136
- * @return Mage_Checkout_Model_Type_Onepage
137
- */
138
- public function getOnepage()
139
- {
140
- return Mage::getSingleton('checkout/type_onepage');
141
- }
142
-
143
- /**
144
- * Return checkout session object
145
- *
146
- * @return Mage_Checkout_Model_Session
147
- */
148
- private function _getCheckoutSession()
149
- {
150
- return Mage::getSingleton('checkout/session');
151
- }
152
-
153
- /**
154
- * Return checkout quote object
155
- *
156
- * @return Mage_Sales_Model_Quote
157
- */
158
- private function _getQuote()
159
- {
160
- if (!$this->_quote) {
161
- $this->_quote = $this->_getCheckoutSession()->getQuote();
162
- }
163
- return $this->_quote;
164
- }
165
-
166
- private function _initCheckout()
167
- {
168
- $quote = $this->_getQuote();
169
- if (!$quote->hasItems() || $quote->getHasError()) {
170
- $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden');
171
- Mage::throwException(Mage::helper('ewayrapid')->__('Unable to initialize Shared page Checkout.'));
172
- }
173
- $this->_checkout = Mage::getSingleton($this->_checkoutType, array(
174
- 'quote' => $quote
175
- ));
176
- }
177
-
178
- /**
179
- * review order when checkout with paypal express
180
- */
181
- public function reviewAction()
182
- {
183
- try {
184
- $this->_initCheckout();
185
- $accessCode = $this->getRequest()->getParam('AccessCode');
186
- $this->_checkout->updateCustomer($accessCode);
187
- $this->loadLayout();
188
- $blockReview = $this->getLayout()->getBlock('eway.block.review');
189
- $blockReview->setQuote($this->_getQuote());
190
- $blockReview->setAccessCode($accessCode);
191
- $blockReview->setActionUrl(Mage::getUrl('*/*/saveInfoShipping'));
192
- $this->renderLayout();
193
- return;
194
- } catch (Exception $e) {
195
- Mage::getSingleton('checkout/session')->addError(
196
- $this->__('Unable to initialize Express Checkout review. Error message: ' . $e->getMessage())
197
- );
198
- Mage::logException($e);
199
- }
200
- $this->_redirect('checkout/cart');
201
- }
202
-
203
- /**
204
- * save shipping total amount to quote
205
- * send new shipping total amount to eway
206
- *
207
- * @throws Exception
208
- * @throws Mage_Core_Exception
209
- */
210
- public function saveInfoShippingAction()
211
- {
212
- $this->_initCheckout();
213
- $formActionURL = Mage::getSingleton('core/session')->getData('FormActionURL');
214
- if ($formActionURL) {
215
- Mage::getSingleton('core/session')->unsetData('FormActionURL');
216
- }
217
- $shippingMethod = $this->getRequest()->getParam('shipping_method');
218
- if ($shippingMethod) {
219
- //Save to quote
220
- $this->_quote->getShippingAddress()->setShippingMethod($shippingMethod)->save();
221
-
222
- //Get price
223
- $quote = $this->_getQuote();
224
- $cRate = $this->_checkout->getShippingByCode($shippingMethod);
225
- if ($cRate) {
226
- echo json_encode(array(
227
- 'form_action' => $formActionURL,
228
- 'input_post' => '<input type="hidden" name="EWAY_NEWSHIPPINGTOTAL" value="' . round($cRate->getPrice() * 100) . '" />'
229
- ));
230
- } else {
231
- Mage::throwException($this->__('Method not found.'));
232
- }
233
- } else {
234
- Mage::throwException($this->__('Method not support.'));
235
- }
236
- die;
237
- }
238
-
239
- /**
240
- * process Payment: authorize only or authorize & capture
241
- *
242
- * @param Eway_Rapid31_Model_Response $response
243
- * @return Eway_Rapid31_Model_Response
244
- * @throws Mage_Core_Exception
245
- */
246
- protected function _processPayment(Eway_Rapid31_Model_Response $response)
247
- {
248
- $this->_initCheckout();
249
-
250
- $cardData = $response->getCustomer();
251
-
252
- if ($cardData['CardNumber'] && $cardData['CardName']) {
253
- $response = $this->_checkout->doAuthorisation($response);
254
- if ($response->isSuccess()
255
- && Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE
256
- ) {
257
- $response = $this->_checkout->doCapturePayment($response);
258
- }
259
- } else {
260
- if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
261
- $response = $this->_checkout->doAuthorisation($response);
262
- } elseif (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
263
- $response = $this->_checkout->doTransaction($response);
264
- }
265
- }
266
- if (!$response->isSuccess()) {
267
- Mage::throwException(Mage::helper('ewayrapid')->__('Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.',
268
- $response->getMessage()));
269
- }
270
- return $response;
271
- }
272
  }
1
+ <?php
2
+
3
+ require_once "Mage" . DS . "Checkout" . DS . "controllers" . DS . "OnepageController.php";
4
+
5
+ class Eway_Rapid31_SharedpageController extends Mage_Checkout_OnepageController
6
+ {
7
+ /**
8
+ * @var Mage_Sales_Model_Quote
9
+ */
10
+ protected $_quote = null;
11
+
12
+ /**
13
+ * @var Eway_Rapid31_Model_Request_Sharedpage
14
+ */
15
+ protected $_checkout = null;
16
+
17
+ protected $_checkoutType = 'ewayrapid/request_sharedpage';
18
+
19
+ /**
20
+ * process checkout with eway Responsive Shared Page
21
+ */
22
+ public function startAction()
23
+ {
24
+ // check method available
25
+ $method = $this->_getQuote()->getPayment()->getMethod();
26
+ if ($method !== Eway_Rapid31_Model_Config::PAYMENT_NOT_SAVED_METHOD
27
+ && $method !== Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
28
+ ) {
29
+ Mage::getSingleton('core/session')->addError($this->__('Payment method ' . $method . ' not available'));
30
+ $this->_redirect('checkout/cart');
31
+ return;
32
+ }
33
+ if ($method === Eway_Rapid31_Model_Config::PAYMENT_SAVED_METHOD
34
+ && !Mage::helper('ewayrapid')->isSavedMethodEnabled()
35
+ ) {
36
+ Mage::getSingleton('core/session')->addError($this->__('This feature has been disabled. Please contact site owner.'));
37
+ $this->_redirect('checkout/cart');
38
+ return;
39
+ }
40
+
41
+ try {
42
+ $this->_initCheckout();
43
+ $data = $this->_checkout->createAccessCode(Mage::getUrl('*/*/return', array('_secure'=>true)), Mage::getUrl('*/*/cancel', array('_secure'=>true)));
44
+ if ($data->isSuccess()) {
45
+ Mage::getSingleton('core/session')->setData('FormActionURL', $data->getFormActionURL());
46
+ if ($data->getSharedPaymentUrl()) {
47
+ $this->_redirectUrl($data->getSharedPaymentUrl());
48
+ return;
49
+ }
50
+ } else {
51
+ Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later. (Error message: ' . $data->getMessage() . ')'));
52
+ $this->_redirect('checkout/cart');
53
+ return;
54
+ }
55
+
56
+ } catch (Exception $e) {
57
+ Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__($e->getMessage()));
58
+ $this->_redirect('checkout/cart');
59
+ }
60
+ }
61
+
62
+ public function cancelAction()
63
+ {
64
+ $this->_redirect('checkout/cart');
65
+ }
66
+
67
+ /**
68
+ * process payment when eway callback
69
+ */
70
+ public function returnAction()
71
+ {
72
+ try {
73
+ $this->_initCheckout();
74
+
75
+ $newToken = $this->getRequest()->getParam('newToken');
76
+ $editToken = $this->getRequest()->getParam('editToken');
77
+ $accessCode = $this->getRequest()->getParam('AccessCode');
78
+
79
+ $response = $this->_checkout->getInfoByAccessCode($accessCode);
80
+ if ($newToken || $editToken) {
81
+ if ($response->getTokenCustomerID()) {
82
+ $response = $this->_checkout->saveTokenById($response, $editToken);
83
+ $response = $this->_processPayment($response);
84
+ } else {
85
+ Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction. Please try again. (Error message: %s)',
86
+ $response->getMessage()));
87
+ }
88
+ }
89
+
90
+ $orderId = null;
91
+ if ($response->isSuccess()) {
92
+ $orderId = $this->storeOrder($response);
93
+ } else {
94
+ Mage::throwException(Mage::helper('ewayrapid')->__('Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.',
95
+ $response->getMessage()));
96
+ }
97
+ if ($orderId) {
98
+ $this->_redirect('checkout/onepage/success');
99
+ return;
100
+ }
101
+ } catch (Exception $e) {
102
+ Mage::getSingleton('checkout/session')->addError($e->getMessage());
103
+ Mage::logException($e);
104
+ $this->_redirect('checkout/cart');
105
+ return;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * save order
111
+ *
112
+ * @param Eway_Rapid31_Model_Response $response
113
+ * @param string $successType
114
+ * @return string
115
+ */
116
+ private function storeOrder($response, $successType = 'success')
117
+ {
118
+ try {
119
+ // Clear the basket and save the order (including some info about how the payment went)
120
+ $this->getOnepage()->getQuote()->collectTotals();
121
+ $payment = $this->getOnepage()->getQuote()->getPayment();
122
+ $payment->setAdditionalInformation('successType', $successType);
123
+ Mage::getSingleton('core/session')->setData('ewayTransactionID', $response->getTransactionID());
124
+ $orderId = $this->getOnepage()->saveOrder()->getLastOrderId();
125
+ $this->getOnepage()->getQuote()->save();
126
+ return $orderId;
127
+ } catch (Exception $e) {
128
+ Mage::throwException(Mage::helper('ewayrapid')->__($e->getMessage()));
129
+ }
130
+
131
+ }
132
+
133
+ /**
134
+ * Get one page checkout model
135
+ *
136
+ * @return Mage_Checkout_Model_Type_Onepage
137
+ */
138
+ public function getOnepage()
139
+ {
140
+ return Mage::getSingleton('checkout/type_onepage');
141
+ }
142
+
143
+ /**
144
+ * Return checkout session object
145
+ *
146
+ * @return Mage_Checkout_Model_Session
147
+ */
148
+ private function _getCheckoutSession()
149
+ {
150
+ return Mage::getSingleton('checkout/session');
151
+ }
152
+
153
+ /**
154
+ * Return checkout quote object
155
+ *
156
+ * @return Mage_Sales_Model_Quote
157
+ */
158
+ private function _getQuote()
159
+ {
160
+ if (!$this->_quote) {
161
+ $this->_quote = $this->_getCheckoutSession()->getQuote();
162
+ }
163
+ return $this->_quote;
164
+ }
165
+
166
+ private function _initCheckout()
167
+ {
168
+ $quote = $this->_getQuote();
169
+ if (!$quote->hasItems() || $quote->getHasError()) {
170
+ $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden');
171
+ Mage::throwException(Mage::helper('ewayrapid')->__('Unable to initialize Shared page Checkout.'));
172
+ }
173
+ $this->_checkout = Mage::getSingleton($this->_checkoutType, array(
174
+ 'quote' => $quote
175
+ ));
176
+ }
177
+
178
+ /**
179
+ * review order when checkout with paypal express
180
+ */
181
+ public function reviewAction()
182
+ {
183
+ try {
184
+ $this->_initCheckout();
185
+ $accessCode = $this->getRequest()->getParam('AccessCode');
186
+ $this->_checkout->updateCustomer($accessCode);
187
+ $this->loadLayout();
188
+ $blockReview = $this->getLayout()->getBlock('eway.block.review');
189
+ $blockReview->setQuote($this->_getQuote());
190
+ $blockReview->setAccessCode($accessCode);
191
+ $blockReview->setActionUrl(Mage::getUrl('*/*/saveInfoShipping'));
192
+ $this->renderLayout();
193
+ return;
194
+ } catch (Exception $e) {
195
+ Mage::getSingleton('checkout/session')->addError(
196
+ $this->__('Unable to initialize Express Checkout review. Error message: ' . $e->getMessage())
197
+ );
198
+ Mage::logException($e);
199
+ }
200
+ $this->_redirect('checkout/cart');
201
+ }
202
+
203
+ /**
204
+ * save shipping total amount to quote
205
+ * send new shipping total amount to eway
206
+ *
207
+ * @throws Exception
208
+ * @throws Mage_Core_Exception
209
+ */
210
+ public function saveInfoShippingAction()
211
+ {
212
+ $this->_initCheckout();
213
+ $formActionURL = Mage::getSingleton('core/session')->getData('FormActionURL');
214
+ if ($formActionURL) {
215
+ Mage::getSingleton('core/session')->unsetData('FormActionURL');
216
+ }
217
+ $shippingMethod = $this->getRequest()->getParam('shipping_method');
218
+ if ($shippingMethod) {
219
+ //Save to quote
220
+ $this->_quote->getShippingAddress()->setShippingMethod($shippingMethod)->save();
221
+
222
+ //Get price
223
+ $quote = $this->_getQuote();
224
+ $cRate = $this->_checkout->getShippingByCode($shippingMethod);
225
+ if ($cRate) {
226
+ echo json_encode(array(
227
+ 'form_action' => $formActionURL,
228
+ 'input_post' => '<input type="hidden" name="EWAY_NEWSHIPPINGTOTAL" value="' . round($cRate->getPrice() * 100) . '" />'
229
+ ));
230
+ } else {
231
+ Mage::throwException($this->__('Method not found.'));
232
+ }
233
+ } else {
234
+ Mage::throwException($this->__('Method not support.'));
235
+ }
236
+ die;
237
+ }
238
+
239
+ /**
240
+ * process Payment: authorize only or authorize & capture
241
+ *
242
+ * @param Eway_Rapid31_Model_Response $response
243
+ * @return Eway_Rapid31_Model_Response
244
+ * @throws Mage_Core_Exception
245
+ */
246
+ protected function _processPayment(Eway_Rapid31_Model_Response $response)
247
+ {
248
+ $this->_initCheckout();
249
+
250
+ $cardData = $response->getCustomer();
251
+
252
+ if ($cardData['CardNumber'] && $cardData['CardName']) {
253
+ $response = $this->_checkout->doAuthorisation($response);
254
+ if ($response->isSuccess()
255
+ && Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE
256
+ ) {
257
+ $response = $this->_checkout->doCapturePayment($response);
258
+ }
259
+ } else {
260
+ if (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
261
+ $response = $this->_checkout->doAuthorisation($response);
262
+ } elseif (Mage::helper('ewayrapid')->getPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
263
+ $response = $this->_checkout->doTransaction($response);
264
+ }
265
+ }
266
+ if (!$response->isSuccess()) {
267
+ Mage::throwException(Mage::helper('ewayrapid')->__('Sorry, your payment could not be processed (Message: %s). Please check your details and try again, or try an alternative payment method.',
268
+ $response->getMessage()));
269
+ }
270
+ return $response;
271
+ }
272
  }
app/code/community/Eway/Rapid31/controllers/TransparentController.php CHANGED
@@ -100,11 +100,24 @@ class Eway_Rapid31_TransparentController extends Mage_Checkout_OnepageController
100
  if (isset($data['CompleteCheckoutURL']))
101
  Mage::getSingleton('core/session')->setCompleteCheckoutURL($data['CompleteCheckoutURL']);
102
  if ($this->transMethod == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD || $this->transMethod == Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD || $this->transMethod == Eway_Rapid31_Model_Config::MASTERPASS_METHOD ) {
103
- $urlRedirect = Mage::getUrl('ewayrapid/transparent/redirect') . '?AccessCode=' . $data['AccessCode'];
104
  } else {
105
- $urlRedirect = Mage::getUrl('ewayrapid/transparent/paynow') . '?AccessCode=' . $data['AccessCode'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
- echo($urlRedirect);
108
  } else {
109
  Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later.'));
110
  $this->transparentModel()->unsetSessionData();
@@ -114,7 +127,21 @@ class Eway_Rapid31_TransparentController extends Mage_Checkout_OnepageController
114
  } catch (Exception $e) {
115
  Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later.'));
116
  $this->transparentModel()->unsetSessionData();
117
- echo Mage::getUrl('checkout/cart/');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  return;
119
  }
120
  die;
@@ -213,7 +240,20 @@ class Eway_Rapid31_TransparentController extends Mage_Checkout_OnepageController
213
  } catch (Exception $e) {
214
  Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Call back error: ' . $e->getMessage()));
215
  $this->transparentModel()->unsetSessionData();
216
- $this->_redirect('checkout/cart/');
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  return;
218
  }
219
  }
@@ -272,9 +312,28 @@ class Eway_Rapid31_TransparentController extends Mage_Checkout_OnepageController
272
  $this->getOnepage()->getQuote()->getPayment()->setTransactionId($transactionID);
273
  $this->getOnepage()->getQuote()->getPayment()->setAdditionalInformation('transactionId', $transactionID);
274
  $this->getOnepage()->getQuote()->getPayment()->setAdditionalInformation('successType', $successType);
 
275
  $orderId = $this->getOnepage()->saveOrder()->getLastOrderId();
276
- $this->getOnepage()->getQuote()->save();
277
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  return $orderId;
279
  } catch (Exception $e) {
280
  Mage::throwException($e->getMessage());
100
  if (isset($data['CompleteCheckoutURL']))
101
  Mage::getSingleton('core/session')->setCompleteCheckoutURL($data['CompleteCheckoutURL']);
102
  if ($this->transMethod == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD || $this->transMethod == Eway_Rapid31_Model_Config::PAYPAL_EXPRESS_METHOD || $this->transMethod == Eway_Rapid31_Model_Config::MASTERPASS_METHOD ) {
103
+ $urlRedirect = Mage::getUrl('ewayrapid/transparent/redirect', array('_secure'=>true)) . '?AccessCode=' . $data['AccessCode'];
104
  } else {
105
+ $urlRedirect = Mage::getUrl('ewayrapid/transparent/paynow', array('_secure'=>true)) . '?AccessCode=' . $data['AccessCode'];
106
+ }
107
+ if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
108
+ === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
109
+ && (Mage::getStoreConfig('onestepcheckout/general/active')
110
+ || Mage::getStoreConfig('opc/global/status')
111
+ || Mage::getStoreConfig('firecheckout/general/enabled')
112
+ || Mage::getStoreConfig('gomage_checkout/general/enabled')
113
+ || Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links'))
114
+ ) {
115
+ $this->_redirectUrl($urlRedirect);
116
+ return;
117
+ }
118
+ else {
119
+ echo($urlRedirect);
120
  }
 
121
  } else {
122
  Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later.'));
123
  $this->transparentModel()->unsetSessionData();
127
  } catch (Exception $e) {
128
  Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('An error occurred while connecting to payment gateway. Please try again later.'));
129
  $this->transparentModel()->unsetSessionData();
130
+ $this->transparentModel()->unsetSessionData();
131
+ if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
132
+ === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
133
+ && (Mage::getStoreConfig('onestepcheckout/general/active')
134
+ || Mage::getStoreConfig('opc/global/status')
135
+ || Mage::getStoreConfig('firecheckout/general/enabled')
136
+ || Mage::getStoreConfig('gomage_checkout/general/enabled')
137
+ || Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links'))
138
+ ) {
139
+ $this->_redirectUrl(Mage::getUrl('checkout/cart/'));
140
+ return;
141
+ }
142
+ else {
143
+ echo Mage::getUrl('checkout/cart/');
144
+ }
145
  return;
146
  }
147
  die;
240
  } catch (Exception $e) {
241
  Mage::getSingleton('core/session')->addError(Mage::helper('ewayrapid')->__('Call back error: ' . $e->getMessage()));
242
  $this->transparentModel()->unsetSessionData();
243
+ if (Mage::getStoreConfig('payment/ewayrapid_general/connection_type')
244
+ === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT
245
+ && (Mage::getStoreConfig('onestepcheckout/general/active')
246
+ || Mage::getStoreConfig('opc/global/status')
247
+ || Mage::getStoreConfig('firecheckout/general/enabled')
248
+ || Mage::getStoreConfig('gomage_checkout/general/enabled')
249
+ || Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links'))
250
+ ) {
251
+ $this->_redirectUrl(Mage::getUrl('checkout/cart/'));
252
+ return;
253
+ }
254
+ else {
255
+ echo Mage::getUrl('checkout/cart/');
256
+ }
257
  return;
258
  }
259
  }
312
  $this->getOnepage()->getQuote()->getPayment()->setTransactionId($transactionID);
313
  $this->getOnepage()->getQuote()->getPayment()->setAdditionalInformation('transactionId', $transactionID);
314
  $this->getOnepage()->getQuote()->getPayment()->setAdditionalInformation('successType', $successType);
315
+ Mage::getSingleton('core/session')->setData('transparentCheckout', true);
316
  $orderId = $this->getOnepage()->saveOrder()->getLastOrderId();
 
317
 
318
+ $this->getOnepage()->getQuote()->setIsActive(1);
319
+ try {
320
+ $cartHelper = Mage::helper('checkout/cart');
321
+
322
+ //Get all items from cart
323
+ $items = $cartHelper->getCart()->getItems();
324
+
325
+ //Loop through all of cart items
326
+ foreach ($items as $item) {
327
+ $itemId = $item->getItemId();
328
+ //Remove items, one by one
329
+ $cartHelper->getCart()->removeItem($itemId)->save();
330
+ }
331
+ } catch (Exception $e) {
332
+
333
+ }
334
+
335
+ $this->getOnepage()->getQuote()->save();
336
+ Mage::getSingleton('core/session')->unsetData('transparentCheckout');
337
  return $orderId;
338
  } catch (Exception $e) {
339
  Mage::throwException($e->getMessage());
app/code/community/Eway/Rapid31/etc/config.xml CHANGED
@@ -254,7 +254,7 @@
254
  <cctypes>VI,MC</cctypes>
255
  <order_status>eway_captured</order_status>
256
  <allowspecific>0</allowspecific>
257
- <ssl_verification>1</ssl_verification>
258
  <transfer_cart_items>1</transfer_cart_items>
259
  <debug>0</debug>
260
  <billing_agreement_title>eWAY Billing Agreement</billing_agreement_title>
254
  <cctypes>VI,MC</cctypes>
255
  <order_status>eway_captured</order_status>
256
  <allowspecific>0</allowspecific>
257
+ <ssl_verification>0</ssl_verification>
258
  <transfer_cart_items>1</transfer_cart_items>
259
  <debug>0</debug>
260
  <billing_agreement_title>eWAY Billing Agreement</billing_agreement_title>
app/code/community/Eway/Rapid31/etc/system.xml CHANGED
@@ -56,7 +56,7 @@
56
  <sort_order>50</sort_order>
57
  <comment>
58
  <![CDATA[
59
- <a href="https://eway.zendesk.com/entries/22370567-How-to-generate-your-Live-Rapid-3-0-API-Key-and-Password" target="_blank">How to generate Live Rapid 3.1 API Key and Password</a>
60
  ]]>
61
  </comment>
62
  </live_api_password>
@@ -87,7 +87,7 @@
87
  <sort_order>70</sort_order>
88
  <comment>
89
  <![CDATA[
90
- <a href="https://eway.zendesk.com/entries/22370486-How-to-generate-your-Sandbox-Rapid-3-0-API-Key-and-Password" target="_blank">How to generate Sandbox Rapid 3.1 API Key and Password</a>
91
  ]]>
92
  </comment>
93
  </sandbox_api_password>
56
  <sort_order>50</sort_order>
57
  <comment>
58
  <![CDATA[
59
+ <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>
60
  ]]>
61
  </comment>
62
  </live_api_password>
87
  <sort_order>70</sort_order>
88
  <comment>
89
  <![CDATA[
90
+ <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>
91
  ]]>
92
  </comment>
93
  </sandbox_api_password>
app/code/community/Eway/Rapid31/sql/ewayrapid_setup/install-0.1.0.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: hiephm
5
- * Date: 4/23/14
6
- * Time: 5:30 PM
7
- */
8
- /* @var $installer Mage_Core_Model_Resource_Setup */
9
- $installer = $this;
10
-
11
- $installer->startSetup();
12
-
13
- $setup = Mage::getResourceModel('customer/setup', 'core_setup');
14
-
15
- $setup->addAttribute('customer', 'saved_tokens_json', array(
16
- 'input' => '',
17
- 'type' => 'text',
18
- 'label' => '',
19
- 'visible' => '0',
20
- 'required' => '0',
21
- 'user_defined' => '0',
22
- 'backend' => 'ewayrapid/backend_savedtokens',
23
- ));
24
-
25
  $installer->endSetup();
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: hiephm
5
+ * Date: 4/23/14
6
+ * Time: 5:30 PM
7
+ */
8
+ /* @var $installer Mage_Core_Model_Resource_Setup */
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+ $setup = Mage::getResourceModel('customer/setup', 'core_setup');
14
+
15
+ $setup->addAttribute('customer', 'saved_tokens_json', array(
16
+ 'input' => '',
17
+ 'type' => 'text',
18
+ 'label' => '',
19
+ 'visible' => '0',
20
+ 'required' => '0',
21
+ 'user_defined' => '0',
22
+ 'backend' => 'ewayrapid/backend_savedtokens',
23
+ ));
24
+
25
  $installer->endSetup();
app/design/adminhtml/default/default/template/ewayrapid/form/direct_saved.phtml CHANGED
@@ -31,8 +31,8 @@
31
  <div class="v-fix" style="float: left; padding-right: 10px;">
32
  <select id="ewayrapid_saved_token" name="payment[saved_token]" class="ewayrapid_saved_token">
33
  <?php
34
- $_tokens = $this->getTokenList();
35
- $_defaultToken = isset($_tokens['default_token']) ? $_tokens['default_token'] : false;
36
  ?>
37
  <?php foreach($_tokens['tokens'] as $_key => $_token):
38
  if ($_key == Eway_Rapid31_Model_Config::TOKEN_NEW || $this->checkCardName($_token) == Eway_Rapid31_Model_Config::CREDITCARD_METHOD): ?>
31
  <div class="v-fix" style="float: left; padding-right: 10px;">
32
  <select id="ewayrapid_saved_token" name="payment[saved_token]" class="ewayrapid_saved_token">
33
  <?php
34
+ $_tokens = $this->getTokenList();
35
+ $_defaultToken = isset($_tokens['default_token']) ? $_tokens['default_token'] : false;
36
  ?>
37
  <?php foreach($_tokens['tokens'] as $_key => $_token):
38
  if ($_key == Eway_Rapid31_Model_Config::TOKEN_NEW || $this->checkCardName($_token) == Eway_Rapid31_Model_Config::CREDITCARD_METHOD): ?>
app/design/adminhtml/default/default/template/ewayrapid/info/direct_notsaved.phtml CHANGED
@@ -25,40 +25,54 @@
25
  */
26
  ?>
27
  <?php
28
- $_helper = Mage::helper('ewayrapid');
29
- /* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
30
- $_info = $this->getInfo();
31
- /* @var Mage_Sales_Model_Order_Payment $_info */
32
 
33
  ?>
34
  <div class="cards-list">
35
 
36
- <?php if (!$this->getHideTitle()): ?>
37
- <div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
38
- <?php endif;?>
39
 
40
- <table class="info-table">
41
- <tbody>
 
42
  <tr>
43
  <td><?php echo $_helper->__('Card Holder\'s Name') ?>:</td>
44
  <td><?php echo $_info->getCcOwner(); ?></td>
45
  </tr>
 
 
 
46
  <tr>
47
  <td><?php echo $_helper->__('Credit Card Number') ?>:</td>
48
  <td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
49
  </tr>
 
 
 
50
  <tr>
51
  <td><?php echo $_helper->__('Credit Card Expiry') ?>:</td>
52
  <td><?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?></td>
53
  </tr>
 
 
 
54
  <tr>
55
  <td><?php echo $_helper->__('Credit Card Type') ?>:</td>
56
  <td><?php echo $this->getCcTypeName($_info->getCcType()); ?></td>
57
  </tr>
 
 
 
58
  <tr>
59
  <td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
60
  <td><?php echo $_info->getLastTransId(); ?></td>
61
  </tr>
62
- </tbody>
63
- </table>
 
64
  </div>
25
  */
26
  ?>
27
  <?php
28
+ $_helper = Mage::helper('ewayrapid');
29
+ /* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
30
+ $_info = $this->getInfo();
31
+ /* @var Mage_Sales_Model_Order_Payment $_info */
32
 
33
  ?>
34
  <div class="cards-list">
35
 
36
+ <?php if (!$this->getHideTitle()): ?>
37
+ <div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
38
+ <?php endif;?>
39
 
40
+ <table class="info-table">
41
+ <tbody>
42
+ <?php if($_info->getCcOwner()) : ?>
43
  <tr>
44
  <td><?php echo $_helper->__('Card Holder\'s Name') ?>:</td>
45
  <td><?php echo $_info->getCcOwner(); ?></td>
46
  </tr>
47
+ <?php endif;?>
48
+
49
+ <?php if($_info->getCcLast4()) : ?>
50
  <tr>
51
  <td><?php echo $_helper->__('Credit Card Number') ?>:</td>
52
  <td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
53
  </tr>
54
+ <?php endif;?>
55
+
56
+ <?php if($_info->getCcExpMonth()) : ?>
57
  <tr>
58
  <td><?php echo $_helper->__('Credit Card Expiry') ?>:</td>
59
  <td><?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?></td>
60
  </tr>
61
+ <?php endif;?>
62
+
63
+ <?php if($_info->getCcType()) : ?>
64
  <tr>
65
  <td><?php echo $_helper->__('Credit Card Type') ?>:</td>
66
  <td><?php echo $this->getCcTypeName($_info->getCcType()); ?></td>
67
  </tr>
68
+ <?php endif;?>
69
+
70
+ <?php if($_info->getLastTransId()) : ?>
71
  <tr>
72
  <td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
73
  <td><?php echo $_info->getLastTransId(); ?></td>
74
  </tr>
75
+ <?php endif;?>
76
+ </tbody>
77
+ </table>
78
  </div>
app/design/adminhtml/default/default/template/ewayrapid/info/direct_saved.phtml CHANGED
@@ -25,32 +25,40 @@
25
  */
26
  ?>
27
  <?php
28
- $_helper = Mage::helper('ewayrapid');
29
- /* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
30
- $_info = $this->getInfo();
31
- /* @var Mage_Sales_Model_Order_Payment $_info */
32
 
33
  ?>
34
  <div class="cards-list">
35
 
36
- <?php if (!$this->getHideTitle()): ?>
37
- <div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
38
- <?php endif;?>
39
 
40
- <table class="info-table">
41
- <tbody>
 
42
  <tr>
43
  <td><?php echo $_helper->__('Payer ID') ?>:</td>
44
  <td><?php echo $this->getTokenId() ?></td>
45
  </tr>
 
 
 
46
  <tr>
47
  <td><?php echo $_helper->__('Credit Card Number') ?>:</td>
48
  <td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
49
  </tr>
 
 
 
50
  <tr>
51
  <td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
52
  <td><?php echo $_info->getLastTransId(); ?></td>
53
  </tr>
54
- </tbody>
55
- </table>
 
56
  </div>
25
  */
26
  ?>
27
  <?php
28
+ $_helper = Mage::helper('ewayrapid');
29
+ /* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
30
+ $_info = $this->getInfo();
31
+ /* @var Mage_Sales_Model_Order_Payment $_info */
32
 
33
  ?>
34
  <div class="cards-list">
35
 
36
+ <?php if (!$this->getHideTitle()): ?>
37
+ <div class="bold"><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></div>
38
+ <?php endif;?>
39
 
40
+ <table class="info-table">
41
+ <tbody>
42
+ <?php if($_info->getTokenId()): ?>
43
  <tr>
44
  <td><?php echo $_helper->__('Payer ID') ?>:</td>
45
  <td><?php echo $this->getTokenId() ?></td>
46
  </tr>
47
+ <?php endif; ?>
48
+
49
+ <?php if($_info->getCcLast4()): ?>
50
  <tr>
51
  <td><?php echo $_helper->__('Credit Card Number') ?>:</td>
52
  <td><?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?></td>
53
  </tr>
54
+ <?php endif; ?>
55
+
56
+ <?php if($_info->getLastTransId()): ?>
57
  <tr>
58
  <td><?php echo $_helper->__('Last Transaction ID') ?>:</td>
59
  <td><?php echo $_info->getLastTransId(); ?></td>
60
  </tr>
61
+ <?php endif; ?>
62
+ </tbody>
63
+ </table>
64
  </div>
app/design/adminhtml/default/default/template/ewayrapid/pdf/direct_notsaved.phtml CHANGED
@@ -24,10 +24,32 @@
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
27
-
28
  <?php
29
- $cards = $this->getCards();
30
- $showCount = count($cards) > 1;
 
 
 
31
  ?>
32
 
33
- <?php echo $this->getMethod()->getTitle() ?>{{pdf_row_separator}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
  ?>
 
27
  <?php
28
+ $_helper = Mage::helper('ewayrapid');
29
+ /* @var Eway_Rapid31_Block_Info_Direct_Notsaved $this */
30
+ $_info = $this->getInfo();
31
+ /* @var Mage_Sales_Model_Order_Payment $_info */
32
+
33
  ?>
34
 
35
+
36
+ <?php echo $this->getMethod()->getTitle() ?>{{pdf_row_separator}}
37
+ <?php if($_info->getCcOwner()): ?>
38
+ <?php echo $_helper->__('Card Holder\'s Name') ?>: <?php echo $_info->getCcOwner(); ?>{{pdf_row_separator}}
39
+ <?php endif; ?>
40
+
41
+ <?php if($_info->getCcLast4()): ?>
42
+ <?php echo $_helper->__('Credit Card Number') ?>: <?php echo str_pad($_info->getCcLast4(), 16, '*', STR_PAD_LEFT); ?>{{pdf_row_separator}}
43
+ <?php endif; ?>
44
+
45
+ <?php if($_info->getCcExpMonth()): ?>
46
+ <?php echo $_helper->__('Credit Card Expiry') ?>: <?php echo str_pad($_info->getCcExpMonth(), 2, '0', STR_PAD_LEFT); ?> / <?php echo $_info->getCcExpYear() ?>{{pdf_row_separator}}
47
+ <?php endif; ?>
48
+
49
+ <?php if($_info->getCcType()): ?>
50
+ <?php echo $_helper->__('Credit Card Type') ?>: <?php echo $this->getCcTypeName($_info->getCcType()); ?>{{pdf_row_separator}}
51
+ <?php endif; ?>
52
+
53
+ <?php if($_info->getLastTransId()): ?>
54
+ <?php echo $_helper->__('Last Transaction ID') ?>: <?php echo $_info->getLastTransId(); ?>{{pdf_row_separator}}
55
+ <?php endif; ?>
app/design/frontend/base/default/layout/ewayrapid/layout.xml CHANGED
@@ -123,6 +123,24 @@
123
  </reference>
124
  </opc_index_index>
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  <hanlder_transparent_layout_empty>
127
  <update handle="default"/>
128
  <reference name="root">
123
  </reference>
124
  </opc_index_index>
125
 
126
+ <gomage_checkout_onepage_index>
127
+ <reference name="head">
128
+ <action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/eCrypt.js</script></action>
129
+ <action ifconfig="payment/ewayrapid_general/active" method="addJs"><script>ewayrapid/ewayrapid.js</script></action>
130
+ <action ifconfig="payment/ewayrapid_general/active" method="addCss"><script>css/ewayrapid.css</script></action>
131
+ </reference>
132
+ <reference name="before_body_end">
133
+ <block type="core/template" name="ewayrapid.js" after="-">
134
+ <action ifconfig="payment/ewayrapid_general/active" method="setTemplate">
135
+ <template>ewayrapid/js.phtml</template>
136
+ </action>
137
+ <action method="setCheckoutExtension">
138
+ <name>LightCheckout</name>
139
+ </action>
140
+ </block>
141
+ </reference>
142
+ </gomage_checkout_onepage_index>
143
+
144
  <hanlder_transparent_layout_empty>
145
  <update handle="default"/>
146
  <reference name="root">
app/design/frontend/base/default/template/ewayrapid/customer/edit.phtml CHANGED
@@ -1,615 +1,615 @@
1
- <?php
2
- $_token = $this->getCurrentToken();
3
- $_address = $this->getCustomerAddress();
4
-
5
- // Form Url
6
- $connectionType = Mage::getStoreConfig('payment/ewayrapid_general/connection_type');
7
- $formUrl = $this->getSaveUrl();
8
- $transparent = false;
9
- switch ($connectionType) {
10
- case Eway_Rapid31_Model_Config::CONNECTION_DIRECT:
11
- echo '<script type="text/javascript" src="' . Mage::getBaseUrl() . '/js/ewayrapid/eCrypt.js"></script>';
12
- break;
13
- case Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT:
14
- $transparent = true;
15
- break;
16
- case Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE:
17
- $formUrl = Mage::getBaseUrl() . '/ewayrapid/mycards/getAccessCode';
18
- break;
19
- default:
20
- break;
21
- }
22
- ?>
23
- <?php if ($this->getTitle()): ?>
24
- <div class="page-title">
25
- <h1><?php echo $this->getTitle() ?></h1>
26
- </div>
27
- <?php endif; ?>
28
- <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
29
- <div class="tool-tip" id="payment-tool-tip" style="display:none;">
30
- <div class="btn-close"><a href="#" id="payment-tool-tip-close"
31
- title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
32
- <div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>"
33
- alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>"
34
- title="<?php echo $this->__('Card Verification Number Visual Reference') ?>"/>
35
- </div>
36
- </div>
37
- <form action="<?php echo $formUrl ?>" method="post" id="form-validate">
38
- <input type="hidden" name="EWAY_ACCESSCODE" id="eway_accesscode"/>
39
- <?php
40
- if ($_token->getTokenId()) {
41
- ?>
42
- <input type="hidden" name="token_id" value="<?php echo $_token->getTokenId() ?>"/>
43
- <input type="hidden" name="TokenCustomerID" value="<?php echo $_token->getToken() ?>"/>
44
- <?php } ?>
45
-
46
- <!-- Card info -->
47
- <?php
48
- if ($connectionType !== Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
49
- ?>
50
- <div class="fieldset">
51
- <?php echo $this->getBlockHtml('formkey') ?>
52
- <h2 class="legend"><?php echo $this->__('Credit Card Information') ?></h2>
53
-
54
- <div class="sp-methods">
55
- <ul class="form-list">
56
- <li>
57
- <div class="input-box">
58
- <label for="ewayrapid_saved_cc_owner"
59
- class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
60
- <input type="text" title="<?php echo $this->__('Name on Card') ?>"
61
- class="input-text required-entry validate-length maximum-length-50"
62
- id="ewayrapid_saved_cc_owner"
63
- name="payment[cc_owner]" value="<?php echo $this->escapeHtml($_token->getOwner()) ?>"
64
- __maxlength="50" autocomplete="off"/>
65
- </div>
66
- </li>
67
- <li>
68
- <label for="ewayrapid_saved_cc_number"
69
- class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
70
-
71
- <div class="input-box help-disabled-cc">
72
- <input type="text" id="ewayrapid_saved_cc_number" data-eway-encrypt-name="payment[cc_number]"
73
- title="<?php echo $this->__('Credit Card Number') ?>"
74
- class="input-text <?php if (!$this->isEdit()): ?>validate-cc-number validate-cc-type-auto<?php endif; ?>"
75
- autocomplete="off" <?php if ($this->isEdit()): ?>value="<?php echo $_token->getCard() ?>"
76
- disabled="disabled" <?php endif; ?> pattern="\d*"/>
77
- <input type="hidden" id="ewayrapid_saved_cc_type" name="payment[cc_type]"
78
- value="<?php echo $_token->getType() ?>"/>
79
- <?php if ($this->isEdit()): ?>
80
- <input type="hidden" name="EWAY_CARDNUMBER" value="444433XXXXXX1111"/>
81
- <a href="#"><?php echo $this->__('Help') ?></a>
82
- <div class="tool-tip" id="cc-help-tool-tip" style="display:none;">
83
- <div class="btn-close">
84
- <a href="#" id="cc-help-tool-tip-close"
85
- title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a>
86
- </div>
87
- <div class="tool-tip-content">To use a new credit card number, please add another card
88
- </div>
89
- </div>
90
- <?php endif; ?>
91
- </div>
92
- </li>
93
-
94
- <li id="ewayrapid_saved_cc_type_exp_div">
95
- <label for="ewayrapid_saved_expiration"
96
- class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
97
-
98
- <div class="input-box">
99
- <div class="v-fix">
100
- <select id="ewayrapid_saved_expiration" name="payment[cc_exp_month]"
101
- class="month validate-cc-exp required-entry" autocomplete="off">
102
- <?php $_ccExpMonth = $_token->getExpMonth() ?>
103
- <?php foreach ($this->getCcMonths() as $k => $v): ?>
104
- <option
105
- value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
106
- <?php endforeach ?>
107
- </select>
108
- </div>
109
- <div class="v-fix">
110
- <?php $_ccExpYear = $_token->getExpYear() ?>
111
- <select id="ewayrapid_saved_expiration_yr" name="payment[cc_exp_year]"
112
- class="year required-entry" autocomplete="off">
113
- <?php foreach ($this->getCcYears() as $k => $v): ?>
114
- <option
115
- value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
116
- <?php endforeach ?>
117
- </select>
118
- </div>
119
- </div>
120
- </li>
121
-
122
- <?php
123
- if ($transparent) {
124
- ?>
125
- <li class="value_from_date">
126
- <label for="ewayrapid_saved_start_month"
127
- class="required"><?php echo $this->__('Valid From Date') ?></label>
128
-
129
- <div class="input-box">
130
- <div class="v-fix">
131
- <select id="ewayrapid_saved_start_month" name="payment[cc_start_month]"
132
- class="month" autocomplete="off">
133
- <?php $_ccStartMonth = $_token->getStartMonth() ?>
134
- <?php foreach ($this->getCcMonths() as $k => $v): ?>
135
- <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccStartMonth): ?>
136
- selected="selected"<?php endif ?>><?php echo $v ?></option>
137
- <?php endforeach ?>
138
- </select>
139
- </div>
140
- <div class="v-fix">
141
- <?php $_ccStartYear = $_token->getStartYear() ?>
142
- <select id="ewayrapid_saved_start_year" name="payment[cc_start_year]"
143
- class="year" autocomplete="off">
144
- <?php
145
- $start_year = 0;
146
- $inc = 0;
147
- foreach ($this->getCcYears() as $k => $v) {
148
- if ($inc == 1) {
149
- $start_year = (int)$k;
150
- break;
151
- }
152
- echo "<option value=''>Year</option>";
153
- $inc++;
154
- }
155
-
156
- for ($i = 10; $i > 0; $i--) {
157
- ?>
158
- <option value="<?php echo $start_year - $i ?>"
159
- <?php if (($start_year - $i) == $_ccStartYear) { ?>
160
- selected="selected"<?php } ?>>
161
- <?php echo $start_year - $i ?>
162
- </option>
163
- <?php
164
- }
165
-
166
- $inc = 0;
167
- foreach ($this->getCcYears() as $k => $v):
168
- $inc++;
169
- if ($inc == 1) {
170
- continue;
171
- }
172
- ?>
173
- <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccStartYear): ?>
174
- selected="selected"<?php endif ?>><?php echo $v ?></option>
175
- <?php
176
- endforeach;
177
- ?>
178
- </select>
179
- </div>
180
- </div>
181
- </li>
182
- <li>
183
- <div class="input-box">
184
- <label for="ewayrapid_saved_issue_number">
185
- <?php echo $this->__('Issue Number') ?>
186
- </label>
187
- <input type="text" title="<?php echo $this->__('Issue Number') ?>"
188
- class="input-text validate-length maximum-length-4"
189
- id="ewayrapid_saved_issue_number"
190
- name="payment[cc_issue_number]"
191
- value="<?php echo $this->escapeHtml($_token->getIssueNumber()) ?>"
192
- __maxlength="50" autocomplete="off"/>
193
- </div>
194
- </li>
195
- <?php
196
- }
197
- ?>
198
-
199
- <?php if ($this->hasVerification()): ?>
200
- <li id="ewayrapid_saved_cc_type_cvv_div">
201
- <label for="ewayrapid_saved_cc_cid"
202
- class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
203
-
204
- <div class="input-box">
205
- <div class="v-fix">
206
- <input type="text" title="<?php echo $this->__('Card Verification Number') ?>"
207
- class="input-text cvv required-entry validate-cc-cvn" id="ewayrapid_saved_cc_cid"
208
- data-eway-encrypt-name="payment[cc_cid]" value="" autocomplete="off"
209
- pattern="\d*"/>
210
- </div>
211
- <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
212
- </div>
213
- </li>
214
- <?php endif; ?>
215
- <?php
216
- $_defaultToken = Mage::helper('ewayrapid/customer')->getDefaultToken();
217
- if (!$_token->getToken() || ($_defaultToken && $_defaultToken != $_token->getTokenId())): ?>
218
- <li>
219
- <div class="v-fix" style="padding-right: 5px;">
220
- <input type="checkbox" id="ewayrapid_saved_default" name="is_default"/>
221
- </div>
222
- <label for="ewayrapid_saved_default"><?php echo $this->__('Default Credit Card') ?></label>
223
- </li>
224
- <?php endif; ?>
225
- </ul>
226
- </div>
227
- </div>
228
- <?php
229
- } else {
230
- // Responsive shared page card data
231
- // ....
232
- $_defaultToken = Mage::helper('ewayrapid/customer')->getDefaultToken();
233
- if (!$_token->getToken() || ($_defaultToken && $_defaultToken != $_token->getTokenId())): ?>
234
- <ul>
235
- <li>
236
- <div class="v-fix" style="padding-right: 5px;">
237
- <input type="checkbox" id="ewayrapid_saved_default" name="is_default"/>
238
- </div>
239
- <label for="ewayrapid_saved_default"><?php echo $this->__('Default Credit Card') ?></label>
240
- </li>
241
- </ul>
242
- <?php endif;
243
- } ?>
244
- <div class="fieldset bill-address">
245
- <h2 class="legend"><?php echo $this->__('Billing Address') ?></h2>
246
- <ul class="form-list">
247
- <li class="fields">
248
- <div class="customer-name-prefix">
249
- <div class="field name-prefix">
250
- <label for="address_prefix"><?php echo $this->__('Title') ?></label>
251
-
252
- <div class="input-box">
253
- <select id="address_prefix" name="address[prefix]" title="<?php echo $this->__('Title') ?>">
254
- <?php foreach ($this->getPrefixOptions() as $_option): ?>
255
- <option
256
- value="<?php echo $_option ?>"<?php if ($_address->getTitle() == $_option): ?>
257
- selected="selected"<?php endif; ?>><?php echo $this->__($_option) ?></option>
258
- <?php endforeach; ?>
259
- </select>
260
- </div>
261
- </div>
262
- <div class="field name-firstname">
263
- <label for="address_firstname" class="required"><em>*</em><?php echo $this->__('First Name') ?>
264
- </label>
265
-
266
- <div class="input-box">
267
- <input type="text" id="address_firstname" name="address[firstname]"
268
- value="<?php echo $this->escapeHtml($_address->getFirstName()) ?>"
269
- title="<?php echo $this->__('First Name') ?>"
270
- __maxlength="50" class="input-text required-entry validate-length maximum-length-50"/>
271
- </div>
272
- </div>
273
- <div class="field name-lastname">
274
- <label for="address_lastname" class="required"><em>*</em><?php echo $this->__('Last Name') ?>
275
- </label>
276
-
277
- <div class="input-box">
278
- <input type="text" id="address_lastname" name="address[lastname]"
279
- value="<?php echo $this->escapeHtml($_address->getLastName()) ?>"
280
- title="<?php echo $this->__('Last Name') ?>" __maxlength="50"
281
- class="input-text required-entry validate-length maximum-length-50"/>
282
- </div>
283
- </div>
284
- </div>
285
- </li>
286
- <li class="fields">
287
- <div class="field">
288
- <label for="address_company"><?php echo $this->__('Company') ?></label>
289
-
290
- <div class="input-box">
291
- <input type="text" name="address[company]" id="address_company"
292
- title="<?php echo $this->__('Company') ?>" __maxlength="50"
293
- value="<?php echo $this->escapeHtml($_address->getCompanyName()) ?>"
294
- class="input-text validate-length maximum-length-50"/>
295
- </div>
296
- </div>
297
- <div class="field">
298
- <label for="address_job_description"><?php echo $this->__('Job Description') ?></label>
299
-
300
- <div class="input-box">
301
- <input type="text" name="address[job_description]" id="address_job_description"
302
- title="<?php echo $this->__('Job Description') ?>" __maxlength="50"
303
- value="<?php echo $this->escapeHtml($_address->getJobDescription()) ?>"
304
- class="input-text validate-length maximum-length-50"/>
305
- </div>
306
- </div>
307
-
308
- </li>
309
- <li class="fields">
310
- <div class="field">
311
- <label for="address_telephone" class="required"><em>*</em><?php echo $this->__('Phone') ?></label>
312
-
313
- <div class="input-box">
314
- <input type="text" name="address[telephone]"
315
- value="<?php echo $this->escapeHtml($_address->getPhone()) ?>"
316
- title="<?php echo $this->__('Phone') ?>"
317
- class="input-text required-entry eway-validate-phone validate-length maximum-length-32"
318
- id="address_telephone" __maxlength="32"/>
319
- </div>
320
- </div>
321
- <div class="field">
322
- <label for="address_mobile"><?php echo $this->__('Mobile') ?></label>
323
-
324
- <div class="input-box">
325
- <input type="text" name="address[mobile]"
326
- value="<?php echo $this->escapeHtml($_address->getMobile()) ?>"
327
- title="<?php echo $this->__('Mobile') ?>"
328
- class="input-text eway-validate-phone validate-length maximum-length-32"
329
- id="address_mobile" __maxlength="32"/>
330
- </div>
331
- </div>
332
- </li>
333
- <li class="fields">
334
- <div class="field">
335
- <label for="address_email"><?php echo $this->__('Email') ?></label>
336
-
337
- <div class="input-box">
338
- <input type="text" name="address[email]" id="address_email" __maxlength="50"
339
- title="<?php echo $this->__('Email') ?>"
340
- value="<?php echo $this->escapeHtml($_address->getEmail()) ?>"
341
- class="input-text validate-email validate-length maximum-length-50"/>
342
- </div>
343
- </div>
344
- <div class="field">
345
- <label for="address_fax"><?php echo $this->__('Fax') ?></label>
346
-
347
- <div class="input-box">
348
- <input type="text" name="address[fax]" id="address_fax" title="<?php echo $this->__('Fax') ?>"
349
- value="<?php echo $this->escapeHtml($_address->getFax()) ?>"
350
- class="input-text eway-validate-phone validate-length maximum-length-32" __maxlength="32"/>
351
- </div>
352
- </div>
353
- </li>
354
- <li class="wide">
355
- <label for="address_street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
356
-
357
- <div class="input-box">
358
- <input type="text" name="address[street][]" __maxlength="50"
359
- value="<?php echo $this->escapeHtml($_address->getStreet1()) ?>"
360
- title="<?php echo $this->__('Street Address') ?>" id="address_street_1"
361
- class="input-text required-entry validate-length maximum-length-50"/>
362
- </div>
363
- </li>
364
- <li class="wide">
365
- <div class="input-box">
366
- <input type="text" name="address[street][]" __maxlength="50"
367
- value="<?php echo $this->escapeHtml($_address->getStreet2()) ?>"
368
- title="<?php echo $this->__('Street Address') ?>" id="address_street_2"
369
- class="input-text validate-length maximum-length-50"/>
370
- </div>
371
- </li>
372
- <li class="fields">
373
- <div class="field">
374
- <label for="address_city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
375
-
376
- <div class="input-box">
377
- <input type="text" name="address[city]" __maxlength="50"
378
- value="<?php echo $_address->getCity() ?>" title="<?php echo $this->__('City') ?>"
379
- class="input-text required-entry validate-length maximum-length-50" id="address_city"/>
380
- </div>
381
- </div>
382
- <div class="field">
383
- <label for="address_region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?>
384
- </label>
385
-
386
- <div class="input-box">
387
- <select id="address_region_id" name="address[region_id]"
388
- title="<?php echo $this->__('State/Province') ?>" class="validate-select"
389
- style="display:none;">
390
- <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
391
- </select>
392
- <script type="text/javascript">
393
- //<![CDATA[
394
- $('address_region_id').setAttribute('defaultValue', "<?php echo $_address->getRegionId() ?>");
395
- //]]>
396
- </script>
397
- <input type="text" id="address_region" name="address[region]" __maxlength="50"
398
- value="<?php echo $this->escapeHtml($_address->getState()) ?>"
399
- title="<?php echo $this->__('State/Province') ?>"
400
- class="input-text validate-length maximum-length-50"/>
401
- </div>
402
- </div>
403
- </li>
404
- <li class="fields">
405
- <div class="field">
406
- <label for="address_zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
407
-
408
- <div class="input-box">
409
- <input type="text" name="address[postcode]"
410
- value="<?php echo $this->escapeHtml($_address->getPostalCode()) ?>"
411
- title="<?php echo $this->__('Zip/Postal Code') ?>" id="address_zip"
412
- class="input-text validate-zip-international required-entry validate-length maximum-length-30"
413
- __maxlength="30"/>
414
- </div>
415
- </div>
416
- <div class="field">
417
- <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
418
-
419
- <div class="input-box">
420
- <?php echo $this->getCountryHtmlSelect(strtoupper($_address->getCountry()), 'address[country_id]', 'address_country') ?>
421
- </div>
422
- </div>
423
- </li>
424
- </ul>
425
- </div>
426
- <div class="buttons-set">
427
- <p class="required"><?php echo $this->__('* Required Fields') ?></p>
428
-
429
- <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>">
430
- <small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
431
- <?php
432
- echo $transparent ? '<button type="button" onclick="beforeSubmit(this)" title="'
433
- . $this->__('Save Credit Card') . '" class="button"><span><span>'
434
- . $this->__('Save Credit Card') . '</span></span></button>'
435
- . '<span id="save-please-wait" class="please-wait" style="display:none;">
436
- <img class="v-middle" title="Loading..." alt="Loading..." src="'
437
- . Mage::getBaseUrl() . '/skin/frontend/default/default/images/opc-ajax-loader.gif">
438
- Please waiting ...
439
- </span>'
440
- : '<button type="submit" title="' . $this->__('Save Credit Card') . '" class="button"><span><span>' . $this->__('Save Credit Card') . '</span></span></button>';
441
- ?>
442
-
443
- </div>
444
- </form>
445
-
446
- <script type="text/javascript">
447
- //<![CDATA[
448
- var dataForm = new VarienForm('form-validate', true);
449
- new RegionUpdater('address_country', 'address_region', 'address_region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'address_zip');
450
- EwayPayment.supportCardTypes = <?php echo json_encode(Mage::getSingleton('ewayrapid/config')->getSupportedCardTypes()) ?>;
451
-
452
- $$('.cvv-what-is-this').each(function (element) {
453
- Event.observe(element, 'click', toggleToolTip);
454
- });
455
-
456
- function toggleToolTip(event) {
457
- if ($('payment-tool-tip')) {
458
- $('payment-tool-tip').setStyle({
459
- top: (Event.pointerY(event) - 200) + 'px'//,
460
- })
461
- $('payment-tool-tip').toggle();
462
- }
463
- Event.stop(event);
464
- }
465
- if ($('payment-tool-tip-close')) {
466
- Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
467
- }
468
-
469
- $('form-validate').onsubmit = function () {
470
- return (dataForm.validator && dataForm.validator.validate());
471
- }
472
- var ewayPayment = new EwayPayment($('form-validate'), '<?php echo Mage::getSingleton('ewayrapid/config')->getEncryptionKey() ?>');
473
-
474
- $$('.help-disabled-cc a').each(function (element) {
475
- Event.observe(element, 'click', toggleToolTipCc);
476
- });
477
-
478
- function toggleToolTipCc(event) {
479
- if ($('cc-help-tool-tip')) {
480
- $('cc-help-tool-tip').toggle();
481
- }
482
- Event.stop(event);
483
- }
484
- if ($('cc-help-tool-tip-close')) {
485
- Event.observe($('cc-help-tool-tip-close'), 'click', toggleToolTipCc);
486
- }
487
-
488
- // TRANSPARENT REDIRECT
489
- function beforeSubmit(obj) {
490
- $('validate_from_date_message') != null ? $('validate_from_date_message').remove() : '';
491
- $('ewayrapid_saved_start_month').removeClassName('validation-failed');
492
- $('ewayrapid_saved_start_year').removeClassName('validation-failed');
493
- $$('li.value_from_date')[0].removeClassName('validation-error');
494
-
495
- if (typeof isTest !== 'undefined') {
496
- // Alert error code ERR-012
497
- alert('An error occurred while connecting to payment gateway. Please try again later.!');
498
- return false;
499
- }
500
-
501
- //*********************************Valid From Date If Select********************************************************************
502
- if($('ewayrapid_saved_start_year').value > 0 && $('ewayrapid_saved_start_month').value <= 0) {
503
- $('validation-advice-year') && $('validation-advice-year').remove();
504
- $('ewayrapid_saved_start_month').addClassName('validation-failed');
505
- $('ewayrapid_saved_start_month').up('div').insert('<div class="validation-advice" id="validation-advice-month">Incorrect credit card from date.</div>');
506
- return;
507
- } else if($('ewayrapid_saved_start_year').value <= 0 && $('ewayrapid_saved_start_month').value > 0) {
508
- $('validation-advice-month') && $('validation-advice-month').remove();
509
- $('ewayrapid_saved_start_year').addClassName('validation-failed');
510
- $('ewayrapid_saved_start_year').up('div').insert('<div class="validation-advice" id="validation-advice-year">Incorrect credit card from year.</div>');
511
- return;
512
- } else {
513
- $('validation-advice-year') && $('validation-advice-year').remove();
514
- $('validation-advice-month') && $('validation-advice-month').remove();
515
- }
516
-
517
- var from_date = new Date($('ewayrapid_saved_start_year').value + '-' + $('ewayrapid_saved_start_month').value).getTime();
518
- var expiration_date = new Date($('ewayrapid_saved_expiration_yr').value + '-' + $('ewayrapid_saved_expiration').value).getTime();
519
- if(Prototype.Browser.IE) {
520
- from_date = new Date($('ewayrapid_saved_start_year').value, $('ewayrapid_saved_start_month').value, 1).getTime();
521
- expiration_date = new Date($('ewayrapid_saved_expiration_yr').value, $('ewayrapid_saved_expiration').value, 1).getTime();
522
- }
523
- //console.log(from_date - expiration_date);
524
-
525
- if(from_date - expiration_date > 0) {
526
- $$('li.value_from_date')[0].insert({after: '<div style="" id="validate_from_date_message" ' +
527
- 'class="validation-advice">From Date is invalid. It must be earlier than Expiration Date.</div>'});
528
- $('ewayrapid_saved_start_month').addClassName('validation-failed');
529
- $('ewayrapid_saved_start_year').addClassName('validation-failed');
530
- $$('li.value_from_date')[0].addClassName('validation-error');
531
- return;
532
- }
533
- //******************************************************************************************************************************
534
-
535
- var validate = dataForm.validator.validate();
536
- if (!validate) {
537
- return;
538
- }
539
-
540
- /*if ($('ewayrapid_saved_start_year').value != '' || $('ewayrapid_saved_start_month').value != '') {
541
- if ((new Date($('ewayrapid_saved_expiration_yr').value + '-'
542
- + ($('ewayrapid_saved_expiration').value <= 9 ? '0' : '') + $('ewayrapid_saved_expiration').value).getTime() )
543
- - ( new Date($('ewayrapid_saved_start_year').value + '-'
544
- + ($('ewayrapid_saved_start_month').value <= 9 ? '0' : '') + $('ewayrapid_saved_start_month').value).getTime() )
545
- <= 0 ) {
546
- $$('li.value_from_date')[0].insert({after: '<div style="" id="validate_from_date_message" ' +
547
- 'class="validation-advice">From Date is invalid. It must be earlier than Expiration Date.</div>'});
548
- $('ewayrapid_saved_start_month').addClassName('validation-failed');
549
- $('ewayrapid_saved_start_year').addClassName('validation-failed');
550
- $$('li.value_from_date')[0].addClassName('validation-error');
551
- return;
552
- }
553
- }*/
554
-
555
- // Waiting
556
- $(obj).setStyle({'display': 'none'});
557
- $('save-please-wait').setStyle({'display': 'block'});
558
-
559
- // Get access code
560
- new Ajax.Request('<?php echo Mage::getBaseUrl() ?>/ewayrapid/mycards/getAccessCode',
561
- {
562
- method: 'post',
563
- parameters: $('form-validate').serialize(true),
564
- onSuccess: function (transport) {
565
- if (transport.responseText) {
566
- var data = JSON.parse(transport.responseText);
567
- if (typeof data == 'object') {
568
-
569
- // Check login require
570
- if (data.login != undefined) {
571
- alert('Session has expired');
572
- window.location = window.location.href;
573
- }
574
-
575
- if (typeof data.AccessCode != 'undefined' & data.AccessCode != null) {
576
-
577
- var actionUrl = data.FormActionURL;
578
- $('form-validate').setAttribute('action', actionUrl);
579
- // Change card info
580
- $('ewayrapid_saved_cc_owner').setAttribute('name', 'EWAY_CARDNAME');
581
- <?php
582
- // Change card name if not edited
583
- if (!$this->isEdit()) {
584
- echo "$('ewayrapid_saved_cc_number').setAttribute('name', 'EWAY_CARDNUMBER');";
585
- }
586
- ?>
587
- $('ewayrapid_saved_expiration').setAttribute('name', 'EWAY_CARDEXPIRYMONTH');
588
- $('ewayrapid_saved_expiration_yr').setAttribute('name', 'EWAY_CARDEXPIRYYEAR');
589
-
590
- $('eway_accesscode').setValue(data.AccessCode);
591
- $('form-validate').submit();
592
- return;
593
- }
594
- else {
595
- // Alert error code ERR-012
596
- alert('An error occurred while connecting to payment gateway. Please try again later.!');
597
- }
598
- } else {
599
- alert(transport.responseText)
600
- }
601
-
602
- // Remove style waiting
603
- $(obj).setStyle({'display': 'block'});
604
- $('save-please-wait').setStyle({'display': 'none'});
605
- }
606
- },
607
- onFailure: function () {
608
- alert('Something went wrong...')
609
- }
610
- });
611
- return false;
612
- }
613
-
614
- //]]>
615
- </script>
1
+ <?php
2
+ $_token = $this->getCurrentToken();
3
+ $_address = $this->getCustomerAddress();
4
+
5
+ // Form Url
6
+ $connectionType = Mage::getStoreConfig('payment/ewayrapid_general/connection_type');
7
+ $formUrl = $this->getSaveUrl();
8
+ $transparent = false;
9
+ switch ($connectionType) {
10
+ case Eway_Rapid31_Model_Config::CONNECTION_DIRECT:
11
+ echo '<script type="text/javascript" src="' . str_replace('index.php', '', Mage::getBaseUrl()) . 'js/ewayrapid/eCrypt.js"></script>';
12
+ break;
13
+ case Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT:
14
+ $transparent = true;
15
+ break;
16
+ case Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE:
17
+ $formUrl = Mage::getBaseUrl() . '/ewayrapid/mycards/getAccessCode';
18
+ break;
19
+ default:
20
+ break;
21
+ }
22
+ ?>
23
+ <?php if ($this->getTitle()): ?>
24
+ <div class="page-title">
25
+ <h1><?php echo $this->getTitle() ?></h1>
26
+ </div>
27
+ <?php endif; ?>
28
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
29
+ <div class="tool-tip" id="payment-tool-tip" style="display:none;">
30
+ <div class="btn-close"><a href="#" id="payment-tool-tip-close"
31
+ title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
32
+ <div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>"
33
+ alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>"
34
+ title="<?php echo $this->__('Card Verification Number Visual Reference') ?>"/>
35
+ </div>
36
+ </div>
37
+ <form action="<?php echo $formUrl ?>" method="post" id="form-validate">
38
+ <input type="hidden" name="EWAY_ACCESSCODE" id="eway_accesscode"/>
39
+ <?php
40
+ if ($_token->getTokenId()) {
41
+ ?>
42
+ <input type="hidden" name="token_id" value="<?php echo $_token->getTokenId() ?>"/>
43
+ <input type="hidden" name="TokenCustomerID" value="<?php echo $_token->getToken() ?>"/>
44
+ <?php } ?>
45
+
46
+ <!-- Card info -->
47
+ <?php
48
+ if ($connectionType !== Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
49
+ ?>
50
+ <div class="fieldset">
51
+ <?php echo $this->getBlockHtml('formkey') ?>
52
+ <h2 class="legend"><?php echo $this->__('Credit Card Information') ?></h2>
53
+
54
+ <div class="sp-methods">
55
+ <ul class="form-list">
56
+ <li>
57
+ <div class="input-box">
58
+ <label for="ewayrapid_saved_cc_owner"
59
+ class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
60
+ <input type="text" title="<?php echo $this->__('Name on Card') ?>"
61
+ class="input-text required-entry validate-length maximum-length-50"
62
+ id="ewayrapid_saved_cc_owner"
63
+ name="payment[cc_owner]" value="<?php echo $this->escapeHtml($_token->getOwner()) ?>"
64
+ __maxlength="50" autocomplete="off"/>
65
+ </div>
66
+ </li>
67
+ <li>
68
+ <label for="ewayrapid_saved_cc_number"
69
+ class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
70
+
71
+ <div class="input-box help-disabled-cc">
72
+ <input type="text" id="ewayrapid_saved_cc_number" data-eway-encrypt-name="payment[cc_number]"
73
+ title="<?php echo $this->__('Credit Card Number') ?>"
74
+ class="input-text <?php if (!$this->isEdit()): ?>validate-cc-number validate-cc-type-auto<?php endif; ?>"
75
+ autocomplete="off" <?php if ($this->isEdit()): ?>value="<?php echo $_token->getCard() ?>"
76
+ disabled="disabled" <?php endif; ?> pattern="\d*"/>
77
+ <input type="hidden" id="ewayrapid_saved_cc_type" name="payment[cc_type]"
78
+ value="<?php echo $_token->getType() ?>"/>
79
+ <?php if ($this->isEdit()): ?>
80
+ <input type="hidden" name="EWAY_CARDNUMBER" value="444433XXXXXX1111"/>
81
+ <a href="#"><?php echo $this->__('Help') ?></a>
82
+ <div class="tool-tip" id="cc-help-tool-tip" style="display:none;">
83
+ <div class="btn-close">
84
+ <a href="#" id="cc-help-tool-tip-close"
85
+ title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a>
86
+ </div>
87
+ <div class="tool-tip-content">To use a new credit card number, please add another card
88
+ </div>
89
+ </div>
90
+ <?php endif; ?>
91
+ </div>
92
+ </li>
93
+
94
+ <li id="ewayrapid_saved_cc_type_exp_div">
95
+ <label for="ewayrapid_saved_expiration"
96
+ class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
97
+
98
+ <div class="input-box">
99
+ <div class="v-fix">
100
+ <select id="ewayrapid_saved_expiration" name="payment[cc_exp_month]"
101
+ class="month validate-cc-exp required-entry" autocomplete="off">
102
+ <?php $_ccExpMonth = $_token->getExpMonth() ?>
103
+ <?php foreach ($this->getCcMonths() as $k => $v): ?>
104
+ <option
105
+ value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
106
+ <?php endforeach ?>
107
+ </select>
108
+ </div>
109
+ <div class="v-fix">
110
+ <?php $_ccExpYear = $_token->getExpYear() ?>
111
+ <select id="ewayrapid_saved_expiration_yr" name="payment[cc_exp_year]"
112
+ class="year required-entry" autocomplete="off">
113
+ <?php foreach ($this->getCcYears() as $k => $v): ?>
114
+ <option
115
+ value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
116
+ <?php endforeach ?>
117
+ </select>
118
+ </div>
119
+ </div>
120
+ </li>
121
+
122
+ <?php
123
+ if ($transparent) {
124
+ ?>
125
+ <li class="value_from_date">
126
+ <label for="ewayrapid_saved_start_month"
127
+ class="required"><?php echo $this->__('Valid From Date') ?></label>
128
+
129
+ <div class="input-box">
130
+ <div class="v-fix">
131
+ <select id="ewayrapid_saved_start_month" name="payment[cc_start_month]"
132
+ class="month" autocomplete="off">
133
+ <?php $_ccStartMonth = $_token->getStartMonth() ?>
134
+ <?php foreach ($this->getCcMonths() as $k => $v): ?>
135
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccStartMonth): ?>
136
+ selected="selected"<?php endif ?>><?php echo $v ?></option>
137
+ <?php endforeach ?>
138
+ </select>
139
+ </div>
140
+ <div class="v-fix">
141
+ <?php $_ccStartYear = $_token->getStartYear() ?>
142
+ <select id="ewayrapid_saved_start_year" name="payment[cc_start_year]"
143
+ class="year" autocomplete="off">
144
+ <?php
145
+ $start_year = 0;
146
+ $inc = 0;
147
+ foreach ($this->getCcYears() as $k => $v) {
148
+ if ($inc == 1) {
149
+ $start_year = (int)$k;
150
+ break;
151
+ }
152
+ echo "<option value=''>Year</option>";
153
+ $inc++;
154
+ }
155
+
156
+ for ($i = 10; $i > 0; $i--) {
157
+ ?>
158
+ <option value="<?php echo $start_year - $i ?>"
159
+ <?php if (($start_year - $i) == $_ccStartYear) { ?>
160
+ selected="selected"<?php } ?>>
161
+ <?php echo $start_year - $i ?>
162
+ </option>
163
+ <?php
164
+ }
165
+
166
+ $inc = 0;
167
+ foreach ($this->getCcYears() as $k => $v):
168
+ $inc++;
169
+ if ($inc == 1) {
170
+ continue;
171
+ }
172
+ ?>
173
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccStartYear): ?>
174
+ selected="selected"<?php endif ?>><?php echo $v ?></option>
175
+ <?php
176
+ endforeach;
177
+ ?>
178
+ </select>
179
+ </div>
180
+ </div>
181
+ </li>
182
+ <li>
183
+ <div class="input-box">
184
+ <label for="ewayrapid_saved_issue_number">
185
+ <?php echo $this->__('Issue Number') ?>
186
+ </label>
187
+ <input type="text" title="<?php echo $this->__('Issue Number') ?>"
188
+ class="input-text validate-length maximum-length-4"
189
+ id="ewayrapid_saved_issue_number"
190
+ name="payment[cc_issue_number]"
191
+ value="<?php echo $this->escapeHtml($_token->getIssueNumber()) ?>"
192
+ __maxlength="50" autocomplete="off"/>
193
+ </div>
194
+ </li>
195
+ <?php
196
+ }
197
+ ?>
198
+
199
+ <?php if ($this->hasVerification()): ?>
200
+ <li id="ewayrapid_saved_cc_type_cvv_div">
201
+ <label for="ewayrapid_saved_cc_cid"
202
+ class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
203
+
204
+ <div class="input-box">
205
+ <div class="v-fix">
206
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>"
207
+ class="input-text cvv required-entry validate-cc-cvn" id="ewayrapid_saved_cc_cid"
208
+ data-eway-encrypt-name="payment[cc_cid]" value="" autocomplete="off"
209
+ pattern="\d*"/>
210
+ </div>
211
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
212
+ </div>
213
+ </li>
214
+ <?php endif; ?>
215
+ <?php
216
+ $_defaultToken = Mage::helper('ewayrapid/customer')->getDefaultToken();
217
+ if (!$_token->getToken() || ($_defaultToken && $_defaultToken != $_token->getTokenId())): ?>
218
+ <li>
219
+ <div class="v-fix" style="padding-right: 5px;">
220
+ <input type="checkbox" id="ewayrapid_saved_default" name="is_default"/>
221
+ </div>
222
+ <label for="ewayrapid_saved_default"><?php echo $this->__('Default Credit Card') ?></label>
223
+ </li>
224
+ <?php endif; ?>
225
+ </ul>
226
+ </div>
227
+ </div>
228
+ <?php
229
+ } else {
230
+ // Responsive shared page card data
231
+ // ....
232
+ $_defaultToken = Mage::helper('ewayrapid/customer')->getDefaultToken();
233
+ if (!$_token->getToken() || ($_defaultToken && $_defaultToken != $_token->getTokenId())): ?>
234
+ <ul>
235
+ <li>
236
+ <div class="v-fix" style="padding-right: 5px;">
237
+ <input type="checkbox" id="ewayrapid_saved_default" name="is_default"/>
238
+ </div>
239
+ <label for="ewayrapid_saved_default"><?php echo $this->__('Default Credit Card') ?></label>
240
+ </li>
241
+ </ul>
242
+ <?php endif;
243
+ } ?>
244
+ <div class="fieldset bill-address">
245
+ <h2 class="legend"><?php echo $this->__('Billing Address') ?></h2>
246
+ <ul class="form-list">
247
+ <li class="fields">
248
+ <div class="customer-name-prefix">
249
+ <div class="field name-prefix">
250
+ <label for="address_prefix"><?php echo $this->__('Title') ?></label>
251
+
252
+ <div class="input-box">
253
+ <select id="address_prefix" name="address[prefix]" title="<?php echo $this->__('Title') ?>">
254
+ <?php foreach ($this->getPrefixOptions() as $_option): ?>
255
+ <option
256
+ value="<?php echo $_option ?>"<?php if ($_address->getTitle() == $_option): ?>
257
+ selected="selected"<?php endif; ?>><?php echo $this->__($_option) ?></option>
258
+ <?php endforeach; ?>
259
+ </select>
260
+ </div>
261
+ </div>
262
+ <div class="field name-firstname">
263
+ <label for="address_firstname" class="required"><em>*</em><?php echo $this->__('First Name') ?>
264
+ </label>
265
+
266
+ <div class="input-box">
267
+ <input type="text" id="address_firstname" name="address[firstname]"
268
+ value="<?php echo $this->escapeHtml($_address->getFirstName()) ?>"
269
+ title="<?php echo $this->__('First Name') ?>"
270
+ __maxlength="50" class="input-text required-entry validate-length maximum-length-50"/>
271
+ </div>
272
+ </div>
273
+ <div class="field name-lastname">
274
+ <label for="address_lastname" class="required"><em>*</em><?php echo $this->__('Last Name') ?>
275
+ </label>
276
+
277
+ <div class="input-box">
278
+ <input type="text" id="address_lastname" name="address[lastname]"
279
+ value="<?php echo $this->escapeHtml($_address->getLastName()) ?>"
280
+ title="<?php echo $this->__('Last Name') ?>" __maxlength="50"
281
+ class="input-text required-entry validate-length maximum-length-50"/>
282
+ </div>
283
+ </div>
284
+ </div>
285
+ </li>
286
+ <li class="fields">
287
+ <div class="field">
288
+ <label for="address_company"><?php echo $this->__('Company') ?></label>
289
+
290
+ <div class="input-box">
291
+ <input type="text" name="address[company]" id="address_company"
292
+ title="<?php echo $this->__('Company') ?>" __maxlength="50"
293
+ value="<?php echo $this->escapeHtml($_address->getCompanyName()) ?>"
294
+ class="input-text validate-length maximum-length-50"/>
295
+ </div>
296
+ </div>
297
+ <div class="field">
298
+ <label for="address_job_description"><?php echo $this->__('Job Description') ?></label>
299
+
300
+ <div class="input-box">
301
+ <input type="text" name="address[job_description]" id="address_job_description"
302
+ title="<?php echo $this->__('Job Description') ?>" __maxlength="50"
303
+ value="<?php echo $this->escapeHtml($_address->getJobDescription()) ?>"
304
+ class="input-text validate-length maximum-length-50"/>
305
+ </div>
306
+ </div>
307
+
308
+ </li>
309
+ <li class="fields">
310
+ <div class="field">
311
+ <label for="address_telephone" class="required"><em>*</em><?php echo $this->__('Phone') ?></label>
312
+
313
+ <div class="input-box">
314
+ <input type="text" name="address[telephone]"
315
+ value="<?php echo $this->escapeHtml($_address->getPhone()) ?>"
316
+ title="<?php echo $this->__('Phone') ?>"
317
+ class="input-text required-entry eway-validate-phone validate-length maximum-length-32"
318
+ id="address_telephone" __maxlength="32"/>
319
+ </div>
320
+ </div>
321
+ <div class="field">
322
+ <label for="address_mobile"><?php echo $this->__('Mobile') ?></label>
323
+
324
+ <div class="input-box">
325
+ <input type="text" name="address[mobile]"
326
+ value="<?php echo $this->escapeHtml($_address->getMobile()) ?>"
327
+ title="<?php echo $this->__('Mobile') ?>"
328
+ class="input-text eway-validate-phone validate-length maximum-length-32"
329
+ id="address_mobile" __maxlength="32"/>
330
+ </div>
331
+ </div>
332
+ </li>
333
+ <li class="fields">
334
+ <div class="field">
335
+ <label for="address_email"><?php echo $this->__('Email') ?></label>
336
+
337
+ <div class="input-box">
338
+ <input type="text" name="address[email]" id="address_email" __maxlength="50"
339
+ title="<?php echo $this->__('Email') ?>"
340
+ value="<?php echo $this->escapeHtml($_address->getEmail()) ?>"
341
+ class="input-text validate-email validate-length maximum-length-50"/>
342
+ </div>
343
+ </div>
344
+ <div class="field">
345
+ <label for="address_fax"><?php echo $this->__('Fax') ?></label>
346
+
347
+ <div class="input-box">
348
+ <input type="text" name="address[fax]" id="address_fax" title="<?php echo $this->__('Fax') ?>"
349
+ value="<?php echo $this->escapeHtml($_address->getFax()) ?>"
350
+ class="input-text eway-validate-phone validate-length maximum-length-32" __maxlength="32"/>
351
+ </div>
352
+ </div>
353
+ </li>
354
+ <li class="wide">
355
+ <label for="address_street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
356
+
357
+ <div class="input-box">
358
+ <input type="text" name="address[street][]" __maxlength="50"
359
+ value="<?php echo $this->escapeHtml($_address->getStreet1()) ?>"
360
+ title="<?php echo $this->__('Street Address') ?>" id="address_street_1"
361
+ class="input-text required-entry validate-length maximum-length-50"/>
362
+ </div>
363
+ </li>
364
+ <li class="wide">
365
+ <div class="input-box">
366
+ <input type="text" name="address[street][]" __maxlength="50"
367
+ value="<?php echo $this->escapeHtml($_address->getStreet2()) ?>"
368
+ title="<?php echo $this->__('Street Address') ?>" id="address_street_2"
369
+ class="input-text validate-length maximum-length-50"/>
370
+ </div>
371
+ </li>
372
+ <li class="fields">
373
+ <div class="field">
374
+ <label for="address_city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
375
+
376
+ <div class="input-box">
377
+ <input type="text" name="address[city]" __maxlength="50"
378
+ value="<?php echo $_address->getCity() ?>" title="<?php echo $this->__('City') ?>"
379
+ class="input-text required-entry validate-length maximum-length-50" id="address_city"/>
380
+ </div>
381
+ </div>
382
+ <div class="field">
383
+ <label for="address_region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?>
384
+ </label>
385
+
386
+ <div class="input-box">
387
+ <select id="address_region_id" name="address[region_id]"
388
+ title="<?php echo $this->__('State/Province') ?>" class="validate-select"
389
+ style="display:none;">
390
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
391
+ </select>
392
+ <script type="text/javascript">
393
+ //<![CDATA[
394
+ $('address_region_id').setAttribute('defaultValue', "<?php echo $_address->getRegionId() ?>");
395
+ //]]>
396
+ </script>
397
+ <input type="text" id="address_region" name="address[region]" __maxlength="50"
398
+ value="<?php echo $this->escapeHtml($_address->getState()) ?>"
399
+ title="<?php echo $this->__('State/Province') ?>"
400
+ class="input-text validate-length maximum-length-50"/>
401
+ </div>
402
+ </div>
403
+ </li>
404
+ <li class="fields">
405
+ <div class="field">
406
+ <label for="address_zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
407
+
408
+ <div class="input-box">
409
+ <input type="text" name="address[postcode]"
410
+ value="<?php echo $this->escapeHtml($_address->getPostalCode()) ?>"
411
+ title="<?php echo $this->__('Zip/Postal Code') ?>" id="address_zip"
412
+ class="input-text validate-zip-international required-entry validate-length maximum-length-30"
413
+ __maxlength="30"/>
414
+ </div>
415
+ </div>
416
+ <div class="field">
417
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
418
+
419
+ <div class="input-box">
420
+ <?php echo $this->getCountryHtmlSelect(strtoupper($_address->getCountry()), 'address[country_id]', 'address_country') ?>
421
+ </div>
422
+ </div>
423
+ </li>
424
+ </ul>
425
+ </div>
426
+ <div class="buttons-set">
427
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
428
+
429
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>">
430
+ <small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
431
+ <?php
432
+ echo $transparent ? '<button type="button" onclick="beforeSubmit(this)" title="'
433
+ . $this->__('Save Credit Card') . '" class="button"><span><span>'
434
+ . $this->__('Save Credit Card') . '</span></span></button>'
435
+ . '<span id="save-please-wait" class="please-wait" style="display:none;">
436
+ <img class="v-middle" title="Loading..." alt="Loading..." src="'
437
+ . Mage::getBaseUrl() . '/skin/frontend/default/default/images/opc-ajax-loader.gif">
438
+ Please waiting ...
439
+ </span>'
440
+ : '<button type="submit" title="' . $this->__('Save Credit Card') . '" class="button"><span><span>' . $this->__('Save Credit Card') . '</span></span></button>';
441
+ ?>
442
+
443
+ </div>
444
+ </form>
445
+
446
+ <script type="text/javascript">
447
+ //<![CDATA[
448
+ var dataForm = new VarienForm('form-validate', true);
449
+ new RegionUpdater('address_country', 'address_region', 'address_region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'address_zip');
450
+ EwayPayment.supportCardTypes = <?php echo json_encode(Mage::getSingleton('ewayrapid/config')->getSupportedCardTypes()) ?>;
451
+
452
+ $$('.cvv-what-is-this').each(function (element) {
453
+ Event.observe(element, 'click', toggleToolTip);
454
+ });
455
+
456
+ function toggleToolTip(event) {
457
+ if ($('payment-tool-tip')) {
458
+ $('payment-tool-tip').setStyle({
459
+ top: (Event.pointerY(event) - 200) + 'px'//,
460
+ })
461
+ $('payment-tool-tip').toggle();
462
+ }
463
+ Event.stop(event);
464
+ }
465
+ if ($('payment-tool-tip-close')) {
466
+ Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
467
+ }
468
+
469
+ $('form-validate').onsubmit = function () {
470
+ return (dataForm.validator && dataForm.validator.validate());
471
+ }
472
+ var ewayPayment = new EwayPayment($('form-validate'), '<?php echo Mage::getSingleton('ewayrapid/config')->getEncryptionKey() ?>');
473
+
474
+ $$('.help-disabled-cc a').each(function (element) {
475
+ Event.observe(element, 'click', toggleToolTipCc);
476
+ });
477
+
478
+ function toggleToolTipCc(event) {
479
+ if ($('cc-help-tool-tip')) {
480
+ $('cc-help-tool-tip').toggle();
481
+ }
482
+ Event.stop(event);
483
+ }
484
+ if ($('cc-help-tool-tip-close')) {
485
+ Event.observe($('cc-help-tool-tip-close'), 'click', toggleToolTipCc);
486
+ }
487
+
488
+ // TRANSPARENT REDIRECT
489
+ function beforeSubmit(obj) {
490
+ $('validate_from_date_message') != null ? $('validate_from_date_message').remove() : '';
491
+ $('ewayrapid_saved_start_month').removeClassName('validation-failed');
492
+ $('ewayrapid_saved_start_year').removeClassName('validation-failed');
493
+ $$('li.value_from_date')[0].removeClassName('validation-error');
494
+
495
+ if (typeof isTest !== 'undefined') {
496
+ // Alert error code ERR-012
497
+ alert('An error occurred while connecting to payment gateway. Please try again later.!');
498
+ return false;
499
+ }
500
+
501
+ //*********************************Valid From Date If Select********************************************************************
502
+ if($('ewayrapid_saved_start_year').value > 0 && $('ewayrapid_saved_start_month').value <= 0) {
503
+ $('validation-advice-year') && $('validation-advice-year').remove();
504
+ $('ewayrapid_saved_start_month').addClassName('validation-failed');
505
+ $('ewayrapid_saved_start_month').up('div').insert('<div class="validation-advice" id="validation-advice-month">Incorrect credit card from date.</div>');
506
+ return;
507
+ } else if($('ewayrapid_saved_start_year').value <= 0 && $('ewayrapid_saved_start_month').value > 0) {
508
+ $('validation-advice-month') && $('validation-advice-month').remove();
509
+ $('ewayrapid_saved_start_year').addClassName('validation-failed');
510
+ $('ewayrapid_saved_start_year').up('div').insert('<div class="validation-advice" id="validation-advice-year">Incorrect credit card from year.</div>');
511
+ return;
512
+ } else {
513
+ $('validation-advice-year') && $('validation-advice-year').remove();
514
+ $('validation-advice-month') && $('validation-advice-month').remove();
515
+ }
516
+
517
+ var from_date = new Date($('ewayrapid_saved_start_year').value + '-' + $('ewayrapid_saved_start_month').value).getTime();
518
+ var expiration_date = new Date($('ewayrapid_saved_expiration_yr').value + '-' + $('ewayrapid_saved_expiration').value).getTime();
519
+ if(Prototype.Browser.IE) {
520
+ from_date = new Date($('ewayrapid_saved_start_year').value, $('ewayrapid_saved_start_month').value, 1).getTime();
521
+ expiration_date = new Date($('ewayrapid_saved_expiration_yr').value, $('ewayrapid_saved_expiration').value, 1).getTime();
522
+ }
523
+ //console.log(from_date - expiration_date);
524
+
525
+ if(from_date - expiration_date > 0) {
526
+ $$('li.value_from_date')[0].insert({after: '<div style="" id="validate_from_date_message" ' +
527
+ 'class="validation-advice">From Date is invalid. It must be earlier than Expiration Date.</div>'});
528
+ $('ewayrapid_saved_start_month').addClassName('validation-failed');
529
+ $('ewayrapid_saved_start_year').addClassName('validation-failed');
530
+ $$('li.value_from_date')[0].addClassName('validation-error');
531
+ return;
532
+ }
533
+ //******************************************************************************************************************************
534
+
535
+ var validate = dataForm.validator.validate();
536
+ if (!validate) {
537
+ return;
538
+ }
539
+
540
+ /*if ($('ewayrapid_saved_start_year').value != '' || $('ewayrapid_saved_start_month').value != '') {
541
+ if ((new Date($('ewayrapid_saved_expiration_yr').value + '-'
542
+ + ($('ewayrapid_saved_expiration').value <= 9 ? '0' : '') + $('ewayrapid_saved_expiration').value).getTime() )
543
+ - ( new Date($('ewayrapid_saved_start_year').value + '-'
544
+ + ($('ewayrapid_saved_start_month').value <= 9 ? '0' : '') + $('ewayrapid_saved_start_month').value).getTime() )
545
+ <= 0 ) {
546
+ $$('li.value_from_date')[0].insert({after: '<div style="" id="validate_from_date_message" ' +
547
+ 'class="validation-advice">From Date is invalid. It must be earlier than Expiration Date.</div>'});
548
+ $('ewayrapid_saved_start_month').addClassName('validation-failed');
549
+ $('ewayrapid_saved_start_year').addClassName('validation-failed');
550
+ $$('li.value_from_date')[0].addClassName('validation-error');
551
+ return;
552
+ }
553
+ }*/
554
+
555
+ // Waiting
556
+ $(obj).setStyle({'display': 'none'});
557
+ $('save-please-wait').setStyle({'display': 'block'});
558
+
559
+ // Get access code
560
+ new Ajax.Request('<?php echo Mage::getBaseUrl() ?>/ewayrapid/mycards/getAccessCode',
561
+ {
562
+ method: 'post',
563
+ parameters: $('form-validate').serialize(true),
564
+ onSuccess: function (transport) {
565
+ if (transport.responseText) {
566
+ var data = JSON.parse(transport.responseText);
567
+ if (typeof data == 'object') {
568
+
569
+ // Check login require
570
+ if (data.login != undefined) {
571
+ alert('Session has expired');
572
+ window.location = window.location.href;
573
+ }
574
+
575
+ if (typeof data.AccessCode != 'undefined' & data.AccessCode != null) {
576
+
577
+ var actionUrl = data.FormActionURL;
578
+ $('form-validate').setAttribute('action', actionUrl);
579
+ // Change card info
580
+ $('ewayrapid_saved_cc_owner').setAttribute('name', 'EWAY_CARDNAME');
581
+ <?php
582
+ // Change card name if not edited
583
+ if (!$this->isEdit()) {
584
+ echo "$('ewayrapid_saved_cc_number').setAttribute('name', 'EWAY_CARDNUMBER');";
585
+ }
586
+ ?>
587
+ $('ewayrapid_saved_expiration').setAttribute('name', 'EWAY_CARDEXPIRYMONTH');
588
+ $('ewayrapid_saved_expiration_yr').setAttribute('name', 'EWAY_CARDEXPIRYYEAR');
589
+
590
+ $('eway_accesscode').setValue(data.AccessCode);
591
+ $('form-validate').submit();
592
+ return;
593
+ }
594
+ else {
595
+ // Alert error code ERR-012
596
+ alert('An error occurred while connecting to payment gateway. Please try again later.!');
597
+ }
598
+ } else {
599
+ alert(transport.responseText)
600
+ }
601
+
602
+ // Remove style waiting
603
+ $(obj).setStyle({'display': 'block'});
604
+ $('save-please-wait').setStyle({'display': 'none'});
605
+ }
606
+ },
607
+ onFailure: function () {
608
+ alert('Something went wrong...')
609
+ }
610
+ });
611
+ return false;
612
+ }
613
+
614
+ //]]>
615
+ </script>
app/design/frontend/base/default/template/ewayrapid/form/direct_notsaved.phtml CHANGED
@@ -1,87 +1,97 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php
28
- $_code=$this->getMethodCode();
29
- ?>
30
-
31
- <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
32
- <li>
33
- <label for="<?php echo $_code ?>_cc_owner" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
34
- <div class="input-box">
35
- <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>" />
36
- </div>
37
- </li>
38
- <li>
39
- <label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
40
- <div class="input-box">
41
- <input type="text" id="<?php echo $_code ?>_cc_number" data-eway-encrypt-name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type-auto" value="" pattern="\d*"/>
42
- <input type="hidden" id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" />
43
- </div>
44
- </li>
45
- <li id="<?php echo $_code ?>_cc_type_exp_div">
46
- <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
47
- <div class="input-box">
48
- <div class="v-fix">
49
- <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
50
- <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
51
- <?php foreach ($this->getCcMonths() as $k=>$v): ?>
52
- <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
53
- <?php endforeach ?>
54
- </select>
55
- </div>
56
- <div class="v-fix">
57
- <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
58
- <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
59
- <?php foreach ($this->getCcYears() as $k=>$v): ?>
60
- <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
61
- <?php endforeach ?>
62
- </select>
63
- </div>
64
- </div>
65
- </li>
66
- <?php echo $this->getChildHtml() ?>
67
- <?php if($this->hasVerification()): ?>
68
- <li id="<?php echo $_code ?>_cc_type_cvv_div">
69
- <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
70
- <div class="input-box">
71
- <div class="v-fix">
72
- <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" data-eway-encrypt-name="payment[cc_cid]" value="" pattern="\d*"/>
73
- </div>
74
- <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
75
- </div>
76
- </li>
77
- <?php endif; ?>
78
- </ul>
79
-
80
- <!--[if lt IE 10]>
81
- <script>
82
- $('p_method_ewayrapid_notsaved').observe('click', function () {
83
- $('p_method_ewayrapid_notsaved').setAttribute('checked', 'true');
84
- $('p_method_ewayrapid_saved').removeAttribute('checked');
85
- });
86
- </script>
87
- <![endif]-->
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $_code=$this->getMethodCode();
29
+ ?>
30
+
31
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
32
+ <li>
33
+ <label for="<?php echo $_code ?>_cc_owner" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
34
+ <div class="input-box">
35
+ <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>" />
36
+ </div>
37
+ </li>
38
+ <li>
39
+ <label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
40
+ <div class="input-box">
41
+ <input type="text" id="<?php echo $_code ?>_cc_number" data-eway-encrypt-name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type-auto" value="" pattern="\d*"/>
42
+ <input type="hidden" id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" />
43
+ </div>
44
+ </li>
45
+ <li id="<?php echo $_code ?>_cc_type_exp_div">
46
+ <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
47
+ <div class="input-box">
48
+ <div class="v-fix">
49
+ <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
50
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
51
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
52
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
53
+ <?php endforeach ?>
54
+ </select>
55
+ </div>
56
+ <div class="v-fix">
57
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
58
+ <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
59
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
60
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
61
+ <?php endforeach ?>
62
+ </select>
63
+ </div>
64
+ </div>
65
+ </li>
66
+ <?php echo $this->getChildHtml() ?>
67
+ <?php if($this->hasVerification()): ?>
68
+ <li id="<?php echo $_code ?>_cc_type_cvv_div">
69
+ <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
70
+ <div class="input-box">
71
+ <div class="v-fix">
72
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" data-eway-encrypt-name="payment[cc_cid]" value="" pattern="\d*"/>
73
+ </div>
74
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
75
+ </div>
76
+ </li>
77
+ <?php endif; ?>
78
+ </ul>
79
+
80
+ <script>
81
+ $('p_method_ewayrapid_notsaved').observe('click', function () {
82
+ $('p_method_ewayrapid_notsaved').setAttribute('checked', 'true');
83
+ $('p_method_ewayrapid_saved') && $('p_method_ewayrapid_saved').removeAttribute('checked');
84
+
85
+ $$('#payment_form_ewayrapid_notsaved input[name*=payment]').each(function(inp) {
86
+ inp.removeAttribute('disabled');
87
+ });
88
+
89
+ $$('#payment_form_ewayrapid_notsaved select[name*=payment]').each(function(inp) {
90
+ inp.removeAttribute('disabled');
91
+ });
92
+
93
+ $$('#payment_form_ewayrapid_notsaved input[data-eway-encrypt-name*=payment]').each(function(inp) {
94
+ inp.removeAttribute('disabled');
95
+ });
96
+ });
97
+ </script>
app/design/frontend/base/default/template/ewayrapid/form/direct_saved.phtml CHANGED
@@ -1,152 +1,162 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php
28
- $_code = $this->getMethodCode()
29
- ?>
30
-
31
- <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display: none">
32
- <li>
33
- <div class="input-box">
34
- <div class="v-fix">
35
- <select id="ewayrapid_saved_token" name="payment[saved_token]" class="ewayrapid_saved_token">
36
- <?php
37
- $_tokens = $this->getTokenList();
38
- $_defaultToken = isset($_tokens['default_token']) ? $_tokens['default_token'] : false;
39
- ?>
40
- <?php foreach($_tokens['tokens'] as $_key => $_token):
41
- if ($_key == Eway_Rapid31_Model_Config::TOKEN_NEW || $this->checkCardName($_token) == Eway_Rapid31_Model_Config::CREDITCARD_METHOD): ?>
42
- <?php /* @var Eway_Rapid31_Model_Customer_Token $_token */ ?>
43
- <option value="<?php echo $_key ?>" <?php if($_key == $_defaultToken): ?>selected="selected"<?php endif; ?>>
44
- <?php echo $_token->getCard() ?>
45
- </option>
46
- <?php endif; ?>
47
- <?php endforeach; ?>
48
- </select>
49
- </div>
50
- <?php if(Mage::getSingleton('ewayrapid/config')->canEditToken() && count($_tokens['tokens']) > 1): ?>
51
- <div class="v-fix">
52
- <a id="ewayrapid_saved_edit" class="ewayrapid_saved_edit" href="javascript:void(0);"><?php echo $this->__('Edit') ?></a>
53
- </div>
54
- <?php endif; ?>
55
- </div>
56
- </li>
57
-
58
- <li class="saved_token_fields" style="display: none">
59
- <label for="<?php echo $_code ?>_cc_owner" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
60
- <div class="input-box">
61
- <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>" />
62
- </div>
63
- </li>
64
- <li class="saved_token_fields" style="display: none">
65
- <label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
66
- <div class="input-box help-disabled-cc">
67
- <input type="text" id="<?php echo $_code ?>_cc_number" data-eway-encrypt-name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type-auto" value="" pattern="\d*"/>
68
- <input type="hidden" id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" />
69
- <a class="card-number-help" href="#"><?php echo $this->__('Help') ?></a>
70
- <div class="tool-tip" id="cc-help-tool-tip" style="display:none;">
71
- <div class="btn-close"><a href="#" id="cc-help-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
72
- <div class="tool-tip-content">To use a new credit card number, please add another card</div>
73
- </div>
74
- </div>
75
- </li>
76
- <li id="<?php echo $_code ?>_cc_type_exp_div" class="saved_token_fields" style="display: none">
77
- <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
78
- <div class="input-box">
79
- <div class="v-fix">
80
- <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
81
- <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
82
- <?php foreach ($this->getCcMonths() as $k=>$v): ?>
83
- <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
84
- <?php endforeach ?>
85
- </select>
86
- </div>
87
- <div class="v-fix">
88
- <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
89
- <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
90
- <?php foreach ($this->getCcYears() as $k=>$v): ?>
91
- <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
92
- <?php endforeach ?>
93
- </select>
94
- </div>
95
- </div>
96
- </li>
97
- <?php echo $this->getChildHtml() ?>
98
- <?php if($this->hasVerification()): ?>
99
- <li id="<?php echo $_code ?>_cc_type_cvv_div">
100
- <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
101
- <div class="input-box">
102
- <div class="v-fix">
103
- <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" data-eway-encrypt-name="payment[cc_cid]" value="" pattern="\d*"/>
104
- </div>
105
- <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
106
- </div>
107
- </li>
108
- <?php if ($this->getIsRecurring()) { ?>
109
- <li>
110
- <p>I authorize <?php echo Mage::app()->getStore()->getName(); ?> to charge the available balance
111
- in my credit card for the future payments of this order. To make a change, I can go to
112
- <a href="<?php echo Mage::getUrl('checkout/cart'); ?>">Cart</a>
113
- </p>
114
- <input type="checkbox" name="recurring-agree" class="recurring-agree required-entry"/><label class="lable-for-recurring" for="">Agree</label>
115
- </li>
116
- <?php } ?>
117
- <?php endif; ?>
118
- </ul>
119
-
120
- <script type="text/javascript">
121
- var ewayPaymentToken = new EwayPaymentToken(
122
- <?php echo $_tokens['tokens_json'] ?>,
123
- <?php echo count($_tokens['tokens']) ?>,
124
- false,
125
- '<?php echo $this->__('Edit') ?>',
126
- '<?php echo $this->__('Cancel edit') ?>'
127
- )
128
-
129
- $$('.help-disabled-cc a').each(function(element){
130
- Event.observe(element, 'click', toggleToolTipCc);
131
- });
132
-
133
- function toggleToolTipCc(event){
134
- if($('cc-help-tool-tip')){
135
- $('cc-help-tool-tip').toggle();
136
- }
137
- Event.stop(event);
138
- }
139
- if($('cc-help-tool-tip-close')){
140
- Event.observe($('cc-help-tool-tip-close'), 'click', toggleToolTipCc);
141
- }
142
-
143
- </script>
144
-
145
- <!--[if lt IE 10]>
146
- <script type="text/javascript">
147
- $('p_method_ewayrapid_saved').observe('click', function () {
148
- $('p_method_ewayrapid_saved').setAttribute('checked', 'true');
149
- $('p_method_ewayrapid_notsaved').removeAttribute('checked');
150
- });
151
- </script>
152
- <![endif]-->
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $_code = $this->getMethodCode()
29
+ ?>
30
+
31
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display: none">
32
+ <li>
33
+ <div class="input-box">
34
+ <div class="v-fix">
35
+ <select id="ewayrapid_saved_token" name="payment[saved_token]" class="ewayrapid_saved_token">
36
+ <?php
37
+ $_tokens = $this->getTokenList();
38
+ $_defaultToken = isset($_tokens['default_token']) ? $_tokens['default_token'] : false;
39
+ ?>
40
+ <?php foreach($_tokens['tokens'] as $_key => $_token):
41
+ if ($_key == Eway_Rapid31_Model_Config::TOKEN_NEW || $this->checkCardName($_token) == Eway_Rapid31_Model_Config::CREDITCARD_METHOD): ?>
42
+ <?php /* @var Eway_Rapid31_Model_Customer_Token $_token */ ?>
43
+ <option value="<?php echo $_key ?>" <?php if($_key == $_defaultToken): ?>selected="selected"<?php endif; ?>>
44
+ <?php echo $_token->getCard() ?>
45
+ </option>
46
+ <?php endif; ?>
47
+ <?php endforeach; ?>
48
+ </select>
49
+ </div>
50
+ <?php if(Mage::getSingleton('ewayrapid/config')->canEditToken() && count($_tokens['tokens']) > 1): ?>
51
+ <div class="v-fix">
52
+ <a id="ewayrapid_saved_edit" class="ewayrapid_saved_edit" href="javascript:void(0);"><?php echo $this->__('Edit') ?></a>
53
+ </div>
54
+ <?php endif; ?>
55
+ </div>
56
+ </li>
57
+
58
+ <li class="saved_token_fields" style="display: none">
59
+ <label for="<?php echo $_code ?>_cc_owner" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
60
+ <div class="input-box">
61
+ <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>" />
62
+ </div>
63
+ </li>
64
+ <li class="saved_token_fields" style="display: none">
65
+ <label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
66
+ <div class="input-box help-disabled-cc">
67
+ <input type="text" id="<?php echo $_code ?>_cc_number" data-eway-encrypt-name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type-auto" value="" pattern="\d*"/>
68
+ <input type="hidden" id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" />
69
+ <a class="card-number-help" href="#"><?php echo $this->__('Help') ?></a>
70
+ <div class="tool-tip" id="cc-help-tool-tip" style="display:none;">
71
+ <div class="btn-close"><a href="#" id="cc-help-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
72
+ <div class="tool-tip-content">To use a new credit card number, please add another card</div>
73
+ </div>
74
+ </div>
75
+ </li>
76
+ <li id="<?php echo $_code ?>_cc_type_exp_div" class="saved_token_fields" style="display: none">
77
+ <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
78
+ <div class="input-box">
79
+ <div class="v-fix">
80
+ <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
81
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
82
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
83
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
84
+ <?php endforeach ?>
85
+ </select>
86
+ </div>
87
+ <div class="v-fix">
88
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
89
+ <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
90
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
91
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
92
+ <?php endforeach ?>
93
+ </select>
94
+ </div>
95
+ </div>
96
+ </li>
97
+ <?php echo $this->getChildHtml() ?>
98
+ <?php if($this->hasVerification()): ?>
99
+ <li id="<?php echo $_code ?>_cc_type_cvv_div">
100
+ <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
101
+ <div class="input-box">
102
+ <div class="v-fix">
103
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" data-eway-encrypt-name="payment[cc_cid]" value="" pattern="\d*"/>
104
+ </div>
105
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
106
+ </div>
107
+ </li>
108
+ <?php if ($this->getIsRecurring()) { ?>
109
+ <li>
110
+ <p>I authorize <?php echo Mage::app()->getStore()->getName(); ?> to charge the available balance
111
+ in my credit card for the future payments of this order. To make a change, I can go to
112
+ <a href="<?php echo Mage::getUrl('checkout/cart'); ?>">Cart</a>
113
+ </p>
114
+ <input type="checkbox" name="recurring-agree" class="recurring-agree required-entry"/><label class="lable-for-recurring" for="">Agree</label>
115
+ </li>
116
+ <?php } ?>
117
+ <?php endif; ?>
118
+ </ul>
119
+
120
+ <script type="text/javascript">
121
+ var ewayPaymentToken = new EwayPaymentToken(
122
+ <?php echo $_tokens['tokens_json'] ?>,
123
+ <?php echo count($_tokens['tokens']) ?>,
124
+ false,
125
+ '<?php echo $this->__('Edit') ?>',
126
+ '<?php echo $this->__('Cancel edit') ?>'
127
+ )
128
+
129
+ $$('.help-disabled-cc a').each(function(element){
130
+ Event.observe(element, 'click', toggleToolTipCc);
131
+ });
132
+
133
+ function toggleToolTipCc(event){
134
+ if($('cc-help-tool-tip')){
135
+ $('cc-help-tool-tip').toggle();
136
+ }
137
+ Event.stop(event);
138
+ }
139
+ if($('cc-help-tool-tip-close')){
140
+ Event.observe($('cc-help-tool-tip-close'), 'click', toggleToolTipCc);
141
+ }
142
+
143
+ </script>
144
+
145
+ <script type="text/javascript">
146
+ $('p_method_ewayrapid_saved').observe('click', function () {
147
+ $('p_method_ewayrapid_saved').setAttribute('checked', 'true');
148
+ $('p_method_ewayrapid_notsaved').removeAttribute('checked');
149
+
150
+ $$('#payment_form_ewayrapid_saved input[name*=payment]').each(function(inp) {
151
+ inp.removeAttribute('disabled');
152
+ });
153
+
154
+ $$('#payment_form_ewayrapid_saved select[name*=payment]').each(function(inp) {
155
+ inp.removeAttribute('disabled');
156
+ });
157
+
158
+ $$('#payment_form_ewayrapid_saved input[data-eway-encrypt-name*=payment]').each(function(inp) {
159
+ inp.removeAttribute('disabled');
160
+ });
161
+ });
162
+ </script>
app/design/frontend/base/default/template/ewayrapid/form/sharedpage_saved.phtml CHANGED
@@ -27,7 +27,7 @@
27
  <?php
28
  $_code = $this->getMethodCode()
29
  ?>
30
- <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display: none">
31
  <li>
32
  <div class="input-box">
33
  <div class="v-fix">
27
  <?php
28
  $_code = $this->getMethodCode()
29
  ?>
30
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display: none;width: 80%;padding-top: 8px;">
31
  <li>
32
  <div class="input-box">
33
  <div class="v-fix">
app/design/frontend/base/default/template/ewayrapid/form/transparent_notsaved.phtml CHANGED
@@ -1,117 +1,133 @@
1
  <?php
2
  $_code = $this->getMethodCode();
3
  ?>
4
- <dl class="sp-methods" id="payment_form_<?php echo $_code ?>"
5
  style="display:none; padding-left: 16px; padding-bottom: 8px; border: 1px solid rgb(193, 193, 193);">
6
 
7
- <dt>
8
  <input id="p_method_ewayrapid_transparent_mastercard"
9
  value="<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>" type="radio"
10
  name="payment[transparent_notsaved]" title="Check / Money order" class="radio" autocomplete="off"
11
  checked="checked">
12
  <label for="p_method_ewayrapid_transparent_paypalexpress">Credit Card </label>
13
 
14
- <ul class="form-list" id="ul_payment_form_<?php echo $_code ?>" style="display: block;">
15
- <li>
16
- <label for="<?php echo $_code ?>_cc_owner"
17
- class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
18
- <div class="input-box">
19
- <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry"
20
- id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]"
21
- value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
22
- </div>
23
- </li>
24
- <li>
25
- <label for="<?php echo $_code ?>_cc_number"
26
- class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
27
-
28
- <div class="input-box">
29
- <input type="text" id="<?php echo $_code ?>_cc_number"
30
- name="payment[cc_number]"
31
- title="<?php echo $this->__('Credit Card Number') ?>"
32
- data-eway-encrypt-name="payment[cc_number]"
33
- class="input-text validate-cc-number validate-cc-type-auto" value="" pattern="\d*"/>
34
- <input type="hidden" id="<?php echo $_code ?>_cc_type" name="payment[cc_type]"/>
35
- </div>
36
- </li>
37
- <li id="<?php echo $_code ?>_cc_type_exp_div">
38
- <label for="<?php echo $_code ?>_expiration"
39
- class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
40
-
41
- <div class="input-box">
42
- <div class="v-fix">
43
- <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]"
44
- class="month validate-cc-exp required-entry">
45
- <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
46
- <?php foreach ($this->getCcMonths() as $k => $v): ?>
47
- <option
48
- value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
49
- <?php endforeach ?>
50
- </select>
51
  </div>
52
- <div class="v-fix">
53
- <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
54
- <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]"
55
- class="year required-entry">
56
- <?php foreach ($this->getCcYears() as $k => $v): ?>
57
- <option
58
- value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
59
- <?php endforeach ?>
60
- </select>
 
 
 
61
  </div>
62
- </div>
63
- </li>
64
- <?php echo $this->getChildHtml() ?>
65
- <?php if ($this->hasVerification()): ?>
66
- <li id="<?php echo $_code ?>_cc_type_cvv_div">
67
- <label for="<?php echo $_code ?>_cc_cid"
68
- class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
69
 
70
  <div class="input-box">
71
  <div class="v-fix">
72
- <input type="text" title="<?php echo $this->__('Card Verification Number') ?>"
73
- name="payment[cc_cid]"
74
- class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid"
75
- data-eway-encrypt-name="payment[cc_cid]"
76
- value="" pattern="\d*"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  </div>
78
- <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
79
  </div>
80
  </li>
81
- <?php endif; ?>
82
- </ul>
83
- </dt>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
  <?php if ($this->getEnablePaypalStandard()) { ?>
86
- <dt>
87
  <input id="p_method_ewayrapid_transparent_paypal"
88
  value="<?php echo Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD ?>" type="radio"
89
  name="payment[transparent_notsaved]" title="Paypal - eWAY (not saved)" class="radio"
90
  autocomplete="off">
91
  <label for="p_method_ewayrapid_transparent_paypal">Paypal Standard </label>
92
- </dt>
93
  <?php } ?>
94
 
95
  <?php if ($this->getEnableMasterPass() && Mage::helper('ewayrapid/data')->getPaymentAction() == Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE) { ?>
96
- <dt>
97
  <input id="p_method_ewayrapid_transparent_masterpass"
98
  value="<?php echo Eway_Rapid31_Model_Config::MASTERPASS_METHOD ?>" type="radio"
99
  name="payment[transparent_notsaved]" title="MasterPass - eWAY (not saved)"
100
  class="radio validate-one-required-by-name"
101
- autocomplete="off">
102
  <label for="p_method_ewayrapid_transparent_masterpass">MasterPass </label>
103
- </dt>
104
  <?php } ?>
105
- </dl>
106
 
107
  <script>
108
-
109
  $('p_method_<?php echo $_code ?>').observe('click', function(){
110
  $('ul_payment_form_<?php echo $_code ?>').show();
111
  });
112
 
113
- $$('.radio').each(function(rd) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  rd.observe('click', function(el) {
 
115
  if(rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>') {
116
  $('ul_payment_form_<?php echo $_code ?>').show();
117
  } else if(rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD ?>'
@@ -122,11 +138,18 @@ $_code = $this->getMethodCode();
122
  }
123
  });
124
  });
 
125
  </script>
126
 
127
  <script>
128
  $('p_method_ewayrapid_notsaved').observe('click', function () {
129
  $('p_method_ewayrapid_notsaved').setAttribute('checked', 'true');
130
- $('p_method_ewayrapid_saved').removeAttribute('checked');
 
 
 
 
 
 
131
  });
132
  </script>
1
  <?php
2
  $_code = $this->getMethodCode();
3
  ?>
4
+ <ul class="sp-methods" id="payment_form_<?php echo $_code ?>"
5
  style="display:none; padding-left: 16px; padding-bottom: 8px; border: 1px solid rgb(193, 193, 193);">
6
 
7
+ <li>
8
  <input id="p_method_ewayrapid_transparent_mastercard"
9
  value="<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>" type="radio"
10
  name="payment[transparent_notsaved]" title="Check / Money order" class="radio" autocomplete="off"
11
  checked="checked">
12
  <label for="p_method_ewayrapid_transparent_paypalexpress">Credit Card </label>
13
 
14
+ <ul class="form-list form-list-notsaved" id="ul_payment_form_<?php echo $_code ?>" style="display: block;">
15
+ <li>
16
+ <label for="<?php echo $_code ?>_cc_owner"
17
+ class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
18
+ <div class="input-box">
19
+ <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry"
20
+ id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]"
21
+ value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  </div>
23
+ </li>
24
+ <li>
25
+ <label for="<?php echo $_code ?>_cc_number"
26
+ class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
27
+
28
+ <div class="input-box">
29
+ <input type="text" id="<?php echo $_code ?>_cc_number"
30
+ name="payment[cc_number]"
31
+ title="<?php echo $this->__('Credit Card Number') ?>"
32
+ data-eway-encrypt-name="payment[cc_number]"
33
+ class="input-text validate-cc-number validate-cc-type-auto" value="" pattern="\d*"/>
34
+ <input type="hidden" id="<?php echo $_code ?>_cc_type" name="payment[cc_type]"/>
35
  </div>
36
+ </li>
37
+ <li id="<?php echo $_code ?>_cc_type_exp_div">
38
+ <label for="<?php echo $_code ?>_expiration"
39
+ class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
 
 
 
40
 
41
  <div class="input-box">
42
  <div class="v-fix">
43
+ <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]"
44
+ class="month validate-cc-exp required-entry">
45
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
46
+ <?php foreach ($this->getCcMonths() as $k => $v): ?>
47
+ <option
48
+ value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
49
+ <?php endforeach ?>
50
+ </select>
51
+ </div>
52
+ <div class="v-fix">
53
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
54
+ <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]"
55
+ class="year required-entry">
56
+ <?php foreach ($this->getCcYears() as $k => $v): ?>
57
+ <option
58
+ value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
59
+ <?php endforeach ?>
60
+ </select>
61
  </div>
 
62
  </div>
63
  </li>
64
+ <?php echo $this->getChildHtml() ?>
65
+ <?php if ($this->hasVerification()): ?>
66
+ <li id="<?php echo $_code ?>_cc_type_cvv_div">
67
+ <label for="<?php echo $_code ?>_cc_cid"
68
+ class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
69
+
70
+ <div class="input-box">
71
+ <div class="v-fix" id="v-fix-cvn-id">
72
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>"
73
+ name="payment[cc_cid]"
74
+ class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid"
75
+ data-eway-encrypt-name="payment[cc_cid]"
76
+ value="" pattern="\d*"/>
77
+ </div>
78
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
79
+ </div>
80
+ </li>
81
+ <?php endif; ?>
82
+ </ul>
83
+ </li>
84
 
85
  <?php if ($this->getEnablePaypalStandard()) { ?>
86
+ <li>
87
  <input id="p_method_ewayrapid_transparent_paypal"
88
  value="<?php echo Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD ?>" type="radio"
89
  name="payment[transparent_notsaved]" title="Paypal - eWAY (not saved)" class="radio"
90
  autocomplete="off">
91
  <label for="p_method_ewayrapid_transparent_paypal">Paypal Standard </label>
92
+ </li>
93
  <?php } ?>
94
 
95
  <?php if ($this->getEnableMasterPass() && Mage::helper('ewayrapid/data')->getPaymentAction() == Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE) { ?>
96
+ <li>
97
  <input id="p_method_ewayrapid_transparent_masterpass"
98
  value="<?php echo Eway_Rapid31_Model_Config::MASTERPASS_METHOD ?>" type="radio"
99
  name="payment[transparent_notsaved]" title="MasterPass - eWAY (not saved)"
100
  class="radio validate-one-required-by-name"
101
+ autocomplete="off" />
102
  <label for="p_method_ewayrapid_transparent_masterpass">MasterPass </label>
103
+ </li>
104
  <?php } ?>
105
+ </ul>
106
 
107
  <script>
108
+ var _notSaved = 0;
109
  $('p_method_<?php echo $_code ?>').observe('click', function(){
110
  $('ul_payment_form_<?php echo $_code ?>').show();
111
  });
112
 
113
+ setInterval(function(){
114
+ if(_notSaved == 1) return false;
115
+ _notSaved = 1;
116
+ $$('#payment_form_ewayrapid_notsaved .radio:checked').each(function(rd) {
117
+ if(rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>') {
118
+ $('ul_payment_form_<?php echo $_code ?>').show();
119
+ } else if(rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD ?>'
120
+ || rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::MASTERPASS_METHOD ?>') {
121
+ $('ul_payment_form_<?php echo $_code ?>').hide();
122
+ } else {
123
+ $('ul_payment_form_<?php echo $_code ?>').show();
124
+ }
125
+ });
126
+ },300);
127
+
128
+ $$('#payment_form_<?php echo $_code ?> .radio').each(function(rd) {
129
  rd.observe('click', function(el) {
130
+ console.log(rd.getValue());
131
  if(rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>') {
132
  $('ul_payment_form_<?php echo $_code ?>').show();
133
  } else if(rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD ?>'
138
  }
139
  });
140
  });
141
+
142
  </script>
143
 
144
  <script>
145
  $('p_method_ewayrapid_notsaved').observe('click', function () {
146
  $('p_method_ewayrapid_notsaved').setAttribute('checked', 'true');
147
+ $('p_method_ewayrapid_saved') && $('p_method_ewayrapid_saved').removeAttribute('checked');
148
+ $$('#payment_form_ewayrapid_notsaved input[name*=payment]').each(function(inp) {
149
+ inp.removeAttribute('disabled');
150
+ });
151
+ $$('#payment_form_ewayrapid_notsaved select[name*=payment]').each(function(inp) {
152
+ inp.removeAttribute('disabled');
153
+ });
154
  });
155
  </script>
app/design/frontend/base/default/template/ewayrapid/form/transparent_saved.phtml CHANGED
@@ -29,11 +29,11 @@ $_code = $this->getMethodCode();
29
  $_tokens = $this->getTokenList();
30
  ?>
31
 
32
- <dl class="sp-methods" id="payment_form_<?php echo $_code ?>"
33
  style="display:none; padding-left: 16px; padding-bottom: 8px; border: 1px solid rgb(193, 193, 193);">
34
 
35
- <dt>
36
- <ul class="form-list" style="display: block;">
37
  <li>
38
  <div class="eway-saved-div-box">
39
  <label class="eway-saved-label-box"><?php echo $this->__('Saved Details') ?></label>
@@ -68,10 +68,10 @@ $_tokens = $this->getTokenList();
68
  </div>
69
  </li>
70
  </ul>
71
- </dt>
72
 
73
 
74
- <dt id="eway_save_creditcard">
75
  <input id="p_method_ewayrapid_saved_mastercard" rel="ul_payment_form_<?php echo $_code ?>"
76
  value="<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>" type="radio"
77
  name="payment[transparent_saved]" title="Check / Money order" class="radio element_save_creditcard" autocomplete="off"
@@ -159,29 +159,29 @@ $_tokens = $this->getTokenList();
159
  <?php } ?>
160
  <?php endif; ?>
161
  </ul>
162
- </dt>
163
 
164
  <?php if ($this->getEnablePaypalStandard()) { ?>
165
- <dt id="eway_save_paypal" style="display: none">
166
  <input id="p_method_ewayrapid_saved_transparent_paypal" rel="payment_form_paypal_saved"
167
  value="<?php echo Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD ?>" type="radio"
168
  name="payment[transparent_saved]" title="Paypal - eWAY (saved)" class="radio" autocomplete="off">
169
  <label for="p_method_ewayrapid_saved_transparent_paypal">Paypal Standard </label>
170
- </dt>
171
  <?php } ?>
172
 
173
  <?php if ($this->getEnableMasterPass() && Mage::helper('ewayrapid/data')->getPaymentAction() == Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE) { ?>
174
- <dt id="eway_save_masterpass" style="display: none">
175
  <input id="p_method_ewayrapid_transparent_masterpass" rel="payment_form_masterpass_saved"
176
  value="<?php echo Eway_Rapid31_Model_Config::MASTERPASS_METHOD ?>" type="radio"
177
  name="payment[transparent_saved]" title="MasterPass - eWAY (saved)" class="radio" autocomplete="off">
178
  <label for="p_method_ewayrapid_transparent_masterpass">MasterPass </label>
179
- </dt>
180
  <?php } ?>
181
- </dl>
182
 
183
  <script type="text/javascript">
184
-
185
  var ewayPaymentToken = new EwayPaymentToken(
186
  <?php echo $_tokens['tokens_json'] ?>,
187
  <?php echo count($_tokens['tokens']) ?>,
@@ -222,7 +222,7 @@ $_tokens = $this->getTokenList();
222
  });
223
  }
224
 
225
- $$('.radio').each(function (el) {
226
  var _rel = $(el).readAttribute('rel');
227
  //console.log(_rel);
228
  if (_rel != '' && _rel != null) {
@@ -312,11 +312,33 @@ $_tokens = $this->getTokenList();
312
  $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').show();
313
  }
314
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  </script>
316
 
317
  <script type="text/javascript">
318
  $('p_method_ewayrapid_saved').observe('click', function () {
319
  $('p_method_ewayrapid_saved').setAttribute('checked', 'true');
320
  $('p_method_ewayrapid_notsaved').removeAttribute('checked');
 
 
 
 
 
 
 
321
  });
322
  </script>
29
  $_tokens = $this->getTokenList();
30
  ?>
31
 
32
+ <ul class="sp-methods" id="payment_form_<?php echo $_code ?>"
33
  style="display:none; padding-left: 16px; padding-bottom: 8px; border: 1px solid rgb(193, 193, 193);">
34
 
35
+ <li>
36
+ <ul class="form-list" style="display: block;" id="ul-eway-saved-div-box">
37
  <li>
38
  <div class="eway-saved-div-box">
39
  <label class="eway-saved-label-box"><?php echo $this->__('Saved Details') ?></label>
68
  </div>
69
  </li>
70
  </ul>
71
+ </li>
72
 
73
 
74
+ <li id="eway_save_creditcard">
75
  <input id="p_method_ewayrapid_saved_mastercard" rel="ul_payment_form_<?php echo $_code ?>"
76
  value="<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>" type="radio"
77
  name="payment[transparent_saved]" title="Check / Money order" class="radio element_save_creditcard" autocomplete="off"
159
  <?php } ?>
160
  <?php endif; ?>
161
  </ul>
162
+ </li>
163
 
164
  <?php if ($this->getEnablePaypalStandard()) { ?>
165
+ <li id="eway_save_paypal" style="display: none">
166
  <input id="p_method_ewayrapid_saved_transparent_paypal" rel="payment_form_paypal_saved"
167
  value="<?php echo Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD ?>" type="radio"
168
  name="payment[transparent_saved]" title="Paypal - eWAY (saved)" class="radio" autocomplete="off">
169
  <label for="p_method_ewayrapid_saved_transparent_paypal">Paypal Standard </label>
170
+ </li>
171
  <?php } ?>
172
 
173
  <?php if ($this->getEnableMasterPass() && Mage::helper('ewayrapid/data')->getPaymentAction() == Eway_Rapid31_Model_Method_Notsaved::ACTION_AUTHORIZE_CAPTURE) { ?>
174
+ <li id="eway_save_masterpass" style="display: none">
175
  <input id="p_method_ewayrapid_transparent_masterpass" rel="payment_form_masterpass_saved"
176
  value="<?php echo Eway_Rapid31_Model_Config::MASTERPASS_METHOD ?>" type="radio"
177
  name="payment[transparent_saved]" title="MasterPass - eWAY (saved)" class="radio" autocomplete="off">
178
  <label for="p_method_ewayrapid_transparent_masterpass">MasterPass </label>
179
+ </li>
180
  <?php } ?>
181
+ </ul>
182
 
183
  <script type="text/javascript">
184
+ var _saved = 0;
185
  var ewayPaymentToken = new EwayPaymentToken(
186
  <?php echo $_tokens['tokens_json'] ?>,
187
  <?php echo count($_tokens['tokens']) ?>,
222
  });
223
  }
224
 
225
+ $$('#payment_form_<?php echo $_code ?> .radio').each(function (el) {
226
  var _rel = $(el).readAttribute('rel');
227
  //console.log(_rel);
228
  if (_rel != '' && _rel != null) {
312
  $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').show();
313
  }
314
  }
315
+
316
+ setInterval(function(){
317
+ if(_saved == 1) return false;
318
+ _saved = 1;
319
+ $$('#payment_form_ewayrapid_saved .radio:checked').each(function(rd) {
320
+ if(rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>') {
321
+ $('ul_payment_form_<?php echo $_code ?>').show();
322
+ } else if(rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD ?>'
323
+ || rd.getValue() == '<?php echo Eway_Rapid31_Model_Config::MASTERPASS_METHOD ?>') {
324
+ $('ul_payment_form_<?php echo $_code ?>').hide();
325
+ } else {
326
+ $('ul_payment_form_<?php echo $_code ?>').show();
327
+ }
328
+ });
329
+ },300);
330
  </script>
331
 
332
  <script type="text/javascript">
333
  $('p_method_ewayrapid_saved').observe('click', function () {
334
  $('p_method_ewayrapid_saved').setAttribute('checked', 'true');
335
  $('p_method_ewayrapid_notsaved').removeAttribute('checked');
336
+ $('ul-eway-saved-div-box').show();
337
+ $$('#payment_form_ewayrapid_saved input[name*=payment]').each(function(inp) {
338
+ inp.removeAttribute('disabled');
339
+ });
340
+ $$('#payment_form_ewayrapid_saved select[name*=payment]').each(function(inp) {
341
+ inp.removeAttribute('disabled');
342
+ });
343
  });
344
  </script>
app/design/frontend/base/default/template/ewayrapid/js.phtml CHANGED
@@ -1,7 +1,7 @@
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()): ?>
@@ -10,31 +10,61 @@
10
  <?php else: ?>
11
  <?php switch($_checkoutExtension):
12
  case 'OneStepCheckout': // OneStepCheckout extension ?>
13
- document.observe("dom:loaded", function() {
 
 
14
  var ewayPayment = new EwayPayment($('onestepcheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
15
- Payment.prototype.switchMethod = ewayPayment.OneStepCheckout.switchMethod;
16
- if(payment.currentMethod) {
17
- payment.switchMethod(payment.currentMethod);
 
 
18
  }
19
- $('onestepcheckout-form').submit = function() {
 
 
 
 
 
 
 
 
 
 
 
 
20
  form = eCrypt.doEncrypt();
21
  form.submit();
22
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  });
24
  <?php break; ?>
 
25
  <?php case 'FireCheckout': // FireCheckout extension ?>
26
- document.observe("dom:loaded", function() {
27
  var ewayPayment = new EwayPayment($('firecheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
28
- if(typeof FireCheckout.prototype.ewayOldSave == "undefined") {
29
  FireCheckout.prototype.ewayOldSave = FireCheckout.prototype.save;
30
  FireCheckout.prototype.save = ewayPayment.FireCheckout.save;
31
  }
32
  });
33
  <?php break; ?>
34
  <?php case 'IWDOnePageCheckout': // FireCheckout extension ?>
35
- document.observe("dom:loaded", function() {
36
  var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
37
- if(typeof IWD.OPC.ewayOldSavePayment == "undefined") {
38
  IWD.OPC.ewayOldSavePayment = IWD.OPC.savePayment;
39
  IWD.OPC.ewayOldSaveOrder = IWD.OPC.saveOrder;
40
  IWD.OPC.savePayment = ewayPayment.IWDOnePageCheckout.savePayment;
@@ -54,32 +84,153 @@
54
  </script>
55
  <?php endif; ?>
56
 
57
- <?php if($_config->isTransparentConnection() && !$_backend): ?>
58
  <script type="text/javascript">
59
  var creditcard = '<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
61
  Payment.prototype.save = ewayPayment.savePaymentWithTransEncryption;
62
- Review.prototype.save = function() {
63
- $('review-please-wait').show();
64
- $('review-buttons-container').down('button').hide();
65
- var request = new Ajax.Request(
66
- '<?php echo Mage::getUrl('ewayrapid/transparent/build'); ?>',
67
- {
68
- method:'post',
69
- onComplete: {
70
-
71
- },
72
- onSuccess: function(response) {
73
- if(response.responseText != '0') {
74
- window.location = response.responseText;
75
- }
76
- return false;
77
- },
78
- onFailure: {
79
-
80
- }
81
- }
82
- );
83
  }
 
 
 
 
84
  </script>
85
  <?php endif; ?>
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()): ?>
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;
84
  </script>
85
  <?php endif; ?>
86
 
87
+ <?php if ($_config->isTransparentConnection() && !$_backend): ?>
88
  <script type="text/javascript">
89
  var creditcard = '<?php echo Eway_Rapid31_Model_Config::CREDITCARD_METHOD ?>';
90
+
91
+ <?php switch($_checkoutExtension):
92
+ case 'OneStepCheckout': // OneStepCheckout extension ?>
93
+ document.observe("dom:loaded", function () {
94
+ <?php if(Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')): ?>
95
+ var ewayPayment = new EwayPayment($('onestepcheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
96
+ Payment.prototype.switchMethod = ewayPayment.OneStepCheckout.switchMethod;
97
+ if (payment.currentMethod) {
98
+ payment.switchMethod(payment.currentMethod);
99
+ }
100
+
101
+ $('onestepcheckout-form') && ($('onestepcheckout-form').submit = function () {
102
+ form = eCrypt.doEncrypt();
103
+ form.submit();
104
+ });
105
+
106
+ if ($('onestepcheckout-form')) {
107
+ $('ewayrapid_notsaved_expiration') && $('ewayrapid_notsaved_expiration').writeAttribute('style', 'width:103px !important;');
108
+ $('ewayrapid_saved_expiration') && $('ewayrapid_saved_expiration').writeAttribute('style', 'width:103px !important;');
109
+ $('ewayrapid_saved_token') && $('ewayrapid_saved_token').writeAttribute('style', 'width:128px !important;');
110
+ $('v-fix-change') && $('v-fix-change').writeAttribute('style', 'width:60px !important;');
111
+ $('v-fix-cvn-id') && $('v-fix-cvn-id').writeAttribute('style', 'width:60px !important;');
112
+
113
+ $('ul_payment_form_ewayrapid_notsaved') && $('ul_payment_form_ewayrapid_notsaved').setStyle({'margin-left': '-2px'});
114
+ $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
115
+ $$('#container_payment_method_ewayrapid_notsaved ul li').each(function (element) {
116
+ element.writeAttribute('style', 'float: left; width: 100%');
117
+ });
118
+ }
119
+ <?php endif; ?>
120
+
121
+ <?php if(Mage::getStoreConfig('onestepcheckout/general/active')): ?>
122
+ var ewayPayment2 = new EwayPayment($('one-step-checkout-form'), '<?php echo $_config->getEncryptionKey() ?>');
123
+ if (ewayPayment2 && $('one-step-checkout-form'))
124
+ Payment.prototype.switchMethod = ewayPayment2.OneStepCheckout.switchMethod;
125
+
126
+ $('one-step-checkout-form') && ($('one-step-checkout-form').submit = function () {
127
+ form = eCrypt.doEncrypt();
128
+ form.submit();
129
+ });
130
+
131
+ if ($('one-step-checkout-form')) {
132
+ $('payment_form_ewayrapid_notsaved') && $('payment_form_ewayrapid_notsaved').setStyle({'width': '95%'});
133
+ $('payment_form_ewayrapid_saved') && $('payment_form_ewayrapid_saved').setStyle({'width': '95%'});
134
+ $('ul_payment_form_ewayrapid_notsaved') && $('ul_payment_form_ewayrapid_notsaved').setStyle({'margin-left': '-2px'});
135
+ $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
136
+ $('payment_form_ewayrapid_saved') && $('payment_form_ewayrapid_saved').setStyle({'margin-left': '-2px'});
137
+
138
+ $('ewayrapid_notsaved_cc_type_cvv_div') && $$('#ewayrapid_notsaved_cc_type_cvv_div div.v-fix')[0].writeAttribute('style', 'width: 35% !important');
139
+ $('ewayrapid_saved_cc_type_cvv_div') && $$('#ewayrapid_saved_cc_type_cvv_div div.v-fix')[0].writeAttribute('style', 'width: 35% !important');
140
+
141
+ $$('#ul_payment_form_ewayrapid_notsaved input[type=text]').each(function (element) {
142
+ element.writeAttribute('style', 'width: 97% !important;');
143
+ });
144
+
145
+ $('ul_payment_form_ewayrapid_saved') && $$('#ul_payment_form_ewayrapid_saved input[type=text]').each(function (element) {
146
+ element.writeAttribute('style', 'width: 97% !important;');
147
+ });
148
+
149
+ $$('#container_payment_method_ewayrapid_notsaved ul li').each(function (element) {
150
+ element.writeAttribute('style', 'float: left; width: 100%');
151
+ });
152
+ $('container_payment_method_ewayrapid_saved') && $$('#container_payment_method_ewayrapid_saved ul li').each(function (element) {
153
+ element.writeAttribute('style', 'float: left; width: 100%');
154
+ });
155
+
156
+ $$('.eway-saved-div-box')[0].writeAttribute('style', 'margin-left:-26px');
157
+ $('ewayrapid_saved_cc_cid') && $('ewayrapid_saved_cc_cid').removeAttribute('disabled');
158
+ $('eway_save_paypal') && $('eway_save_paypal').hide();
159
+ $('eway_save_masterpass') && $('eway_save_masterpass').hide();
160
+ var _ctype = $('ewayrapid_saved_token')[0].readAttribute('rel');
161
+ if (_ctype == 'paypal') {
162
+ $('ewayrapid_saved_cc_type_cvv_div') && $('ewayrapid_saved_cc_type_cvv_div').hide();
163
+ $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
164
+ $$('.element_save_creditcard').each(function (el) {
165
+ el.hide();
166
+ });
167
+ } else if ((_ctype == "" || _ctype == null || $('ewayrapid_saved_token').getValue() == 'new')) {
168
+ $('<?php echo $_code ?>_cc_number') && $('<?php echo $_code ?>_cc_number').writeAttribute('disabled', false);
169
+ $('eway_save_masterpass') && $('eway_save_masterpass').show(150);
170
+ $('eway_save_paypal') && $('eway_save_paypal').show(150);
171
+ $('ul_payment_form_<?php echo $_code ?>') && $('ul_payment_form_<?php echo $_code ?>').show(150);
172
+
173
+ $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
174
+
175
+ $$('.element_save_creditcard').each(function (el) {
176
+ el.show();
177
+ });
178
+ $('ul_payment_form_ewayrapid_saved') && $('ul_payment_form_ewayrapid_saved').show();
179
+ $('ewayrapid_saved_cc_type_cvv_div') && $('ewayrapid_saved_cc_type_cvv_div').show();
180
+ } else {
181
+ $$('.element_save_creditcard').each(function (el) {
182
+ el.hide();
183
+ });
184
+ }
185
+ }
186
+ <?php endif; ?>
187
+ });
188
+ <?php break; ?>
189
+
190
+ <?php case 'LightCheckout': ?>
191
+ document.observe("dom:loaded", function () {
192
+ var ewayPayment = new EwayPayment($('gcheckout-onepage-form'), '<?php echo $_config->getEncryptionKey() ?>');
193
+ if (typeof checkout.LightcheckoutSubmitOld == "undefined") {
194
+ checkout.LightcheckoutSubmitOld = checkout.LightcheckoutSubmit;
195
+ checkout.LightcheckoutSubmit = ewayPayment.Lightcheckout.LightcheckoutSubmit;
196
+ checkout.getFormData = ewayPayment.Lightcheckout.getFormData;
197
+ }
198
+ });
199
+ <?php break; ?>
200
+
201
+
202
+ <?php case 'FireCheckout': // FireCheckout extension ?>
203
+ document.observe("dom:loaded", function () {
204
+ var ewayPayment = new EwayPayment($('firecheckout-form'), '<?php echo $_config->getEncryptionKey() ?>');
205
+ if (typeof FireCheckout.prototype.ewayOldSave == "undefined") {
206
+ FireCheckout.prototype.ewayOldSave = FireCheckout.prototype.save;
207
+ FireCheckout.prototype.save = ewayPayment.FireCheckout.savePayment;
208
+ }
209
+ });
210
+ <?php break; ?>
211
+ <?php case 'IWDOnePageCheckout': // FireCheckout extension ?>
212
+ document.observe("dom:loaded", function () {
213
+ var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
214
+ if (typeof IWD.OPC.ewayOldSavePayment == "undefined") {
215
+ IWD.OPC.ewayOldSavePayment = IWD.OPC.savePayment;
216
+ IWD.OPC.savePayment = ewayPayment.IWDOnePageCheckout.savePaymentTrans;
217
+ }
218
+ });
219
+ <?php break; ?>
220
+ <?php case 'MultiShippingAddress': // Magento default multi shipping address ?>
221
+ var ewayPayment = new EwayPayment($('multishipping-billing-form'), '<?php echo $_config->getEncryptionKey() ?>');
222
+ <?php break; ?>
223
+
224
+ <?php default: // Magento default one page checkout ?>
225
  var ewayPayment = new EwayPayment($('co-payment-form'), '<?php echo $_config->getEncryptionKey() ?>');
226
  Payment.prototype.save = ewayPayment.savePaymentWithTransEncryption;
227
+
228
+ if (typeof (ewayPayment.ewaysavedOldOrder) == "undefined") {
229
+ ewayPayment.ewaysavedOldOrder = Review.prototype.save;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  }
231
+ ewayPayment.paymentUrl = "<?php echo Mage::getUrl('ewayrapid/transparent/build', array('_secure'=>true)); ?>";
232
+ Review.prototype.save = ewayPayment.saveReviewWithEncryptionTrans;
233
+ <?php endswitch; ?>
234
+
235
  </script>
236
  <?php endif; ?>
app/etc/modules/Eway_Rapid31.xml CHANGED
@@ -1,9 +1,9 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Eway_Rapid31>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </Eway_Rapid31>
8
- </modules>
9
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Eway_Rapid31>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Eway_Rapid31>
8
+ </modules>
9
  </config>
js/ewayrapid/eCrypt.js CHANGED
@@ -1,1001 +1,1024 @@
1
- // eWAY RSA Client Cryptography
2
- // Version 0.6 Alpha
3
-
4
- function eCrypt() {
5
- this.init = null;
6
- this.doEncrypt = null;
7
- }
8
-
9
- (function (eCrypt) {
10
- function eCryptInit() {
11
-
12
- var ewayPublicKeyAttribute = "data-eway-encrypt-key";
13
- var ewayEncryptAttribute = "data-eway-encrypt-name";
14
-
15
- var PUBLIC_KEY_N = null;
16
- var PUBLIC_KEY_E = b64tohex("AQAB");
17
-
18
- var isAjaxCall = false;
19
-
20
- // TODO: How should we handle form not found...
21
- var form = findFormToEncrypt();
22
- extractPublicKey(form);
23
- addSubmitEvent(form);
24
-
25
- function encryptForm(event) {
26
- try {
27
- var target;
28
- // the form is not the event target in ajax call, so we use form variable found before
29
- if(form != null) {
30
- target = form;
31
- } else {
32
- event = event || window.event; // event is undefined in IE
33
- target = event.target || event.srcElement; // IE uses srcElement, everything else uses target
34
- }
35
- var rsa = new RSAKey();
36
- rsa.setPublic(PUBLIC_KEY_N, PUBLIC_KEY_E);
37
- var newForm = cloneForm(target);
38
- if (newForm.id) {
39
- newForm.id = "EWAY_CLONED_" + newForm.id;
40
- }
41
-
42
- for (formNode = 0, formLength = newForm.length; formNode < formLength; formNode++) {
43
- var dataAttribute = newForm[formNode].getAttribute(ewayEncryptAttribute);
44
- if (dataAttribute != null) {
45
- encryptElement(newForm[formNode], rsa);
46
- }
47
- else if (newForm[formNode].id) {
48
- newForm[formNode].id = "EWAY_ENCRYPTED_" + newForm[formNode].id;
49
- }
50
- }
51
-
52
- newForm.style.display = "none";
53
- form.parentNode.appendChild(newForm); //IE and FF will not submit form without it being inserted into the DOM
54
- if(isAjaxCall) {
55
- return newForm;
56
- } else {
57
- var formProxy = document.createElement('form');
58
- formProxy.submit.apply(newForm); // To guard against a form with a button named 'submit'
59
- }
60
- }
61
- catch (err) {
62
- // Debugging - In case console not open in IE
63
- if (!window.console) window.console = {};
64
- if (!window.console.log) window.console.log = function () { };
65
- console.log('Uh oh, something went wrong');
66
- console.log(err);
67
- console.log(err.message);
68
- }
69
- finally {
70
- if(!isAjaxCall) {
71
- return false;
72
- }
73
- }
74
- }
75
-
76
- function findFormToEncrypt() {
77
- var forms = document.getElementsByTagName('form');
78
- for (var i = 0; i < forms.length; i++) {
79
- var key = forms[i].getAttribute(ewayPublicKeyAttribute);
80
- if (key) {
81
- return forms[i];
82
- }
83
- }
84
- return null;
85
- }
86
-
87
- function extractPublicKey(f) {
88
- PUBLIC_KEY_N = b64tohex(f.getAttribute(ewayPublicKeyAttribute));
89
- }
90
-
91
- function cloneForm(oldForm) {
92
- var newForm = oldForm.cloneNode(true);
93
- copySelectLists(oldForm, newForm);
94
- return newForm;
95
- }
96
-
97
- function copySelectLists(oldForm, newForm) {
98
- var selectElementsOld = oldForm.getElementsByTagName('Select');
99
- var selectElementsNew = newForm.getElementsByTagName('Select');
100
-
101
- for (var i = 0; i < selectElementsOld.length; i++) {
102
- selectElementsNew[i].selectedIndex = selectElementsOld[i].selectedIndex;
103
- }
104
- }
105
-
106
- function encryptElement(element, rsa) {
107
- if (element.id) {
108
- element.id = "EWAY_ENCRYPTED_" + element.id;
109
- }
110
- element.name = element.getAttribute(ewayEncryptAttribute);
111
- element.value = "eCrypted:" + rsa.encrypt(element.value);
112
- }
113
-
114
- function addSubmitEvent(frm) {
115
- var oldonsubmit = frm.onsubmit;
116
- if (typeof frm.onsubmit != 'function') {
117
- frm.onsubmit = encryptForm;
118
- } else {
119
- frm.onsubmit = function (e) {
120
- if (!oldonsubmit(e)) {
121
- return false;
122
- };
123
- return encryptForm(e);
124
- }
125
- }
126
-
127
- eCrypt.doEncrypt = function() {
128
- isAjaxCall = true;
129
- return encryptForm();
130
- }
131
- }
132
- };
133
-
134
-
135
-
136
- // Start jsbn.js
137
- var dbits;
138
-
139
- // JavaScript engine analysis
140
- var canary = 0xdeadbeefcafe;
141
- var j_lm = ((canary & 0xffffff) == 0xefcafe);
142
-
143
- // (public) Constructor
144
- function BigInteger(a, b, c) {
145
- if (a != null)
146
- if ("number" == typeof a) this.fromNumber(a, b, c);
147
- else if (b == null && "string" != typeof a) this.fromString(a, 256);
148
- else this.fromString(a, b);
149
- }
150
-
151
- // return new, unset BigInteger
152
- function nbi() { return new BigInteger(null); }
153
-
154
- // am: Compute w_j += (x*this_i), propagate carries,
155
- // c is initial carry, returns final carry.
156
- // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
157
- // We need to select the fastest one that works in this environment.
158
-
159
- // am1: use a single mult and divide to get the high bits,
160
- // max digit bits should be 26 because
161
- // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
162
- function am1(i, x, w, j, c, n) {
163
- while (--n >= 0) {
164
- var v = x * this[i++] + w[j] + c;
165
- c = Math.floor(v / 0x4000000);
166
- w[j++] = v & 0x3ffffff;
167
- }
168
- return c;
169
- }
170
- // am2 avoids a big mult-and-extract completely.
171
- // Max digit bits should be <= 30 because we do bitwise ops
172
- // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
173
- function am2(i, x, w, j, c, n) {
174
- var xl = x & 0x7fff, xh = x >> 15;
175
- while (--n >= 0) {
176
- var l = this[i] & 0x7fff;
177
- var h = this[i++] >> 15;
178
- var m = xh * l + h * xl;
179
- l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
180
- c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
181
- w[j++] = l & 0x3fffffff;
182
- }
183
- return c;
184
- }
185
- // Alternately, set max digit bits to 28 since some
186
- // browsers slow down when dealing with 32-bit numbers.
187
- function am3(i, x, w, j, c, n) {
188
- var xl = x & 0x3fff, xh = x >> 14;
189
- while (--n >= 0) {
190
- var l = this[i] & 0x3fff;
191
- var h = this[i++] >> 14;
192
- var m = xh * l + h * xl;
193
- l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
194
- c = (l >> 28) + (m >> 14) + xh * h;
195
- w[j++] = l & 0xfffffff;
196
- }
197
- return c;
198
- }
199
- if (j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
200
- BigInteger.prototype.am = am2;
201
- dbits = 30;
202
- }
203
- else if (j_lm && (navigator.appName != "Netscape")) {
204
- BigInteger.prototype.am = am1;
205
- dbits = 26;
206
- }
207
- else { // Mozilla/Netscape seems to prefer am3
208
- BigInteger.prototype.am = am3;
209
- dbits = 28;
210
- }
211
-
212
- BigInteger.prototype.DB = dbits;
213
- BigInteger.prototype.DM = ((1 << dbits) - 1);
214
- BigInteger.prototype.DV = (1 << dbits);
215
-
216
- var BI_FP = 52;
217
- BigInteger.prototype.FV = Math.pow(2, BI_FP);
218
- BigInteger.prototype.F1 = BI_FP - dbits;
219
- BigInteger.prototype.F2 = 2 * dbits - BI_FP;
220
-
221
- // Digit conversions
222
- var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
223
- var BI_RC = new Array();
224
- var rr, vv;
225
- rr = "0".charCodeAt(0);
226
- for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
227
- rr = "a".charCodeAt(0);
228
- for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
229
- rr = "A".charCodeAt(0);
230
- for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
231
-
232
- function int2char(n) { return BI_RM.charAt(n); }
233
- function intAt(s, i) {
234
- var c = BI_RC[s.charCodeAt(i)];
235
- return (c == null) ? -1 : c;
236
- }
237
-
238
- // (protected) copy this to r
239
- function bnpCopyTo(r) {
240
- for (var i = this.t - 1; i >= 0; --i) r[i] = this[i];
241
- r.t = this.t;
242
- r.s = this.s;
243
- }
244
-
245
- // (protected) set from integer value x, -DV <= x < DV
246
- function bnpFromInt(x) {
247
- this.t = 1;
248
- this.s = (x < 0) ? -1 : 0;
249
- if (x > 0) this[0] = x;
250
- else if (x < -1) this[0] = x + this.DV;
251
- else this.t = 0;
252
- }
253
-
254
- // return bigint initialized to value
255
- function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
256
-
257
- // (protected) set from string and radix
258
- function bnpFromString(s, b) {
259
- var k;
260
- if (b == 16) k = 4;
261
- else if (b == 8) k = 3;
262
- else if (b == 256) k = 8; // byte array
263
- else if (b == 2) k = 1;
264
- else if (b == 32) k = 5;
265
- else if (b == 4) k = 2;
266
- else { this.fromRadix(s, b); return; }
267
- this.t = 0;
268
- this.s = 0;
269
- var i = s.length, mi = false, sh = 0;
270
- while (--i >= 0) {
271
- var x = (k == 8) ? s[i] & 0xff : intAt(s, i);
272
- if (x < 0) {
273
- if (s.charAt(i) == "-") mi = true;
274
- continue;
275
- }
276
- mi = false;
277
- if (sh == 0)
278
- this[this.t++] = x;
279
- else if (sh + k > this.DB) {
280
- this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
281
- this[this.t++] = (x >> (this.DB - sh));
282
- }
283
- else
284
- this[this.t - 1] |= x << sh;
285
- sh += k;
286
- if (sh >= this.DB) sh -= this.DB;
287
- }
288
- if (k == 8 && (s[0] & 0x80) != 0) {
289
- this.s = -1;
290
- if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
291
- }
292
- this.clamp();
293
- if (mi) BigInteger.ZERO.subTo(this, this);
294
- }
295
-
296
- // (protected) clamp off excess high words
297
- function bnpClamp() {
298
- var c = this.s & this.DM;
299
- while (this.t > 0 && this[this.t - 1] == c)--this.t;
300
- }
301
-
302
- // (public) return string representation in given radix
303
- function bnToString(b) {
304
- if (this.s < 0) return "-" + this.negate().toString(b);
305
- var k;
306
- if (b == 16) k = 4;
307
- else if (b == 8) k = 3;
308
- else if (b == 2) k = 1;
309
- else if (b == 32) k = 5;
310
- else if (b == 4) k = 2;
311
- else return this.toRadix(b);
312
- var km = (1 << k) - 1, d, m = false, r = "", i = this.t;
313
- var p = this.DB - (i * this.DB) % k;
314
- if (i-- > 0) {
315
- if (p < this.DB && (d = this[i] >> p) > 0) { m = true; r = int2char(d); }
316
- while (i >= 0) {
317
- if (p < k) {
318
- d = (this[i] & ((1 << p) - 1)) << (k - p);
319
- d |= this[--i] >> (p += this.DB - k);
320
- }
321
- else {
322
- d = (this[i] >> (p -= k)) & km;
323
- if (p <= 0) { p += this.DB; --i; }
324
- }
325
- if (d > 0) m = true;
326
- if (m) r += int2char(d);
327
- }
328
- }
329
- return m ? r : "0";
330
- }
331
-
332
- // (public) -this
333
- function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this, r); return r; }
334
-
335
- // (public) |this|
336
- function bnAbs() { return (this.s < 0) ? this.negate() : this; }
337
-
338
- // (public) return + if this > a, - if this < a, 0 if equal
339
- function bnCompareTo(a) {
340
- var r = this.s - a.s;
341
- if (r != 0) return r;
342
- var i = this.t;
343
- r = i - a.t;
344
- if (r != 0) return (this.s < 0) ? -r : r;
345
- while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r;
346
- return 0;
347
- }
348
-
349
- // returns bit length of the integer x
350
- function nbits(x) {
351
- var r = 1, t;
352
- if ((t = x >>> 16) != 0) { x = t; r += 16; }
353
- if ((t = x >> 8) != 0) { x = t; r += 8; }
354
- if ((t = x >> 4) != 0) { x = t; r += 4; }
355
- if ((t = x >> 2) != 0) { x = t; r += 2; }
356
- if ((t = x >> 1) != 0) { x = t; r += 1; }
357
- return r;
358
- }
359
-
360
- // (public) return the number of bits in "this"
361
- function bnBitLength() {
362
- if (this.t <= 0) return 0;
363
- return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
364
- }
365
-
366
- // (protected) r = this << n*DB
367
- function bnpDLShiftTo(n, r) {
368
- var i;
369
- for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i];
370
- for (i = n - 1; i >= 0; --i) r[i] = 0;
371
- r.t = this.t + n;
372
- r.s = this.s;
373
- }
374
-
375
- // (protected) r = this >> n*DB
376
- function bnpDRShiftTo(n, r) {
377
- for (var i = n; i < this.t; ++i) r[i - n] = this[i];
378
- r.t = Math.max(this.t - n, 0);
379
- r.s = this.s;
380
- }
381
-
382
- // (protected) r = this << n
383
- function bnpLShiftTo(n, r) {
384
- var bs = n % this.DB;
385
- var cbs = this.DB - bs;
386
- var bm = (1 << cbs) - 1;
387
- var ds = Math.floor(n / this.DB), c = (this.s << bs) & this.DM, i;
388
- for (i = this.t - 1; i >= 0; --i) {
389
- r[i + ds + 1] = (this[i] >> cbs) | c;
390
- c = (this[i] & bm) << bs;
391
- }
392
- for (i = ds - 1; i >= 0; --i) r[i] = 0;
393
- r[ds] = c;
394
- r.t = this.t + ds + 1;
395
- r.s = this.s;
396
- r.clamp();
397
- }
398
-
399
- // (protected) r = this >> n
400
- function bnpRShiftTo(n, r) {
401
- r.s = this.s;
402
- var ds = Math.floor(n / this.DB);
403
- if (ds >= this.t) { r.t = 0; return; }
404
- var bs = n % this.DB;
405
- var cbs = this.DB - bs;
406
- var bm = (1 << bs) - 1;
407
- r[0] = this[ds] >> bs;
408
- for (var i = ds + 1; i < this.t; ++i) {
409
- r[i - ds - 1] |= (this[i] & bm) << cbs;
410
- r[i - ds] = this[i] >> bs;
411
- }
412
- if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
413
- r.t = this.t - ds;
414
- r.clamp();
415
- }
416
-
417
- // (protected) r = this - a
418
- function bnpSubTo(a, r) {
419
- var i = 0, c = 0, m = Math.min(a.t, this.t);
420
- while (i < m) {
421
- c += this[i] - a[i];
422
- r[i++] = c & this.DM;
423
- c >>= this.DB;
424
- }
425
- if (a.t < this.t) {
426
- c -= a.s;
427
- while (i < this.t) {
428
- c += this[i];
429
- r[i++] = c & this.DM;
430
- c >>= this.DB;
431
- }
432
- c += this.s;
433
- }
434
- else {
435
- c += this.s;
436
- while (i < a.t) {
437
- c -= a[i];
438
- r[i++] = c & this.DM;
439
- c >>= this.DB;
440
- }
441
- c -= a.s;
442
- }
443
- r.s = (c < 0) ? -1 : 0;
444
- if (c < -1) r[i++] = this.DV + c;
445
- else if (c > 0) r[i++] = c;
446
- r.t = i;
447
- r.clamp();
448
- }
449
-
450
- // (protected) r = this * a, r != this,a (HAC 14.12)
451
- // "this" should be the larger one if appropriate.
452
- function bnpMultiplyTo(a, r) {
453
- var x = this.abs(), y = a.abs();
454
- var i = x.t;
455
- r.t = i + y.t;
456
- while (--i >= 0) r[i] = 0;
457
- for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
458
- r.s = 0;
459
- r.clamp();
460
- if (this.s != a.s) BigInteger.ZERO.subTo(r, r);
461
- }
462
-
463
- // (protected) r = this^2, r != this (HAC 14.16)
464
- function bnpSquareTo(r) {
465
- var x = this.abs();
466
- var i = r.t = 2 * x.t;
467
- while (--i >= 0) r[i] = 0;
468
- for (i = 0; i < x.t - 1; ++i) {
469
- var c = x.am(i, x[i], r, 2 * i, 0, 1);
470
- if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
471
- r[i + x.t] -= x.DV;
472
- r[i + x.t + 1] = 1;
473
- }
474
- }
475
- if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
476
- r.s = 0;
477
- r.clamp();
478
- }
479
-
480
- // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
481
- // r != q, this != m. q or r may be null.
482
- function bnpDivRemTo(m, q, r) {
483
- var pm = m.abs();
484
- if (pm.t <= 0) return;
485
- var pt = this.abs();
486
- if (pt.t < pm.t) {
487
- if (q != null) q.fromInt(0);
488
- if (r != null) this.copyTo(r);
489
- return;
490
- }
491
- if (r == null) r = nbi();
492
- var y = nbi(), ts = this.s, ms = m.s;
493
- var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus
494
- if (nsh > 0) { pm.lShiftTo(nsh, y); pt.lShiftTo(nsh, r); }
495
- else { pm.copyTo(y); pt.copyTo(r); }
496
- var ys = y.t;
497
- var y0 = y[ys - 1];
498
- if (y0 == 0) return;
499
- var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
500
- var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;
501
- var i = r.t, j = i - ys, t = (q == null) ? nbi() : q;
502
- y.dlShiftTo(j, t);
503
- if (r.compareTo(t) >= 0) {
504
- r[r.t++] = 1;
505
- r.subTo(t, r);
506
- }
507
- BigInteger.ONE.dlShiftTo(ys, t);
508
- t.subTo(y, y); // "negative" y so we can replace sub with am later
509
- while (y.t < ys) y[y.t++] = 0;
510
- while (--j >= 0) {
511
- // Estimate quotient digit
512
- var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
513
- if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out
514
- y.dlShiftTo(j, t);
515
- r.subTo(t, r);
516
- while (r[i] < --qd) r.subTo(t, r);
517
- }
518
- }
519
- if (q != null) {
520
- r.drShiftTo(ys, q);
521
- if (ts != ms) BigInteger.ZERO.subTo(q, q);
522
- }
523
- r.t = ys;
524
- r.clamp();
525
- if (nsh > 0) r.rShiftTo(nsh, r); // Denormalize remainder
526
- if (ts < 0) BigInteger.ZERO.subTo(r, r);
527
- }
528
-
529
- // (public) this mod a
530
- function bnMod(a) {
531
- var r = nbi();
532
- this.abs().divRemTo(a, null, r);
533
- if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
534
- return r;
535
- }
536
-
537
- // Modular reduction using "classic" algorithm
538
- function Classic(m) { this.m = m; }
539
- function cConvert(x) {
540
- if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
541
- else return x;
542
- }
543
- function cRevert(x) { return x; }
544
- function cReduce(x) { x.divRemTo(this.m, null, x); }
545
- function cMulTo(x, y, r) { x.multiplyTo(y, r); this.reduce(r); }
546
- function cSqrTo(x, r) { x.squareTo(r); this.reduce(r); }
547
-
548
- Classic.prototype.convert = cConvert;
549
- Classic.prototype.revert = cRevert;
550
- Classic.prototype.reduce = cReduce;
551
- Classic.prototype.mulTo = cMulTo;
552
- Classic.prototype.sqrTo = cSqrTo;
553
-
554
- // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
555
- // justification:
556
- // xy == 1 (mod m)
557
- // xy = 1+km
558
- // xy(2-xy) = (1+km)(1-km)
559
- // x[y(2-xy)] = 1-k^2m^2
560
- // x[y(2-xy)] == 1 (mod m^2)
561
- // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
562
- // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
563
- // JS multiply "overflows" differently from C/C++, so care is needed here.
564
- function bnpInvDigit() {
565
- if (this.t < 1) return 0;
566
- var x = this[0];
567
- if ((x & 1) == 0) return 0;
568
- var y = x & 3; // y == 1/x mod 2^2
569
- y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
570
- y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
571
- y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
572
- // last step - calculate inverse mod DV directly;
573
- // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
574
- y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits
575
- // we really want the negative inverse, and -DV < y < DV
576
- return (y > 0) ? this.DV - y : -y;
577
- }
578
-
579
- // Montgomery reduction
580
- function Montgomery(m) {
581
- this.m = m;
582
- this.mp = m.invDigit();
583
- this.mpl = this.mp & 0x7fff;
584
- this.mph = this.mp >> 15;
585
- this.um = (1 << (m.DB - 15)) - 1;
586
- this.mt2 = 2 * m.t;
587
- }
588
-
589
- // xR mod m
590
- function montConvert(x) {
591
- var r = nbi();
592
- x.abs().dlShiftTo(this.m.t, r);
593
- r.divRemTo(this.m, null, r);
594
- if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
595
- return r;
596
- }
597
-
598
- // x/R mod m
599
- function montRevert(x) {
600
- var r = nbi();
601
- x.copyTo(r);
602
- this.reduce(r);
603
- return r;
604
- }
605
-
606
- // x = x/R mod m (HAC 14.32)
607
- function montReduce(x) {
608
- while (x.t <= this.mt2) // pad x so am has enough room later
609
- x[x.t++] = 0;
610
- for (var i = 0; i < this.m.t; ++i) {
611
- // faster way of calculating u0 = x[i]*mp mod DV
612
- var j = x[i] & 0x7fff;
613
- var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
614
- // use am to combine the multiply-shift-add into one call
615
- j = i + this.m.t;
616
- x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
617
- // propagate carry
618
- while (x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
619
- }
620
- x.clamp();
621
- x.drShiftTo(this.m.t, x);
622
- if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
623
- }
624
-
625
- // r = "x^2/R mod m"; x != r
626
- function montSqrTo(x, r) { x.squareTo(r); this.reduce(r); }
627
-
628
- // r = "xy/R mod m"; x,y != r
629
- function montMulTo(x, y, r) { x.multiplyTo(y, r); this.reduce(r); }
630
-
631
- Montgomery.prototype.convert = montConvert;
632
- Montgomery.prototype.revert = montRevert;
633
- Montgomery.prototype.reduce = montReduce;
634
- Montgomery.prototype.mulTo = montMulTo;
635
- Montgomery.prototype.sqrTo = montSqrTo;
636
-
637
- // (protected) true iff this is even
638
- function bnpIsEven() { return ((this.t > 0) ? (this[0] & 1) : this.s) == 0; }
639
-
640
- // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
641
- function bnpExp(e, z) {
642
- if (e > 0xffffffff || e < 1) return BigInteger.ONE;
643
- var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e) - 1;
644
- g.copyTo(r);
645
- while (--i >= 0) {
646
- z.sqrTo(r, r2);
647
- if ((e & (1 << i)) > 0) z.mulTo(r2, g, r);
648
- else { var t = r; r = r2; r2 = t; }
649
- }
650
- return z.revert(r);
651
- }
652
-
653
- // (public) this^e % m, 0 <= e < 2^32
654
- function bnModPowInt(e, m) {
655
- var z;
656
- if (e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
657
- return this.exp(e, z);
658
- }
659
-
660
- // protected
661
- BigInteger.prototype.copyTo = bnpCopyTo;
662
- BigInteger.prototype.fromInt = bnpFromInt;
663
- BigInteger.prototype.fromString = bnpFromString;
664
- BigInteger.prototype.clamp = bnpClamp;
665
- BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
666
- BigInteger.prototype.drShiftTo = bnpDRShiftTo;
667
- BigInteger.prototype.lShiftTo = bnpLShiftTo;
668
- BigInteger.prototype.rShiftTo = bnpRShiftTo;
669
- BigInteger.prototype.subTo = bnpSubTo;
670
- BigInteger.prototype.multiplyTo = bnpMultiplyTo;
671
- BigInteger.prototype.squareTo = bnpSquareTo;
672
- BigInteger.prototype.divRemTo = bnpDivRemTo;
673
- BigInteger.prototype.invDigit = bnpInvDigit;
674
- BigInteger.prototype.isEven = bnpIsEven;
675
- BigInteger.prototype.exp = bnpExp;
676
-
677
- // public
678
- BigInteger.prototype.toString = bnToString;
679
- BigInteger.prototype.negate = bnNegate;
680
- BigInteger.prototype.abs = bnAbs;
681
- BigInteger.prototype.compareTo = bnCompareTo;
682
- BigInteger.prototype.bitLength = bnBitLength;
683
- BigInteger.prototype.mod = bnMod;
684
- BigInteger.prototype.modPowInt = bnModPowInt;
685
-
686
- // "constants"
687
- BigInteger.ZERO = nbv(0);
688
- BigInteger.ONE = nbv(1);
689
-
690
-
691
- // prng4.js - uses Arcfour as a PRNG
692
-
693
- function Arcfour() {
694
- this.i = 0;
695
- this.j = 0;
696
- this.S = new Array();
697
- }
698
-
699
- // Initialize arcfour context from key, an array of ints, each from [0..255]
700
- function ARC4init(key) {
701
- var i, j, t;
702
- for (i = 0; i < 256; ++i)
703
- this.S[i] = i;
704
- j = 0;
705
- for (i = 0; i < 256; ++i) {
706
- j = (j + this.S[i] + key[i % key.length]) & 255;
707
- t = this.S[i];
708
- this.S[i] = this.S[j];
709
- this.S[j] = t;
710
- }
711
- this.i = 0;
712
- this.j = 0;
713
- }
714
-
715
- function ARC4next() {
716
- var t;
717
- this.i = (this.i + 1) & 255;
718
- this.j = (this.j + this.S[this.i]) & 255;
719
- t = this.S[this.i];
720
- this.S[this.i] = this.S[this.j];
721
- this.S[this.j] = t;
722
- return this.S[(t + this.S[this.i]) & 255];
723
- }
724
-
725
- Arcfour.prototype.init = ARC4init;
726
- Arcfour.prototype.next = ARC4next;
727
-
728
- // Plug in your RNG constructor here
729
- function prng_newstate() {
730
- return new Arcfour();
731
- }
732
-
733
- // Pool size must be a multiple of 4 and greater than 32.
734
- // An array of bytes the size of the pool will be passed to init()
735
- var rng_psize = 256;
736
-
737
- // Random number generator - requires a PRNG backend, e.g. prng4.js
738
-
739
- // For best results, put code like
740
- // <body onClick='rng_seed_time();' onKeyPress='rng_seed_time();'>
741
- // in your main HTML document.
742
-
743
- var rng_state;
744
- var rng_pool;
745
- var rng_pptr;
746
-
747
- // Mix in a 32-bit integer into the pool
748
- function rng_seed_int(x) {
749
- rng_pool[rng_pptr++] ^= x & 255;
750
- rng_pool[rng_pptr++] ^= (x >> 8) & 255;
751
- rng_pool[rng_pptr++] ^= (x >> 16) & 255;
752
- rng_pool[rng_pptr++] ^= (x >> 24) & 255;
753
- if (rng_pptr >= rng_psize) rng_pptr -= rng_psize;
754
- }
755
-
756
- // Mix in the current time (w/milliseconds) into the pool
757
- function rng_seed_time() {
758
- rng_seed_int(new Date().getTime());
759
- }
760
-
761
- // Initialize the pool with junk if needed.
762
- if (rng_pool == null) {
763
- rng_pool = new Array();
764
- rng_pptr = 0;
765
- var t;
766
- if (window.crypto && window.crypto.getRandomValues) {
767
- // Use webcrypto if available
768
- var ua = new Uint8Array(32);
769
- window.crypto.getRandomValues(ua);
770
- for (t = 0; t < 32; ++t)
771
- rng_pool[rng_pptr++] = ua[t];
772
- }
773
- if (navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto) {
774
- // Extract entropy (256 bits) from NS4 RNG if available
775
- var z = window.crypto.random(32);
776
- for (t = 0; t < z.length; ++t)
777
- rng_pool[rng_pptr++] = z.charCodeAt(t) & 255;
778
- }
779
- while (rng_pptr < rng_psize) { // extract some randomness from Math.random()
780
- t = Math.floor(65536 * Math.random());
781
- rng_pool[rng_pptr++] = t >>> 8;
782
- rng_pool[rng_pptr++] = t & 255;
783
- }
784
- rng_pptr = 0;
785
- rng_seed_time();
786
- //rng_seed_int(window.screenX);
787
- //rng_seed_int(window.screenY);
788
- }
789
-
790
- function rng_get_byte() {
791
- if (rng_state == null) {
792
- rng_seed_time();
793
- rng_state = prng_newstate();
794
- rng_state.init(rng_pool);
795
- for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
796
- rng_pool[rng_pptr] = 0;
797
- rng_pptr = 0;
798
- //rng_pool = null;
799
- }
800
- // TODO: allow reseeding after first request
801
- return rng_state.next();
802
- }
803
-
804
- function rng_get_bytes(ba) {
805
- var i;
806
- for (i = 0; i < ba.length; ++i) ba[i] = rng_get_byte();
807
- }
808
-
809
- function SecureRandom() { }
810
-
811
- SecureRandom.prototype.nextBytes = rng_get_bytes;
812
-
813
-
814
- // Depends on jsbn.js and rng.js
815
-
816
- // Version 1.1: support utf-8 encoding in pkcs1pad2
817
-
818
- // convert a (hex) string to a bignum object
819
- function parseBigInt(str, r) {
820
- return new BigInteger(str, r);
821
- }
822
-
823
- function linebrk(s, n) {
824
- var ret = "";
825
- var i = 0;
826
- while (i + n < s.length) {
827
- ret += s.substring(i, i + n) + "\n";
828
- i += n;
829
- }
830
- return ret + s.substring(i, s.length);
831
- }
832
-
833
- function byte2Hex(b) {
834
- if (b < 0x10)
835
- return "0" + b.toString(16);
836
- else
837
- return b.toString(16);
838
- }
839
-
840
- // PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint
841
- function pkcs1pad2(s, n) {
842
- if (n < s.length + 11) { // TODO: fix for utf-8
843
- alert("Message too long for RSA");
844
- return null;
845
- }
846
- var ba = new Array();
847
- var i = s.length - 1;
848
- while (i >= 0 && n > 0) {
849
- var c = s.charCodeAt(i--);
850
- if (c < 128) { // encode using utf-8
851
- ba[--n] = c;
852
- }
853
- else if ((c > 127) && (c < 2048)) {
854
- ba[--n] = (c & 63) | 128;
855
- ba[--n] = (c >> 6) | 192;
856
- }
857
- else {
858
- ba[--n] = (c & 63) | 128;
859
- ba[--n] = ((c >> 6) & 63) | 128;
860
- ba[--n] = (c >> 12) | 224;
861
- }
862
- }
863
- ba[--n] = 0;
864
- var rng = new SecureRandom();
865
- var x = new Array();
866
- while (n > 2) { // random non-zero pad
867
- x[0] = 0;
868
- while (x[0] == 0) rng.nextBytes(x);
869
- ba[--n] = x[0];
870
- }
871
- ba[--n] = 2;
872
- ba[--n] = 0;
873
- return new BigInteger(ba);
874
- }
875
-
876
- // "empty" RSA key constructor
877
- function RSAKey() {
878
- this.n = null;
879
- this.e = 0;
880
- this.d = null;
881
- this.p = null;
882
- this.q = null;
883
- this.dmp1 = null;
884
- this.dmq1 = null;
885
- this.coeff = null;
886
- }
887
-
888
- // Set the public key fields N and e from hex strings
889
- function RSASetPublic(N, E) {
890
- if (N != null && E != null && N.length > 0 && E.length > 0) {
891
- this.n = parseBigInt(N, 16);
892
- this.e = parseInt(E, 16);
893
- }
894
- else
895
- alert("Invalid RSA public key");
896
- }
897
-
898
- // Perform raw public operation on "x": return x^e (mod n)
899
- function RSADoPublic(x) {
900
- return x.modPowInt(this.e, this.n);
901
- }
902
-
903
- // Return the PKCS#1 RSA encryption of "text" as an even-length hex string
904
- function RSAEncrypt(text) {
905
- var m = pkcs1pad2(text, (this.n.bitLength() + 7) >> 3);
906
- if (m == null) return null;
907
- var c = this.doPublic(m);
908
- if (c == null) return null;
909
- var h = c.toString(16);
910
- if ((h.length & 1) == 0) return hex2b64(h); else return hex2b64("0" + h);
911
- }
912
-
913
- // Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string
914
- //function RSAEncryptB64(text) {
915
- // var h = this.encrypt(text);
916
- // if (h) return hex2b64(h); else return null;
917
- //}
918
-
919
- // protected
920
- RSAKey.prototype.doPublic = RSADoPublic;
921
-
922
- // public
923
- RSAKey.prototype.setPublic = RSASetPublic;
924
- RSAKey.prototype.encrypt = RSAEncrypt;
925
-
926
- // base64.js
927
-
928
- var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
929
- var b64padchar = "=";
930
-
931
- function hex2b64(h) {
932
- var i;
933
- var c;
934
- var ret = "";
935
- for (i = 0; i + 3 <= h.length; i += 3) {
936
- c = parseInt(h.substring(i, i + 3), 16);
937
- ret += b64map.charAt(c >> 6) + b64map.charAt(c & 63);
938
- }
939
- if (i + 1 == h.length) {
940
- c = parseInt(h.substring(i, i + 1), 16);
941
- ret += b64map.charAt(c << 2);
942
- }
943
- else if (i + 2 == h.length) {
944
- c = parseInt(h.substring(i, i + 2), 16);
945
- ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4);
946
- }
947
- while ((ret.length & 3) > 0) ret += b64padchar;
948
- return ret;
949
- }
950
-
951
- // convert a base64 string to hex
952
- function b64tohex(s) {
953
- var ret = ""
954
- var i;
955
- var k = 0; // b64 state, 0-3
956
- var slop;
957
- for (i = 0; i < s.length; ++i) {
958
- if (s.charAt(i) == b64padchar) break;
959
- v = b64map.indexOf(s.charAt(i));
960
- if (v < 0) continue;
961
- if (k == 0) {
962
- ret += int2char(v >> 2);
963
- slop = v & 3;
964
- k = 1;
965
- }
966
- else if (k == 1) {
967
- ret += int2char((slop << 2) | (v >> 4));
968
- slop = v & 0xf;
969
- k = 2;
970
- }
971
- else if (k == 2) {
972
- ret += int2char(slop);
973
- ret += int2char(v >> 2);
974
- slop = v & 3;
975
- k = 3;
976
- }
977
- else {
978
- ret += int2char((slop << 2) | (v >> 4));
979
- ret += int2char(v & 0xf);
980
- k = 0;
981
- }
982
- }
983
- if (k == 1)
984
- ret += int2char(slop << 2);
985
- return ret;
986
- }
987
-
988
- // convert a base64 string to a byte/number array
989
- function b64toBA(s) {
990
- //piggyback on b64tohex for now, optimize later
991
- var h = b64tohex(s);
992
- var i;
993
- var a = new Array();
994
- for (i = 0; 2 * i < h.length; ++i) {
995
- a[i] = parseInt(h.substring(2 * i, 2 * i + 2), 16);
996
- }
997
- return a;
998
- }
999
-
1000
- eCrypt.init = eCryptInit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1001
  })(eCrypt);
1
+ // eWAY RSA Client Cryptography
2
+ // Version 0.6 Alpha
3
+
4
+ function eCrypt() {
5
+ this.init = null;
6
+ this.doEncrypt = null;
7
+ }
8
+
9
+ (function (eCrypt) {
10
+ function eCryptInit() {
11
+
12
+ var ewayPublicKeyAttribute = "data-eway-encrypt-key";
13
+ var ewayEncryptAttribute = "data-eway-encrypt-name";
14
+
15
+ var PUBLIC_KEY_N = null;
16
+ var PUBLIC_KEY_E = b64tohex("AQAB");
17
+
18
+ var isAjaxCall = false;
19
+
20
+ // TODO: How should we handle form not found...
21
+ var form = findFormToEncrypt();
22
+ extractPublicKey(form);
23
+ addSubmitEvent(form);
24
+
25
+ function encryptForm(event) {
26
+ try {
27
+ var target;
28
+ // the form is not the event target in ajax call, so we use form variable found before
29
+ if(form != null) {
30
+ target = form;
31
+ } else {
32
+ event = event || window.event; // event is undefined in IE
33
+ target = event.target || event.srcElement; // IE uses srcElement, everything else uses target
34
+ }
35
+ var rsa = new RSAKey();
36
+ rsa.setPublic(PUBLIC_KEY_N, PUBLIC_KEY_E);
37
+ var newForm = cloneForm(target);
38
+ if (newForm.id) {
39
+ newForm.id = "EWAY_CLONED_" + newForm.id;
40
+ }
41
+
42
+ for (formNode = 0, formLength = newForm.length; formNode < formLength; formNode++) {
43
+ var dataAttribute = newForm[formNode].getAttribute(ewayEncryptAttribute);
44
+ if (dataAttribute != null) {
45
+ encryptElement(newForm[formNode], rsa);
46
+ }
47
+ else if (newForm[formNode].id) {
48
+ newForm[formNode].id = "EWAY_ENCRYPTED_" + newForm[formNode].id;
49
+ }
50
+ }
51
+
52
+ newForm.style.display = "none";
53
+ form.parentNode.appendChild(newForm); //IE and FF will not submit form without it being inserted into the DOM
54
+ if(isAjaxCall) {
55
+ return newForm;
56
+ } else {
57
+ var formProxy = document.createElement('form');
58
+ formProxy.submit.apply(newForm); // To guard against a form with a button named 'submit'
59
+ }
60
+ }
61
+ catch (err) {
62
+ // Debugging - In case console not open in IE
63
+ if (!window.console) window.console = {};
64
+ if (!window.console.log) window.console.log = function () { };
65
+ console.log('Uh oh, something went wrong');
66
+ console.log(err);
67
+ console.log(err.message);
68
+ }
69
+ finally {
70
+ if(!isAjaxCall) {
71
+ return false;
72
+ }
73
+ }
74
+ }
75
+
76
+ function findFormToEncrypt() {
77
+ var forms = document.getElementsByTagName('form');
78
+ for (var i = 0; i < forms.length; i++) {
79
+ var key = forms[i].getAttribute(ewayPublicKeyAttribute);
80
+ if (key) {
81
+ return forms[i];
82
+ }
83
+ }
84
+ return null;
85
+ }
86
+
87
+ function extractPublicKey(f) {
88
+ PUBLIC_KEY_N = b64tohex(f.getAttribute(ewayPublicKeyAttribute));
89
+ }
90
+
91
+ function cloneForm(oldForm) {
92
+ var newForm = oldForm.cloneNode(true);
93
+ copySelectLists(oldForm, newForm);
94
+ copyTextAreas(oldForm, newForm);
95
+ copyCheckboxAndRadioValues(oldForm, newForm);
96
+ return newForm;
97
+ }
98
+
99
+ function copySelectLists(oldForm, newForm) {
100
+ var selectElementsOld = oldForm.getElementsByTagName('Select');
101
+ var selectElementsNew = newForm.getElementsByTagName('Select');
102
+
103
+ for (var i = 0; i < selectElementsOld.length; i++) {
104
+ selectElementsNew[i].selectedIndex = selectElementsOld[i].selectedIndex;
105
+ }
106
+ }
107
+
108
+ function copyTextAreas(oldForm, newForm) {
109
+ var textElementsOld = oldForm.getElementsByTagName('TextArea');
110
+ var textElementsNew = newForm.getElementsByTagName('TextArea');
111
+
112
+ for (var i = 0; i < textElementsOld.length; i++) {
113
+ textElementsNew[i].value = textElementsOld[i].value;
114
+ }
115
+ }
116
+
117
+ function copyCheckboxAndRadioValues(oldForm, newForm) {
118
+ var inputsOld = oldForm.getElementsByTagName('input');
119
+ var inputsNew = newForm.getElementsByTagName('input');
120
+
121
+ for (var i = 0; i < inputsOld.length; i++) {
122
+ if (inputsOld[i].type === 'checkbox' || inputsOld[i].type === 'radio') {
123
+ inputsNew[i].checked = inputsOld[i].checked; // Need this for IE
124
+ inputsNew[i].value = inputsOld[i].value; // Need this for IE10
125
+ }
126
+ }
127
+ }
128
+
129
+ function encryptElement(element, rsa) {
130
+ if (element.id) {
131
+ element.id = "EWAY_ENCRYPTED_" + element.id;
132
+ }
133
+ element.name = element.getAttribute(ewayEncryptAttribute);
134
+ element.value = "eCrypted:" + rsa.encrypt(element.value);
135
+ }
136
+
137
+ function addSubmitEvent(frm) {
138
+ var oldonsubmit = frm.onsubmit;
139
+ if (typeof frm.onsubmit != 'function') {
140
+ frm.onsubmit = encryptForm;
141
+ } else {
142
+ frm.onsubmit = function (e) {
143
+ if (!oldonsubmit(e)) {
144
+ return false;
145
+ };
146
+ return encryptForm(e);
147
+ }
148
+ }
149
+
150
+ eCrypt.doEncrypt = function() {
151
+ isAjaxCall = true;
152
+ return encryptForm();
153
+ }
154
+ }
155
+ };
156
+
157
+
158
+
159
+ // Start jsbn.js
160
+ var dbits;
161
+
162
+ // JavaScript engine analysis
163
+ var canary = 0xdeadbeefcafe;
164
+ var j_lm = ((canary & 0xffffff) == 0xefcafe);
165
+
166
+ // (public) Constructor
167
+ function BigInteger(a, b, c) {
168
+ if (a != null)
169
+ if ("number" == typeof a) this.fromNumber(a, b, c);
170
+ else if (b == null && "string" != typeof a) this.fromString(a, 256);
171
+ else this.fromString(a, b);
172
+ }
173
+
174
+ // return new, unset BigInteger
175
+ function nbi() { return new BigInteger(null); }
176
+
177
+ // am: Compute w_j += (x*this_i), propagate carries,
178
+ // c is initial carry, returns final carry.
179
+ // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
180
+ // We need to select the fastest one that works in this environment.
181
+
182
+ // am1: use a single mult and divide to get the high bits,
183
+ // max digit bits should be 26 because
184
+ // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
185
+ function am1(i, x, w, j, c, n) {
186
+ while (--n >= 0) {
187
+ var v = x * this[i++] + w[j] + c;
188
+ c = Math.floor(v / 0x4000000);
189
+ w[j++] = v & 0x3ffffff;
190
+ }
191
+ return c;
192
+ }
193
+ // am2 avoids a big mult-and-extract completely.
194
+ // Max digit bits should be <= 30 because we do bitwise ops
195
+ // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
196
+ function am2(i, x, w, j, c, n) {
197
+ var xl = x & 0x7fff, xh = x >> 15;
198
+ while (--n >= 0) {
199
+ var l = this[i] & 0x7fff;
200
+ var h = this[i++] >> 15;
201
+ var m = xh * l + h * xl;
202
+ l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
203
+ c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
204
+ w[j++] = l & 0x3fffffff;
205
+ }
206
+ return c;
207
+ }
208
+ // Alternately, set max digit bits to 28 since some
209
+ // browsers slow down when dealing with 32-bit numbers.
210
+ function am3(i, x, w, j, c, n) {
211
+ var xl = x & 0x3fff, xh = x >> 14;
212
+ while (--n >= 0) {
213
+ var l = this[i] & 0x3fff;
214
+ var h = this[i++] >> 14;
215
+ var m = xh * l + h * xl;
216
+ l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
217
+ c = (l >> 28) + (m >> 14) + xh * h;
218
+ w[j++] = l & 0xfffffff;
219
+ }
220
+ return c;
221
+ }
222
+ if (j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
223
+ BigInteger.prototype.am = am2;
224
+ dbits = 30;
225
+ }
226
+ else if (j_lm && (navigator.appName != "Netscape")) {
227
+ BigInteger.prototype.am = am1;
228
+ dbits = 26;
229
+ }
230
+ else { // Mozilla/Netscape seems to prefer am3
231
+ BigInteger.prototype.am = am3;
232
+ dbits = 28;
233
+ }
234
+
235
+ BigInteger.prototype.DB = dbits;
236
+ BigInteger.prototype.DM = ((1 << dbits) - 1);
237
+ BigInteger.prototype.DV = (1 << dbits);
238
+
239
+ var BI_FP = 52;
240
+ BigInteger.prototype.FV = Math.pow(2, BI_FP);
241
+ BigInteger.prototype.F1 = BI_FP - dbits;
242
+ BigInteger.prototype.F2 = 2 * dbits - BI_FP;
243
+
244
+ // Digit conversions
245
+ var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
246
+ var BI_RC = new Array();
247
+ var rr, vv;
248
+ rr = "0".charCodeAt(0);
249
+ for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
250
+ rr = "a".charCodeAt(0);
251
+ for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
252
+ rr = "A".charCodeAt(0);
253
+ for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
254
+
255
+ function int2char(n) { return BI_RM.charAt(n); }
256
+ function intAt(s, i) {
257
+ var c = BI_RC[s.charCodeAt(i)];
258
+ return (c == null) ? -1 : c;
259
+ }
260
+
261
+ // (protected) copy this to r
262
+ function bnpCopyTo(r) {
263
+ for (var i = this.t - 1; i >= 0; --i) r[i] = this[i];
264
+ r.t = this.t;
265
+ r.s = this.s;
266
+ }
267
+
268
+ // (protected) set from integer value x, -DV <= x < DV
269
+ function bnpFromInt(x) {
270
+ this.t = 1;
271
+ this.s = (x < 0) ? -1 : 0;
272
+ if (x > 0) this[0] = x;
273
+ else if (x < -1) this[0] = x + this.DV;
274
+ else this.t = 0;
275
+ }
276
+
277
+ // return bigint initialized to value
278
+ function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
279
+
280
+ // (protected) set from string and radix
281
+ function bnpFromString(s, b) {
282
+ var k;
283
+ if (b == 16) k = 4;
284
+ else if (b == 8) k = 3;
285
+ else if (b == 256) k = 8; // byte array
286
+ else if (b == 2) k = 1;
287
+ else if (b == 32) k = 5;
288
+ else if (b == 4) k = 2;
289
+ else { this.fromRadix(s, b); return; }
290
+ this.t = 0;
291
+ this.s = 0;
292
+ var i = s.length, mi = false, sh = 0;
293
+ while (--i >= 0) {
294
+ var x = (k == 8) ? s[i] & 0xff : intAt(s, i);
295
+ if (x < 0) {
296
+ if (s.charAt(i) == "-") mi = true;
297
+ continue;
298
+ }
299
+ mi = false;
300
+ if (sh == 0)
301
+ this[this.t++] = x;
302
+ else if (sh + k > this.DB) {
303
+ this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
304
+ this[this.t++] = (x >> (this.DB - sh));
305
+ }
306
+ else
307
+ this[this.t - 1] |= x << sh;
308
+ sh += k;
309
+ if (sh >= this.DB) sh -= this.DB;
310
+ }
311
+ if (k == 8 && (s[0] & 0x80) != 0) {
312
+ this.s = -1;
313
+ if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
314
+ }
315
+ this.clamp();
316
+ if (mi) BigInteger.ZERO.subTo(this, this);
317
+ }
318
+
319
+ // (protected) clamp off excess high words
320
+ function bnpClamp() {
321
+ var c = this.s & this.DM;
322
+ while (this.t > 0 && this[this.t - 1] == c)--this.t;
323
+ }
324
+
325
+ // (public) return string representation in given radix
326
+ function bnToString(b) {
327
+ if (this.s < 0) return "-" + this.negate().toString(b);
328
+ var k;
329
+ if (b == 16) k = 4;
330
+ else if (b == 8) k = 3;
331
+ else if (b == 2) k = 1;
332
+ else if (b == 32) k = 5;
333
+ else if (b == 4) k = 2;
334
+ else return this.toRadix(b);
335
+ var km = (1 << k) - 1, d, m = false, r = "", i = this.t;
336
+ var p = this.DB - (i * this.DB) % k;
337
+ if (i-- > 0) {
338
+ if (p < this.DB && (d = this[i] >> p) > 0) { m = true; r = int2char(d); }
339
+ while (i >= 0) {
340
+ if (p < k) {
341
+ d = (this[i] & ((1 << p) - 1)) << (k - p);
342
+ d |= this[--i] >> (p += this.DB - k);
343
+ }
344
+ else {
345
+ d = (this[i] >> (p -= k)) & km;
346
+ if (p <= 0) { p += this.DB; --i; }
347
+ }
348
+ if (d > 0) m = true;
349
+ if (m) r += int2char(d);
350
+ }
351
+ }
352
+ return m ? r : "0";
353
+ }
354
+
355
+ // (public) -this
356
+ function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this, r); return r; }
357
+
358
+ // (public) |this|
359
+ function bnAbs() { return (this.s < 0) ? this.negate() : this; }
360
+
361
+ // (public) return + if this > a, - if this < a, 0 if equal
362
+ function bnCompareTo(a) {
363
+ var r = this.s - a.s;
364
+ if (r != 0) return r;
365
+ var i = this.t;
366
+ r = i - a.t;
367
+ if (r != 0) return (this.s < 0) ? -r : r;
368
+ while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r;
369
+ return 0;
370
+ }
371
+
372
+ // returns bit length of the integer x
373
+ function nbits(x) {
374
+ var r = 1, t;
375
+ if ((t = x >>> 16) != 0) { x = t; r += 16; }
376
+ if ((t = x >> 8) != 0) { x = t; r += 8; }
377
+ if ((t = x >> 4) != 0) { x = t; r += 4; }
378
+ if ((t = x >> 2) != 0) { x = t; r += 2; }
379
+ if ((t = x >> 1) != 0) { x = t; r += 1; }
380
+ return r;
381
+ }
382
+
383
+ // (public) return the number of bits in "this"
384
+ function bnBitLength() {
385
+ if (this.t <= 0) return 0;
386
+ return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
387
+ }
388
+
389
+ // (protected) r = this << n*DB
390
+ function bnpDLShiftTo(n, r) {
391
+ var i;
392
+ for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i];
393
+ for (i = n - 1; i >= 0; --i) r[i] = 0;
394
+ r.t = this.t + n;
395
+ r.s = this.s;
396
+ }
397
+
398
+ // (protected) r = this >> n*DB
399
+ function bnpDRShiftTo(n, r) {
400
+ for (var i = n; i < this.t; ++i) r[i - n] = this[i];
401
+ r.t = Math.max(this.t - n, 0);
402
+ r.s = this.s;
403
+ }
404
+
405
+ // (protected) r = this << n
406
+ function bnpLShiftTo(n, r) {
407
+ var bs = n % this.DB;
408
+ var cbs = this.DB - bs;
409
+ var bm = (1 << cbs) - 1;
410
+ var ds = Math.floor(n / this.DB), c = (this.s << bs) & this.DM, i;
411
+ for (i = this.t - 1; i >= 0; --i) {
412
+ r[i + ds + 1] = (this[i] >> cbs) | c;
413
+ c = (this[i] & bm) << bs;
414
+ }
415
+ for (i = ds - 1; i >= 0; --i) r[i] = 0;
416
+ r[ds] = c;
417
+ r.t = this.t + ds + 1;
418
+ r.s = this.s;
419
+ r.clamp();
420
+ }
421
+
422
+ // (protected) r = this >> n
423
+ function bnpRShiftTo(n, r) {
424
+ r.s = this.s;
425
+ var ds = Math.floor(n / this.DB);
426
+ if (ds >= this.t) { r.t = 0; return; }
427
+ var bs = n % this.DB;
428
+ var cbs = this.DB - bs;
429
+ var bm = (1 << bs) - 1;
430
+ r[0] = this[ds] >> bs;
431
+ for (var i = ds + 1; i < this.t; ++i) {
432
+ r[i - ds - 1] |= (this[i] & bm) << cbs;
433
+ r[i - ds] = this[i] >> bs;
434
+ }
435
+ if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
436
+ r.t = this.t - ds;
437
+ r.clamp();
438
+ }
439
+
440
+ // (protected) r = this - a
441
+ function bnpSubTo(a, r) {
442
+ var i = 0, c = 0, m = Math.min(a.t, this.t);
443
+ while (i < m) {
444
+ c += this[i] - a[i];
445
+ r[i++] = c & this.DM;
446
+ c >>= this.DB;
447
+ }
448
+ if (a.t < this.t) {
449
+ c -= a.s;
450
+ while (i < this.t) {
451
+ c += this[i];
452
+ r[i++] = c & this.DM;
453
+ c >>= this.DB;
454
+ }
455
+ c += this.s;
456
+ }
457
+ else {
458
+ c += this.s;
459
+ while (i < a.t) {
460
+ c -= a[i];
461
+ r[i++] = c & this.DM;
462
+ c >>= this.DB;
463
+ }
464
+ c -= a.s;
465
+ }
466
+ r.s = (c < 0) ? -1 : 0;
467
+ if (c < -1) r[i++] = this.DV + c;
468
+ else if (c > 0) r[i++] = c;
469
+ r.t = i;
470
+ r.clamp();
471
+ }
472
+
473
+ // (protected) r = this * a, r != this,a (HAC 14.12)
474
+ // "this" should be the larger one if appropriate.
475
+ function bnpMultiplyTo(a, r) {
476
+ var x = this.abs(), y = a.abs();
477
+ var i = x.t;
478
+ r.t = i + y.t;
479
+ while (--i >= 0) r[i] = 0;
480
+ for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
481
+ r.s = 0;
482
+ r.clamp();
483
+ if (this.s != a.s) BigInteger.ZERO.subTo(r, r);
484
+ }
485
+
486
+ // (protected) r = this^2, r != this (HAC 14.16)
487
+ function bnpSquareTo(r) {
488
+ var x = this.abs();
489
+ var i = r.t = 2 * x.t;
490
+ while (--i >= 0) r[i] = 0;
491
+ for (i = 0; i < x.t - 1; ++i) {
492
+ var c = x.am(i, x[i], r, 2 * i, 0, 1);
493
+ if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
494
+ r[i + x.t] -= x.DV;
495
+ r[i + x.t + 1] = 1;
496
+ }
497
+ }
498
+ if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
499
+ r.s = 0;
500
+ r.clamp();
501
+ }
502
+
503
+ // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
504
+ // r != q, this != m. q or r may be null.
505
+ function bnpDivRemTo(m, q, r) {
506
+ var pm = m.abs();
507
+ if (pm.t <= 0) return;
508
+ var pt = this.abs();
509
+ if (pt.t < pm.t) {
510
+ if (q != null) q.fromInt(0);
511
+ if (r != null) this.copyTo(r);
512
+ return;
513
+ }
514
+ if (r == null) r = nbi();
515
+ var y = nbi(), ts = this.s, ms = m.s;
516
+ var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus
517
+ if (nsh > 0) { pm.lShiftTo(nsh, y); pt.lShiftTo(nsh, r); }
518
+ else { pm.copyTo(y); pt.copyTo(r); }
519
+ var ys = y.t;
520
+ var y0 = y[ys - 1];
521
+ if (y0 == 0) return;
522
+ var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
523
+ var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;
524
+ var i = r.t, j = i - ys, t = (q == null) ? nbi() : q;
525
+ y.dlShiftTo(j, t);
526
+ if (r.compareTo(t) >= 0) {
527
+ r[r.t++] = 1;
528
+ r.subTo(t, r);
529
+ }
530
+ BigInteger.ONE.dlShiftTo(ys, t);
531
+ t.subTo(y, y); // "negative" y so we can replace sub with am later
532
+ while (y.t < ys) y[y.t++] = 0;
533
+ while (--j >= 0) {
534
+ // Estimate quotient digit
535
+ var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
536
+ if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out
537
+ y.dlShiftTo(j, t);
538
+ r.subTo(t, r);
539
+ while (r[i] < --qd) r.subTo(t, r);
540
+ }
541
+ }
542
+ if (q != null) {
543
+ r.drShiftTo(ys, q);
544
+ if (ts != ms) BigInteger.ZERO.subTo(q, q);
545
+ }
546
+ r.t = ys;
547
+ r.clamp();
548
+ if (nsh > 0) r.rShiftTo(nsh, r); // Denormalize remainder
549
+ if (ts < 0) BigInteger.ZERO.subTo(r, r);
550
+ }
551
+
552
+ // (public) this mod a
553
+ function bnMod(a) {
554
+ var r = nbi();
555
+ this.abs().divRemTo(a, null, r);
556
+ if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
557
+ return r;
558
+ }
559
+
560
+ // Modular reduction using "classic" algorithm
561
+ function Classic(m) { this.m = m; }
562
+ function cConvert(x) {
563
+ if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
564
+ else return x;
565
+ }
566
+ function cRevert(x) { return x; }
567
+ function cReduce(x) { x.divRemTo(this.m, null, x); }
568
+ function cMulTo(x, y, r) { x.multiplyTo(y, r); this.reduce(r); }
569
+ function cSqrTo(x, r) { x.squareTo(r); this.reduce(r); }
570
+
571
+ Classic.prototype.convert = cConvert;
572
+ Classic.prototype.revert = cRevert;
573
+ Classic.prototype.reduce = cReduce;
574
+ Classic.prototype.mulTo = cMulTo;
575
+ Classic.prototype.sqrTo = cSqrTo;
576
+
577
+ // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
578
+ // justification:
579
+ // xy == 1 (mod m)
580
+ // xy = 1+km
581
+ // xy(2-xy) = (1+km)(1-km)
582
+ // x[y(2-xy)] = 1-k^2m^2
583
+ // x[y(2-xy)] == 1 (mod m^2)
584
+ // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
585
+ // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
586
+ // JS multiply "overflows" differently from C/C++, so care is needed here.
587
+ function bnpInvDigit() {
588
+ if (this.t < 1) return 0;
589
+ var x = this[0];
590
+ if ((x & 1) == 0) return 0;
591
+ var y = x & 3; // y == 1/x mod 2^2
592
+ y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
593
+ y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
594
+ y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
595
+ // last step - calculate inverse mod DV directly;
596
+ // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
597
+ y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits
598
+ // we really want the negative inverse, and -DV < y < DV
599
+ return (y > 0) ? this.DV - y : -y;
600
+ }
601
+
602
+ // Montgomery reduction
603
+ function Montgomery(m) {
604
+ this.m = m;
605
+ this.mp = m.invDigit();
606
+ this.mpl = this.mp & 0x7fff;
607
+ this.mph = this.mp >> 15;
608
+ this.um = (1 << (m.DB - 15)) - 1;
609
+ this.mt2 = 2 * m.t;
610
+ }
611
+
612
+ // xR mod m
613
+ function montConvert(x) {
614
+ var r = nbi();
615
+ x.abs().dlShiftTo(this.m.t, r);
616
+ r.divRemTo(this.m, null, r);
617
+ if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
618
+ return r;
619
+ }
620
+
621
+ // x/R mod m
622
+ function montRevert(x) {
623
+ var r = nbi();
624
+ x.copyTo(r);
625
+ this.reduce(r);
626
+ return r;
627
+ }
628
+
629
+ // x = x/R mod m (HAC 14.32)
630
+ function montReduce(x) {
631
+ while (x.t <= this.mt2) // pad x so am has enough room later
632
+ x[x.t++] = 0;
633
+ for (var i = 0; i < this.m.t; ++i) {
634
+ // faster way of calculating u0 = x[i]*mp mod DV
635
+ var j = x[i] & 0x7fff;
636
+ var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
637
+ // use am to combine the multiply-shift-add into one call
638
+ j = i + this.m.t;
639
+ x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
640
+ // propagate carry
641
+ while (x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
642
+ }
643
+ x.clamp();
644
+ x.drShiftTo(this.m.t, x);
645
+ if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
646
+ }
647
+
648
+ // r = "x^2/R mod m"; x != r
649
+ function montSqrTo(x, r) { x.squareTo(r); this.reduce(r); }
650
+
651
+ // r = "xy/R mod m"; x,y != r
652
+ function montMulTo(x, y, r) { x.multiplyTo(y, r); this.reduce(r); }
653
+
654
+ Montgomery.prototype.convert = montConvert;
655
+ Montgomery.prototype.revert = montRevert;
656
+ Montgomery.prototype.reduce = montReduce;
657
+ Montgomery.prototype.mulTo = montMulTo;
658
+ Montgomery.prototype.sqrTo = montSqrTo;
659
+
660
+ // (protected) true iff this is even
661
+ function bnpIsEven() { return ((this.t > 0) ? (this[0] & 1) : this.s) == 0; }
662
+
663
+ // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
664
+ function bnpExp(e, z) {
665
+ if (e > 0xffffffff || e < 1) return BigInteger.ONE;
666
+ var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e) - 1;
667
+ g.copyTo(r);
668
+ while (--i >= 0) {
669
+ z.sqrTo(r, r2);
670
+ if ((e & (1 << i)) > 0) z.mulTo(r2, g, r);
671
+ else { var t = r; r = r2; r2 = t; }
672
+ }
673
+ return z.revert(r);
674
+ }
675
+
676
+ // (public) this^e % m, 0 <= e < 2^32
677
+ function bnModPowInt(e, m) {
678
+ var z;
679
+ if (e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
680
+ return this.exp(e, z);
681
+ }
682
+
683
+ // protected
684
+ BigInteger.prototype.copyTo = bnpCopyTo;
685
+ BigInteger.prototype.fromInt = bnpFromInt;
686
+ BigInteger.prototype.fromString = bnpFromString;
687
+ BigInteger.prototype.clamp = bnpClamp;
688
+ BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
689
+ BigInteger.prototype.drShiftTo = bnpDRShiftTo;
690
+ BigInteger.prototype.lShiftTo = bnpLShiftTo;
691
+ BigInteger.prototype.rShiftTo = bnpRShiftTo;
692
+ BigInteger.prototype.subTo = bnpSubTo;
693
+ BigInteger.prototype.multiplyTo = bnpMultiplyTo;
694
+ BigInteger.prototype.squareTo = bnpSquareTo;
695
+ BigInteger.prototype.divRemTo = bnpDivRemTo;
696
+ BigInteger.prototype.invDigit = bnpInvDigit;
697
+ BigInteger.prototype.isEven = bnpIsEven;
698
+ BigInteger.prototype.exp = bnpExp;
699
+
700
+ // public
701
+ BigInteger.prototype.toString = bnToString;
702
+ BigInteger.prototype.negate = bnNegate;
703
+ BigInteger.prototype.abs = bnAbs;
704
+ BigInteger.prototype.compareTo = bnCompareTo;
705
+ BigInteger.prototype.bitLength = bnBitLength;
706
+ BigInteger.prototype.mod = bnMod;
707
+ BigInteger.prototype.modPowInt = bnModPowInt;
708
+
709
+ // "constants"
710
+ BigInteger.ZERO = nbv(0);
711
+ BigInteger.ONE = nbv(1);
712
+
713
+
714
+ // prng4.js - uses Arcfour as a PRNG
715
+
716
+ function Arcfour() {
717
+ this.i = 0;
718
+ this.j = 0;
719
+ this.S = new Array();
720
+ }
721
+
722
+ // Initialize arcfour context from key, an array of ints, each from [0..255]
723
+ function ARC4init(key) {
724
+ var i, j, t;
725
+ for (i = 0; i < 256; ++i)
726
+ this.S[i] = i;
727
+ j = 0;
728
+ for (i = 0; i < 256; ++i) {
729
+ j = (j + this.S[i] + key[i % key.length]) & 255;
730
+ t = this.S[i];
731
+ this.S[i] = this.S[j];
732
+ this.S[j] = t;
733
+ }
734
+ this.i = 0;
735
+ this.j = 0;
736
+ }
737
+
738
+ function ARC4next() {
739
+ var t;
740
+ this.i = (this.i + 1) & 255;
741
+ this.j = (this.j + this.S[this.i]) & 255;
742
+ t = this.S[this.i];
743
+ this.S[this.i] = this.S[this.j];
744
+ this.S[this.j] = t;
745
+ return this.S[(t + this.S[this.i]) & 255];
746
+ }
747
+
748
+ Arcfour.prototype.init = ARC4init;
749
+ Arcfour.prototype.next = ARC4next;
750
+
751
+ // Plug in your RNG constructor here
752
+ function prng_newstate() {
753
+ return new Arcfour();
754
+ }
755
+
756
+ // Pool size must be a multiple of 4 and greater than 32.
757
+ // An array of bytes the size of the pool will be passed to init()
758
+ var rng_psize = 256;
759
+
760
+ // Random number generator - requires a PRNG backend, e.g. prng4.js
761
+
762
+ // For best results, put code like
763
+ // <body onClick='rng_seed_time();' onKeyPress='rng_seed_time();'>
764
+ // in your main HTML document.
765
+
766
+ var rng_state;
767
+ var rng_pool;
768
+ var rng_pptr;
769
+
770
+ // Mix in a 32-bit integer into the pool
771
+ function rng_seed_int(x) {
772
+ rng_pool[rng_pptr++] ^= x & 255;
773
+ rng_pool[rng_pptr++] ^= (x >> 8) & 255;
774
+ rng_pool[rng_pptr++] ^= (x >> 16) & 255;
775
+ rng_pool[rng_pptr++] ^= (x >> 24) & 255;
776
+ if (rng_pptr >= rng_psize) rng_pptr -= rng_psize;
777
+ }
778
+
779
+ // Mix in the current time (w/milliseconds) into the pool
780
+ function rng_seed_time() {
781
+ rng_seed_int(new Date().getTime());
782
+ }
783
+
784
+ // Initialize the pool with junk if needed.
785
+ if (rng_pool == null) {
786
+ rng_pool = new Array();
787
+ rng_pptr = 0;
788
+ var t;
789
+ if (window.crypto && window.crypto.getRandomValues) {
790
+ // Use webcrypto if available
791
+ var ua = new Uint8Array(32);
792
+ window.crypto.getRandomValues(ua);
793
+ for (t = 0; t < 32; ++t)
794
+ rng_pool[rng_pptr++] = ua[t];
795
+ }
796
+ if (navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto) {
797
+ // Extract entropy (256 bits) from NS4 RNG if available
798
+ var z = window.crypto.random(32);
799
+ for (t = 0; t < z.length; ++t)
800
+ rng_pool[rng_pptr++] = z.charCodeAt(t) & 255;
801
+ }
802
+ while (rng_pptr < rng_psize) { // extract some randomness from Math.random()
803
+ t = Math.floor(65536 * Math.random());
804
+ rng_pool[rng_pptr++] = t >>> 8;
805
+ rng_pool[rng_pptr++] = t & 255;
806
+ }
807
+ rng_pptr = 0;
808
+ rng_seed_time();
809
+ //rng_seed_int(window.screenX);
810
+ //rng_seed_int(window.screenY);
811
+ }
812
+
813
+ function rng_get_byte() {
814
+ if (rng_state == null) {
815
+ rng_seed_time();
816
+ rng_state = prng_newstate();
817
+ rng_state.init(rng_pool);
818
+ for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
819
+ rng_pool[rng_pptr] = 0;
820
+ rng_pptr = 0;
821
+ //rng_pool = null;
822
+ }
823
+ // TODO: allow reseeding after first request
824
+ return rng_state.next();
825
+ }
826
+
827
+ function rng_get_bytes(ba) {
828
+ var i;
829
+ for (i = 0; i < ba.length; ++i) ba[i] = rng_get_byte();
830
+ }
831
+
832
+ function SecureRandom() { }
833
+
834
+ SecureRandom.prototype.nextBytes = rng_get_bytes;
835
+
836
+
837
+ // Depends on jsbn.js and rng.js
838
+
839
+ // Version 1.1: support utf-8 encoding in pkcs1pad2
840
+
841
+ // convert a (hex) string to a bignum object
842
+ function parseBigInt(str, r) {
843
+ return new BigInteger(str, r);
844
+ }
845
+
846
+ function linebrk(s, n) {
847
+ var ret = "";
848
+ var i = 0;
849
+ while (i + n < s.length) {
850
+ ret += s.substring(i, i + n) + "\n";
851
+ i += n;
852
+ }
853
+ return ret + s.substring(i, s.length);
854
+ }
855
+
856
+ function byte2Hex(b) {
857
+ if (b < 0x10)
858
+ return "0" + b.toString(16);
859
+ else
860
+ return b.toString(16);
861
+ }
862
+
863
+ // PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint
864
+ function pkcs1pad2(s, n) {
865
+ if (n < s.length + 11) { // TODO: fix for utf-8
866
+ alert("Message too long for RSA");
867
+ return null;
868
+ }
869
+ var ba = new Array();
870
+ var i = s.length - 1;
871
+ while (i >= 0 && n > 0) {
872
+ var c = s.charCodeAt(i--);
873
+ if (c < 128) { // encode using utf-8
874
+ ba[--n] = c;
875
+ }
876
+ else if ((c > 127) && (c < 2048)) {
877
+ ba[--n] = (c & 63) | 128;
878
+ ba[--n] = (c >> 6) | 192;
879
+ }
880
+ else {
881
+ ba[--n] = (c & 63) | 128;
882
+ ba[--n] = ((c >> 6) & 63) | 128;
883
+ ba[--n] = (c >> 12) | 224;
884
+ }
885
+ }
886
+ ba[--n] = 0;
887
+ var rng = new SecureRandom();
888
+ var x = new Array();
889
+ while (n > 2) { // random non-zero pad
890
+ x[0] = 0;
891
+ while (x[0] == 0) rng.nextBytes(x);
892
+ ba[--n] = x[0];
893
+ }
894
+ ba[--n] = 2;
895
+ ba[--n] = 0;
896
+ return new BigInteger(ba);
897
+ }
898
+
899
+ // "empty" RSA key constructor
900
+ function RSAKey() {
901
+ this.n = null;
902
+ this.e = 0;
903
+ this.d = null;
904
+ this.p = null;
905
+ this.q = null;
906
+ this.dmp1 = null;
907
+ this.dmq1 = null;
908
+ this.coeff = null;
909
+ }
910
+
911
+ // Set the public key fields N and e from hex strings
912
+ function RSASetPublic(N, E) {
913
+ if (N != null && E != null && N.length > 0 && E.length > 0) {
914
+ this.n = parseBigInt(N, 16);
915
+ this.e = parseInt(E, 16);
916
+ }
917
+ else
918
+ alert("Invalid RSA public key");
919
+ }
920
+
921
+ // Perform raw public operation on "x": return x^e (mod n)
922
+ function RSADoPublic(x) {
923
+ return x.modPowInt(this.e, this.n);
924
+ }
925
+
926
+ // Return the PKCS#1 RSA encryption of "text" as an even-length hex string
927
+ function RSAEncrypt(text) {
928
+ var m = pkcs1pad2(text, (this.n.bitLength() + 7) >> 3);
929
+ if (m == null) return null;
930
+ var c = this.doPublic(m);
931
+ if (c == null) return null;
932
+ var h = c.toString(16);
933
+ if ((h.length & 1) == 0) return hex2b64(h); else return hex2b64("0" + h);
934
+ }
935
+
936
+ // Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string
937
+ //function RSAEncryptB64(text) {
938
+ // var h = this.encrypt(text);
939
+ // if (h) return hex2b64(h); else return null;
940
+ //}
941
+
942
+ // protected
943
+ RSAKey.prototype.doPublic = RSADoPublic;
944
+
945
+ // public
946
+ RSAKey.prototype.setPublic = RSASetPublic;
947
+ RSAKey.prototype.encrypt = RSAEncrypt;
948
+
949
+ // base64.js
950
+
951
+ var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
952
+ var b64padchar = "=";
953
+
954
+ function hex2b64(h) {
955
+ var i;
956
+ var c;
957
+ var ret = "";
958
+ for (i = 0; i + 3 <= h.length; i += 3) {
959
+ c = parseInt(h.substring(i, i + 3), 16);
960
+ ret += b64map.charAt(c >> 6) + b64map.charAt(c & 63);
961
+ }
962
+ if (i + 1 == h.length) {
963
+ c = parseInt(h.substring(i, i + 1), 16);
964
+ ret += b64map.charAt(c << 2);
965
+ }
966
+ else if (i + 2 == h.length) {
967
+ c = parseInt(h.substring(i, i + 2), 16);
968
+ ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4);
969
+ }
970
+ while ((ret.length & 3) > 0) ret += b64padchar;
971
+ return ret;
972
+ }
973
+
974
+ // convert a base64 string to hex
975
+ function b64tohex(s) {
976
+ var ret = ""
977
+ var i;
978
+ var k = 0; // b64 state, 0-3
979
+ var slop;
980
+ for (i = 0; i < s.length; ++i) {
981
+ if (s.charAt(i) == b64padchar) break;
982
+ v = b64map.indexOf(s.charAt(i));
983
+ if (v < 0) continue;
984
+ if (k == 0) {
985
+ ret += int2char(v >> 2);
986
+ slop = v & 3;
987
+ k = 1;
988
+ }
989
+ else if (k == 1) {
990
+ ret += int2char((slop << 2) | (v >> 4));
991
+ slop = v & 0xf;
992
+ k = 2;
993
+ }
994
+ else if (k == 2) {
995
+ ret += int2char(slop);
996
+ ret += int2char(v >> 2);
997
+ slop = v & 3;
998
+ k = 3;
999
+ }
1000
+ else {
1001
+ ret += int2char((slop << 2) | (v >> 4));
1002
+ ret += int2char(v & 0xf);
1003
+ k = 0;
1004
+ }
1005
+ }
1006
+ if (k == 1)
1007
+ ret += int2char(slop << 2);
1008
+ return ret;
1009
+ }
1010
+
1011
+ // convert a base64 string to a byte/number array
1012
+ function b64toBA(s) {
1013
+ //piggyback on b64tohex for now, optimize later
1014
+ var h = b64tohex(s);
1015
+ var i;
1016
+ var a = new Array();
1017
+ for (i = 0; 2 * i < h.length; ++i) {
1018
+ a[i] = parseInt(h.substring(2 * i, 2 * i + 2), 16);
1019
+ }
1020
+ return a;
1021
+ }
1022
+
1023
+ eCrypt.init = eCryptInit;
1024
  })(eCrypt);
js/ewayrapid/ewayrapid.js CHANGED
@@ -1,682 +1,1009 @@
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
- ewayPayment: this,
8
- initialize: function(form, encryptionKey) {
9
- if(form) {
10
- // Init client-side encryption
11
- if(typeof eCrypt == 'function') {
12
- form.writeAttribute('data-eway-encrypt-key', encryptionKey);
13
- eCrypt && eCrypt.init();
14
- }
15
- }
16
- },
17
-
18
- savePaymentWithEncryption: function() {
19
- if (checkout.loadWaiting!=false) return;
20
- var validator = new Validation(this.form);
21
- if (this.validate() && validator.validate()) {
22
- checkout.setLoadWaiting('payment');
23
- var form = $(this.form);
24
- if($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
25
- form = eCrypt.doEncrypt();
26
- }
27
- this.ewayForm = form;
28
- var request = new Ajax.Request(
29
- this.saveUrl,
30
- {
31
- method:'post',
32
- onComplete: this.onComplete,
33
- onSuccess: this.onSave,
34
- onFailure: checkout.ajaxFailure.bind(checkout),
35
- parameters: $(form.id).serialize()
36
- }
37
- );
38
- }
39
- },
40
-
41
- savePaymentWithTransEncryption: function() {
42
- if (checkout.loadWaiting!=false) return;
43
- var validator = new Validation(this.form);
44
- if (this.validate() && validator.validate()) {
45
- checkout.setLoadWaiting('payment');
46
- var form = $(this.form);
47
- var _method = $$("input[name='payment[method]']:checked")[0].getValue();
48
- var _transparent_method = '';
49
-
50
- if(_method == 'ewayrapid_notsaved' && $$("input[name='payment[transparent_notsaved]']:checked").length > 0) {
51
- _transparent_method = $$("input[name='payment[transparent_notsaved]']:checked")[0];
52
- } else if(_method == 'ewayrapid_saved' && $$("input[name='payment[transparent_saved]']:checked").length > 0) {
53
- _transparent_method = $$("input[name='payment[transparent_saved]']:checked")[0];
54
- }
55
-
56
- if(_transparent_method != '' && $(_transparent_method.id).getValue() == creditcard) {
57
- if($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
58
- form = eCrypt.doEncrypt();
59
- }
60
- }
61
-
62
- this.ewayForm = form;
63
- var request = new Ajax.Request(
64
- this.saveUrl,
65
- {
66
- method:'post',
67
- onComplete: this.onComplete,
68
- onSuccess: this.onSave,
69
- onFailure: checkout.ajaxFailure.bind(checkout),
70
- parameters: $(form.id).serialize()
71
- }
72
- );
73
- }
74
- },
75
-
76
- saveReviewWithEncryption: function() {
77
- if (checkout.loadWaiting!=false) return;
78
- checkout.setLoadWaiting('review');
79
- //var params = Form.serialize(payment.form);
80
- var params = payment.ewayForm.serialize();
81
- if (this.agreementsForm) {
82
- params += '&'+Form.serialize(this.agreementsForm);
83
- }
84
- params.save = true;
85
- var request = new Ajax.Request(
86
- this.saveUrl,
87
- {
88
- method:'post',
89
- parameters:params,
90
- onComplete: this.onComplete,
91
- onSuccess: this.onSave,
92
- onFailure: checkout.ajaxFailure.bind(checkout)
93
- }
94
- );
95
- },
96
-
97
- submitAdminOrder: function() {
98
- if(editForm.validator && editForm.validator.validate()) {
99
- if($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
100
- editForm = eCrypt.doEncrypt();
101
- }
102
- if (this.orderItemChanged) {
103
- if (confirm('You have item changes')) {
104
- if (editForm.submit()) {
105
- disableElements('save');
106
- }
107
- } else {
108
- this.itemsUpdate();
109
- }
110
- } else {
111
- if (editForm.submit()) {
112
- disableElements('save');
113
- }
114
- }
115
- }
116
- },
117
-
118
- OneStepCheckout: {
119
- switchMethod: function(method) {
120
- $$('.payment-method .form-list').each(function(form) {
121
- form.style.display = 'none';
122
- var elements = form.select('input').concat(form.select('select')).concat(form.select('textarea'));
123
- for (var i=0; i<elements.length; i++) elements[i].disabled = true;
124
- });
125
-
126
- if ($('payment_form_'+method)){
127
- var form = $('payment_form_'+method);
128
- form.style.display = '';
129
- var elements = form.select('input').concat(form.select('select')).concat(form.select('textarea'));
130
- for (var i=0; i<elements.length; i++) elements[i].disabled = false;
131
- this.currentMethod = method;
132
- }
133
- }
134
- },
135
-
136
- FireCheckout: {
137
- save: function(urlSuffix, forceSave) {
138
- var currentMethod = payment.currentMethod ? payment.currentMethod : '';
139
- if(EwayPayment.isEwayRapidMethod(currentMethod)) {
140
- if (this.loadWaiting != false) {
141
- return;
142
- }
143
-
144
- if (!this.validate()) {
145
- return;
146
- }
147
-
148
- // infostrates tnt
149
- if (!forceSave && (typeof shippingMethod === 'object')
150
- && shippingMethod.getCurrentMethod().indexOf("tnt_") === 0) {
151
-
152
- shippingMethodTnt(shippingMethodTntUrl);
153
- return;
154
- }
155
- // infostrates tnt
156
-
157
- checkout.setLoadWaiting(true);
158
-
159
- var params = Form.serialize(this.form, true);
160
- $('review-please-wait').show();
161
-
162
- encryptedForm = eCrypt.doEncrypt();
163
- params = Form.serialize(encryptedForm, true);
164
-
165
- urlSuffix = urlSuffix || '';
166
- var request = new Ajax.Request(this.urls.save + urlSuffix, {
167
- method:'post',
168
- parameters:params,
169
- onSuccess: this.setResponse.bind(this),
170
- onFailure: this.ajaxFailure.bind(this)
171
- });
172
- } else if(typeof this.ewayOldSave == 'function') {
173
- this.ewayOldSave(urlSuffix, forceSave);
174
- }
175
- }
176
- },
177
-
178
- IWDOnePageCheckout: {
179
- savePayment: function() {
180
- if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
181
- if (IWD.OPC.Checkout.xhr!=null){
182
- IWD.OPC.Checkout.xhr.abort();
183
- }
184
- IWD.OPC.Checkout.showLoader();
185
- var ewayForm = eCrypt.doEncrypt();
186
- form = $j(ewayForm).serializeArray();
187
- IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.config.baseUrl + 'onepage/json/savePayment',form, IWD.OPC.preparePaymentResponse,'json');
188
- } else if(typeof IWD.OPC.ewayOldSavePayment == 'function') {
189
- IWD.OPC.ewayOldSavePayment();
190
- }
191
- },
192
- saveOrder: function() {
193
- if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
194
- var ewayForm = eCrypt.doEncrypt();
195
- form = $j(ewayForm).serializeArray();
196
- form = IWD.OPC.checkAgreement(form);
197
- IWD.OPC.Checkout.showLoader();
198
- if (IWD.OPC.Checkout.config.comment!=="0"){
199
- IWD.OPC.saveCustomerComment();
200
- }
201
-
202
- IWD.OPC.Plugin.dispatch('saveOrder');
203
- IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.saveOrderUrl ,form, IWD.OPC.prepareOrderResponse,'json');
204
- } else if(typeof IWD.OPC.ewayOldSaveOrder == 'function') {
205
- IWD.OPC.ewayOldSaveOrder();
206
- }
207
- }
208
- }
209
- }
210
-
211
- var EwayPaymentToken = Class.create();
212
- EwayPaymentToken.prototype = {
213
- savedTokens: null,
214
- tokenCount: 0,
215
- isAdmin: false,
216
- labelEdit: 'Edit',
217
- labelCancel: 'Cancel edit',
218
- isEdit: true,
219
- initialize: function(savedTokens, tokenCount, isAdmin, labelEdit, labelCancel) {
220
- savedTokens['new']['Card'] = '';
221
- this.savedTokens = savedTokens;
222
- this.tokenCount = tokenCount;
223
- this.isAdmin = isAdmin;
224
- this.labelEdit = labelEdit;
225
- this.labelCancel = labelCancel;
226
-
227
- $('ewayrapid_saved_token') && $('ewayrapid_saved_token').observe('change', this.onSavedTokenChanged.bind(this));
228
-
229
- $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').observe('click', this.onEditClick.bind(this));
230
-
231
- if(this.tokenCount == 1) {
232
- // Show credit card form in case customer does not have saved credit card (only 'Add new card' option)
233
- this.ewayrapidToggleCcForm(true);
234
- } else {
235
- this.onSavedTokenChanged();
236
- }
237
- },
238
-
239
- onSavedTokenChanged: function() {
240
- if($('ewayrapid_saved_token') && $('ewayrapid_saved_token').value == 'new') {
241
- this.ewayrapidToggleCcForm(true);
242
- this.ewayrapidSelectToken('new');
243
- $('ewayrapid_saved_cc_type') && $('ewayrapid_saved_cc_type').setValue('');
244
- $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
245
- $$('.help-disabled-cc a').each(function(element){
246
- element.hide();
247
- });
248
- } else {
249
- this.ewayrapidToggleCcForm(false);
250
- $('ewayrapid_saved_cc_type') && $('ewayrapid_saved_cc_type').setValue(this.savedTokens[$('ewayrapid_saved_token').getValue()]['Type']);
251
- if($('ewayrapid_saved_edit')) {
252
- this.isEdit = true;
253
- $('ewayrapid_saved_edit').update(this.labelEdit);
254
- $('ewayrapid_saved_edit').show();
255
- }
256
- }
257
- $('ewayrapid_saved_cc_cid') && $('ewayrapid_saved_cc_cid').setValue('');
258
- },
259
-
260
- onEditClick: function() {
261
- if(this.isEdit) {
262
- this.ewayrapidToggleCcForm(true);
263
- this.ewayrapidSelectToken($('ewayrapid_saved_token').getValue());
264
- $('ewayrapid_saved_edit').update(this.labelCancel);
265
- $('ewayrapid_saved_cc_number').disable();
266
- $('ewayrapid_saved_cc_number').removeClassName('validate-cc-number').removeClassName('validate-cc-type-auto');
267
- $$('.help-disabled-cc a').each(function(element){
268
- element.show();
269
- });
270
-
271
- this.isEdit = false;
272
- } else {
273
- this.ewayrapidToggleCcForm(false);
274
- $('ewayrapid_saved_edit').update(this.labelEdit);
275
- this.isEdit = true;
276
- }
277
- var validator = new Validation('co-payment-form');
278
- validator.validate();
279
- $('advice-validate-cc-type-auto-ewayrapid_saved_cc_number') && $('advice-validate-cc-type-auto-ewayrapid_saved_cc_number').hide();
280
- },
281
-
282
- ewayrapidToggleCcForm: function(isShow) {
283
- $$('.saved_token_fields input,.saved_token_fields select').each(function(ele) {
284
- isShow ? ele.enable() : ele.disable();
285
- });
286
- $$('.saved_token_fields').each(function(ele) {
287
- isShow ? ele.show() : ele.hide();
288
- });
289
-
290
- 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') : '' );
291
- },
292
-
293
- ewayrapidSelectToken: function(tokenId) {
294
- $('ewayrapid_saved_cc_owner').setValue(this.savedTokens[tokenId]['Owner']);
295
- $('ewayrapid_saved_cc_number').setValue(this.savedTokens[tokenId]['Card']);
296
- $('ewayrapid_saved_expiration').setValue(this.savedTokens[tokenId]['ExpMonth']);
297
- $('ewayrapid_saved_expiration_yr').setValue(this.savedTokens[tokenId]['ExpYear']);
298
- $('ewayrapid_saved_cc_owner').focus();
299
- }
300
- }
301
-
302
- Validation.creditCartTypes = $H({
303
- // Add Diners Club, Maestro and Visa Electron card type
304
- 'DC': [new RegExp('^3(?:0[0-5]|[68][0-9])[0-9]{11}$'), new RegExp('^[0-9]{3}$'), true],
305
- 'VE': [new RegExp('^(4026|4405|4508|4844|4913|4917)[0-9]{12}|417500[0-9]{10}$'), new RegExp('^[0-9]{3}$'), true],
306
- '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],
307
-
308
- '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],
309
- 'VI': [new RegExp('^4[0-9]{12}([0-9]{3})?$'), new RegExp('^[0-9]{3}$'), true],
310
- 'MC': [new RegExp('^5[1-5][0-9]{14}$'), new RegExp('^[0-9]{3}$'), true],
311
- 'AE': [new RegExp('^3[47][0-9]{13}$'), new RegExp('^[0-9]{4}$'), true],
312
- '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],
313
- '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],
314
- // '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],
315
- '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],
316
- 'OT': [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), false]
317
- });
318
-
319
- Validation.add('validate-cc-type-auto', 'Invalid credit card number or credit card type is not supported.',
320
- function(v, elm) {
321
- // remove credit card number delimiters such as "-" and space
322
- elm.value = removeDelimiters(elm.value);
323
- v = removeDelimiters(v);
324
- var acceptedTypes = EwayPayment.supportCardTypes;
325
-
326
- var ccType = '';
327
- Validation.creditCartTypes.each(function(cardType) {
328
- $cardNumberPattern = cardType.value[0];
329
- if($cardNumberPattern && v.match($cardNumberPattern)) {
330
- ccType = cardType.key;
331
-
332
- // Correct JCB/DI type since they has identical pattern:
333
- if(ccType === 'DI' && v.indexOf('35') == 0) {
334
- ccType = 'JCB';
335
- }
336
-
337
- throw $break;
338
- }
339
- });
340
-
341
- if(acceptedTypes.indexOf(ccType) == -1) {
342
- return false;
343
- }
344
-
345
- var ccTypeContainer = $(elm.id.substr(0,elm.id.indexOf('_cc_number')) + '_cc_type');
346
- if (ccTypeContainer) {
347
- ccTypeContainer.value = ccType;
348
- }
349
-
350
- return true;
351
- }
352
- );
353
-
354
- Validation.add('eway-validate-phone', 'Please enter a valid phone number.', function(v, elm) {
355
- return Validation.get('IsEmpty').test(v) || /^[0-9\+\*\(\)]{1,32}$/.test(v);
356
- });
357
-
358
- document.observe('dom:loaded', function(){
359
- /*
360
- var name = 'ewayrapid_saved_cc_owner';
361
- // Validate card name
362
- $('' + name).observe('keyup',function() {
363
- if($('ewayrapid_saved_cc_owner').up()
364
- .select('#advice-required-entry-ewayrapid_saved_cc_owner').length > 0) {
365
- $('ewayrapid_saved_cc_owner').up()
366
- .select('#advice-required-entry-ewayrapid_saved_cc_owner')[0].remove();
367
- }
368
- if($('ewayrapid_saved_cc_owner').value.length > 50) {
369
- $('ewayrapid_saved_cc_owner').addClassName('validation-failed');
370
- $('ewayrapid_saved_cc_owner').up().insert(
371
- '<div id="advice-required-entry-ewayrapid_saved_cc_owner" ' +
372
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
373
- } else {
374
- // Remove notify
375
- if($('ewayrapid_saved_cc_owner').up()
376
- .select('#advice-required-entry-ewayrapid_saved_cc_owner').length > 0) {
377
- $('ewayrapid_saved_cc_owner').up()
378
- .select('#advice-required-entry-ewayrapid_saved_cc_owner')[0].remove();
379
- }
380
- // Remove class require on text field
381
- $('ewayrapid_saved_cc_owner').removeClassName('validation-failed');
382
- }
383
- });
384
-
385
- // First name
386
- $('address_firstname').observe('keyup',function() {
387
- if($('address_firstname').up()
388
- .select('#advice-required-entry-address_firstname').length > 0) {
389
- $('address_firstname').up()
390
- .select('#advice-required-entry-address_firstname')[0].remove();
391
- }
392
- if($('address_firstname').value.length > 50) {
393
- $('address_firstname').addClassName('validation-failed');
394
- $('address_firstname').up().insert(
395
- '<div id="advice-required-entry-address_firstname" ' +
396
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
397
- } else {
398
- // Remove notify
399
- if($('ewayrapid_saved_cc_owner').up()
400
- .select('#advice-required-entry-address_firstname').length > 0) {
401
- $('address_firstname').up()
402
- .select('#advice-required-entry-address_firstname')[0].remove();
403
- }
404
- // Remove class require on text field
405
- $('address_firstname').removeClassName('validation-failed');
406
- }
407
- });
408
-
409
- // Last name
410
- $('address_lastname').observe('keyup',function() {
411
- if($('address_lastname').up()
412
- .select('#advice-required-entry-address_lastname').length > 0) {
413
- $('address_lastname').up()
414
- .select('#advice-required-entry-address_lastname')[0].remove();
415
- }
416
- if($('address_lastname').value.length > 50) {
417
- $('address_lastname').addClassName('validation-failed');
418
- $('address_lastname').up().insert(
419
- '<div id="advice-required-entry-address_lastname" ' +
420
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
421
- } else {
422
- // Remove notify
423
- if($('address_lastname').up()
424
- .select('#advice-required-entry-address_lastname').length > 0) {
425
- $('address_lastname').up()
426
- .select('#advice-required-entry-address_lastname')[0].remove();
427
- }
428
- // Remove class require on text field
429
- $('address_lastname').removeClassName('validation-failed');
430
- }
431
- });
432
-
433
- // Company
434
- $('address_company').observe('keyup',function() {
435
- if($('address_company').up()
436
- .select('#advice-required-entry-address_company').length > 0) {
437
- $('address_company').up()
438
- .select('#advice-required-entry-address_company')[0].remove();
439
- }
440
- if($('address_company').value.length > 50) {
441
- $('address_company').addClassName('validation-failed');
442
- $('address_company').up().insert(
443
- '<div id="advice-required-entry-address_company" ' +
444
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
445
- } else {
446
- // Remove notify
447
- if($('address_company').up()
448
- .select('#advice-required-entry-address_company').length > 0) {
449
- $('address_company').up()
450
- .select('#advice-required-entry-address_company')[0].remove();
451
- }
452
- // Remove class require on text field
453
- $('address_company').removeClassName('validation-failed');
454
- }
455
- });
456
-
457
- // job description
458
- $('address_job_description').observe('keyup',function() {
459
- if($('address_job_description').up()
460
- .select('#advice-required-entry-address_job_description').length > 0) {
461
- $('address_job_description').up()
462
- .select('#advice-required-entry-address_job_description')[0].remove();
463
- }
464
- if($('address_job_description').value.length > 50) {
465
- $('address_job_description').addClassName('validation-failed');
466
- $('address_job_description').up().insert(
467
- '<div id="advice-required-entry-address_job_description" ' +
468
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
469
- } else {
470
- // Remove notify
471
- if($('address_job_description').up()
472
- .select('#advice-required-entry-address_job_description').length > 0) {
473
- $('address_job_description').up()
474
- .select('#advice-required-entry-address_job_description')[0].remove();
475
- }
476
- // Remove class require on text field
477
- $('address_job_description').removeClassName('validation-failed');
478
- }
479
- });
480
-
481
- // Phone
482
- $('address_telephone').observe('keyup',function() {
483
- if($('address_telephone').up()
484
- .select('#advice-required-entry-address_telephone').length > 0) {
485
- $('address_telephone').up()
486
- .select('#advice-required-entry-address_telephone')[0].remove();
487
- }
488
- if($('address_telephone').value.length > 32) {
489
- $('address_telephone').addClassName('validation-failed');
490
- $('address_telephone').up().insert(
491
- '<div id="advice-required-entry-address_telephone" ' +
492
- 'class="validation-advice" style="">Maxlength of this field is 32.</div>');
493
- } else {
494
- // Remove notify
495
- if($('address_telephone').up()
496
- .select('#advice-required-entry-address_telephone').length > 0) {
497
- $('address_telephone').up()
498
- .select('#advice-required-entry-address_telephone')[0].remove();
499
- }
500
- // Remove class require on text field
501
- $('address_telephone').removeClassName('validation-failed');
502
- }
503
- });
504
- $('address_mobile').observe('keyup',function() {
505
- if($('address_mobile').up()
506
- .select('#advice-required-entry-address_mobile').length > 0) {
507
- $('address_mobile').up()
508
- .select('#advice-required-entry-address_mobile')[0].remove();
509
- }
510
- if($('address_mobile').value.length > 32) {
511
- $('address_mobile').addClassName('validation-failed');
512
- $('address_mobile').up().insert(
513
- '<div id="advice-required-entry-address_mobile" ' +
514
- 'class="validation-advice" style="">Maxlength of this field is 32.</div>');
515
- } else {
516
- // Remove notify
517
- if($('address_mobile').up()
518
- .select('#advice-required-entry-address_mobile').length > 0) {
519
- $('address_mobile').up()
520
- .select('#advice-required-entry-address_mobile')[0].remove();
521
- }
522
- // Remove class require on text field
523
- $('address_mobile').removeClassName('validation-failed');
524
- }
525
- });
526
- $('address_email').observe('keyup',function() {
527
- if($('address_email').up()
528
- .select('#advice-required-entry-address_email').length > 0) {
529
- $('address_email').up()
530
- .select('#advice-required-entry-address_email')[0].remove();
531
- }
532
- if($('address_email').value.length > 50) {
533
- $('address_email').addClassName('validation-failed');
534
- $('address_email').up().insert(
535
- '<div id="advice-required-entry-address_email" ' +
536
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
537
- } else {
538
- // Remove notify
539
- if($('address_email').up()
540
- .select('#advice-required-entry-address_email').length > 0) {
541
- $('address_email').up()
542
- .select('#advice-required-entry-address_email')[0].remove();
543
- }
544
- // Remove class require on text field
545
- $('address_email').removeClassName('validation-failed');
546
- }
547
- });
548
- $('address_fax').observe('keyup',function() {
549
- if($('address_fax').up()
550
- .select('#advice-required-entry-address_fax').length > 0) {
551
- $('address_fax').up()
552
- .select('#advice-required-entry-address_fax')[0].remove();
553
- }
554
- if($('address_fax').value.length > 32) {
555
- $('address_fax').addClassName('validation-failed');
556
- $('address_fax').up().insert(
557
- '<div id="advice-required-entry-address_fax" ' +
558
- 'class="validation-advice" style="">Maxlength of this field is 32.</div>');
559
- } else {
560
- // Remove notify
561
- if($('address_fax').up()
562
- .select('#advice-required-entry-address_fax').length > 0) {
563
- $('address_fax').up()
564
- .select('#advice-required-entry-address_fax')[0].remove();
565
- }
566
- // Remove class require on text field
567
- $('address_fax').removeClassName('validation-failed');
568
- }
569
- });
570
- $('address_street_1').observe('keyup',function() {
571
- if($('address_street_1').up()
572
- .select('#advice-required-entry-address_street_1').length > 0) {
573
- $('address_street_1').up()
574
- .select('#advice-required-entry-address_street_1')[0].remove();
575
- }
576
- if($('address_street_1').value.length > 50) {
577
- $('address_street_1').addClassName('validation-failed');
578
- $('address_street_1').up().insert(
579
- '<div id="advice-required-entry-address_street_1" ' +
580
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
581
- } else {
582
- // Remove notify
583
- if($('address_street_1').up()
584
- .select('#advice-required-entry-address_street_1').length > 0) {
585
- $('address_street_1').up()
586
- .select('#advice-required-entry-address_street_1')[0].remove();
587
- }
588
- // Remove class require on text field
589
- $('address_street_1').removeClassName('validation-failed');
590
- }
591
- });
592
- $('address_street_2').observe('keyup',function() {
593
- if($('address_street_2').up()
594
- .select('#advice-required-entry-address_street_2').length > 0) {
595
- $('address_street_2').up()
596
- .select('#advice-required-entry-address_street_2')[0].remove();
597
- }
598
- if($('address_street_2').value.length > 50) {
599
- $('address_street_2').addClassName('validation-failed');
600
- $('address_street_2').up().insert(
601
- '<div id="advice-required-entry-address_street_2" ' +
602
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
603
- } else {
604
- // Remove notify
605
- if($('address_street_2').up()
606
- .select('#advice-required-entry-address_street_2').length > 0) {
607
- $('address_street_2').up()
608
- .select('#advice-required-entry-address_street_2')[0].remove();
609
- }
610
- // Remove class require on text field
611
- $('address_street_2').removeClassName('validation-failed');
612
- }
613
- });
614
- $('address_city').observe('keyup',function() {
615
- if($('address_city').up()
616
- .select('#advice-required-entry-address_city').length > 0) {
617
- $('address_city').up()
618
- .select('#advice-required-entry-address_city')[0].remove();
619
- }
620
- if($('address_city').value.length > 50) {
621
- $('address_city').addClassName('validation-failed');
622
- $('address_city').up().insert(
623
- '<div id="advice-required-entry-address_city" ' +
624
- 'class="validation-advice" style="">Maxlength of this field is 30.</div>');
625
- } else {
626
- // Remove notify
627
- if($('address_city').up()
628
- .select('#advice-required-entry-address_city').length > 0) {
629
- $('address_city').up()
630
- .select('#advice-required-entry-address_city')[0].remove();
631
- }
632
- // Remove class require on text field
633
- $('address_city').removeClassName('validation-failed');
634
- }
635
- });
636
- $('address_region').observe('keyup',function() {
637
- if($('address_region').up()
638
- .select('#advice-required-entry-address_region').length > 0) {
639
- $('address_region').up()
640
- .select('#advice-required-entry-address_region')[0].remove();
641
- }
642
- if($('address_region').value.length > 50) {
643
- $('address_region').addClassName('validation-failed');
644
- $('address_region').up().insert(
645
- '<div id="advice-required-entry-address_region" ' +
646
- 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
647
- } else {
648
- // Remove notify
649
- if($('address_region').up()
650
- .select('#advice-required-entry-address_region').length > 0) {
651
- $('address_region').up()
652
- .select('#advice-required-entry-address_region')[0].remove();
653
- }
654
- // Remove class require on text field
655
- $('address_region').removeClassName('validation-failed');
656
- }
657
- });
658
- $('address_zip').observe('keyup',function() {
659
- if($('address_zip').up()
660
- .select('#advice-required-entry-address_zip').length > 0) {
661
- $('address_zip').up()
662
- .select('#advice-required-entry-address_zip')[0].remove();
663
- }
664
- if($('address_zip').value.length > 50) {
665
- $('address_zip').addClassName('validation-failed');
666
- $('address_zip').up().insert(
667
- '<div id="advice-required-entry-address_zip" ' +
668
- 'class="validation-advice" style="">Maxlength of this field is 30.</div>');
669
- } else {
670
- // Remove notify
671
- if($('address_zip').up()
672
- .select('#advice-required-entry-address_zip').length > 0) {
673
- $('address_zip').up()
674
- .select('#advice-required-entry-address_zip')[0].remove();
675
- }
676
- // Remove class require on text field
677
- $('address_zip').removeClassName('validation-failed');
678
- }
679
- });
680
- */
681
-
682
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 () {alert(12121212);
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
+ }
163
+ }
164
+ },
165
+
166
+ FireCheckout: {
167
+ save: function(urlSuffix, forceSave) {
168
+ var currentMethod = payment.currentMethod ? payment.currentMethod : '';
169
+ if(EwayPayment.isEwayRapidMethod(currentMethod)) {
170
+ if (this.loadWaiting != false) {
171
+ return;
172
+ }
173
+
174
+ if (!this.validate()) {
175
+ return;
176
+ }
177
+
178
+ // infostrates tnt
179
+ if (!forceSave && (typeof shippingMethod === 'object')
180
+ && shippingMethod.getCurrentMethod().indexOf("tnt_") === 0) {
181
+
182
+ shippingMethodTnt(shippingMethodTntUrl);
183
+ return;
184
+ }
185
+ // infostrates tnt
186
+
187
+ checkout.setLoadWaiting(true);
188
+
189
+ var params = Form.serialize(this.form, true);
190
+ $('review-please-wait').show();
191
+
192
+ encryptedForm = eCrypt.doEncrypt();
193
+ params = Form.serialize(encryptedForm, true);
194
+
195
+ urlSuffix = urlSuffix || '';
196
+ var request = new Ajax.Request(this.urls.save + urlSuffix, {
197
+ method:'post',
198
+ parameters:params,
199
+ onSuccess: this.setResponse.bind(this),
200
+ onFailure: this.ajaxFailure.bind(this)
201
+ });
202
+ } else if(typeof this.ewayOldSave == 'function') {
203
+ this.ewayOldSave(urlSuffix, forceSave);
204
+ }
205
+ },
206
+ savePayment: function(urlSuffix, forceSave) {
207
+ var currentMethod = payment.currentMethod ? payment.currentMethod : '';
208
+ if(EwayPayment.isEwayRapidMethod(currentMethod)) {
209
+ if (this.loadWaiting != false) {
210
+ return;
211
+ }
212
+
213
+ if (!this.validate()) {
214
+ return;
215
+ }
216
+
217
+ // infostrates tnt
218
+ if (!forceSave && (typeof shippingMethod === 'object')
219
+ && shippingMethod.getCurrentMethod().indexOf("tnt_") === 0) {
220
+
221
+ shippingMethodTnt(shippingMethodTntUrl);
222
+ return;
223
+ }
224
+ // infostrates tnt
225
+
226
+ checkout.setLoadWaiting(true);
227
+
228
+ var params = Form.serialize(this.form, true);
229
+ $('review-please-wait').show();
230
+
231
+ var _method = $$("input[name='payment[method]']:checked")[0].getValue();
232
+ var _transparent_method = '';
233
+ if (_method == 'ewayrapid_notsaved' && $$("input[name='payment[transparent_notsaved]']:checked").length > 0) {
234
+ _transparent_method = $$("input[name='payment[transparent_notsaved]']:checked")[0];
235
+ } else if (_method == 'ewayrapid_saved' && $$("input[name='payment[transparent_saved]']:checked").length > 0) {
236
+ _transparent_method = $$("input[name='payment[transparent_saved]']:checked")[0];
237
+ }
238
+
239
+ if (_transparent_method != '' && $(_transparent_method.id).getValue() == creditcard) {
240
+ if ($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
241
+ encryptedForm = eCrypt.doEncrypt();
242
+ }
243
+ }
244
+
245
+ params = Form.serialize(encryptedForm, true);
246
+
247
+ urlSuffix = urlSuffix || '';
248
+ var request = new Ajax.Request(this.urls.save + urlSuffix, {
249
+ method:'post',
250
+ parameters:params,
251
+ onSuccess: this.setResponse.bind(this),
252
+ onFailure: this.ajaxFailure.bind(this)
253
+ });
254
+ } else if(typeof this.ewayOldSave == 'function') {
255
+ this.ewayOldSave(urlSuffix, forceSave);
256
+ }
257
+ }
258
+ },
259
+
260
+ IWDOnePageCheckout: {
261
+ savePayment: function() {
262
+ if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
263
+ if (IWD.OPC.Checkout.xhr!=null){
264
+ IWD.OPC.Checkout.xhr.abort();
265
+ }
266
+ IWD.OPC.Checkout.showLoader();
267
+ var ewayForm = eCrypt.doEncrypt();
268
+ form = $j(ewayForm).serializeArray();
269
+ IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.config.baseUrl + 'onepage/json/savePayment',form, IWD.OPC.preparePaymentResponse,'json');
270
+ } else if(typeof IWD.OPC.ewayOldSavePayment == 'function') {
271
+ IWD.OPC.ewayOldSavePayment();
272
+ }
273
+ },
274
+ savePaymentTrans: function() {
275
+ if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
276
+ /*var ewayForm = $(this.form);
277
+ if (IWD.OPC.Checkout.xhr!=null){
278
+ IWD.OPC.Checkout.xhr.abort();
279
+ }
280
+ IWD.OPC.Checkout.showLoader();
281
+ var _method = $$("input[name='payment[method]']:checked")[0].getValue();
282
+ var _transparent_method = '';
283
+ if (_method == 'ewayrapid_notsaved' && $$("input[name='payment[transparent_notsaved]']:checked").length > 0) {
284
+ _transparent_method = $$("input[name='payment[transparent_notsaved]']:checked")[0];
285
+ } else if (_method == 'ewayrapid_saved' && $$("input[name='payment[transparent_saved]']:checked").length > 0) {
286
+ _transparent_method = $$("input[name='payment[transparent_saved]']:checked")[0];
287
+ }
288
+
289
+ if (_transparent_method != '' && $(_transparent_method.id).getValue() == creditcard) {
290
+ if ($$("input[id*='ewayrapid_'][name='payment[method]']:checked").length > 0) {
291
+ ewayForm = eCrypt.doEncrypt();
292
+ }
293
+ }*/
294
+ var ewayForm = eCrypt.doEncrypt();
295
+ form = $j(ewayForm).serializeArray();
296
+ IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.config.baseUrl + 'onepage/json/savePayment',form, IWD.OPC.preparePaymentResponse,'json');
297
+ } else if(typeof IWD.OPC.ewayOldSavePayment == 'function') {
298
+ IWD.OPC.ewayOldSavePayment();
299
+ }
300
+ },
301
+ saveOrder: function() {
302
+ if(EwayPayment.isEwayRapidMethod(payment.currentMethod)) {
303
+ var ewayForm = eCrypt.doEncrypt();
304
+ form = $j(ewayForm).serializeArray();
305
+ form = IWD.OPC.checkAgreement(form);
306
+ IWD.OPC.Checkout.showLoader();
307
+ if (IWD.OPC.Checkout.config.comment!=="0"){
308
+ IWD.OPC.saveCustomerComment();
309
+ }
310
+
311
+ IWD.OPC.Plugin.dispatch('saveOrder');
312
+ IWD.OPC.Checkout.xhr = $j.post(IWD.OPC.Checkout.saveOrderUrl ,form, IWD.OPC.prepareOrderResponse,'json');
313
+ } else if(typeof IWD.OPC.ewayOldSaveOrder == 'function') {
314
+ IWD.OPC.ewayOldSaveOrder();
315
+ }
316
+ }
317
+ },
318
+ Lightcheckout : {
319
+ LightcheckoutSubmit: function() {
320
+ if (payment.currentMethod && (payment.currentMethod.indexOf('sagepay') == 0) &&
321
+ (SageServer != undefined) && (review != undefined)) {
322
+ if (checkoutForm.validator.validate()) {
323
+ review.preparedata();
324
+ }
325
+ }
326
+ else {
327
+ if (checkoutForm.validator.validate()) {
328
+ this.submit(this.getFormData(), 'save_payment_methods');
329
+ }
330
+ }
331
+ },
332
+ submit: function (params, action) {
333
+
334
+ this.showLoadinfo();
335
+
336
+ params.action = action;
337
+
338
+ var request = new Ajax.Request(this.url,
339
+ {
340
+ method: 'post',
341
+ parameters: params,
342
+ onSuccess: function (transport) {
343
+
344
+ eval('var response = ' + transport.responseText);
345
+
346
+ if (response.messages_block) {
347
+ var gcheckout_onepage_wrap = $$('div.gcheckout-onepage-wrap')[0];
348
+ if (gcheckout_onepage_wrap) {
349
+ new Insertion.Before(gcheckout_onepage_wrap, response.messages_block);
350
+ }
351
+ this.disable_place_order = true;
352
+ } else {
353
+ this.disable_place_order = false;
354
+ }
355
+
356
+ if (response.url) {
357
+
358
+ this.existsreview = false;
359
+ setLocation(response.url);
360
+
361
+ } else {
362
+
363
+ if (response.error) {
364
+ if (response.message) {
365
+ alert(response.message);
366
+ }
367
+ this.existsreview = false;
368
+ this.hideLoadinfo();
369
+ } else {
370
+
371
+ var process_save_order = false;
372
+
373
+ if (response.methods) {
374
+ // Quote isVirtual
375
+ this.innerHTMLwithScripts($('gcheckout-onepage-methods'), response.methods);
376
+ var wrap = $$('div.gcheckout-onepage-wrap')[0];
377
+ if (wrap && !wrap.hasClassName('not_shipping_mode')) {
378
+ wrap.addClassName('not_shipping_mode');
379
+ }
380
+ if ($('billing_use_for_shipping_yes') && $('billing_use_for_shipping_yes').up('li.control')) {
381
+ $('billing_use_for_shipping_yes').up('li.control').remove();
382
+ }
383
+ if ($('gcheckout-shipping-address')) {
384
+ $('gcheckout-shipping-address').remove();
385
+ }
386
+ payment.init();
387
+ this.observeMethods();
388
+ }
389
+
390
+ if (response.shippings) {
391
+ if (shipping_rates_block = $('gcheckout-shipping-method-available')) {
392
+ this.innerHTMLwithScripts(shipping_rates_block, response.shippings);
393
+ this.observeShippingMethods();
394
+ }
395
+ }
396
+
397
+ if (response.payments) {
398
+ this.innerHTMLwithScripts($('gcheckout-payment-methods-available'), response.payments);
399
+ payment.init();
400
+ this.observePaymentMethods();
401
+ }
402
+
403
+ if (response.gift_message) {
404
+ if (giftmessage_block = $('gomage-lightcheckout-giftmessage')) {
405
+ this.innerHTMLwithScripts(giftmessage_block, response.gift_message);
406
+ }
407
+ }
408
+
409
+ if (response.toplinks) {
410
+ this.replaceTopLinks(response.toplinks);
411
+ }
412
+
413
+ if (response.minicart) {
414
+ this.replaceMiniCart(response);
415
+ }
416
+
417
+ if (response.cart_sidebar && typeof(GomageProcartConfig) != 'undefined') {
418
+ GomageProcartConfig._replaceEnterpriseTopCart(response.cart_sidebar, ($('topCartContent') && $('topCartContent').visible()));
419
+ }
420
+
421
+ if (response.review) {
422
+ this.innerHTMLwithScripts($$('#gcheckout-onepage-review div.totals')[0], response.review);
423
+ }
424
+
425
+ if (response.content_billing) {
426
+ var div_billing = document.createElement('div');
427
+ div_billing.innerHTML = response.content_billing;
428
+ $('gcheckout-onepage-address').replaceChild(div_billing.firstChild, $('gcheckout-billing-address'));
429
+ }
430
+
431
+ if (response.content_shipping && $('gcheckout-shipping-address')) {
432
+ var div_shipping = document.createElement('div');
433
+ div_shipping.innerHTML = response.content_shipping;
434
+ $('gcheckout-onepage-address').replaceChild(div_shipping.firstChild, $('gcheckout-shipping-address'));
435
+ }
436
+
437
+ if (response.content_billing || response.content_shipping) {
438
+ this.observeAddresses();
439
+ initAddresses();
440
+ }
441
+
442
+ if (response.section == 'varify_taxvat') {
443
+
444
+ if ($('billing_taxvat_verified')) {
445
+ $('billing_taxvat_verified').remove();
446
+ }
447
+
448
+ if ($('shipping_taxvat_verified')) {
449
+ $('shipping_taxvat_verified').remove();
450
+ }
451
+
452
+ this.taxvat_verify_result = response.verify_result;
453
+
454
+ if ($('billing_taxvat') && $('billing_taxvat').value) {
455
+ if (response.verify_result.billing) {
456
+ if (label = $('billing_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
457
+ label.innerHTML += '<strong id="billing_taxvat_verified" style="margin-left:5px;">(<span style="color:green;">Verified</span>)</strong>';
458
+ $('billing_taxvat').removeClassName('validation-failed');
459
+ }
460
+ } else if ($('billing_taxvat').value) {
461
+ if (label = $('billing_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
462
+ label.innerHTML += '<strong id="billing_taxvat_verified" style="margin-left:5px;">(<span style="color:red;">Not Verified</span>)</strong>';
463
+ }
464
+ }
465
+ }
466
+
467
+ if ($('shipping_taxvat') && $('shipping_taxvat').value) {
468
+ if (response.verify_result.shipping) {
469
+ if (label = $('shipping_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
470
+ label.innerHTML += '<strong id="shipping_taxvat_verified" style="margin-left:5px;">(<span style="color:green;">Verified</span>)</strong>';
471
+ $('shipping_taxvat').removeClassName('validation-failed');
472
+ }
473
+ } else if ($('shipping_taxvat').value) {
474
+ if (label = $('shipping_taxvat').parentNode.parentNode.getElementsByTagName('label')[0]) {
475
+ label.innerHTML += '<strong id="shipping_taxvat_verified" style="margin-left:5px;">(<span style="color:red;">Not Verified</span>)</strong>';
476
+ }
477
+ }
478
+ }
479
+
480
+ }
481
+
482
+ if (response.section == 'centinel') {
483
+
484
+ if (response.centinel) {
485
+ this.showCentinel(response.centinel);
486
+ } else {
487
+ process_save_order = true;
488
+ if ((payment.currentMethod == 'authorizenet_directpost') && ((typeof directPostModel != 'undefined'))) {
489
+ directPostModel.saveOnepageOrder();
490
+ } else {
491
+ this.saveorder();
492
+ }
493
+ }
494
+ }
495
+
496
+ this.setBlocksNumber();
497
+
498
+ if (this.existsreview) {
499
+ this.existsreview = false;
500
+ review.save();
501
+ }
502
+ else {
503
+ if (!process_save_order) {
504
+ this.hideLoadinfo();
505
+ }
506
+ }
507
+
508
+ }
509
+
510
+ }
511
+
512
+ }.bind(this),
513
+ onFailure: function () {
514
+ this.existsreview = false;
515
+ }
516
+ });
517
+ },
518
+ getFormData: function () {
519
+ //var form_data = $('gcheckout-onepage-form').serialize(true);
520
+ var form = eCrypt.doEncrypt();
521
+ var form_data = form.serialize(true);
522
+ for (var key in form_data) {
523
+ if ((key == 'billing[customer_password]') || (key == 'billing[confirm_password]')) {
524
+ form_data[key] = GlcUrl.encode(form_data[key]);
525
+ }
526
+ if (payment.currentMethod == 'authorizenet_directpost') {
527
+ if (key.indexOf('payment[') == 0 && key != 'payment[method]' && key != 'payment[use_customer_balance]') {
528
+ delete form_data[key];
529
+ }
530
+ }
531
+ }
532
+
533
+ return form_data;
534
+ }
535
+ }
536
+ };
537
+
538
+ var EwayPaymentToken = Class.create();
539
+ EwayPaymentToken.prototype = {
540
+ savedTokens: null,
541
+ tokenCount: 0,
542
+ isAdmin: false,
543
+ labelEdit: 'Edit',
544
+ labelCancel: 'Cancel edit',
545
+ isEdit: true,
546
+ initialize: function(savedTokens, tokenCount, isAdmin, labelEdit, labelCancel) {
547
+ savedTokens['new']['Card'] = '';
548
+ this.savedTokens = savedTokens;
549
+ this.tokenCount = tokenCount;
550
+ this.isAdmin = isAdmin;
551
+ this.labelEdit = labelEdit;
552
+ this.labelCancel = labelCancel;
553
+
554
+ $('ewayrapid_saved_token') && $('ewayrapid_saved_token').observe('change', this.onSavedTokenChanged.bind(this));
555
+
556
+ $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').observe('click', this.onEditClick.bind(this));
557
+
558
+ if(this.tokenCount == 1) {
559
+ // Show credit card form in case customer does not have saved credit card (only 'Add new card' option)
560
+ this.ewayrapidToggleCcForm(true);
561
+ } else {
562
+ this.onSavedTokenChanged();
563
+ }
564
+ },
565
+
566
+ onSavedTokenChanged: function() {
567
+ if($('ewayrapid_saved_token') && $('ewayrapid_saved_token').value == 'new') {
568
+ this.ewayrapidToggleCcForm(true);
569
+ this.ewayrapidSelectToken('new');
570
+ $('ewayrapid_saved_cc_type') && $('ewayrapid_saved_cc_type').setValue('');
571
+ $('ewayrapid_saved_edit') && $('ewayrapid_saved_edit').hide();
572
+ $$('.help-disabled-cc a').each(function(element){
573
+ element.hide();
574
+ });
575
+ } else {
576
+ this.ewayrapidToggleCcForm(false);
577
+ $('ewayrapid_saved_cc_type') && $('ewayrapid_saved_cc_type').setValue(this.savedTokens[$('ewayrapid_saved_token').getValue()]['Type']);
578
+ if($('ewayrapid_saved_edit')) {
579
+ this.isEdit = true;
580
+ $('ewayrapid_saved_edit').update(this.labelEdit);
581
+ $('ewayrapid_saved_edit').show();
582
+ }
583
+ }
584
+ $('ewayrapid_saved_cc_cid') && $('ewayrapid_saved_cc_cid').setValue('');
585
+ },
586
+
587
+ onEditClick: function() {
588
+ if(this.isEdit) {
589
+ this.ewayrapidToggleCcForm(true);
590
+ this.ewayrapidSelectToken($('ewayrapid_saved_token').getValue());
591
+ $('ewayrapid_saved_edit').update(this.labelCancel);
592
+ $('ewayrapid_saved_cc_number').disable();
593
+ $('ewayrapid_saved_cc_number').removeClassName('validate-cc-number').removeClassName('validate-cc-type-auto');
594
+ $$('.help-disabled-cc a').each(function(element){
595
+ element.show();
596
+ });
597
+
598
+ this.isEdit = false;
599
+ } else {
600
+ this.ewayrapidToggleCcForm(false);
601
+ $('ewayrapid_saved_edit').update(this.labelEdit);
602
+ this.isEdit = true;
603
+ }
604
+ var validator = new Validation('co-payment-form');
605
+ validator.validate();
606
+ $('advice-validate-cc-type-auto-ewayrapid_saved_cc_number') && $('advice-validate-cc-type-auto-ewayrapid_saved_cc_number').hide();
607
+ },
608
+
609
+ ewayrapidToggleCcForm: function(isShow) {
610
+ $$('.saved_token_fields input,.saved_token_fields select').each(function(ele) {
611
+ isShow ? ele.enable() : ele.disable();
612
+ });
613
+ $$('.saved_token_fields').each(function(ele) {
614
+ isShow ? ele.show() : ele.hide();
615
+ });
616
+
617
+ 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') : '' );
618
+ },
619
+
620
+ ewayrapidSelectToken: function(tokenId) {
621
+ $('ewayrapid_saved_cc_owner').setValue(this.savedTokens[tokenId]['Owner']);
622
+ $('ewayrapid_saved_cc_number').setValue(this.savedTokens[tokenId]['Card']);
623
+ $('ewayrapid_saved_expiration').setValue(this.savedTokens[tokenId]['ExpMonth']);
624
+ $('ewayrapid_saved_expiration_yr').setValue(this.savedTokens[tokenId]['ExpYear']);
625
+ $('ewayrapid_saved_cc_owner').focus();
626
+ }
627
+ }
628
+
629
+ Validation.creditCartTypes = $H({
630
+ // Add Diners Club, Maestro and Visa Electron card type
631
+ 'DC': [new RegExp('^3(?:0[0-5]|[68][0-9])[0-9]{11}$'), new RegExp('^[0-9]{3}$'), true],
632
+ 'VE': [new RegExp('^(4026|4405|4508|4844|4913|4917)[0-9]{12}|417500[0-9]{10}$'), new RegExp('^[0-9]{3}$'), true],
633
+ '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],
634
+
635
+ '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],
636
+ 'VI': [new RegExp('^4[0-9]{12}([0-9]{3})?$'), new RegExp('^[0-9]{3}$'), true],
637
+ 'MC': [new RegExp('^5[1-5][0-9]{14}$'), new RegExp('^[0-9]{3}$'), true],
638
+ 'AE': [new RegExp('^3[47][0-9]{13}$'), new RegExp('^[0-9]{4}$'), true],
639
+ '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],
640
+ '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],
641
+ // '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],
642
+ '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],
643
+ 'OT': [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), false]
644
+ });
645
+
646
+ Validation.add('validate-cc-type-auto', 'Invalid credit card number or credit card type is not supported.',
647
+ function(v, elm) {
648
+ // remove credit card number delimiters such as "-" and space
649
+ elm.value = removeDelimiters(elm.value);
650
+ v = removeDelimiters(v);
651
+ var acceptedTypes = EwayPayment.supportCardTypes;
652
+
653
+ var ccType = '';
654
+ Validation.creditCartTypes.each(function(cardType) {
655
+ $cardNumberPattern = cardType.value[0];
656
+ if($cardNumberPattern && v.match($cardNumberPattern)) {
657
+ ccType = cardType.key;
658
+
659
+ // Correct JCB/DI type since they has identical pattern:
660
+ if(ccType === 'DI' && v.indexOf('35') == 0) {
661
+ ccType = 'JCB';
662
+ }
663
+
664
+ throw $break;
665
+ }
666
+ });
667
+
668
+ if(acceptedTypes.indexOf(ccType) == -1) {
669
+ return false;
670
+ }
671
+
672
+ var ccTypeContainer = $(elm.id.substr(0,elm.id.indexOf('_cc_number')) + '_cc_type');
673
+ if (ccTypeContainer) {
674
+ ccTypeContainer.value = ccType;
675
+ }
676
+
677
+ return true;
678
+ }
679
+ );
680
+
681
+ Validation.add('eway-validate-phone', 'Please enter a valid phone number.', function(v, elm) {
682
+ return Validation.get('IsEmpty').test(v) || /^[0-9\+\*\(\)]{1,32}$/.test(v);
683
+ });
684
+
685
+ document.observe('dom:loaded', function(){
686
+ /*
687
+ var name = 'ewayrapid_saved_cc_owner';
688
+ // Validate card name
689
+ $('' + name).observe('keyup',function() {
690
+ if($('ewayrapid_saved_cc_owner').up()
691
+ .select('#advice-required-entry-ewayrapid_saved_cc_owner').length > 0) {
692
+ $('ewayrapid_saved_cc_owner').up()
693
+ .select('#advice-required-entry-ewayrapid_saved_cc_owner')[0].remove();
694
+ }
695
+ if($('ewayrapid_saved_cc_owner').value.length > 50) {
696
+ $('ewayrapid_saved_cc_owner').addClassName('validation-failed');
697
+ $('ewayrapid_saved_cc_owner').up().insert(
698
+ '<div id="advice-required-entry-ewayrapid_saved_cc_owner" ' +
699
+ 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
700
+ } else {
701
+ // Remove notify
702
+ if($('ewayrapid_saved_cc_owner').up()
703
+ .select('#advice-required-entry-ewayrapid_saved_cc_owner').length > 0) {
704
+ $('ewayrapid_saved_cc_owner').up()
705
+ .select('#advice-required-entry-ewayrapid_saved_cc_owner')[0].remove();
706
+ }
707
+ // Remove class require on text field
708
+ $('ewayrapid_saved_cc_owner').removeClassName('validation-failed');
709
+ }
710
+ });
711
+
712
+ // First name
713
+ $('address_firstname').observe('keyup',function() {
714
+ if($('address_firstname').up()
715
+ .select('#advice-required-entry-address_firstname').length > 0) {
716
+ $('address_firstname').up()
717
+ .select('#advice-required-entry-address_firstname')[0].remove();
718
+ }
719
+ if($('address_firstname').value.length > 50) {
720
+ $('address_firstname').addClassName('validation-failed');
721
+ $('address_firstname').up().insert(
722
+ '<div id="advice-required-entry-address_firstname" ' +
723
+ 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
724
+ } else {
725
+ // Remove notify
726
+ if($('ewayrapid_saved_cc_owner').up()
727
+ .select('#advice-required-entry-address_firstname').length > 0) {
728
+ $('address_firstname').up()
729
+ .select('#advice-required-entry-address_firstname')[0].remove();
730
+ }
731
+ // Remove class require on text field
732
+ $('address_firstname').removeClassName('validation-failed');
733
+ }
734
+ });
735
+
736
+ // Last name
737
+ $('address_lastname').observe('keyup',function() {
738
+ if($('address_lastname').up()
739
+ .select('#advice-required-entry-address_lastname').length > 0) {
740
+ $('address_lastname').up()
741
+ .select('#advice-required-entry-address_lastname')[0].remove();
742
+ }
743
+ if($('address_lastname').value.length > 50) {
744
+ $('address_lastname').addClassName('validation-failed');
745
+ $('address_lastname').up().insert(
746
+ '<div id="advice-required-entry-address_lastname" ' +
747
+ 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
748
+ } else {
749
+ // Remove notify
750
+ if($('address_lastname').up()
751
+ .select('#advice-required-entry-address_lastname').length > 0) {
752
+ $('address_lastname').up()
753
+ .select('#advice-required-entry-address_lastname')[0].remove();
754
+ }
755
+ // Remove class require on text field
756
+ $('address_lastname').removeClassName('validation-failed');
757
+ }
758
+ });
759
+
760
+ // Company
761
+ $('address_company').observe('keyup',function() {
762
+ if($('address_company').up()
763
+ .select('#advice-required-entry-address_company').length > 0) {
764
+ $('address_company').up()
765
+ .select('#advice-required-entry-address_company')[0].remove();
766
+ }
767
+ if($('address_company').value.length > 50) {
768
+ $('address_company').addClassName('validation-failed');
769
+ $('address_company').up().insert(
770
+ '<div id="advice-required-entry-address_company" ' +
771
+ 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
772
+ } else {
773
+ // Remove notify
774
+ if($('address_company').up()
775
+ .select('#advice-required-entry-address_company').length > 0) {
776
+ $('address_company').up()
777
+ .select('#advice-required-entry-address_company')[0].remove();
778
+ }
779
+ // Remove class require on text field
780
+ $('address_company').removeClassName('validation-failed');
781
+ }
782
+ });
783
+
784
+ // job description
785
+ $('address_job_description').observe('keyup',function() {
786
+ if($('address_job_description').up()
787
+ .select('#advice-required-entry-address_job_description').length > 0) {
788
+ $('address_job_description').up()
789
+ .select('#advice-required-entry-address_job_description')[0].remove();
790
+ }
791
+ if($('address_job_description').value.length > 50) {
792
+ $('address_job_description').addClassName('validation-failed');
793
+ $('address_job_description').up().insert(
794
+ '<div id="advice-required-entry-address_job_description" ' +
795
+ 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
796
+ } else {
797
+ // Remove notify
798
+ if($('address_job_description').up()
799
+ .select('#advice-required-entry-address_job_description').length > 0) {
800
+ $('address_job_description').up()
801
+ .select('#advice-required-entry-address_job_description')[0].remove();
802
+ }
803
+ // Remove class require on text field
804
+ $('address_job_description').removeClassName('validation-failed');
805
+ }
806
+ });
807
+
808
+ // Phone
809
+ $('address_telephone').observe('keyup',function() {
810
+ if($('address_telephone').up()
811
+ .select('#advice-required-entry-address_telephone').length > 0) {
812
+ $('address_telephone').up()
813
+ .select('#advice-required-entry-address_telephone')[0].remove();
814
+ }
815
+ if($('address_telephone').value.length > 32) {
816
+ $('address_telephone').addClassName('validation-failed');
817
+ $('address_telephone').up().insert(
818
+ '<div id="advice-required-entry-address_telephone" ' +
819
+ 'class="validation-advice" style="">Maxlength of this field is 32.</div>');
820
+ } else {
821
+ // Remove notify
822
+ if($('address_telephone').up()
823
+ .select('#advice-required-entry-address_telephone').length > 0) {
824
+ $('address_telephone').up()
825
+ .select('#advice-required-entry-address_telephone')[0].remove();
826
+ }
827
+ // Remove class require on text field
828
+ $('address_telephone').removeClassName('validation-failed');
829
+ }
830
+ });
831
+ $('address_mobile').observe('keyup',function() {
832
+ if($('address_mobile').up()
833
+ .select('#advice-required-entry-address_mobile').length > 0) {
834
+ $('address_mobile').up()
835
+ .select('#advice-required-entry-address_mobile')[0].remove();
836
+ }
837
+ if($('address_mobile').value.length > 32) {
838
+ $('address_mobile').addClassName('validation-failed');
839
+ $('address_mobile').up().insert(
840
+ '<div id="advice-required-entry-address_mobile" ' +
841
+ 'class="validation-advice" style="">Maxlength of this field is 32.</div>');
842
+ } else {
843
+ // Remove notify
844
+ if($('address_mobile').up()
845
+ .select('#advice-required-entry-address_mobile').length > 0) {
846
+ $('address_mobile').up()
847
+ .select('#advice-required-entry-address_mobile')[0].remove();
848
+ }
849
+ // Remove class require on text field
850
+ $('address_mobile').removeClassName('validation-failed');
851
+ }
852
+ });
853
+ $('address_email').observe('keyup',function() {
854
+ if($('address_email').up()
855
+ .select('#advice-required-entry-address_email').length > 0) {
856
+ $('address_email').up()
857
+ .select('#advice-required-entry-address_email')[0].remove();
858
+ }
859
+ if($('address_email').value.length > 50) {
860
+ $('address_email').addClassName('validation-failed');
861
+ $('address_email').up().insert(
862
+ '<div id="advice-required-entry-address_email" ' +
863
+ 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
864
+ } else {
865
+ // Remove notify
866
+ if($('address_email').up()
867
+ .select('#advice-required-entry-address_email').length > 0) {
868
+ $('address_email').up()
869
+ .select('#advice-required-entry-address_email')[0].remove();
870
+ }
871
+ // Remove class require on text field
872
+ $('address_email').removeClassName('validation-failed');
873
+ }
874
+ });
875
+ $('address_fax').observe('keyup',function() {
876
+ if($('address_fax').up()
877
+ .select('#advice-required-entry-address_fax').length > 0) {
878
+ $('address_fax').up()
879
+ .select('#advice-required-entry-address_fax')[0].remove();
880
+ }
881
+ if($('address_fax').value.length > 32) {
882
+ $('address_fax').addClassName('validation-failed');
883
+ $('address_fax').up().insert(
884
+ '<div id="advice-required-entry-address_fax" ' +
885
+ 'class="validation-advice" style="">Maxlength of this field is 32.</div>');
886
+ } else {
887
+ // Remove notify
888
+ if($('address_fax').up()
889
+ .select('#advice-required-entry-address_fax').length > 0) {
890
+ $('address_fax').up()
891
+ .select('#advice-required-entry-address_fax')[0].remove();
892
+ }
893
+ // Remove class require on text field
894
+ $('address_fax').removeClassName('validation-failed');
895
+ }
896
+ });
897
+ $('address_street_1').observe('keyup',function() {
898
+ if($('address_street_1').up()
899
+ .select('#advice-required-entry-address_street_1').length > 0) {
900
+ $('address_street_1').up()
901
+ .select('#advice-required-entry-address_street_1')[0].remove();
902
+ }
903
+ if($('address_street_1').value.length > 50) {
904
+ $('address_street_1').addClassName('validation-failed');
905
+ $('address_street_1').up().insert(
906
+ '<div id="advice-required-entry-address_street_1" ' +
907
+ 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
908
+ } else {
909
+ // Remove notify
910
+ if($('address_street_1').up()
911
+ .select('#advice-required-entry-address_street_1').length > 0) {
912
+ $('address_street_1').up()
913
+ .select('#advice-required-entry-address_street_1')[0].remove();
914
+ }
915
+ // Remove class require on text field
916
+ $('address_street_1').removeClassName('validation-failed');
917
+ }
918
+ });
919
+ $('address_street_2').observe('keyup',function() {
920
+ if($('address_street_2').up()
921
+ .select('#advice-required-entry-address_street_2').length > 0) {
922
+ $('address_street_2').up()
923
+ .select('#advice-required-entry-address_street_2')[0].remove();
924
+ }
925
+ if($('address_street_2').value.length > 50) {
926
+ $('address_street_2').addClassName('validation-failed');
927
+ $('address_street_2').up().insert(
928
+ '<div id="advice-required-entry-address_street_2" ' +
929
+ 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
930
+ } else {
931
+ // Remove notify
932
+ if($('address_street_2').up()
933
+ .select('#advice-required-entry-address_street_2').length > 0) {
934
+ $('address_street_2').up()
935
+ .select('#advice-required-entry-address_street_2')[0].remove();
936
+ }
937
+ // Remove class require on text field
938
+ $('address_street_2').removeClassName('validation-failed');
939
+ }
940
+ });
941
+ $('address_city').observe('keyup',function() {
942
+ if($('address_city').up()
943
+ .select('#advice-required-entry-address_city').length > 0) {
944
+ $('address_city').up()
945
+ .select('#advice-required-entry-address_city')[0].remove();
946
+ }
947
+ if($('address_city').value.length > 50) {
948
+ $('address_city').addClassName('validation-failed');
949
+ $('address_city').up().insert(
950
+ '<div id="advice-required-entry-address_city" ' +
951
+ 'class="validation-advice" style="">Maxlength of this field is 30.</div>');
952
+ } else {
953
+ // Remove notify
954
+ if($('address_city').up()
955
+ .select('#advice-required-entry-address_city').length > 0) {
956
+ $('address_city').up()
957
+ .select('#advice-required-entry-address_city')[0].remove();
958
+ }
959
+ // Remove class require on text field
960
+ $('address_city').removeClassName('validation-failed');
961
+ }
962
+ });
963
+ $('address_region').observe('keyup',function() {
964
+ if($('address_region').up()
965
+ .select('#advice-required-entry-address_region').length > 0) {
966
+ $('address_region').up()
967
+ .select('#advice-required-entry-address_region')[0].remove();
968
+ }
969
+ if($('address_region').value.length > 50) {
970
+ $('address_region').addClassName('validation-failed');
971
+ $('address_region').up().insert(
972
+ '<div id="advice-required-entry-address_region" ' +
973
+ 'class="validation-advice" style="">Maxlength of this field is 50.</div>');
974
+ } else {
975
+ // Remove notify
976
+ if($('address_region').up()
977
+ .select('#advice-required-entry-address_region').length > 0) {
978
+ $('address_region').up()
979
+ .select('#advice-required-entry-address_region')[0].remove();
980
+ }
981
+ // Remove class require on text field
982
+ $('address_region').removeClassName('validation-failed');
983
+ }
984
+ });
985
+ $('address_zip').observe('keyup',function() {
986
+ if($('address_zip').up()
987
+ .select('#advice-required-entry-address_zip').length > 0) {
988
+ $('address_zip').up()
989
+ .select('#advice-required-entry-address_zip')[0].remove();
990
+ }
991
+ if($('address_zip').value.length > 50) {
992
+ $('address_zip').addClassName('validation-failed');
993
+ $('address_zip').up().insert(
994
+ '<div id="advice-required-entry-address_zip" ' +
995
+ 'class="validation-advice" style="">Maxlength of this field is 30.</div>');
996
+ } else {
997
+ // Remove notify
998
+ if($('address_zip').up()
999
+ .select('#advice-required-entry-address_zip').length > 0) {
1000
+ $('address_zip').up()
1001
+ .select('#advice-required-entry-address_zip')[0].remove();
1002
+ }
1003
+ // Remove class require on text field
1004
+ $('address_zip').removeClassName('validation-failed');
1005
+ }
1006
+ });
1007
+ */
1008
+
1009
+ });
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eWAY_Payment_Rapid31</name>
4
- <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
@@ -20,19 +20,20 @@
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>First full release of eWAY's Rapid 3.1 payment module. Process credit card payments with eWAY. Features:&#xD;
24
  &#xD;
25
- - Supports three connection types: Direct Connection, Transparent Redirect and Responsive Shared Page&#xD;
26
- - Authorise and Capture or Authorise payments&#xD;
27
- - Full and parial refunds&#xD;
28
- - Use MasterPass and PayPal through eWAY, track your transactions in one place&#xD;
29
- - Securely store customer's card details as tokens with eWAY&#xD;
30
- - Integrated with eWAY's Beagle anti-fraud&#xD;
31
- - Use eWAY's Live or Sandbox gateway</notes>
 
32
  <authors><author><name>eWAY Payments</name><user>eWAYPayments</user><email>partner@eway.com.au</email></author></authors>
33
- <date>2014-11-10</date>
34
- <time>05:40:10</time>
35
- <contents><target name="magecommunity"><dir name="Eway"><dir name="Rapid31"><dir name="Block"><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="adde0646618931ee2f61eb107fa5bdd6"/><file name="Saved.php" hash="8de32b94291d6ce778adff5e5cb8bd0c"/></dir><dir name="Transparent"><file name="Notsaved.php" hash="c53c26ce01caaa88f7b66f5e4193cb46"/><file name="Saved.php" hash="46e0fc182e8f51fc84733c75e147038c"/></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="a6ef9de991184f5f009fe979d7d6e2fa"/><file name="Saved.php" hash="c4504bd457395b60545a797431008f51"/></dir><dir name="Transparent"><file name="Notsaved.php" hash="9ff716868b289d9eed866b130369df84"/><file name="Saved.php" hash="b83b7032ab677a04a3cb45421095a96f"/></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="e480272d3c88f22b31102b2588110f32"/><file name="Data.php" hash="9e77b610fe6bbdc39d1ee86e977fb988"/></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="a426a8f6a7fde721eebfb4863b880b47"/><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="1f1e8475bfc71731cb8a69dc5cf0e19d"/><file name="Saved.php" hash="43662ca59e0f47edf1e3992330aed64a"/></dir><file name="Observer.php" hash="bef99e2b34a78c70daf4b1641b1b93dd"/><file name="RecurringProfile.php" hash="1d9b4b3d92664a885d222304b613d378"/><dir name="Request"><file name="Abstract.php" hash="b339384263b3139d7711fcf1288f9ca7"/><file name="Direct.php" hash="e2eec1c953aeebb85cc4cf5e8387f763"/><file name="Sharedpage.php" hash="106f32db2db1c6a09abbe049302c8a3d"/><file name="Token.php" hash="39bab32f5f8b428ec39e7e4f93ac1312"/><file name="Transparent.php" hash="e010ae30ba07a521c512db33c7b632fb"/></dir><file name="Response.php" hash="94346cfea6521bb45d8424dd1d54f750"/><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="1677f97c007f6da3e67c5bd2c2779aa7"/></dir><file name="MycardsController.php" hash="6f91776f56decab5beedda246c54437f"/><file name="SharedpageController.php" hash="eae60af9c9c83656342ac300b6cc5895"/><file name="TestController.php" hash="68c0eed4d6142f00e6d67c719cd08abc"/><file name="TransparentController.php" hash="55a0efd1d7a6982ce9c260a1c57fbf6e"/></dir><dir name="etc"><file name="config.xml" hash="bada7cdf321bd5050c2167d7182e3f1d"/><file name="system.xml" hash="eceea5c968c5171561d65eb06c7beba0"/></dir><dir name="sql"><dir name="ewayrapid_setup"><file name="install-0.1.0.php" hash="54e7220359ce69267caafaffda73709e"/><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="69070e4a3c9c7931154457029d996976"/></dir><dir name="info"><file name="direct_notsaved.phtml" hash="e222c4fb5900cd0bef303fc042b5ffb1"/><file name="direct_saved.phtml" hash="464ec1cda4fc6b297873f6dea0a0ea68"/></dir><dir name="pdf"><file name="direct_notsaved.phtml" hash="2e6a90083a15298e463b29c6120018c3"/></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="7e3b28ed8b30cbedab1a54b76ff394b0"/></dir></dir><dir name="template"><dir name="ewayrapid"><dir name="customer"><file name="edit.phtml" hash="4083e59fdbe25b9cb4b4571c7fb70a72"/><file name="mycards.phtml" hash="edef4b70420c7225e9ee0e8098a686e0"/></dir><dir name="form"><file name="direct_notsaved.phtml" hash="713fbcf4022c87f20f5756c0a3553a82"/><file name="direct_saved.phtml" hash="0335e638099347a967eb8f99c2c40c75"/><file name="sharedpage_notsaved.phtml" hash="84bcdff59da4888fde3d68b0e0044854"/><file name="sharedpage_saved.phtml" hash="3ec62b5d5847a5353b538de9b26900c1"/><file name="transparent_notsaved.phtml" hash="020a5b1b5348ad9bd99f807f68bd89c0"/><file name="transparent_saved.phtml" hash="1539252ba72afa2d58b5bc2916da0a8b"/></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="2412777214fbee8722678094ed08e0e2"/><dir name="redirect"><file name="review.phtml" hash="8f64dfebe347f45cc9cfa6be3554d7e7"/><file name="transparent.phtml" hash="cbebd7e80098232886a8b854b8c6bde5"/><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="00ca307f8ad6f1bf88e9ad79ed9eac1f"/></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="751f4dc335e904908cea2368de394dc6"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="ewayrapid"><file name="eCrypt.js" hash="0a4a054505eb9789092afcfab5c50220"/><file name="ewayrapid.js" hash="fc871be5939c19acf0e455a8930fa93f"/></dir></dir></target></contents>
36
  <compatible/>
37
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
38
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eWAY_Payment_Rapid31</name>
4
+ <version>1.2.0</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
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
+ - Fixed virtual products causing errors in checkout&#xD;
26
+ - Fixed customer comments sometimes not being added to orders&#xD;
27
+ - Transparent Redirect now works with the Fire Checkout one page checkout extension&#xD;
28
+ - Transparent Redirect now works with the IWD One Page Checkout extension&#xD;
29
+ - Added support for MageStore One Step Checkout&#xD;
30
+ - Added support for GoMage LightCheckout&#xD;
31
+ - Added payment details to the invoice print format&#xD;
32
+ </notes>
33
  <authors><author><name>eWAY Payments</name><user>eWAYPayments</user><email>partner@eway.com.au</email></author></authors>
34
+ <date>2015-01-09</date>
35
+ <time>00:20:35</time>
36
+ <contents><target name="magecommunity"><dir name="Eway"><dir name="Rapid31"><dir name="Block"><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="adde0646618931ee2f61eb107fa5bdd6"/><file name="Saved.php" hash="8de32b94291d6ce778adff5e5cb8bd0c"/></dir><dir name="Transparent"><file name="Notsaved.php" hash="c53c26ce01caaa88f7b66f5e4193cb46"/><file name="Saved.php" hash="46e0fc182e8f51fc84733c75e147038c"/></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="aa7918f91c120e76dcab166581d64e69"/></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="43b2012fd545997f8124d4cc3664a4a3"/><file name="Saved.php" hash="8b0772ea5731ec3c21b6e23968d59c85"/></dir><file name="Observer.php" hash="ba6b24c6061cae8700731413cd99b7f1"/><file name="RecurringProfile.php" hash="66bf152dadaa09aeeb875fb92e66b543"/><dir name="Request"><file name="Abstract.php" hash="2b338f1123ee11b0612a50d16cd8e07e"/><file name="Direct.php" hash="45a4c73434fd29de97ce4211d324edb0"/><file name="Sharedpage.php" hash="ca588f17077ae30827a258906b5ec0b2"/><file name="Token.php" hash="3cf175946d39213ca7c27520a1467909"/><file name="Transparent.php" hash="44b57650b86ed175b7a6cdf8617ed20d"/></dir><file name="Response.php" hash="94346cfea6521bb45d8424dd1d54f750"/><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="7849327dbe3e459a9c1d0a3de3eafd2f"/><file name="TestController.php" hash="68c0eed4d6142f00e6d67c719cd08abc"/><file name="TransparentController.php" hash="680a4cb25f9388e25e2e58122057a229"/></dir><dir name="etc"><file name="config.xml" hash="f97a0d466bc0d900b96cab9615f75ad1"/><file name="system.xml" hash="2f1d7c65d3d0678b395d61c799693ec0"/></dir><dir name="sql"><dir name="ewayrapid_setup"><file name="install-0.1.0.php" hash="238872bb63449ea347177d594e63af59"/><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="54eb28a1ccc234a03a0a7ffd4199e1f8"/><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="1145fe2a6d6326bbd2016990a28a89ec"/><dir name="redirect"><file name="review.phtml" hash="8f64dfebe347f45cc9cfa6be3554d7e7"/><file name="transparent.phtml" hash="cbebd7e80098232886a8b854b8c6bde5"/><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="aa2534816e01321db409a4c833ba56d0"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="ewayrapid"><file name="eCrypt.js" hash="bbd9ff93a03209520659bd354080c20e"/><file name="ewayrapid.js" hash="fba1e683db7461a1ab772ad8c7f53642"/></dir></dir></target></contents>
37
  <compatible/>
38
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
39
  </package>
skin/frontend/base/default/css/ewayrapid.css CHANGED
@@ -31,4 +31,31 @@
31
  .eway-saved-div-box {float: left;}
32
  .eway-saved-label-box {float: left;}
33
  .eway-saved-edit-box { float: left;}
34
- .eway-saved-select-box {float: left;margin-left: 10px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  .eway-saved-div-box {float: left;}
32
  .eway-saved-label-box {float: left;}
33
  .eway-saved-edit-box { float: left;}
34
+ .eway-saved-select-box {float: left;margin-left: 10px;}
35
+ /** support 1.9 */
36
+ #payment_form_ewayrapid_saved #ul-eway-saved-div-box { float: left; width: 100%; }
37
+ #onestepcheckout-form #ewayrapid_saved_cc_type_exp_div .v-fix,
38
+ #onestepcheckout-form #ewayrapid_notsaved_cc_type_exp_div .v-fix,
39
+ #one-step-checkout-form #ewayrapid_saved_cc_type_exp_div .v-fix,
40
+ #one-step-checkout-form #ewayrapid_notsaved_cc_type_exp_div .v-fix { width: 48%; }
41
+ /*gcheckout-onepage*/
42
+ #gcheckout-onepage-form #gcheckout-payment-methods #p_method_ewayrapid_notsaved,
43
+ #gcheckout-onepage-form #gcheckout-payment-methods #p_method_ewayrapid_saved { float: none; margin: 0px 0px 0px 0px !important;}
44
+ #gcheckout-onepage-form #gcheckout-payment-methods #p_method_checkmo,
45
+ #gcheckout-onepage-form #gcheckout-payment-methods #p_method_ccsave,
46
+ #gcheckout-onepage-form #gcheckout-payment-methods #p_method_cashondelivery { float: none; margin: 0px 0px 0px 0px !important;}
47
+ #gcheckout-onepage-form #gcheckout-payment-methods #payment_form_ewayrapid_notsaved,
48
+ #gcheckout-onepage-form #gcheckout-payment-methods #payment_form_ewayrapid_saved { margin-bottom: 10px !important; }
49
+ #gcheckout-onepage-form #gcheckout-payment-methods #ul_payment_form_ewayrapid_notsaved,
50
+ #gcheckout-onepage-form #gcheckout-payment-methods #ul_payment_form_ewayrapid_saved,
51
+ #gcheckout-onepage-form #gcheckout-payment-methods #payment_form_ewayrapid_notsaved,
52
+ #gcheckout-onepage-form #gcheckout-payment-methods #payment_form_ewayrapid_saved { width:90% !important;padding: 5px !important; }
53
+ #gcheckout-onepage-form #gcheckout-payment-methods #ul_payment_form_ewayrapid_notsaved,
54
+ #gcheckout-onepage-form #gcheckout-payment-methods #ul_payment_form_ewayrapid_saved { margin-top: 7px !important; }
55
+ #gcheckout-onepage-form #gcheckout-payment-methods #ul-eway-saved-div-box #ewayrapid_saved_token { margin-left: 2px !important; float: left; }
56
+ #gcheckout-onepage-form #gcheckout-payment-methods .eway-saved-div-box { padding: 5px !important; width: 94% !important;}
57
+ #gcheckout-onepage-form #gcheckout-payment-methods #ul-eway-saved-div-box #ewayrapid_saved_token { width: 50% !important;margin-right: 5px !important;}
58
+ #one-step-checkout-form #onestepcheckout-payment-methods #ul-eway-saved-div-box #ewayrapid_saved_token { width: 48% !important;margin-left: 5px !important;margin-right: 5px !important;float: left; }
59
+ #container_payment_method_ewayrapid_saved label,
60
+ #container_payment_method_ewayrapid_notsaved label{ text-align: left; }
61
+ .eway-saved-label-box { width: auto !important; }