HC_PayByFinance - Version 2.0.0.0

Version Notes

Change Log:
* HC-246 Notification for eSignature
* HC-242, HC-175 added non-ascii characters replacements
* HC-223 added yes/no option to admin panel for displaying message in result/category
* HC-186 added message for minimum finance amount
* Use Increment ID rather than Order ID in notifications and all across PBF
* HC-239 Google Analytics orders tracking fix
* HC-244 added check for switching PBF on later in steps after user added shipping address.
* HC-249 Notification and totals on invoice
* JS error on IE
* HC-252 Order status for multiple notifications
* HC-220 Cart calculation should be based on the row total
* HC-185 added automatic calculation to RPM from APM field
* HC-256 Product eligibility on cart (Minimum Amount)
* HC-220 Order total modification events (for extendibility)
* HC-261 Race condition on notification events fix
* HC-261: Send a 503 status code when the notification is not applicable, this makes Hitachi to send it again after:
* 10 minutes
* 1 hour
* 2 hours
* 5 hours
* HC-214 Additional text to the selector
* HC-257 Text changes on referred handback pages
* HC-259 remove virtual, downloadable products

Download this release

Release Info

Developer Sandor Czettner
Extension HC_PayByFinance
Version 2.0.0.0
Comparing to
See all releases


Code changes from version 1.0.6.0 to 2.0.0.0

Files changed (30) hide show
  1. app/code/local/HC/PayByFinance/Block/Adminhtml/Paybyfinance/Service/Edit/Tab/Form.php +2 -2
  2. app/code/local/HC/PayByFinance/Block/Adminhtml/Version.php +5 -0
  3. app/code/local/HC/PayByFinance/Block/Product/List/Finance.php +18 -0
  4. app/code/local/HC/PayByFinance/Block/Selector.php +6 -0
  5. app/code/local/HC/PayByFinance/Helper/Checkout.php +34 -8
  6. app/code/local/HC/PayByFinance/Helper/Data.php +77 -10
  7. app/code/local/HC/PayByFinance/Helper/Notification.php +132 -16
  8. app/code/local/HC/PayByFinance/Model/Config/Source/Catalog/Product/Type.php +5 -0
  9. app/code/local/HC/PayByFinance/Model/Config/Source/Connectionmode.php +0 -2
  10. app/code/local/HC/PayByFinance/Model/Observer.php +43 -3
  11. app/code/local/HC/PayByFinance/Model/Post/Simulationrtl.php +0 -33
  12. app/code/local/HC/PayByFinance/Model/Post/Testrtl.php +0 -33
  13. app/code/local/HC/PayByFinance/Model/Sales/Order/Invoice/Financeamount.php +12 -7
  14. app/code/local/HC/PayByFinance/Model/Sessionobserver.php +7 -0
  15. app/code/local/HC/PayByFinance/controllers/Adminhtml/Paybyfinance/ServiceController.php +1 -1
  16. app/code/local/HC/PayByFinance/controllers/CheckoutController.php +12 -7
  17. app/code/local/HC/PayByFinance/controllers/NotificationController.php +34 -10
  18. app/code/local/HC/PayByFinance/controllers/StatusController.php +17 -7
  19. app/code/local/HC/PayByFinance/etc/config.xml +23 -3
  20. app/code/local/HC/PayByFinance/etc/system.xml +20 -0
  21. app/code/local/HC/PayByFinance/sql/paybyfinance_setup/html/referred.html +0 -3
  22. app/code/local/HC/PayByFinance/sql/paybyfinance_setup/{mysql4-install-1.0.6.php → mysql4-install-2.0.0.php} +6 -4
  23. app/code/local/HC/PayByFinance/sql/paybyfinance_setup/mysql4-upgrade-1.0.6-1.0.7.php +30 -0
  24. app/code/local/HC/PayByFinance/sql/paybyfinance_setup/mysql4-upgrade-1.0.7-2.0.0.php +21 -0
  25. app/design/frontend/base/default/template/paybyfinance/catalog/product/list/finance.phtml +1 -1
  26. app/design/frontend/base/default/template/paybyfinance/selector.phtml +13 -0
  27. app/etc/modules/HC_PayByFinance.xml +1 -0
  28. js/paybyfinance/service.js +3 -3
  29. package.xml +28 -13
  30. skin/frontend/base/default/js/paybyfinance/checkout.js +25 -12
app/code/local/HC/PayByFinance/Block/Adminhtml/Paybyfinance/Service/Edit/Tab/Form.php CHANGED
@@ -154,12 +154,12 @@ class HC_PayByFinance_Block_Adminhtml_Paybyfinance_Service_Edit_Tab_Form
154
  )
155
  );
156
 
157
- if ( Mage::getSingleton('adminhtml/session')->getServiceData() ) {
158
  $form->setValues(
159
  Mage::getSingleton('adminhtml/session')->getServiceData()
160
  );
161
  Mage::getSingleton('adminhtml/session')->setServiceData(null);
162
- } elseif ( Mage::registry('service_data') ) {
163
  $form->setValues(Mage::registry('service_data')->getData());
164
  }
165
 
154
  )
155
  );
156
 
157
+ if (Mage::getSingleton('adminhtml/session')->getServiceData()) {
158
  $form->setValues(
159
  Mage::getSingleton('adminhtml/session')->getServiceData()
160
  );
161
  Mage::getSingleton('adminhtml/session')->setServiceData(null);
162
+ } elseif (Mage::registry('service_data')) {
163
  $form->setValues(Mage::registry('service_data')->getData());
164
  }
165
 
app/code/local/HC/PayByFinance/Block/Adminhtml/Version.php CHANGED
@@ -53,6 +53,11 @@ class HC_PayByFinance_Block_Adminhtml_Version extends Mage_Adminhtml_Block_Templ
53
  {
54
  $ver = Mage::getConfig()->getNode('modules/HC_PayByFinance/version');
55
  $ver .= '.'.self::PATCH_LEVEL;
 
 
 
 
 
56
  return $ver;
57
  }
58
 
53
  {
54
  $ver = Mage::getConfig()->getNode('modules/HC_PayByFinance/version');
55
  $ver .= '.'.self::PATCH_LEVEL;
56
+ $buildFile = __DIR__.DS.'..'.DS.'..'.DS.'..'.DS.'build.ini';
57
+ if (file_exists($buildFile)) {
58
+ $ini = parse_ini_file($buildFile, true);
59
+ $ver .= ' build: '.$ini['HC_PayByFinance']['build'];
60
+ }
61
  return $ver;
62
  }
63
 
app/code/local/HC/PayByFinance/Block/Product/List/Finance.php CHANGED
@@ -28,6 +28,7 @@
28
  */
29
  class HC_PayByFinance_Block_Product_List_Finance extends Mage_Core_Block_Template
30
  {
 
31
 
32
  /**
33
  * Current product has finance?
@@ -55,4 +56,21 @@ class HC_PayByFinance_Block_Product_List_Finance extends Mage_Core_Block_Templat
55
 
56
  return $price;
57
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
28
  */
29
  class HC_PayByFinance_Block_Product_List_Finance extends Mage_Core_Block_Template
30
  {
31
+ private $_canDisplayFinance = null;
32
 
33
  /**
34
  * Current product has finance?
56
 
57
  return $price;
58
  }
59
+
60
+ /**
61
+ * Whether to display finance text under product in search result and category or not
62
+ *
63
+ * @return boolean
64
+ */
65
+ public function canDisplayFinance()
66
+ {
67
+ if ($this->_canDisplayFinance === null) {
68
+ $helper = Mage::helper('paybyfinance');
69
+ $this->_canDisplayFinance = (Mage::getStoreConfig(
70
+ $helper::XML_PATH_IN_BLOCK_DISPLAY
71
+ ) == 1);
72
+ }
73
+
74
+ return $this->_canDisplayFinance;
75
+ }
76
  }
app/code/local/HC/PayByFinance/Block/Selector.php CHANGED
@@ -66,6 +66,12 @@ class HC_PayByFinance_Block_Selector extends Mage_Core_Block_Template
66
  $cartHelper = Mage::helper('paybyfinance/cart');
67
  $this->_amount = $cartHelper->getEligibleAmount()
68
  + $cartHelper->getQuoteAdditionalAmount();
 
 
 
 
 
 
69
  }
70
  }
71
 
66
  $cartHelper = Mage::helper('paybyfinance/cart');
67
  $this->_amount = $cartHelper->getEligibleAmount()
68
  + $cartHelper->getQuoteAdditionalAmount();
69
+
70
+ $calculator = Mage::getSingleton('paybyfinance/calculator');
71
+ $minInstallment = $calculator->getLowestMonthlyInstallment($this->_amount);
72
+ if (!$minInstallment) {
73
+ return false;
74
+ }
75
  }
76
  }
77
 
app/code/local/HC/PayByFinance/Helper/Checkout.php CHANGED
@@ -67,24 +67,50 @@ class HC_PayByFinance_Helper_Checkout extends Mage_Core_Helper_Data
67
  throw new Exception("Invalid decision code", 1);
68
  }
69
 
70
-
71
- $message .= 'id: ' . $parameters['id'];
72
- $message .= ' id2: ' . $parameters['id2'];
73
- $message .= "\n" . $parameters['decision'];
74
  $message .= "\nApplication: " . $parameters['applicationNo'];
75
  $message .= "\nAuthorization: " . $parameters['authorisationcode'];
76
  $message .= "\nSURL: " . $parameters['sourceurl'];
77
- $message .= "\nReason: " . $parameters['Errreason'];
78
- $message .= "\nMessage: " . $parameters['Errtext'];
79
 
80
  $state = Mage_Sales_Model_Order::STATE_PROCESSING;
81
- $order->setState($state, $status);
82
- $order->addStatusToHistory($status, nl2br(trim($message)), false);
 
 
 
 
 
 
 
 
 
 
83
  $order->save();
84
 
85
  return $redirectUrl;
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  /**
89
  * Processes unexpected return from the CheckoutController
90
  *
67
  throw new Exception("Invalid decision code", 1);
68
  }
69
 
70
+ $message .= $this->getParamText('id', 'id', $parameters);
71
+ $message .= $this->getParamText('id2', 'id2', $parameters);
72
+ $message .= "\nFinance: " . $parameters['decision'];
 
73
  $message .= "\nApplication: " . $parameters['applicationNo'];
74
  $message .= "\nAuthorization: " . $parameters['authorisationcode'];
75
  $message .= "\nSURL: " . $parameters['sourceurl'];
76
+ $message .= $this->getParamText('Errreason', 'Reason', $parameters);
77
+ $message .= $this->getParamText('Errtext', 'Message', $parameters);
78
 
79
  $state = Mage_Sales_Model_Order::STATE_PROCESSING;
80
+ $financeStatus = $order->getFinanceStatus();
81
+ if ($financeStatus == 'ACCEPT') {
82
+ $financeStatus = 'ACCEPTED';
83
+ }
84
+ if ($parameters['decision'] != $financeStatus // Don't change status if not modified.
85
+ && !$order->getPaybyfinanceEnable() // Don't change status on second return.
86
+ ) {
87
+ $order->setState($state, $status);
88
+ $order->setFinanceStatus($parameters['decision']);
89
+ }
90
+ $order->addStatusHistoryComment(nl2br(trim($message), false));
91
+ $order->setPaybyfinanceEnable(true);
92
  $order->save();
93
 
94
  return $redirectUrl;
95
  }
96
 
97
+ /**
98
+ * Get parmeter by it's id with text and semicolon.
99
+ *
100
+ * @param string $id Id
101
+ * @param string $text text
102
+ * @param array $parameters Parameters array
103
+ *
104
+ * @return string String representation
105
+ */
106
+ protected function getParamText($id, $text, $parameters)
107
+ {
108
+ if (isset($parameters[$id]) && $parameters[$id]) {
109
+ return "\n" . $text . ': ' . $parameters[$id];
110
+ }
111
+
112
+ }
113
+
114
  /**
115
  * Processes unexpected return from the CheckoutController
116
  *
app/code/local/HC/PayByFinance/Helper/Data.php CHANGED
@@ -36,6 +36,8 @@ class HC_PayByFinance_Helper_Data extends Mage_Core_Helper_Data
36
  const XML_PATH_INCLUDE_SHIPPING = 'hc_paybyfinance/general/include_shipping';
37
  const XML_PATH_ADDRESS_CHECKED = 'hc_paybyfinance/general/address_checked';
38
  const XML_PATH_WIZARD = 'hc_paybyfinance/general/wizard';
 
 
39
  const XML_PATH_STATUS_ACCEPTED = 'hc_paybyfinance/order_status/accepted';
40
  const XML_PATH_STATUS_REFERRED = 'hc_paybyfinance/order_status/referred';
41
  const XML_PATH_STATUS_DECLINED = 'hc_paybyfinance/order_status/declined';
@@ -58,6 +60,10 @@ class HC_PayByFinance_Helper_Data extends Mage_Core_Helper_Data
58
  const ERROR_LOG_PATH_LOG = 'paybyfinance/paybyfinance-log.log';
59
  const ERROR_LOG_PATH_POST = 'paybyfinance/paybyfinance-post.log';
60
  const ERROR_LOG_PATH_NOTIFICATION = 'paybyfinance/paybyfinance-notification.log';
 
 
 
 
61
 
62
  private $_types;
63
 
@@ -155,11 +161,11 @@ class HC_PayByFinance_Helper_Data extends Mage_Core_Helper_Data
155
  {
156
  $options = Mage::getSingleton('paybyfinance/config_source_catalog_product_finance');
157
 
158
- if ( $item instanceof Mage_Sales_Model_Quote_Item
159
  || $item instanceof Mage_Sales_Model_Order_Item
160
  ) {
161
  $product = $item->getProduct();
162
- $price = $item->getPrice();
163
  } elseif ($item instanceof Mage_Catalog_Model_Product) {
164
  $product = $item;
165
  $price = $product->getFinalPrice();
@@ -177,13 +183,16 @@ class HC_PayByFinance_Helper_Data extends Mage_Core_Helper_Data
177
  return false;
178
  }
179
  $minPriceProduct = Mage::getStoreConfig($helper::XML_PATH_MINIMUM_PRICE_PRODUCT);
180
- if ($price < $minPriceProduct) {
181
  return false;
182
  }
183
- $calculator = Mage::getSingleton('paybyfinance/calculator');
184
- $minInstallment = $calculator->getLowestMonthlyInstallment($product->getPrice());
185
- if (!$minInstallment) {
186
- return false;
 
 
 
187
  }
188
 
189
  return true;
@@ -233,7 +242,7 @@ class HC_PayByFinance_Helper_Data extends Mage_Core_Helper_Data
233
  *
234
  * @return integer Id of the saved log.
235
  */
236
- public function logDB($data, $type ='log')
237
  {
238
 
239
  if (!is_null($data)) {
@@ -304,8 +313,66 @@ class HC_PayByFinance_Helper_Data extends Mage_Core_Helper_Data
304
  */
305
  public function sanitizeProductName($productName)
306
  {
307
- $cleanedName = preg_replace('/[^a-zA-Z0-9\s@\.\-\(\)\+:\/\?\']/', '', $productName);
308
- return $cleanedName;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  }
310
 
311
  /**
36
  const XML_PATH_INCLUDE_SHIPPING = 'hc_paybyfinance/general/include_shipping';
37
  const XML_PATH_ADDRESS_CHECKED = 'hc_paybyfinance/general/address_checked';
38
  const XML_PATH_WIZARD = 'hc_paybyfinance/general/wizard';
39
+ const XML_PATH_IN_BLOCK_DISPLAY = 'hc_paybyfinance/general/display_in_results';
40
+ const XML_PATH_INVOICE_FINANCE = 'hc_paybyfinance/general/invoice_finance';
41
  const XML_PATH_STATUS_ACCEPTED = 'hc_paybyfinance/order_status/accepted';
42
  const XML_PATH_STATUS_REFERRED = 'hc_paybyfinance/order_status/referred';
43
  const XML_PATH_STATUS_DECLINED = 'hc_paybyfinance/order_status/declined';
60
  const ERROR_LOG_PATH_LOG = 'paybyfinance/paybyfinance-log.log';
61
  const ERROR_LOG_PATH_POST = 'paybyfinance/paybyfinance-post.log';
62
  const ERROR_LOG_PATH_NOTIFICATION = 'paybyfinance/paybyfinance-notification.log';
63
+ const REGEXP_PRODUCT_NAME = '/[^a-zA-Z0-9\s@\.\-\(\)\+:\/\?\']/';
64
+ const REGEXP_NAME = '/[^a-zA-Z\s]/';
65
+ const REGEXP_TITLE = '/[^a-zA-Z\s\.]/';
66
+ const REGEXP_STREET = '/[^a-zA-Z0-9\s\.\-\/]/';
67
 
68
  private $_types;
69
 
161
  {
162
  $options = Mage::getSingleton('paybyfinance/config_source_catalog_product_finance');
163
 
164
+ if ($item instanceof Mage_Sales_Model_Quote_Item
165
  || $item instanceof Mage_Sales_Model_Order_Item
166
  ) {
167
  $product = $item->getProduct();
168
+ $price = $item->getRowTotalInclTax();
169
  } elseif ($item instanceof Mage_Catalog_Model_Product) {
170
  $product = $item;
171
  $price = $product->getFinalPrice();
183
  return false;
184
  }
185
  $minPriceProduct = Mage::getStoreConfig($helper::XML_PATH_MINIMUM_PRICE_PRODUCT);
186
+ if ($product->getPrice() < $minPriceProduct) {
187
  return false;
188
  }
189
+
190
+ if ($item instanceof Mage_Catalog_Model_Product) {
191
+ $calculator = Mage::getSingleton('paybyfinance/calculator');
192
+ $minInstallment = $calculator->getLowestMonthlyInstallment($price);
193
+ if (!$minInstallment) {
194
+ return false;
195
+ }
196
  }
197
 
198
  return true;
242
  *
243
  * @return integer Id of the saved log.
244
  */
245
+ public function logDB($data, $type = 'log')
246
  {
247
 
248
  if (!is_null($data)) {
313
  */
314
  public function sanitizeProductName($productName)
315
  {
316
+ return $this->toAscii($productName, self::REGEXP_PRODUCT_NAME);
317
+ }
318
+
319
+ /**
320
+ * Converts string from non-ascii to ascii characters
321
+ *
322
+ * @param string $string to be converted to ascii representation
323
+ * @param string $regexToRemove regular expression of chars to be removed
324
+ *
325
+ * @return string. If no intl module present, returns $string
326
+ */
327
+ private function toAscii($string, $regexToRemove)
328
+ {
329
+ if (class_exists("Transliterator")) {
330
+ $string = transliterator_transliterate(
331
+ 'Any-Latin; Latin-ASCII',
332
+ $string
333
+ );
334
+ }
335
+
336
+ return preg_replace($regexToRemove, '', $string);
337
+ }
338
+
339
+ /**
340
+ * Sanitize objects name
341
+ * Allow chars: A-Z a-z
342
+ *
343
+ * @param string $string for transliterate and sanitize
344
+ *
345
+ * @return string Cleaned string
346
+ */
347
+ public function sanitizeName($string)
348
+ {
349
+ return $this->toAscii($string, self::REGEXP_NAME);
350
+ }
351
+
352
+ /**
353
+ * Sanitize title before name
354
+ * Allow chars: A-Z a-z .
355
+ *
356
+ * @param string $string for transliterate and sanitize
357
+ *
358
+ * @return string Cleaned string
359
+ */
360
+ public function sanitizeTitle($string)
361
+ {
362
+ return $this->toAscii($string, self::REGEXP_TITLE);
363
+ }
364
+
365
+ /**
366
+ * Sanitize street name
367
+ * Allow chars: a-z A-Z 0-9 . - /
368
+ *
369
+ * @param string $string for transliterate and sanitize
370
+ *
371
+ * @return string Cleaned string
372
+ */
373
+ public function sanitizeStreet($string)
374
+ {
375
+ return $this->toAscii($string, self::REGEXP_STREET);
376
  }
377
 
378
  /**
app/code/local/HC/PayByFinance/Helper/Notification.php CHANGED
@@ -75,6 +75,8 @@ class HC_PayByFinance_Helper_Notification extends Mage_Core_Helper_Data
75
  * @param array $parameters Array of parameters
76
  *
77
  * @return boolean true if success, false on error
 
 
78
  */
79
  public function processOrder($order, $parameters)
80
  {
@@ -94,21 +96,142 @@ class HC_PayByFinance_Helper_Notification extends Mage_Core_Helper_Data
94
  $orderState = $orderStatus = Mage_Sales_Model_Order::STATE_CANCELED;
95
  }
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  switch ($status) {
98
  case 'ACCEPT':
99
  case 'CONDITIONAL_ACCEPT':
100
  if (array_key_exists('goodsDispatched', $parameters)
101
  && $parameters['goodsDispatched'] == 'N'
102
  ) {
103
- $message .= ' Awaiting dispatch of goods. authorisationNumber: '
104
- . $parameters['authorisationNumber'];
105
  $orderState = $orderStatus = Mage_Sales_Model_Order::STATE_PROCESSING;
106
- $order->setTotalPaid(
107
- $order->getTotalPaid() + abs($order->getFinanceAmount())
108
- );
109
- $order->setBaseTotalPaid(
110
- $order->getBaseTotalPaid() + abs($order->getFinanceAmount())
111
- );
112
  } else {
113
  $orderStatus = Mage::getStoreConfig($helper::XML_PATH_STATUS_ACCEPTED);
114
  }
@@ -124,13 +247,6 @@ class HC_PayByFinance_Helper_Notification extends Mage_Core_Helper_Data
124
  break;
125
  }
126
 
127
- $message = "<strong>Hitachi Capital Pay By Finance"
128
- . "</strong> notification received: " . $status . ': ' . $message;
129
- $order->setFinanceStatus($status)
130
- ->setFinanceApplicationNo($applicationNo)
131
- ->setState($orderState, $orderStatus)
132
- ->addStatusToHistory($orderStatus, $message, false);
133
- return $order->save();
134
  }
135
-
136
  }
75
  * @param array $parameters Array of parameters
76
  *
77
  * @return boolean true if success, false on error
78
+ *
79
+ * @throws Exception when notification received too early for order
80
  */
81
  public function processOrder($order, $parameters)
82
  {
96
  $orderState = $orderStatus = Mage_Sales_Model_Order::STATE_CANCELED;
97
  }
98
 
99
+ if ($status == 'ACCEPT' || $status == 'CONDITIONAL_ACCEPT') {
100
+ if (array_key_exists('goodsDispatched', $parameters)
101
+ && $parameters['goodsDispatched'] == 'N'
102
+ ) {
103
+ $message .= ' Awaiting dispatch of goods (WET). authorisationNumber: '
104
+ . $parameters['authorisationNumber'];
105
+ $this->addTotals($order);
106
+ } elseif (array_key_exists('esignatureStatus', $parameters)
107
+ && array_key_exists('goodsDispatched', $parameters)
108
+ && $parameters['esignatureStatus'] == 'COMPLETED - E-signature was completed'
109
+ && $parameters['goodsDispatched'] == ''
110
+ ) {
111
+ $message .= ' Awaiting dispatch of goods (eSignature). authorisationNumber: '
112
+ . $parameters['authorisationNumber'];
113
+ $this->addTotals($order);
114
+ }
115
+ }
116
+
117
+ if (isset($parameters['esignatureStatus']) && $parameters['esignatureStatus']) {
118
+ $message .= ' esignatureStatus: ' . $parameters['esignatureStatus'] . '. ';
119
+ }
120
+ if (isset($parameters['goodsDispatched']) && $parameters['goodsDispatched']) {
121
+ $message .= ' goodsDispatched: ' . $parameters['goodsDispatched'] . '. ';
122
+ }
123
+
124
+ $message = "<strong>Hitachi Capital Pay By Finance"
125
+ . "</strong> notification received: " . $status . ': ' . $message;
126
+
127
+ list($orderState, $orderStatus) = $this->getOrderStateAndStatus($parameters);
128
+
129
+ $this->financeStatusChange($status, $order, $orderStatus, $orderState);
130
+ $order
131
+ ->setFinanceApplicationNo($applicationNo)
132
+ ->addStatusHistoryComment($message, false);
133
+ return $order->save();
134
+ }
135
+
136
+ /**
137
+ * Add totals to the order
138
+ *
139
+ * @param Mage_Sales_Model_Order $order Order object
140
+ *
141
+ * @return void
142
+ *
143
+ * @throws Exception when notification received too early for order
144
+ */
145
+ protected function addTotals($order)
146
+ {
147
+ if (!$order->getPaybyfinanceEnable()) {
148
+ throw new Exception('Notification received too early for order: ' . $order->getId(), 1);
149
+ }
150
+ $finance = new Varien_Object();
151
+ $finance->setUpdateTotals(true);
152
+ Mage::dispatchEvent(
153
+ 'paybyfinance_totals_notification_update',
154
+ array('order' => $order, 'finance' => $finance)
155
+ );
156
+ if ($order->getFinanceTotalAdded() != 1) {
157
+ if ($finance->getUpdateTotals()) {
158
+ $order->setGrandTotal(
159
+ $order->getGrandTotal() + abs($order->getFinanceAmount())
160
+ );
161
+ $order->setBaseGrandTotal(
162
+ $order->getBaseGrandTotal() + abs($order->getFinanceAmount())
163
+ );
164
+ }
165
+ $order->setFinanceTotalAdded(1);
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Change finance order status, but only when status changed in the request
171
+ *
172
+ * @param string $status Finance status
173
+ * @param Mage_Sales_Model_Order $order Order
174
+ * @param String $orderStatus Order status
175
+ * @param String $orderState Order state
176
+ *
177
+ * @return bool True if the status was changed
178
+ */
179
+ protected function financeStatusChange($status, $order, $orderStatus, $orderState)
180
+ {
181
+ $disallowChange = array(
182
+ Mage_Sales_Model_Order::STATE_COMPLETE,
183
+ Mage_Sales_Model_Order::STATE_CLOSED,
184
+ Mage_Sales_Model_Order::STATE_CANCELED,
185
+ Mage_Sales_Model_Order::STATE_PROCESSING
186
+ );
187
+ $origStatus = $order->getFinanceStatus();
188
+ if ($origStatus == 'ACCEPTED') {
189
+ $origStatus = 'ACCEPT';
190
+ }
191
+
192
+ if ($status == 'ACCEPT' && !in_array($order->getStatus(), $disallowChange)) {
193
+ $order->setState($orderState, $orderStatus);
194
+ }
195
+ if ($origStatus != $status) {
196
+ $order->setFinanceStatus($status);
197
+ $order->setState($orderState, $orderStatus);
198
+ return true;
199
+ }
200
+
201
+ return false;
202
+ }
203
+
204
+ /**
205
+ * Calculate order state and status based on notification parameters
206
+ *
207
+ * @param array $parameters request parameters
208
+ *
209
+ * @return array Array of state and status
210
+ */
211
+ protected function getOrderStateAndStatus($parameters)
212
+ {
213
+ $helper = Mage::helper('paybyfinance');
214
+ $status = strtoupper($parameters['status']);
215
+
216
+ $orderState = $orderStatus = '';
217
+
218
+ if (in_array($status, $this->cancelStatus)) {
219
+ $orderState = $orderStatus = Mage_Sales_Model_Order::STATE_CANCELED;
220
+ }
221
+
222
  switch ($status) {
223
  case 'ACCEPT':
224
  case 'CONDITIONAL_ACCEPT':
225
  if (array_key_exists('goodsDispatched', $parameters)
226
  && $parameters['goodsDispatched'] == 'N'
227
  ) {
 
 
228
  $orderState = $orderStatus = Mage_Sales_Model_Order::STATE_PROCESSING;
229
+ } elseif (array_key_exists('esignatureStatus', $parameters)
230
+ && array_key_exists('goodsDispatched', $parameters)
231
+ && $parameters['esignatureStatus'] == 'COMPLETED - E-signature was completed'
232
+ && $parameters['goodsDispatched'] == ''
233
+ ) {
234
+ $orderState = $orderStatus = Mage_Sales_Model_Order::STATE_PROCESSING;
235
  } else {
236
  $orderStatus = Mage::getStoreConfig($helper::XML_PATH_STATUS_ACCEPTED);
237
  }
247
  break;
248
  }
249
 
250
+ return array($orderState, $orderStatus);
 
 
 
 
 
 
251
  }
 
252
  }
app/code/local/HC/PayByFinance/Model/Config/Source/Catalog/Product/Type.php CHANGED
@@ -38,6 +38,11 @@ class HC_PayByFinance_Model_Config_Source_Catalog_Product_Type
38
  if (!$this->_options) {
39
  $this->_options = Mage_Catalog_Model_Product_Type::getAllOptions();
40
  unset($this->_options[0]);
 
 
 
 
 
41
  }
42
  $options = $this->_options;
43
 
38
  if (!$this->_options) {
39
  $this->_options = Mage_Catalog_Model_Product_Type::getAllOptions();
40
  unset($this->_options[0]);
41
+ foreach ($this->_options as $key => $value) {
42
+ if (in_array($value['value'], array('downloadable', 'virtual'))) {
43
+ unset($this->_options[$key]);
44
+ }
45
+ }
46
  }
47
  $options = $this->_options;
48
 
app/code/local/HC/PayByFinance/Model/Config/Source/Connectionmode.php CHANGED
@@ -35,9 +35,7 @@ class HC_PayByFinance_Model_Config_Source_Connectionmode
35
  {
36
  $options = array(
37
  'test' => 'Test',
38
- 'testrtl' => 'Test RTL',
39
  'simulation' => 'Simulation',
40
- 'simulationrtl' => 'Simulation RTL',
41
  'custom' => 'Custom',
42
  'live' => 'Live',
43
  );
35
  {
36
  $options = array(
37
  'test' => 'Test',
 
38
  'simulation' => 'Simulation',
 
39
  'custom' => 'Custom',
40
  'live' => 'Live',
41
  );
app/code/local/HC/PayByFinance/Model/Observer.php CHANGED
@@ -81,13 +81,21 @@ class HC_PayByFinance_Model_Observer
81
 
82
  $amt = $finance->getFinanceAmount() * -1;
83
  if ($amt) {
 
 
 
 
 
 
84
  $order->setFinanceAmount($amt)
85
  ->setBaseFinanceAmount($amt)
86
  ->setFinanceService($serviceId)
87
  ->setFinanceDeposit($deposit)
88
- ->setBaseTotalDue($order->getBaseGrandTotal())
89
- ->setTotalDue($order->getGrandTotal())
90
  ->setFromQuote(true);
 
 
 
 
91
  }
92
  }
93
 
@@ -188,7 +196,7 @@ class HC_PayByFinance_Model_Observer
188
  $post->setNotificationData($data);
189
  $response = $post->post();
190
  $helper->log(
191
- 'Inbound notification for order: ' . $order->getId() . "\n"
192
  . $helper->arrayDump($post->getPostAdapter()->getPostData()) . "\n"
193
  . 'Response: ' . $response,
194
  'post'
@@ -313,4 +321,36 @@ class HC_PayByFinance_Model_Observer
313
  Varien_Profiler::stop('hc_paybyfinance_collection_load_after');
314
  }
315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  }
81
 
82
  $amt = $finance->getFinanceAmount() * -1;
83
  if ($amt) {
84
+ $finance->setUpdateTotals(true);
85
+ // Use $finance->setUpdateTotals(false) to avoid Total Due to change
86
+ Mage::dispatchEvent(
87
+ 'paybyfinance_totals_pre_update',
88
+ array('order' => $order, 'address' => $address, 'finance' => $finance)
89
+ );
90
  $order->setFinanceAmount($amt)
91
  ->setBaseFinanceAmount($amt)
92
  ->setFinanceService($serviceId)
93
  ->setFinanceDeposit($deposit)
 
 
94
  ->setFromQuote(true);
95
+ if ($finance->getUpdateTotals()) {
96
+ $order->setBaseTotalDue($order->getBaseGrandTotal())
97
+ ->setTotalDue($order->getGrandTotal());
98
+ }
99
  }
100
  }
101
 
196
  $post->setNotificationData($data);
197
  $response = $post->post();
198
  $helper->log(
199
+ 'Inbound notification for order: ' . $order->getIncrementId() . "\n"
200
  . $helper->arrayDump($post->getPostAdapter()->getPostData()) . "\n"
201
  . 'Response: ' . $response,
202
  'post'
321
  Varien_Profiler::stop('hc_paybyfinance_collection_load_after');
322
  }
323
 
324
+ /**
325
+ * Set Analyitics Order ID.
326
+ *
327
+ * @param Varien_Event_Observer $observer Observer
328
+ *
329
+ * @return void
330
+ */
331
+ public function googleAnalyticsSetOrderId(Varien_Event_Observer $observer)
332
+ {
333
+ if (Mage::getSingleton('paybyfinance/session')->getData('analytics_sent')) {
334
+ return;
335
+ }
336
+ $order = Mage::getModel('sales/order')->load(
337
+ Mage::getSingleton('paybyfinance/session')->getData('order_id')
338
+ );
339
+ $lastOrderId = $order->getId();
340
+ if (!is_numeric($lastOrderId)) {
341
+ return;
342
+ }
343
+
344
+ $block = Mage::app()
345
+ ->getFrontController()
346
+ ->getAction()
347
+ ->getLayout()
348
+ ->getBlock('google_analytics');
349
+
350
+ if ($block) {
351
+ $block->setOrderIds(array($lastOrderId));
352
+ Mage::getSingleton('paybyfinance/session')->setData('analytics_sent', true);
353
+ }
354
+ }
355
+
356
  }
app/code/local/HC/PayByFinance/Model/Post/Simulationrtl.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- /**
3
- * Hitachi Capital Pay By Finance
4
- *
5
- * Hitachi Capital Pay By Finance Extension
6
- *
7
- * PHP version >= 5.3.*
8
- *
9
- * @category HC
10
- * @package PayByFinance
11
- * @author Healthy Websites <support@healthywebsites.co.uk>
12
- * @copyright 2014 Hitachi Capital
13
- * @license http://www.gnu.org/copyleft/gpl.html GPL License
14
- * @link http://www.healthywebsites.co.uk/
15
- *
16
- */
17
-
18
- /**
19
- * Hitachi Post Simulation Model
20
- *
21
- * @category HC
22
- * @package PayByFinance
23
- * @author Healthy Websites <support@healthywebsites.co.uk>
24
- * @license http://www.gnu.org/copyleft/gpl.html GPL License
25
- * @link http://www.healthywebsites.co.uk/
26
- */
27
- class HC_PayByFinance_Model_Post_Simulationrtl extends HC_PayByFinance_Model_Post_Abstract
28
- {
29
- protected $_postUrl =
30
- 'https://rtl-www.creditmaster2.co.uk/Ecommerce/etailer/createQuote.action';
31
- protected $_notifyUrl = 'https://rtl-www.creditmaster2.co.uk/Ecommerce/etailer/notify.action';
32
- protected $_mode = 'simulation';
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/HC/PayByFinance/Model/Post/Testrtl.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- /**
3
- * Hitachi Capital Pay By Finance
4
- *
5
- * Hitachi Capital Pay By Finance Extension
6
- *
7
- * PHP version >= 5.3.*
8
- *
9
- * @category HC
10
- * @package PayByFinance
11
- * @author Healthy Websites <support@healthywebsites.co.uk>
12
- * @copyright 2014 Hitachi Capital
13
- * @license http://www.gnu.org/copyleft/gpl.html GPL License
14
- * @link http://www.healthywebsites.co.uk/
15
- *
16
- */
17
-
18
- /**
19
- * Hitachi Post TEst Model
20
- *
21
- * @category HC
22
- * @package PayByFinance
23
- * @author Healthy Websites <support@healthywebsites.co.uk>
24
- * @license http://www.gnu.org/copyleft/gpl.html GPL License
25
- * @link http://www.healthywebsites.co.uk/
26
- */
27
- class HC_PayByFinance_Model_Post_Testrtl extends HC_PayByFinance_Model_Post_Abstract
28
- {
29
- protected $_postUrl =
30
- 'https://rtl-www.creditmaster2.co.uk/Ecommerce/etailer/createQuote.action';
31
- protected $_notifyUrl = 'https://rtl-www.creditmaster2.co.uk/Ecommerce/etailer/notify.action';
32
- protected $_mode = 'test';
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/HC/PayByFinance/Model/Sales/Order/Invoice/Financeamount.php CHANGED
@@ -38,6 +38,7 @@ class HC_PayByFinance_Model_Sales_Order_Invoice_Financeamount
38
  */
39
  public function collect(Mage_Sales_Model_Order_Invoice $invoice)
40
  {
 
41
  $order = $invoice->getOrder();
42
  $amount = $order->getFinanceAmount();
43
  if ($amount == 0) {
@@ -46,7 +47,9 @@ class HC_PayByFinance_Model_Sales_Order_Invoice_Financeamount
46
 
47
  // Previous invoices.
48
  foreach ($order->getInvoiceCollection() as $previusInvoice) {
49
- if ((float) $previusInvoice->getHcfinanced() != 0 && !$previusInvoice->isCanceled()) {
 
 
50
  return $this;
51
  }
52
  }
@@ -54,12 +57,14 @@ class HC_PayByFinance_Model_Sales_Order_Invoice_Financeamount
54
  $invoice->setFinanceAmount($amount);
55
  $invoice->setBaseFinanceAmount($order->getBaseFinanceAmount());
56
 
57
- $invoice->setGrandTotal(
58
- $invoice->getGrandTotal() - abs($invoice->getFinanceAmount())
59
- );
60
- $invoice->setBaseGrandTotal(
61
- $invoice->getBaseGrandTotal() - abs($invoice->getBaseFinanceAmount())
62
- );
 
 
63
 
64
  return $this;
65
  }
38
  */
39
  public function collect(Mage_Sales_Model_Order_Invoice $invoice)
40
  {
41
+ $helper = Mage::helper('paybyfinance');
42
  $order = $invoice->getOrder();
43
  $amount = $order->getFinanceAmount();
44
  if ($amount == 0) {
47
 
48
  // Previous invoices.
49
  foreach ($order->getInvoiceCollection() as $previusInvoice) {
50
+ if ((float) $previusInvoice->getHcfinanced() != 0
51
+ && !$previusInvoice->isCanceled()
52
+ ) {
53
  return $this;
54
  }
55
  }
57
  $invoice->setFinanceAmount($amount);
58
  $invoice->setBaseFinanceAmount($order->getBaseFinanceAmount());
59
 
60
+ if (Mage::getStoreConfig($helper::XML_PATH_INVOICE_FINANCE)) {
61
+ $invoice->setGrandTotal(
62
+ $invoice->getGrandTotal() - abs($invoice->getFinanceAmount())
63
+ );
64
+ $invoice->setBaseGrandTotal(
65
+ $invoice->getBaseGrandTotal() - abs($invoice->getBaseFinanceAmount())
66
+ );
67
+ }
68
 
69
  return $this;
70
  }
app/code/local/HC/PayByFinance/Model/Sessionobserver.php CHANGED
@@ -59,9 +59,16 @@ class HC_PayByFinance_Model_Sessionobserver
59
  $eligibleAmount += $shippingCost;
60
  }
61
 
 
 
 
 
 
 
62
  if (($eligibleAmount) < $minAmount) {
63
  $session->setData('enabled', false);
64
  }
 
65
  if (!$helper->isActive()) {
66
  $session->setData('enabled', false);
67
  }
59
  $eligibleAmount += $shippingCost;
60
  }
61
 
62
+ $calculator = Mage::getSingleton('paybyfinance/calculator');
63
+ $minInstallment = $calculator->getLowestMonthlyInstallment($eligibleAmount);
64
+ if (!$minInstallment) {
65
+ $session->setData('enabled', false);
66
+ }
67
+
68
  if (($eligibleAmount) < $minAmount) {
69
  $session->setData('enabled', false);
70
  }
71
+
72
  if (!$helper->isActive()) {
73
  $session->setData('enabled', false);
74
  }
app/code/local/HC/PayByFinance/controllers/Adminhtml/Paybyfinance/ServiceController.php CHANGED
@@ -126,7 +126,7 @@ class HC_PayByFinance_Adminhtml_Paybyfinance_ServiceController
126
  */
127
  public function saveAction()
128
  {
129
- if ( $this->getRequest()->getPost() ) {
130
  try {
131
  $postData = $this->getRequest()->getPost();
132
 
126
  */
127
  public function saveAction()
128
  {
129
+ if ($this->getRequest()->getPost()) {
130
  try {
131
  $postData = $this->getRequest()->getPost();
132
 
app/code/local/HC/PayByFinance/controllers/CheckoutController.php CHANGED
@@ -143,12 +143,17 @@ class HC_PayByFinance_CheckoutController extends Mage_Core_Controller_Front_Acti
143
  'apr' => floor($service->getApr() * 1000) / 1000,
144
  'instalment' => $financeResult->getMonthlyPayment(), // monthly instalment
145
  'it' => count($eligibleProducts) + $additionalItems, // number of items
146
- 'ro' => $order->getId(), // Order reference
147
- 'title' => $address->getPrefix(),
148
- 'firstname' => $address->getFirstname(),
149
- 'surname' => $address->getLastname(),
150
- 'street' => trim($street[0] . ' ' . (isset($street[1]) ? $street[1] : '')),
151
- 'town' => $address->getCity(),
 
 
 
 
 
152
  'postcode' => $address->getPostcode(),
153
  'email' => $order->getCustomerEmail(),
154
  ),
@@ -190,7 +195,7 @@ class HC_PayByFinance_CheckoutController extends Mage_Core_Controller_Front_Acti
190
  $helper->log("Response: \n" . $helper->arrayDump($parameters), 'post');
191
 
192
  if (array_key_exists('ro', $parameters) && is_numeric($parameters['ro'])) {
193
- $order = Mage::getModel('sales/order')->load($parameters['ro']);
194
  }
195
 
196
  // Unexpected error, PBF didn't send a correct order id (authentication error?)
143
  'apr' => floor($service->getApr() * 1000) / 1000,
144
  'instalment' => $financeResult->getMonthlyPayment(), // monthly instalment
145
  'it' => count($eligibleProducts) + $additionalItems, // number of items
146
+ 'ro' => $order->getIncrementId(), // Order reference
147
+ 'title' => $helper->sanitizeTitle($address->getPrefix()),
148
+ 'firstname' => $helper->sanitizeName($address->getFirstname()),
149
+ 'surname' => $helper->sanitizeName($address->getLastname()),
150
+ 'street' => $helper->sanitizeStreet(
151
+ trim(
152
+ $street[0] . ' ' . (isset($street[1]) ? $street[1]
153
+ : '')
154
+ )
155
+ ),
156
+ 'town' => $helper->sanitizeName($address->getCity()),
157
  'postcode' => $address->getPostcode(),
158
  'email' => $order->getCustomerEmail(),
159
  ),
195
  $helper->log("Response: \n" . $helper->arrayDump($parameters), 'post');
196
 
197
  if (array_key_exists('ro', $parameters) && is_numeric($parameters['ro'])) {
198
+ $order = Mage::getModel('sales/order')->load($parameters['ro'], 'increment_id');
199
  }
200
 
201
  // Unexpected error, PBF didn't send a correct order id (authentication error?)
app/code/local/HC/PayByFinance/controllers/NotificationController.php CHANGED
@@ -28,8 +28,9 @@
28
  */
29
  class HC_PayByFinance_NotificationController extends Mage_Core_Controller_Front_Action
30
  {
 
31
  /**
32
- * indexAction
33
  *
34
  * @return void.
35
  */
@@ -47,17 +48,16 @@ class HC_PayByFinance_NotificationController extends Mage_Core_Controller_Front_
47
  'Error in notification parameters: ' . $helper->arrayDump($parameters),
48
  'notification'
49
  );
50
- echo "0";
51
  die();
52
  }
53
 
54
  $orderId = $parameters['supplierReference'];
55
 
56
- $order = Mage::getModel('sales/order')->load($orderId);
57
  if (!$order->getId()) {
58
  $helper->log('Order does not exist: ' . $orderId, 'notification');
59
- echo "0";
60
- die();
61
  }
62
 
63
  $helper->log(
@@ -66,18 +66,42 @@ class HC_PayByFinance_NotificationController extends Mage_Core_Controller_Front_
66
  );
67
 
68
  $notificationHelper = Mage::helper('paybyfinance/notification');
69
- $result = $notificationHelper->processOrder($order, $parameters);
 
 
 
 
 
 
 
70
 
71
  if ($result) {
72
  $helper->log(
73
  'Notification received successfully for order: ' . $orderId,
74
  'notification'
75
  );
76
- echo "1";
77
- die(); // Success
78
  } else {
79
- echo "0";
80
- die(); // Error saving the order
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
  }
83
  }
28
  */
29
  class HC_PayByFinance_NotificationController extends Mage_Core_Controller_Front_Action
30
  {
31
+
32
  /**
33
+ * Index action
34
  *
35
  * @return void.
36
  */
48
  'Error in notification parameters: ' . $helper->arrayDump($parameters),
49
  'notification'
50
  );
51
+ $this->returnStatus(false);
52
  die();
53
  }
54
 
55
  $orderId = $parameters['supplierReference'];
56
 
57
+ $order = Mage::getModel('sales/order')->load($orderId, 'increment_id');
58
  if (!$order->getId()) {
59
  $helper->log('Order does not exist: ' . $orderId, 'notification');
60
+ $this->returnStatus(false);
 
61
  }
62
 
63
  $helper->log(
66
  );
67
 
68
  $notificationHelper = Mage::helper('paybyfinance/notification');
69
+ try {
70
+ $result = $notificationHelper->processOrder($order, $parameters);
71
+ } catch (Exception $e) {
72
+ $helper->log(
73
+ $e->getMessage(),
74
+ 'notification'
75
+ );
76
+ }
77
 
78
  if ($result) {
79
  $helper->log(
80
  'Notification received successfully for order: ' . $orderId,
81
  'notification'
82
  );
83
+ $this->returnStatus(true); // Success.
 
84
  } else {
85
+ $this->returnStatus(false); // Error saving the order.
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Set return status
91
+ *
92
+ * @param bool $success Is success
93
+ *
94
+ * @return void
95
+ */
96
+ protected function returnStatus($success)
97
+ {
98
+ if ($success) {
99
+ echo '1';
100
+ die();
101
+ } else {
102
+ http_response_code(503);
103
+ echo '0';
104
+ die();
105
  }
106
  }
107
  }
app/code/local/HC/PayByFinance/controllers/StatusController.php CHANGED
@@ -45,7 +45,9 @@ class HC_PayByFinance_StatusController extends Mage_Core_Controller_Front_Action
45
  */
46
  public function acceptedAction()
47
  {
48
- $this->loadLayout()->renderLayout();
 
 
49
  }
50
 
51
  /**
@@ -55,7 +57,9 @@ class HC_PayByFinance_StatusController extends Mage_Core_Controller_Front_Action
55
  */
56
  public function referredAction()
57
  {
58
- $this->loadLayout()->renderLayout();
 
 
59
  }
60
 
61
  /**
@@ -65,27 +69,33 @@ class HC_PayByFinance_StatusController extends Mage_Core_Controller_Front_Action
65
  */
66
  public function declinedAction()
67
  {
68
- $this->loadLayout()->renderLayout();
 
 
69
  }
70
 
71
  /**
72
- * abandoned
73
  *
74
  * @return void
75
  */
76
  public function abandonedAction()
77
  {
78
- $this->loadLayout()->renderLayout();
 
 
79
  }
80
 
81
  /**
82
- * error
83
  *
84
  * @return void
85
  */
86
  public function errorAction()
87
  {
88
- $this->loadLayout()->renderLayout();
 
 
89
  }
90
 
91
  }
45
  */
46
  public function acceptedAction()
47
  {
48
+ $this->loadLayout();
49
+ Mage::dispatchEvent('paybyfinance_status_controller_accepted');
50
+ $this->renderLayout();
51
  }
52
 
53
  /**
57
  */
58
  public function referredAction()
59
  {
60
+ $this->loadLayout();
61
+ Mage::dispatchEvent('paybyfinance_status_controller_referred');
62
+ $this->renderLayout();
63
  }
64
 
65
  /**
69
  */
70
  public function declinedAction()
71
  {
72
+ $this->loadLayout();
73
+ Mage::dispatchEvent('paybyfinance_status_controller_declined');
74
+ $this->renderLayout();
75
  }
76
 
77
  /**
78
+ * Abandoned. This will be never loaded.
79
  *
80
  * @return void
81
  */
82
  public function abandonedAction()
83
  {
84
+ $this->loadLayout();
85
+ Mage::dispatchEvent('paybyfinance_status_controller_abandoned');
86
+ $this->renderLayout();
87
  }
88
 
89
  /**
90
+ * Error. This might be never used.
91
  *
92
  * @return void
93
  */
94
  public function errorAction()
95
  {
96
+ $this->loadLayout();
97
+ Mage::dispatchEvent('paybyfinance_status_controller_error');
98
+ $this->renderLayout();
99
  }
100
 
101
  }
app/code/local/HC/PayByFinance/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <HC_PayByFinance>
5
- <version>1.0.6</version>
6
  </HC_PayByFinance>
7
  </modules>
8
  <global>
@@ -202,6 +202,24 @@
202
  </hc_paypalpreparelineitemsObserver>
203
  </observers>
204
  </paypal_prepare_line_items>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  </events>
206
 
207
  </global>
@@ -280,6 +298,8 @@
280
  <include_shipping>1</include_shipping>
281
  <address_checked>0</address_checked>
282
  <wizard>0</wizard>
 
 
283
  </general>
284
  <order_status>
285
  <accepted>finance_accepted</accepted>
@@ -293,8 +313,8 @@
293
  </blocks_info>
294
  <account>
295
  <connectionmode>test</connectionmode>
296
- <connection_post>https://demo.creditmaster2.co.uk/Ecommerce/etailer/createQuote.action</connection_post>
297
- <connection_notify>https://demo.creditmaster2.co.uk/Ecommerce/etailer/notify.action</connection_notify>
298
  <id1></id1>
299
  <id2></id2>
300
  <erroremail></erroremail>
2
  <config>
3
  <modules>
4
  <HC_PayByFinance>
5
+ <version>2.0.0</version>
6
  </HC_PayByFinance>
7
  </modules>
8
  <global>
202
  </hc_paypalpreparelineitemsObserver>
203
  </observers>
204
  </paypal_prepare_line_items>
205
+ <paybyfinance_status_controller_accepted>
206
+ <observers>
207
+ <paybyfinance_status_accepted>
208
+ <type>singleton</type>
209
+ <class>paybyfinance/observer</class>
210
+ <method>googleAnalyticsSetOrderId</method>
211
+ </paybyfinance_status_accepted>
212
+ </observers>
213
+ </paybyfinance_status_controller_accepted>
214
+ <paybyfinance_status_controller_referred>
215
+ <observers>
216
+ <paybyfinance_status_referred>
217
+ <type>singleton</type>
218
+ <class>paybyfinance/observer</class>
219
+ <method>googleAnalyticsSetOrderId</method>
220
+ </paybyfinance_status_referred>
221
+ </observers>
222
+ </paybyfinance_status_controller_referred>
223
  </events>
224
 
225
  </global>
298
  <include_shipping>1</include_shipping>
299
  <address_checked>0</address_checked>
300
  <wizard>0</wizard>
301
+ <display_in_results>0</display_in_results>
302
+ <invoice_finance>0</invoice_finance>
303
  </general>
304
  <order_status>
305
  <accepted>finance_accepted</accepted>
313
  </blocks_info>
314
  <account>
315
  <connectionmode>test</connectionmode>
316
+ <connection_post></connection_post>
317
+ <connection_notify></connection_notify>
318
  <id1></id1>
319
  <id2></id2>
320
  <erroremail></erroremail>
app/code/local/HC/PayByFinance/etc/system.xml CHANGED
@@ -106,6 +106,26 @@
106
  <show_in_website>1</show_in_website>
107
  <show_in_store>1</show_in_store>
108
  </wizard>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  </fields>
110
  </general>
111
  <order_status>
106
  <show_in_website>1</show_in_website>
107
  <show_in_store>1</show_in_store>
108
  </wizard>
109
+ <display_in_results>
110
+ <label>Display Finance offer on category/search pages</label>
111
+ <comment>If enabled you will require a representative example for compliance sign off, ask your account manager</comment>
112
+ <frontend_type>select</frontend_type>
113
+ <source_model>adminhtml/system_config_source_yesno</source_model>
114
+ <sort_order>9</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ </display_in_results>
119
+ <invoice_finance>
120
+ <label>Add finance amount to grand total in invoice</label>
121
+ <comment>If your payment gateway is using capture and you set to yes when the invoice is created the payment gateway will capture the full amount rather than the grand total amount.</comment>
122
+ <frontend_type>select</frontend_type>
123
+ <source_model>adminhtml/system_config_source_yesno</source_model>
124
+ <sort_order>10</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ </invoice_finance>
129
  </fields>
130
  </general>
131
  <order_status>
app/code/local/HC/PayByFinance/sql/paybyfinance_setup/html/referred.html CHANGED
@@ -11,6 +11,3 @@
11
  <p>
12
  Hitachi Capital will normally provide a final decision within the next 24 hours.
13
  </p>
14
- <p>
15
- * Some referrals require some additional security checks so may take longer to obtain a decision.
16
- </p>
11
  <p>
12
  Hitachi Capital will normally provide a final decision within the next 24 hours.
13
  </p>
 
 
 
app/code/local/HC/PayByFinance/sql/paybyfinance_setup/{mysql4-install-1.0.6.php → mysql4-install-2.0.0.php} RENAMED
@@ -41,7 +41,7 @@ ALTER TABLE {$setup->getTable('sales_flat_quote_address')} ADD COLUMN finance_se
41
  ALTER TABLE {$setup->getTable('sales_flat_order')} ADD COLUMN finance_service int(11);
42
  ALTER TABLE {$setup->getTable('sales_flat_invoice')} ADD COLUMN finance_service int(11);
43
 
44
- ALTER TABLE {$setup->getTable('sales_flat_order')} ADD COLUMN finance_status varchar(1);
45
  ALTER TABLE {$setup->getTable('sales_flat_order')} ADD COLUMN finance_application_no varchar(50);
46
  "
47
  );
@@ -78,7 +78,7 @@ CREATE TABLE {$this->getTable('paybyfinance_log')} (
78
  `type` varchar(255) NOT NULL default '',
79
  `flow` varchar(255) NOT NULL default '',
80
  `time` varchar(255) NOT NULL default '',
81
- `content` text NOT NULL default '',
82
  PRIMARY KEY (`api_id`)
83
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
84
  "
@@ -174,7 +174,9 @@ foreach ($statuses as $key => $value) {
174
  }
175
 
176
  $setup->addAttribute(
177
- 'catalog_product', 'paybyfinance_enable', array(
 
 
178
  'group' => 'Hitachi Capital - Pay By Finance',
179
  'type' => 'int',
180
  'backend' => '',
@@ -234,7 +236,7 @@ foreach ($entities as $entity) {
234
  $content = file_get_contents(
235
  'app/code/local/HC/PayByFinance/sql/paybyfinance_setup/html/page-finance-options.html'
236
  );
237
- $cmsPage = Array (
238
  'title' => 'Finance Options',
239
  'root_template' => 'one_column',
240
  'identifier' => 'finance-options',
41
  ALTER TABLE {$setup->getTable('sales_flat_order')} ADD COLUMN finance_service int(11);
42
  ALTER TABLE {$setup->getTable('sales_flat_invoice')} ADD COLUMN finance_service int(11);
43
 
44
+ ALTER TABLE {$setup->getTable('sales_flat_order')} ADD COLUMN finance_status varchar(24);
45
  ALTER TABLE {$setup->getTable('sales_flat_order')} ADD COLUMN finance_application_no varchar(50);
46
  "
47
  );
78
  `type` varchar(255) NOT NULL default '',
79
  `flow` varchar(255) NOT NULL default '',
80
  `time` varchar(255) NOT NULL default '',
81
+ `content` text NOT NULL,
82
  PRIMARY KEY (`api_id`)
83
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
84
  "
174
  }
175
 
176
  $setup->addAttribute(
177
+ 'catalog_product',
178
+ 'paybyfinance_enable',
179
+ array(
180
  'group' => 'Hitachi Capital - Pay By Finance',
181
  'type' => 'int',
182
  'backend' => '',
236
  $content = file_get_contents(
237
  'app/code/local/HC/PayByFinance/sql/paybyfinance_setup/html/page-finance-options.html'
238
  );
239
+ $cmsPage = array (
240
  'title' => 'Finance Options',
241
  'root_template' => 'one_column',
242
  'identifier' => 'finance-options',
app/code/local/HC/PayByFinance/sql/paybyfinance_setup/mysql4-upgrade-1.0.6-1.0.7.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Hitachi Capital Pay By Finance
4
+ *
5
+ * Hitachi Capital Pay By Finance Extension
6
+ *
7
+ * PHP version >= 5.3.*
8
+ *
9
+ * @category HC
10
+ * @package PayByFinance
11
+ * @author Healthy Websites <support@healthywebsites.co.uk>
12
+ * @copyright 2014 Hitachi Capital
13
+ * @license http://www.gnu.org/copyleft/gpl.html GPL License
14
+ * @link http://www.healthywebsites.co.uk/
15
+ *
16
+ */
17
+
18
+ $updater = $this; // $this is class Mage_Eav_Model_Entity_Setup
19
+ $updater->startSetup();
20
+
21
+ $updater->run(
22
+ "
23
+ ALTER TABLE {$this->getTable('sales_flat_order')}
24
+ MODIFY COLUMN `finance_status` varchar(24);
25
+
26
+ ALTER TABLE {$this->getTable('sales_flat_order')}
27
+ ADD `finance_total_added` SMALLINT(5) UNSIGNED NULL;
28
+ "
29
+ );
30
+ $updater->endSetup();
app/code/local/HC/PayByFinance/sql/paybyfinance_setup/mysql4-upgrade-1.0.7-2.0.0.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Hitachi Capital Pay By Finance
4
+ *
5
+ * Hitachi Capital Pay By Finance Extension
6
+ *
7
+ * PHP version >= 5.3.*
8
+ *
9
+ * @category HC
10
+ * @package PayByFinance
11
+ * @author Healthy Websites <support@healthywebsites.co.uk>
12
+ * @copyright 2014 Hitachi Capital
13
+ * @license http://www.gnu.org/copyleft/gpl.html GPL License
14
+ * @link http://www.healthywebsites.co.uk/
15
+ *
16
+ */
17
+
18
+ $updater = $this; // $this is class Mage_Eav_Model_Entity_Setup
19
+ $updater->startSetup();
20
+
21
+ $updater->endSetup();
app/design/frontend/base/default/template/paybyfinance/catalog/product/list/finance.phtml CHANGED
@@ -1,4 +1,4 @@
1
- <?php if ($this->hasFinance()) : ?>
2
  <div class="productlist-paybyfinance-label">
3
  <?php echo $this->__('Finance Available From %s', $this->getFinanceFromPrice()) ?>
4
  </div>
1
+ <?php if ($this->hasFinance() && $this->canDisplayFinance()) : ?>
2
  <div class="productlist-paybyfinance-label">
3
  <?php echo $this->__('Finance Available From %s', $this->getFinanceFromPrice()) ?>
4
  </div>
app/design/frontend/base/default/template/paybyfinance/selector.phtml CHANGED
@@ -132,6 +132,7 @@ $_secure = $this->getRequest()->isSecure();
132
  </table>
133
  </div>
134
  <div class="pbf-footnote">
 
135
  <p>The figures shown are an illustration based on the cost of goods. Final details including shipping and discounts where applicable will be displayed on the checkout page.</p>
136
  <p>Credit is provided by Hitachi Capital Consumer Finance, a division of Hitachi Capital (UK) PLC authorised and regulated by the Financial Conduct Authority.</p>
137
  <p><?php echo $this->getRetailerName(); ?> <?php echo $this->getTradingName(); ?> acts as a credit broker and is authorised and regulated by the Financial Conduct Authority.</p>
@@ -207,6 +208,7 @@ $_secure = $this->getRequest()->isSecure();
207
  if (value < service.deposit) {
208
  $('pbf-error-msg').update("The minimum deposit value is "+parseInt(service.deposit)+"%");
209
  $('pbf-error').setStyle({height: 45+"px", opacity: 0.99});
 
210
  if ($('pbf-productcart-btn')) {
211
  Form.Element.disable('pbf-productcart-btn');
212
  }
@@ -216,6 +218,7 @@ $_secure = $this->getRequest()->isSecure();
216
  } else if(credit < service.min_amount) {
217
  $('pbf-error-msg').update("The minimum Finance Amount is £"+ currencyFormat(service.min_amount));
218
  $('pbf-error').setStyle({height: 45+"px", opacity: 0.99});
 
219
  if ($('pbf-productcart-btn')) {
220
  Form.Element.disable('pbf-productcart-btn');
221
  }
@@ -225,6 +228,7 @@ $_secure = $this->getRequest()->isSecure();
225
  } else {
226
  $('pbf-error-msg').update(null);
227
  $('pbf-error').setStyle({height: 0, opacity: 0});
 
228
  if ($('pbf-productcart-btn')) {
229
  Form.Element.enable('pbf-productcart-btn');
230
  }
@@ -357,6 +361,15 @@ $_secure = $this->getRequest()->isSecure();
357
  Form.Element.enable('pbf-cart-btn');
358
  } else if (document.getElementById('checkoutSteps')) {
359
  // OnePage checkout (Magento's default)
 
 
 
 
 
 
 
 
 
360
  Form.Element.disable('pbf-cart-btn');
361
  steppable = ["shipping_method", "payment", "review"]
362
  var i = steppable.length;
132
  </table>
133
  </div>
134
  <div class="pbf-footnote">
135
+ <p>Total Amount Payable Includes Deposit Amount.</p>
136
  <p>The figures shown are an illustration based on the cost of goods. Final details including shipping and discounts where applicable will be displayed on the checkout page.</p>
137
  <p>Credit is provided by Hitachi Capital Consumer Finance, a division of Hitachi Capital (UK) PLC authorised and regulated by the Financial Conduct Authority.</p>
138
  <p><?php echo $this->getRetailerName(); ?> <?php echo $this->getTradingName(); ?> acts as a credit broker and is authorised and regulated by the Financial Conduct Authority.</p>
208
  if (value < service.deposit) {
209
  $('pbf-error-msg').update("The minimum deposit value is "+parseInt(service.deposit)+"%");
210
  $('pbf-error').setStyle({height: 45+"px", opacity: 0.99});
211
+ $('pbf-error-msg').show();
212
  if ($('pbf-productcart-btn')) {
213
  Form.Element.disable('pbf-productcart-btn');
214
  }
218
  } else if(credit < service.min_amount) {
219
  $('pbf-error-msg').update("The minimum Finance Amount is £"+ currencyFormat(service.min_amount));
220
  $('pbf-error').setStyle({height: 45+"px", opacity: 0.99});
221
+ $('pbf-error-msg').show();
222
  if ($('pbf-productcart-btn')) {
223
  Form.Element.disable('pbf-productcart-btn');
224
  }
228
  } else {
229
  $('pbf-error-msg').update(null);
230
  $('pbf-error').setStyle({height: 0, opacity: 0});
231
+ $('pbf-error-msg').hide();
232
  if ($('pbf-productcart-btn')) {
233
  Form.Element.enable('pbf-productcart-btn');
234
  }
361
  Form.Element.enable('pbf-cart-btn');
362
  } else if (document.getElementById('checkoutSteps')) {
363
  // OnePage checkout (Magento's default)
364
+
365
+ if (enabled && $('billing:use_for_shipping_no').checked === true) {
366
+ pbf_selector_data.enabled = true;
367
+ checkout.gotoSection('billing');
368
+ pbfOnDOMLoad();
369
+ clearInputsInBilling();
370
+ return false; // Have to return, because calling shipping.save() will produce checkout on AJAX response handler next() called and checkout will move to next step of accordion,leaving desired billing step
371
+ }
372
+
373
  Form.Element.disable('pbf-cart-btn');
374
  steppable = ["shipping_method", "payment", "review"]
375
  var i = steppable.length;
app/etc/modules/HC_PayByFinance.xml CHANGED
@@ -7,6 +7,7 @@
7
  <depends>
8
  <Mage_Checkout />
9
  <Mage_Sales />
 
10
  </depends>
11
  </HC_PayByFinance>
12
  </modules>
7
  <depends>
8
  <Mage_Checkout />
9
  <Mage_Sales />
10
+ <Mage_GoogleAnalytics />
11
  </depends>
12
  </HC_PayByFinance>
13
  </modules>
js/paybyfinance/service.js CHANGED
@@ -4,8 +4,10 @@ PaybyfinanceService.prototype = {
4
  this.form = $('edit_form');
5
  this.aprField = $('apr');
6
  this.rpmField = $('rpm');
 
7
 
8
  this.aprField.observe('change', this.aprChange.bind(this));
 
9
  },
10
 
11
  aprChange: function(event) {
@@ -14,9 +16,7 @@ PaybyfinanceService.prototype = {
14
  rpm = (Math.pow((parseFloat(apr)/100 + 1), (1 / 12)) - 1) * 100;
15
  rpm = Math.round(rpm * 1000) / 1000;
16
 
17
- if (!this.rpmField.value) {
18
- this.rpmField.value = rpm;
19
- }
20
  }
21
  };
22
  Event.observe(window, 'load', function() {
4
  this.form = $('edit_form');
5
  this.aprField = $('apr');
6
  this.rpmField = $('rpm');
7
+ this.rpmField.readOnly = true;
8
 
9
  this.aprField.observe('change', this.aprChange.bind(this));
10
+ this.aprField.observe('blur', this.aprChange.bind(this));
11
  },
12
 
13
  aprChange: function(event) {
16
  rpm = (Math.pow((parseFloat(apr)/100 + 1), (1 / 12)) - 1) * 100;
17
  rpm = Math.round(rpm * 1000) / 1000;
18
 
19
+ this.rpmField.value = rpm;
 
 
20
  }
21
  };
22
  Event.observe(window, 'load', function() {
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>HC_PayByFinance</name>
4
- <version>1.0.6.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.healthywebsites.co.uk/license.html">Healthy Websites</license>
7
  <channel>community</channel>
@@ -9,18 +9,33 @@
9
  <summary>Hitachi Capital Pay By Finance</summary>
10
  <description>Hitachi Capital Pay By Finance</description>
11
  <notes>Change Log:&#xD;
12
- * HC-210 Store scope for services&#xD;
13
- * Automatically calculate RPM from APR if not present&#xD;
14
- * HC-225 Do not display finance widget when there are no services&#xD;
15
- * HC-226 RTL urls for testing and simulation&#xD;
16
- * HC-210 Enable / disable finance per store&#xD;
17
- * HC-234 Custom test urls&#xD;
18
- * HC-237 Text changes / phone number added&#xD;
19
- * Missing admin template files</notes>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  <authors><author><name>Sandor Czettner</name><user>MAG000003395</user><email>support@healthywebsites.co.uk</email></author><author><name>Alistair Macneil</name><user>MAG000006529</user><email>support@healthywebsites.co.uk</email></author><author><name>Rhuaridh Clark</name><user>MAG002562063</user><email>support@healthywebsites.co.uk</email></author></authors>
21
- <date>2015-07-22</date>
22
- <time>08:52:36</time>
23
- <contents><target name="magelocal"><dir><dir name="HC"><dir name="PayByFinance"><dir name="Block"><dir name="Adminhtml"><dir name="Paybyfinance"><file name="Redirect.php" hash="b7aadc98068529d4fb08219a83b2e69b"/><dir name="Service"><dir name="Edit"><file name="Form.php" hash="19f94b6405f5ec45510022c5aff868c2"/><dir name="Tab"><file name="Form.php" hash="25e4e9295f31e62d28143d25865d0d1a"/></dir><file name="Tabs.php" hash="5af9151c310841d8dd0b6f7e8f984625"/></dir><file name="Edit.php" hash="d73f958b0abaebff8aff703f650c5a01"/><file name="Grid.php" hash="e617125bf81d1f8d243c834a878ebac8"/></dir><file name="Service.php" hash="26112ba2733a9db951addfef4e0152e8"/></dir><file name="Version.php" hash="35de8d29521a61365b49e59f8ef5a24c"/></dir><dir name="Checkout"><file name="Redirect.php" hash="30f1cf1f682abc985e872619b67a86d7"/></dir><dir name="Product"><dir name="List"><file name="Finance.php" hash="a9dd554c1c95fc4c912f71ab3ac94d2c"/></dir></dir><dir name="Sales"><dir name="Order"><file name="Totals.php" hash="1fe522dd0d6a4c890374b2602b840d3b"/></dir></dir><file name="Selector.php" hash="8552ee10289ac2a6448a31b268cf273f"/><file name="Status.php" hash="f76d4e3558d096055234a877e4a24d8f"/></dir><dir name="Helper"><file name="Cart.php" hash="b26ae9571db19b3efea4a78e841d254c"/><file name="Checkout.php" hash="2e5c242b333cda10fa0993b036b9cbf4"/><file name="Data.php" hash="ace798886b37de1e18f3890eb6151735"/><file name="Notification.php" hash="c1274345f71edbf3e11de180704aaec2"/></dir><dir name="Model"><file name="Calculator.php" hash="6298a84cc8ff849046ae6a8a5b39eb9c"/><dir name="Config"><dir name="Source"><dir name="Catalog"><dir name="Product"><file name="Finance.php" hash="68dfc0233403f61c82aa62009cdd2da7"/><file name="Type.php" hash="4494b3f46eddc7455e363281072df315"/></dir></dir><dir name="Cms"><file name="Block.php" hash="a4302b47926c40f480ea84f81420070f"/></dir><file name="Connectionmode.php" hash="c85860668569c1642d9c6d86536c9076"/><dir name="Notification"><file name="Status.php" hash="0e9792c4ea7e27e61472d60e07227c5e"/></dir><file name="Type.php" hash="ce4604dccb55c6ce450fd34d4fa8ad4d"/></dir></dir><file name="Log.php" hash="446fc48510a09b279ad725bf87b839ff"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="6ebe6b95b2565601cd77f1d4db264ff4"/></dir><file name="Log.php" hash="914cb47c3274c2cce6a3913302a2d4e3"/><dir name="Service"><file name="Collection.php" hash="135b986e60187998e224b8f5b10c9ff2"/></dir><file name="Service.php" hash="3dac2e956f57c9a1467e52a0f008fefd"/></dir><file name="Observer.php" hash="42e7f70f31e7ac1c4e897b3393f75224"/><dir name="Paypal"><dir name="Api"><file name="Nvp.php" hash="5d1f7b687e2ca293ac1dc0c0425d1b8f"/></dir><dir name="Hostedpro"><file name="Request.php" hash="11ba073df9037d899eecb211c062d5f5"/></dir></dir><dir name="PaypalUk"><dir name="Api"><file name="Nvp.php" hash="49ba8cbd3145939a3d78e4964d1fe27e"/></dir></dir><dir name="Post"><file name="Abstract.php" hash="1583544fb76cd6552f733de5c320d6bd"/><file name="Custom.php" hash="f7afad244324db80af64014b51cf9b18"/><file name="Live.php" hash="8a70b4568b06fb27b29e35a35af3a160"/><file name="Simulation.php" hash="d24a30fbdd29dde34814bdaa4f134e85"/><file name="Simulationrtl.php" hash="9be1396b8e35a3a672cd51b149137592"/><file name="Test.php" hash="8183e4fcec09e963ffee39bb8f7d7c3e"/><file name="Testrtl.php" hash="affbd6a9ab4b0b6f0172c2dd63ae03fc"/><file name="Unittest.php" hash="422ed96628a703e4efedf64817edec98"/></dir><file name="Post.php" hash="c45665581817d711048d37bed0ecb67b"/><dir name="Resource"><file name="Setup.php" hash="c20cba205135fbfb01055518102b4681"/></dir><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Financeamount.php" hash="0ab402b6f55a4b9d13d0cafb36b6280f"/></dir><dir name="Invoice"><file name="Financeamount.php" hash="40d2be0622ac85e7776ce102b7de9e29"/></dir></dir><dir name="Quote"><file name="Financeamount.php" hash="85eba4714b45677e5e97fd8227c22a06"/><file name="Totalcost.php" hash="f7b360b6fd09029fd48c47c2be803d97"/></dir></dir><file name="Service.php" hash="5cc3d5959b8e08b11ca754da67776efd"/><file name="Session.php" hash="c2cdc285f6297ad2dc100973022ec6d4"/><file name="Sessionobserver.php" hash="07c72be99de76d41cd953c8104bceec4"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Paybyfinance"><file name="RedirectController.php" hash="8098982cfa01371e3427d0b7a8da6829"/><file name="ServiceController.php" hash="bbd7854759f5e10df8e0d1c85d42a02e"/></dir></dir><file name="CheckoutController.php" hash="e35b1ab01af610c5fd8ab24eda4ee8e2"/><file name="NotificationController.php" hash="95bd98bea5c92763d2755a3e2bc65e4b"/><file name="SelectorController.php" hash="5d440a1a0cea72787d7370679fe34e60"/><file name="SessionController.php" hash="b3756993e0d8e6e49434354c824f837e"/><file name="StatusController.php" hash="9e8681654954590f2694780f18ab0675"/></dir><dir name="etc"><file name="adminhtml.xml" hash="216df222a5f5d9fdcf29c238cfd78bd5"/><file name="config.xml" hash="48840ba078848f2bc0772d266756d99f"/><file name="system.xml" hash="32442cb0d9673ccc914d2573927caeba"/></dir><dir name="sql"><dir name="paybyfinance_setup"><dir name="html"><file name="abandoned.html" hash="424f900dbddc267f7dac72e67752df25"/><file name="accepted.html" hash="3cd819649eeb88b108cfbd87d6bb5048"/><file name="declined.html" hash="4cb2e73cbf449ced4596b6d14289a76f"/><file name="error.html" hash="4a448b052f101b2648dfe84423ad1313"/><file name="information.html" hash="b364458ba3d9ad7579fa4935e3449b46"/><file name="page-finance-options.html" hash="d9f090c84559caf2311cabced715b668"/><file name="referred.html" hash="05f0b7dedeedac26916dd8f88d7bf32c"/></dir><file name="mysql4-install-1.0.6.php" hash="bdbf0c30590dbffd266f82cb4c7af854"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="35e40e56f4eaa482cf76861bf268b9d7"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="f88bb5dae696c130c0038c05e86dfd9c"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="abd3f7c7e68120a6bcad82470f62db25"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="2cc09a77b0c36f2f0a2bdce97ba0f50d"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="04656ff6a19b294c8e6340dd44cce470"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="paybyfinance"><dir><dir name="catalog"><dir name="product"><dir name="list"><file name="finance.phtml" hash="30f6500bc535bdf851ff6d5768e383dc"/></dir></dir></dir><dir name="sales"><dir name="order"><file name="totals.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir><file name="form.phtml" hash="6f583d5629e39fe564d4b86535242c7a"/><file name="selector-no.phtml" hash="b54c570f68254a2e879464a0b761c7db"/><file name="selector.phtml" hash="e983ba67dfd1c1282f4cf0258a49797f"/><file name="status.phtml" hash="9e02cb668c470d72612bccc09e34c51a"/></dir><dir name="checkout"><dir name="cart"><file name="totals-pbf.phtml" hash="f14878e618aa3c8943f3728128aadaa6"/></dir><dir name="onepage"><dir name="review"><file name="info-pbf.phtml" hash="e4c7c70c798f1956ae7aaa5c09114fab"/><file name="totals-pbf.phtml" hash="f26e488359433c3814a1cd416006869a"/></dir></dir><file name="cart-pbf.phtml" hash="9f6b1873ed02e5e2ae1966e3e5a1910d"/></dir></dir><dir name="layout"><file name="paybyfinance.xml" hash="f541883d7e115794fcde3b0a4ac1bb3d"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="paybyfinance.xml" hash="21e409f98bd00b6de93a09610dabdbdd"/></dir><dir name="template"><dir name="paybyfinance"><file name="history.phtml" hash="31fbbbb8477717175da3de1e9fe98f54"/><file name="redirect.phtml" hash="90e7aa306768f5aac337300848c04e6a"/><file name="version.phtml" hash="09a8f416156d853ecc47b24a15744563"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><dir name="paybyfinance"><file name="checkout.js" hash="21051d8691dd773427d3e761403896ab"/><file name="functions.js" hash="98c27381b3f7eaeaa845271dbe763f05"/><file name="slider.js" hash="16d83f4f0faa449276c926d2afac75fb"/></dir></dir><dir name="css"><file name="paybyfinance.css" hash="25d02dc5cf228662c30d908d7c2f1356"/><file name="paybyfinance-ie8.css" hash="a6be9c7af8b95300bc62e4fe9ef252ac"/></dir><dir name="images"><dir name="paybyfinance"><file name="bullet.png" hash="ea2baab34b2eb7d0aacb7a67d5b080f1"/><file name="pointer-toggle.png" hash="e661d42aed7a5562f75828312c7a635a"/><file name="pointer.png" hash="68c58b28d6ebd77d415f8666c301a199"/><file name="progress.png" hash="6d46a109cc9e38a663678918142d89f2"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="HC_PayByFinance.xml" hash="7cbf54af53b5b2fe9047988444fd407c"/></dir></dir></target><target name="mageweb"><dir><dir name="js"><dir name="paybyfinance"><file name="config-edit.js" hash="81817d23afdf99d10b01072d2471ff65"/><file name="service.js" hash="c356bab3db9d2ddb60c60bd9bb3a6ab2"/></dir></dir></dir></target></contents>
24
  <compatible/>
25
- <dependencies><required><php><min>5.4.26</min><max>5.6.10</max></php></required></dependencies>
26
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>HC_PayByFinance</name>
4
+ <version>2.0.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.healthywebsites.co.uk/license.html">Healthy Websites</license>
7
  <channel>community</channel>
9
  <summary>Hitachi Capital Pay By Finance</summary>
10
  <description>Hitachi Capital Pay By Finance</description>
11
  <notes>Change Log:&#xD;
12
+ * HC-246 Notification for eSignature&#xD;
13
+ * HC-242, HC-175 added non-ascii characters replacements&#xD;
14
+ * HC-223 added yes/no option to admin panel for displaying message in result/category&#xD;
15
+ * HC-186 added message for minimum finance amount&#xD;
16
+ * Use Increment ID rather than Order ID in notifications and all across PBF&#xD;
17
+ * HC-239 Google Analytics orders tracking fix&#xD;
18
+ * HC-244 added check for switching PBF on later in steps after user added shipping address.&#xD;
19
+ * HC-249 Notification and totals on invoice&#xD;
20
+ * JS error on IE&#xD;
21
+ * HC-252 Order status for multiple notifications&#xD;
22
+ * HC-220 Cart calculation should be based on the row total&#xD;
23
+ * HC-185 added automatic calculation to RPM from APM field&#xD;
24
+ * HC-256 Product eligibility on cart (Minimum Amount)&#xD;
25
+ * HC-220 Order total modification events (for extendibility)&#xD;
26
+ * HC-261 Race condition on notification events fix&#xD;
27
+ * HC-261: Send a 503 status code when the notification is not applicable, this makes Hitachi to send it again after:&#xD;
28
+ * 10 minutes&#xD;
29
+ * 1 hour&#xD;
30
+ * 2 hours&#xD;
31
+ * 5 hours&#xD;
32
+ * HC-214 Additional text to the selector&#xD;
33
+ * HC-257 Text changes on referred handback pages&#xD;
34
+ * HC-259 remove virtual, downloadable products</notes>
35
  <authors><author><name>Sandor Czettner</name><user>MAG000003395</user><email>support@healthywebsites.co.uk</email></author><author><name>Alistair Macneil</name><user>MAG000006529</user><email>support@healthywebsites.co.uk</email></author><author><name>Rhuaridh Clark</name><user>MAG002562063</user><email>support@healthywebsites.co.uk</email></author></authors>
36
+ <date>2015-09-07</date>
37
+ <time>15:35:11</time>
38
+ <contents><target name="magelocal"><dir><dir name="HC"><dir name="PayByFinance"><dir name="Block"><dir name="Adminhtml"><dir name="Paybyfinance"><file name="Redirect.php" hash="b7aadc98068529d4fb08219a83b2e69b"/><dir name="Service"><dir name="Edit"><file name="Form.php" hash="19f94b6405f5ec45510022c5aff868c2"/><dir name="Tab"><file name="Form.php" hash="74936b4d5056fdad950d1b98e94c83c2"/></dir><file name="Tabs.php" hash="5af9151c310841d8dd0b6f7e8f984625"/></dir><file name="Edit.php" hash="d73f958b0abaebff8aff703f650c5a01"/><file name="Grid.php" hash="e617125bf81d1f8d243c834a878ebac8"/></dir><file name="Service.php" hash="26112ba2733a9db951addfef4e0152e8"/></dir><file name="Version.php" hash="3d4e3f13bf89bcd2277718c4e957f827"/></dir><dir name="Checkout"><file name="Redirect.php" hash="30f1cf1f682abc985e872619b67a86d7"/></dir><dir name="Product"><dir name="List"><file name="Finance.php" hash="459249d30ad2f93e57faf4cab8f55e14"/></dir></dir><dir name="Sales"><dir name="Order"><file name="Totals.php" hash="1fe522dd0d6a4c890374b2602b840d3b"/></dir></dir><file name="Selector.php" hash="9b3b8b7b3711966aad2b2208fbfb15c5"/><file name="Status.php" hash="f76d4e3558d096055234a877e4a24d8f"/></dir><dir name="Helper"><file name="Cart.php" hash="b26ae9571db19b3efea4a78e841d254c"/><file name="Checkout.php" hash="fb5fdbc1f1999fe6a8fcb6e1fb1c99df"/><file name="Data.php" hash="0ca1c9390b16b490ca84fc9875bea980"/><file name="Notification.php" hash="61b2c989209abb4678d6da588031a22b"/></dir><dir name="Model"><file name="Calculator.php" hash="6298a84cc8ff849046ae6a8a5b39eb9c"/><dir name="Config"><dir name="Source"><dir name="Catalog"><dir name="Product"><file name="Finance.php" hash="68dfc0233403f61c82aa62009cdd2da7"/><file name="Type.php" hash="3ad78910aec093cc1b552821fc097a8d"/></dir></dir><dir name="Cms"><file name="Block.php" hash="a4302b47926c40f480ea84f81420070f"/></dir><file name="Connectionmode.php" hash="e446478c837f7bfffe7e6fa686d5f91e"/><dir name="Notification"><file name="Status.php" hash="0e9792c4ea7e27e61472d60e07227c5e"/></dir><file name="Type.php" hash="ce4604dccb55c6ce450fd34d4fa8ad4d"/></dir></dir><file name="Log.php" hash="446fc48510a09b279ad725bf87b839ff"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="6ebe6b95b2565601cd77f1d4db264ff4"/></dir><file name="Log.php" hash="914cb47c3274c2cce6a3913302a2d4e3"/><dir name="Service"><file name="Collection.php" hash="135b986e60187998e224b8f5b10c9ff2"/></dir><file name="Service.php" hash="3dac2e956f57c9a1467e52a0f008fefd"/></dir><file name="Observer.php" hash="a72c50340ce29c0da6eaaded1213a99c"/><dir name="Paypal"><dir name="Api"><file name="Nvp.php" hash="5d1f7b687e2ca293ac1dc0c0425d1b8f"/></dir><dir name="Hostedpro"><file name="Request.php" hash="11ba073df9037d899eecb211c062d5f5"/></dir></dir><dir name="PaypalUk"><dir name="Api"><file name="Nvp.php" hash="49ba8cbd3145939a3d78e4964d1fe27e"/></dir></dir><dir name="Post"><file name="Abstract.php" hash="1583544fb76cd6552f733de5c320d6bd"/><file name="Custom.php" hash="f7afad244324db80af64014b51cf9b18"/><file name="Live.php" hash="8a70b4568b06fb27b29e35a35af3a160"/><file name="Simulation.php" hash="d24a30fbdd29dde34814bdaa4f134e85"/><file name="Test.php" hash="8183e4fcec09e963ffee39bb8f7d7c3e"/><file name="Unittest.php" hash="422ed96628a703e4efedf64817edec98"/></dir><file name="Post.php" hash="c45665581817d711048d37bed0ecb67b"/><dir name="Resource"><file name="Setup.php" hash="c20cba205135fbfb01055518102b4681"/></dir><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Financeamount.php" hash="0ab402b6f55a4b9d13d0cafb36b6280f"/></dir><dir name="Invoice"><file name="Financeamount.php" hash="7c07f5432f0781314df41bae3ccdb145"/></dir></dir><dir name="Quote"><file name="Financeamount.php" hash="85eba4714b45677e5e97fd8227c22a06"/><file name="Totalcost.php" hash="f7b360b6fd09029fd48c47c2be803d97"/></dir></dir><file name="Service.php" hash="5cc3d5959b8e08b11ca754da67776efd"/><file name="Session.php" hash="c2cdc285f6297ad2dc100973022ec6d4"/><file name="Sessionobserver.php" hash="2730d896b8e56e8f752bd8a01df86767"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Paybyfinance"><file name="RedirectController.php" hash="8098982cfa01371e3427d0b7a8da6829"/><file name="ServiceController.php" hash="841b9e942f7050f2b065be281cc1ac8f"/></dir></dir><file name="CheckoutController.php" hash="cacc13e3454a4062bdf8523350b372a0"/><file name="NotificationController.php" hash="55510e41fdee3f15460bfed6a2ade04d"/><file name="SelectorController.php" hash="5d440a1a0cea72787d7370679fe34e60"/><file name="SessionController.php" hash="b3756993e0d8e6e49434354c824f837e"/><file name="StatusController.php" hash="3a8d40001d3f843d3a69147734072370"/></dir><dir name="etc"><file name="adminhtml.xml" hash="216df222a5f5d9fdcf29c238cfd78bd5"/><file name="config.xml" hash="c815a0084a0855402269bfd6f6049c0b"/><file name="system.xml" hash="ab4ebbf8e699c3adb88e2df469cca654"/></dir><dir name="sql"><dir name="paybyfinance_setup"><dir name="html"><file name="abandoned.html" hash="424f900dbddc267f7dac72e67752df25"/><file name="accepted.html" hash="3cd819649eeb88b108cfbd87d6bb5048"/><file name="declined.html" hash="4cb2e73cbf449ced4596b6d14289a76f"/><file name="error.html" hash="4a448b052f101b2648dfe84423ad1313"/><file name="information.html" hash="b364458ba3d9ad7579fa4935e3449b46"/><file name="page-finance-options.html" hash="d9f090c84559caf2311cabced715b668"/><file name="referred.html" hash="1c143c51776357bcad9e27aff6e6b9b8"/></dir><file name="mysql4-install-2.0.0.php" hash="c3a2e10a36b8950ddcbb4c5b7df2ce27"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="35e40e56f4eaa482cf76861bf268b9d7"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="f88bb5dae696c130c0038c05e86dfd9c"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="abd3f7c7e68120a6bcad82470f62db25"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="2cc09a77b0c36f2f0a2bdce97ba0f50d"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="04656ff6a19b294c8e6340dd44cce470"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="49f12a49af3619329e5566b633169d02"/><file name="mysql4-upgrade-1.0.7-2.0.0.php" hash="38bf860781960d49b9bfaa9c6292838b"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="paybyfinance"><dir><dir name="catalog"><dir name="product"><dir name="list"><file name="finance.phtml" hash="fc9c4b43b09338aa33ba034b31508869"/></dir></dir></dir><dir name="sales"><dir name="order"><file name="totals.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir><file name="form.phtml" hash="6f583d5629e39fe564d4b86535242c7a"/><file name="selector-no.phtml" hash="b54c570f68254a2e879464a0b761c7db"/><file name="selector.phtml" hash="5b576ea8d7111905213b545eba50fc46"/><file name="status.phtml" hash="9e02cb668c470d72612bccc09e34c51a"/></dir><dir name="checkout"><dir name="cart"><file name="totals-pbf.phtml" hash="f14878e618aa3c8943f3728128aadaa6"/></dir><dir name="onepage"><dir name="review"><file name="info-pbf.phtml" hash="e4c7c70c798f1956ae7aaa5c09114fab"/><file name="totals-pbf.phtml" hash="f26e488359433c3814a1cd416006869a"/></dir></dir><file name="cart-pbf.phtml" hash="9f6b1873ed02e5e2ae1966e3e5a1910d"/></dir></dir><dir name="layout"><file name="paybyfinance.xml" hash="f541883d7e115794fcde3b0a4ac1bb3d"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="paybyfinance.xml" hash="21e409f98bd00b6de93a09610dabdbdd"/></dir><dir name="template"><dir name="paybyfinance"><file name="history.phtml" hash="31fbbbb8477717175da3de1e9fe98f54"/><file name="redirect.phtml" hash="90e7aa306768f5aac337300848c04e6a"/><file name="version.phtml" hash="09a8f416156d853ecc47b24a15744563"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><dir name="paybyfinance"><file name="checkout.js" hash="6930043a719765833f6d64de1216b7ad"/><file name="functions.js" hash="98c27381b3f7eaeaa845271dbe763f05"/><file name="slider.js" hash="16d83f4f0faa449276c926d2afac75fb"/></dir></dir><dir name="css"><file name="paybyfinance.css" hash="25d02dc5cf228662c30d908d7c2f1356"/><file name="paybyfinance-ie8.css" hash="a6be9c7af8b95300bc62e4fe9ef252ac"/></dir><dir name="images"><dir name="paybyfinance"><file name="bullet.png" hash="ea2baab34b2eb7d0aacb7a67d5b080f1"/><file name="pointer-toggle.png" hash="e661d42aed7a5562f75828312c7a635a"/><file name="pointer.png" hash="68c58b28d6ebd77d415f8666c301a199"/><file name="progress.png" hash="6d46a109cc9e38a663678918142d89f2"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="HC_PayByFinance.xml" hash="58a12daf6bb6aeb8b94471bf605514e5"/></dir></dir></target><target name="mageweb"><dir><dir name="js"><dir name="paybyfinance"><file name="config-edit.js" hash="81817d23afdf99d10b01072d2471ff65"/><file name="service.js" hash="7e1fe3ffe2d4b95eeb5b27c8d07b23f1"/></dir></dir></dir></target></contents>
39
  <compatible/>
40
+ <dependencies><required><php><min>5.4.26</min><max>5.6.13</max></php></required></dependencies>
41
  </package>
skin/frontend/base/default/js/paybyfinance/checkout.js CHANGED
@@ -1,17 +1,20 @@
1
- document.observe('dom:loaded', function() {
2
-
3
  selector_data = window.pbf_selector_data;
4
  if (selector_data && selector_data.enabled) {
5
- if(document.getElementById('onestepcheckout-form')) {
6
  //if we're using onestepcheckout
7
- $('billing_address').insert({
8
- top: '<p class="paybyfinance-info">If you are paying by finance then goods MUST be delivered to your billing address. Products can not be delivered outside the UK.</p>',
9
- });
 
 
10
  hideCountries();
11
  } else {
12
- $('co-billing-form').insert({
13
- top: '<p class="paybyfinance-info">If you are paying by finance then goods MUST be delivered to your billing address. Products can not be delivered outside the UK.</p>',
14
- });
 
 
15
  $('billing:use_for_shipping_yes').checked = true;
16
  $('billing:use_for_shipping_no').up().hide();
17
  $('billing:use_for_shipping_no').disabled = true;
@@ -20,12 +23,12 @@ document.observe('dom:loaded', function() {
20
  $('checkout-step-shipping').insert({
21
  top: '<p class="paybyfinance-info-shipping">It is not possible to select a different shipping address when the order is being paid by finance.</p>'
22
  });
23
- if($('shipping-address-select') != null) {
24
- $('shipping-address-select').observe('change', function() {
25
  alert('If you are paying by finance then goods MUST be delivered to your billing address. Products can not be delivered outside the UK.');
26
  });
27
  }
28
- $('billing:country_id').observe('focus', function() {
29
  var inputs = this.form.getElements();
30
  var idx = inputs.indexOf(this);
31
  inputs[idx + 1].focus(); // handles submit buttons
@@ -33,8 +36,18 @@ document.observe('dom:loaded', function() {
33
  });
34
  }
35
  }
 
 
 
36
  });
37
 
 
 
 
 
 
 
 
38
  function hideCountries() {
39
  $('billing:country_id').value = 'GB';
40
  if (window.billingRegionUpdater) {
1
+ function pbfOnDOMLoad() {
 
2
  selector_data = window.pbf_selector_data;
3
  if (selector_data && selector_data.enabled) {
4
+ if (document.getElementById('onestepcheckout-form')) {
5
  //if we're using onestepcheckout
6
+ if ($('paybyfinance-info-p') == null) {
7
+ $('billing_address').insert({
8
+ top: '<p id="paybyfinance-info-p" class="paybyfinance-info">If you are paying by finance then goods MUST be delivered to your billing address. Products can not be delivered outside the UK.</p>',
9
+ });
10
+ }
11
  hideCountries();
12
  } else {
13
+ if ($('paybyfinance-info-p') == null) {
14
+ $('co-billing-form').insert({
15
+ top: '<p id="paybyfinance-info-p" class="paybyfinance-info">If you are paying by finance then goods MUST be delivered to your billing address. Products can not be delivered outside the UK.</p>',
16
+ });
17
+ }
18
  $('billing:use_for_shipping_yes').checked = true;
19
  $('billing:use_for_shipping_no').up().hide();
20
  $('billing:use_for_shipping_no').disabled = true;
23
  $('checkout-step-shipping').insert({
24
  top: '<p class="paybyfinance-info-shipping">It is not possible to select a different shipping address when the order is being paid by finance.</p>'
25
  });
26
+ if ($('shipping-address-select') != null) {
27
+ $('shipping-address-select').observe('change', function () {
28
  alert('If you are paying by finance then goods MUST be delivered to your billing address. Products can not be delivered outside the UK.');
29
  });
30
  }
31
+ $('billing:country_id').observe('focus', function () {
32
  var inputs = this.form.getElements();
33
  var idx = inputs.indexOf(this);
34
  inputs[idx + 1].focus(); // handles submit buttons
36
  });
37
  }
38
  }
39
+ }
40
+ document.observe('dom:loaded', function() {
41
+ pbfOnDOMLoad();
42
  });
43
 
44
+ function clearInputsInBilling(){
45
+ var inputs = $('co-billing-form').getElementsByTagName("input");
46
+ for (var i = 0; i < inputs.length; i++) {
47
+ inputs[i].value = '';
48
+ }
49
+ }
50
+
51
  function hideCountries() {
52
  $('billing:country_id').value = 'GB';
53
  if (window.billingRegionUpdater) {