Cardsave_Cardsaveonlinepayments - Version 1.14.3

Version Notes

Added Multi-Currency support. New option added to configuration page to allow payments to be taken in customers chosen currency, or to force all payments through in the store base currency. Please Note: to accept payments using in a non-GBP currency, you must have a Multi-Currency Merchant Account - Please contact us to set this up if you do not have one.

Download this release

Release Info

Developer CardSave
Extension Cardsave_Cardsaveonlinepayments
Version 1.14.3
Comparing to
See all releases


Code changes from version 1.14.2 to 1.14.3

app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/PaymentFormHelper.php CHANGED
@@ -352,7 +352,7 @@
352
  'PostCode='.$formVariables['PostCode'].'&'.
353
  'CountryCode='.$formVariables['CountryCode'];
354
 
355
- echo $szStringBeforeHash;
356
 
357
  if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
358
  $hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
352
  'PostCode='.$formVariables['PostCode'].'&'.
353
  'CountryCode='.$formVariables['CountryCode'];
354
 
355
+ //echo $szStringBeforeHash;
356
 
357
  if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
358
  $hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Direct.php CHANGED
@@ -215,6 +215,8 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
215
  */
216
  public function _runTransaction(Varien_Object $payment, $amount)
217
  {
 
 
218
  $error = '';
219
  $session = Mage::getSingleton('checkout/session');
220
  $nVersion = $this->getVersion();
@@ -278,16 +280,33 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
278
 
279
  $cdtCardDetailsTransaction->getTransactionDetails()->getMessageDetails()->setTransactionType($szTransactionType);
280
 
281
- if ($szCurrencyShort != '' &&
282
- $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
283
- {
284
- $nCurrencyCode = new CSV_NullableInt($icISOCurrency->getISOCode());
285
- $cdtCardDetailsTransaction->getTransactionDetails()->getCurrencyCode()->setValue($icISOCurrency->getISOCode());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  }
287
-
288
- $nDecimalAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
289
-
290
- $cdtCardDetailsTransaction->getTransactionDetails()->getAmount()->setValue($nDecimalAmount);
291
 
292
  $cdtCardDetailsTransaction->getTransactionDetails()->setOrderID($szOrderID);
293
  $cdtCardDetailsTransaction->getTransactionDetails()->setOrderDescription($szOrderDescription);
@@ -462,6 +481,8 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
462
  */
463
  public function _runHostedPaymentTransaction(Varien_Object $payment, $amount)
464
  {
 
 
465
  $session = Mage::getSingleton('checkout/session');
466
  $nVersion = $this->getVersion();
467
 
@@ -519,16 +540,31 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
519
  $szServerResultURLCookieVariables .= "@@";
520
  }
521
  }
522
-
523
- $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
524
- if ($szCurrencyShort != '' &&
525
- $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
526
- {
527
- $nCurrencyCode = $icISOCurrency->getISOCode();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  }
529
-
530
- $nAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
531
-
532
  $szISO2CountryCode = $billingAddress->getCountry();
533
  $szCountryShort = $this->_getISO3Code($szISO2CountryCode);
534
  if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
@@ -647,6 +683,8 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
647
  */
648
  public function _runTransparentRedirectTransaction(Varien_Object $payment, $amount)
649
  {
 
 
650
  $GLOBALS['m_boPayInvoice'] = false;
651
  $payment->setIsTransactionPending(true);
652
  $nVersion = $this->getVersion();
@@ -663,15 +701,30 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
663
  $szStartDateMonth = '';
664
  $szStartDateYear = '';
665
 
666
- $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
667
- if ($szCurrencyShort != '' &&
668
- $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
669
- {
670
- $nCurrencyCode = $icISOCurrency->getISOCode();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
671
  }
672
 
673
- $nAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
674
-
675
  $szOrderID = $payment->getOrder()->increment_id;
676
  //date time with 2008-12-01 14:12:00 +01:00 format
677
  $szTransactionDateTime = date('Y-m-d H:i:s P');
@@ -1389,6 +1442,8 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
1389
  */
1390
  private function _runCrossReferenceTransaction(Varien_Object $payment, $szTransactionType, $amount = false)
1391
  {
 
 
1392
  $error = false;
1393
  $boTransactionProcessed = false;
1394
  $PaymentProcessorFullDomain;
@@ -1439,14 +1494,11 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
1439
  $crtCrossReferenceTransaction->getMerchantAuthentication()->setMerchantID($szMerchantID);
1440
  $crtCrossReferenceTransaction->getMerchantAuthentication()->setPassword($szPassword);
1441
 
1442
- // if no amount is specified get the grand total amount
1443
- if($amount === false)
1444
- {
1445
- $nAmount = $order->getBaseGrandTotal();
1446
- }
1447
- else
1448
- {
1449
- $nAmount = $amount;
1450
  }
1451
 
1452
  $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
@@ -1458,10 +1510,10 @@ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Me
1458
  }
1459
 
1460
  // round the amount before use
1461
- $nDecimalAmount = $this->_getRoundedAmount($nAmount, $icISOCurrency->getExponent());
1462
 
1463
  $crtCrossReferenceTransaction->getTransactionDetails()->setOrderID($szOrderID);
1464
- $crtCrossReferenceTransaction->getTransactionDetails()->getAmount()->setValue($nDecimalAmount);
1465
 
1466
  $crtCrossReferenceTransaction->getTransactionDetails()->getMessageDetails()->setCrossReference($szCrossReference);
1467
  $crtCrossReferenceTransaction->getTransactionDetails()->getMessageDetails()->setTransactionType($szTransactionType);
215
  */
216
  public function _runTransaction(Varien_Object $payment, $amount)
217
  {
218
+ $takePaymentInStoreBaseCurrency = $this->getConfigData('takePaymentInStoreBaseCurrency');
219
+
220
  $error = '';
221
  $session = Mage::getSingleton('checkout/session');
222
  $nVersion = $this->getVersion();
280
 
281
  $cdtCardDetailsTransaction->getTransactionDetails()->getMessageDetails()->setTransactionType($szTransactionType);
282
 
283
+ if (!$takePaymentInStoreBaseCurrency) {
284
+ // Take payment in order currency
285
+ $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
286
+ if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
287
+ {
288
+ $nCurrencyCode = $icISOCurrency->getISOCode();
289
+ $cdtCardDetailsTransaction->getTransactionDetails()->getCurrencyCode()->setValue($icISOCurrency->getISOCode());
290
+ }
291
+
292
+ // Calculate amount
293
+ $power = pow(10, $icISOCurrency->getExponent());
294
+ $nAmount = round($order->getGrandTotal() * $power,0);
295
+ } else {
296
+ // Take payment in site base currency
297
+ //$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
298
+ $szCurrencyShort = $order->getBaseCurrencyCode();
299
+ if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
300
+ {
301
+ $nCurrencyCode = $icISOCurrency->getISOCode();
302
+ $cdtCardDetailsTransaction->getTransactionDetails()->getCurrencyCode()->setValue($icISOCurrency->getISOCode());
303
+ }
304
+
305
+ // Calculate amount
306
+ $nAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
307
  }
308
+
309
+ $cdtCardDetailsTransaction->getTransactionDetails()->getAmount()->setValue($nAmount);
 
 
310
 
311
  $cdtCardDetailsTransaction->getTransactionDetails()->setOrderID($szOrderID);
312
  $cdtCardDetailsTransaction->getTransactionDetails()->setOrderDescription($szOrderDescription);
481
  */
482
  public function _runHostedPaymentTransaction(Varien_Object $payment, $amount)
483
  {
484
+ $takePaymentInStoreBaseCurrency = $this->getConfigData('takePaymentInStoreBaseCurrency');
485
+
486
  $session = Mage::getSingleton('checkout/session');
487
  $nVersion = $this->getVersion();
488
 
540
  $szServerResultURLCookieVariables .= "@@";
541
  }
542
  }
543
+
544
+ if (!$takePaymentInStoreBaseCurrency) {
545
+ // Take payment in order currency
546
+ $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
547
+ if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
548
+ {
549
+ $nCurrencyCode = $icISOCurrency->getISOCode();
550
+ }
551
+
552
+ // Calculate amount
553
+ $power = pow(10, $icISOCurrency->getExponent());
554
+ $nAmount = round($order->getGrandTotal() * $power,0);
555
+ } else {
556
+ // Take payment in site base currency
557
+ //$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
558
+ $szCurrencyShort = $order->getBaseCurrencyCode();
559
+ if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
560
+ {
561
+ $nCurrencyCode = $icISOCurrency->getISOCode();
562
+ }
563
+
564
+ // Calculate amount
565
+ $nAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
566
  }
567
+
 
 
568
  $szISO2CountryCode = $billingAddress->getCountry();
569
  $szCountryShort = $this->_getISO3Code($szISO2CountryCode);
570
  if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
683
  */
684
  public function _runTransparentRedirectTransaction(Varien_Object $payment, $amount)
685
  {
686
+ $takePaymentInStoreBaseCurrency = $this->getConfigData('takePaymentInStoreBaseCurrency');
687
+
688
  $GLOBALS['m_boPayInvoice'] = false;
689
  $payment->setIsTransactionPending(true);
690
  $nVersion = $this->getVersion();
701
  $szStartDateMonth = '';
702
  $szStartDateYear = '';
703
 
704
+ if (!$takePaymentInStoreBaseCurrency) {
705
+ // Take payment in order currency
706
+ $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
707
+ if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
708
+ {
709
+ $nCurrencyCode = $icISOCurrency->getISOCode();
710
+ }
711
+
712
+ // Calculate amount
713
+ $power = pow(10, $icISOCurrency->getExponent());
714
+ $nAmount = round($order->getGrandTotal() * $power,0);
715
+ } else {
716
+ // Take payment in site base currency
717
+ //$szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
718
+ $szCurrencyShort = $order->getBaseCurrencyCode();
719
+ if ($szCurrencyShort != '' && $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
720
+ {
721
+ $nCurrencyCode = $icISOCurrency->getISOCode();
722
+ }
723
+
724
+ // Calculate amount
725
+ $nAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
726
  }
727
 
 
 
728
  $szOrderID = $payment->getOrder()->increment_id;
729
  //date time with 2008-12-01 14:12:00 +01:00 format
730
  $szTransactionDateTime = date('Y-m-d H:i:s P');
1442
  */
1443
  private function _runCrossReferenceTransaction(Varien_Object $payment, $szTransactionType, $amount = false)
1444
  {
1445
+ $takePaymentInStoreBaseCurrency = $this->getConfigData('takePaymentInStoreBaseCurrency');
1446
+
1447
  $error = false;
1448
  $boTransactionProcessed = false;
1449
  $PaymentProcessorFullDomain;
1494
  $crtCrossReferenceTransaction->getMerchantAuthentication()->setMerchantID($szMerchantID);
1495
  $crtCrossReferenceTransaction->getMerchantAuthentication()->setPassword($szPassword);
1496
 
1497
+ if (!$takePaymentInStoreBaseCurrency) {
1498
+ $power = pow(10, $icISOCurrency->getExponent());
1499
+ $nAmount = round($order->getGrandTotal() * $power,0);
1500
+ } else {
1501
+ $nAmount = $this->_getRoundedAmount($amount, $icISOCurrency->getExponent());
 
 
 
1502
  }
1503
 
1504
  $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
1510
  }
1511
 
1512
  // round the amount before use
1513
+ //$nDecimalAmount = $this->_getRoundedAmount($nAmount, $icISOCurrency->getExponent());
1514
 
1515
  $crtCrossReferenceTransaction->getTransactionDetails()->setOrderID($szOrderID);
1516
+ $crtCrossReferenceTransaction->getTransactionDetails()->getAmount()->setValue($nAmount);
1517
 
1518
  $crtCrossReferenceTransaction->getTransactionDetails()->getMessageDetails()->setCrossReference($szCrossReference);
1519
  $crtCrossReferenceTransaction->getTransactionDetails()->getMessageDetails()->setTransactionType($szTransactionType);
app/code/local/Cardsave/Cardsaveonlinepayments/etc/config.xml CHANGED
@@ -42,11 +42,21 @@
42
  <info_cc>Cardsave_Cardsaveonlinepayments_Block_Payment_Info_Cc</info_cc>
43
  </rewrite>
44
  </payment>
 
 
 
 
 
 
 
 
 
 
45
  <adminhtml>
46
  <rewrite>
47
  <sales_order_payment>Cardsave_Cardsaveonlinepayments_Block_Adminhtml_Sales_Order_Payment</sales_order_payment>
48
  </rewrite>
49
- </adminhtml>
50
  </blocks>
51
  <!-- Define the helper class type -->
52
  <helpers>
@@ -118,6 +128,7 @@
118
  <resultdeliverymethod>POST</resultdeliverymethod>
119
  <allowspecific>0</allowspecific>
120
  <customstockmanagementenabled>1</customstockmanagementenabled>
 
121
  </cardsaveonlinepayments>
122
  </payment>
123
  </default>
42
  <info_cc>Cardsave_Cardsaveonlinepayments_Block_Payment_Info_Cc</info_cc>
43
  </rewrite>
44
  </payment>
45
+ <checkout>
46
+ <rewrite>
47
+ <cart_totals>Cardsave_Checkout_Block_Cart_Totals</cart_totals>
48
+ </rewrite>
49
+ </checkout>
50
+ <sales>
51
+ <rewrite>
52
+ <order_totals>Cardsave_Sales_Block_Order_Totals</order_totals>
53
+ </rewrite>
54
+ </sales>
55
  <adminhtml>
56
  <rewrite>
57
  <sales_order_payment>Cardsave_Cardsaveonlinepayments_Block_Adminhtml_Sales_Order_Payment</sales_order_payment>
58
  </rewrite>
59
+ </adminhtml>
60
  </blocks>
61
  <!-- Define the helper class type -->
62
  <helpers>
128
  <resultdeliverymethod>POST</resultdeliverymethod>
129
  <allowspecific>0</allowspecific>
130
  <customstockmanagementenabled>1</customstockmanagementenabled>
131
+ <takePaymentInStoreBaseCurrency>1</takePaymentInStoreBaseCurrency>
132
  </cardsaveonlinepayments>
133
  </payment>
134
  </default>
app/code/local/Cardsave/Cardsaveonlinepayments/etc/system.xml CHANGED
@@ -123,6 +123,18 @@
123
  <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
124
  </comment>
125
  </resultdeliverymethod>
 
 
 
 
 
 
 
 
 
 
 
 
126
  <heading_mandatoryfields translate="label">
127
  <label>Hosted Payment Form Mandatory Fields</label>
128
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -187,13 +199,13 @@
187
  <heading_additionalsettings translate="label">
188
  <label>Additional Settings</label>
189
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
190
- <sort_order>197</sort_order>
191
  <show_in_default>1</show_in_default>
192
  <show_in_website>1</show_in_website>
193
  </heading_additionalsettings>
194
  <customstockmanagementenabled>
195
  <label>Custom Stock Management Enabled</label>
196
- <sort_order>198</sort_order>
197
  <frontend_type>select</frontend_type>
198
  <source_model>adminhtml/system_config_source_yesno</source_model>
199
  <show_in_default>1</show_in_default>
@@ -202,13 +214,13 @@
202
  </customstockmanagementenabled>
203
  <order_status translate="label">
204
  <label>New order status</label>
205
- <sort_order>199</sort_order>
206
  <frontend_type>select</frontend_type>
207
  <source_model>cardsaveonlinepayments/source_orderStatus</source_model>
208
  <show_in_default>1</show_in_default>
209
  <show_in_website>1</show_in_website>
210
  <show_in_store>0</show_in_store>
211
- </order_status>
212
  <heading_technicalinfo translate="label">
213
  <label>Additional Technical Information</label>
214
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
123
  <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
124
  </comment>
125
  </resultdeliverymethod>
126
+ <takePaymentInStoreBaseCurrency translate="label">
127
+ <label>Always take payments in Magento Store Base Currency?</label>
128
+ <sort_order>132</sort_order>
129
+ <frontend_type>select</frontend_type>
130
+ <source_model>adminhtml/system_config_source_yesno</source_model>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>0</show_in_store>
134
+ <comment>
135
+ <![CDATA[<strong>Please note</strong>: Only change this setting to 'No' if you have a Multi-Currency merchant account.]]>
136
+ </comment>
137
+ </takePaymentInStoreBaseCurrency>
138
  <heading_mandatoryfields translate="label">
139
  <label>Hosted Payment Form Mandatory Fields</label>
140
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
199
  <heading_additionalsettings translate="label">
200
  <label>Additional Settings</label>
201
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
202
+ <sort_order>195</sort_order>
203
  <show_in_default>1</show_in_default>
204
  <show_in_website>1</show_in_website>
205
  </heading_additionalsettings>
206
  <customstockmanagementenabled>
207
  <label>Custom Stock Management Enabled</label>
208
+ <sort_order>196</sort_order>
209
  <frontend_type>select</frontend_type>
210
  <source_model>adminhtml/system_config_source_yesno</source_model>
211
  <show_in_default>1</show_in_default>
214
  </customstockmanagementenabled>
215
  <order_status translate="label">
216
  <label>New order status</label>
217
+ <sort_order>197</sort_order>
218
  <frontend_type>select</frontend_type>
219
  <source_model>cardsaveonlinepayments/source_orderStatus</source_model>
220
  <show_in_default>1</show_in_default>
221
  <show_in_website>1</show_in_website>
222
  <show_in_store>0</show_in_store>
223
+ </order_status>
224
  <heading_technicalinfo translate="label">
225
  <label>Additional Technical Information</label>
226
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
app/code/local/Cardsave/Checkout/Block/Cart/Totals.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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 Mage
22
+ * @package Mage_Checkout
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ //class Mage_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Abstract
28
+ class Cardsave_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Totals
29
+ {
30
+ /**
31
+ * Check if we have display grand total in base currency
32
+ *
33
+ * @return bool
34
+ */
35
+ public function needDisplayBaseGrandtotal()
36
+ {
37
+ $takePaymentInStoreBaseCurrency = Mage::getModel('cardsaveonlinepayments/direct')->getConfigData('takePaymentInStoreBaseCurrency');
38
+ $quote = $this->getQuote();
39
+
40
+ if ($quote->getPayment()->getMethod() == 'cardsaveonlinepayments') {
41
+ if ($takePaymentInStoreBaseCurrency) {
42
+ if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode()) {
43
+ return true;
44
+ } else {
45
+ return false;
46
+ }
47
+ } else {
48
+ return false;
49
+ }
50
+ }
51
+
52
+ if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode()) {
53
+ return true;
54
+ }
55
+
56
+ return false;
57
+ }
58
+ }
app/code/local/Cardsave/Sales/Block/Order/Totals.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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 Mage
22
+ * @package Mage_Sales
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ //class Mage_Sales_Block_Order_Totals extends Mage_Core_Block_Template
27
+ class Cardsave_Sales_Block_Order_Totals extends Mage_Sales_Block_Order_Totals
28
+ {
29
+ /**
30
+ * Initialize order totals array
31
+ *
32
+ * @return Mage_Sales_Block_Order_Totals
33
+ */
34
+ protected function _initTotals()
35
+ {
36
+ $source = $this->getSource();
37
+
38
+ $this->_totals = array();
39
+ $this->_totals['subtotal'] = new Varien_Object(array(
40
+ 'code' => 'subtotal',
41
+ 'value' => $source->getSubtotal(),
42
+ 'label' => $this->__('Subtotal')
43
+ ));
44
+
45
+
46
+ /**
47
+ * Add shipping
48
+ */
49
+ if (!$source->getIsVirtual() && ((float) $source->getShippingAmount() || $source->getShippingDescription()))
50
+ {
51
+ $this->_totals['shipping'] = new Varien_Object(array(
52
+ 'code' => 'shipping',
53
+ 'field' => 'shipping_amount',
54
+ 'value' => $this->getSource()->getShippingAmount(),
55
+ 'label' => $this->__('Shipping & Handling')
56
+ ));
57
+ }
58
+
59
+ /**
60
+ * Add discount
61
+ */
62
+ if (((float)$this->getSource()->getDiscountAmount()) != 0) {
63
+ if ($this->getSource()->getDiscountDescription()) {
64
+ $discountLabel = $this->__('Discount (%s)', $source->getDiscountDescription());
65
+ } else {
66
+ $discountLabel = $this->__('Discount');
67
+ }
68
+ $this->_totals['discount'] = new Varien_Object(array(
69
+ 'code' => 'discount',
70
+ 'field' => 'discount_amount',
71
+ 'value' => $source->getDiscountAmount(),
72
+ 'label' => $discountLabel
73
+ ));
74
+ }
75
+
76
+ $this->_totals['grand_total'] = new Varien_Object(array(
77
+ 'code' => 'grand_total',
78
+ 'field' => 'grand_total',
79
+ 'strong'=> true,
80
+ 'value' => $source->getGrandTotal(),
81
+ 'label' => $this->__('Grand Total')
82
+ ));
83
+
84
+ /**
85
+ * Base grandtotal
86
+ */
87
+ $takePaymentInStoreBaseCurrency = Mage::getModel('cardsaveonlinepayments/direct')->getConfigData('takePaymentInStoreBaseCurrency');
88
+
89
+ if ($this->getOrder()->getPayment()->getMethod() == 'cardsaveonlinepayments') {
90
+ if ($takePaymentInStoreBaseCurrency){
91
+ if ($this->getOrder()->isCurrencyDifferent()) {
92
+ $this->_totals['base_grandtotal'] = new Varien_Object(array(
93
+ 'code' => 'base_grandtotal',
94
+ 'value' => $this->getOrder()->formatBasePrice($source->getBaseGrandTotal()),
95
+ 'label' => $this->__('Grand Total to be Charged'),
96
+ 'is_formated' => true,
97
+ ));
98
+ }
99
+ }
100
+ } else {
101
+ if ($this->getOrder()->isCurrencyDifferent()) {
102
+ $this->_totals['base_grandtotal'] = new Varien_Object(array(
103
+ 'code' => 'base_grandtotal',
104
+ 'value' => $this->getOrder()->formatBasePrice($source->getBaseGrandTotal()),
105
+ 'label' => $this->__('Grand Total to be Charged'),
106
+ 'is_formated' => true,
107
+ ));
108
+ }
109
+ }
110
+ return $this;
111
+ }
112
+ }
package.xml CHANGED
@@ -1,20 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cardsave_Cardsaveonlinepayments</name>
4
- <version>1.14.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>CardSave Payment Extension (Official)</summary>
10
  <description>Supports all of the integration methods provided by CardSave and 3D Secure. Now updated for Magento v1.7.</description>
11
- <notes>Fix 3D Secure bug with new gateway accounts&#xD;
12
- &#xD;
13
- </notes>
14
  <authors><author><name>CardSave</name><user>CardSave</user><email>alistair.richardson@cardsave.net</email></author></authors>
15
- <date>2013-03-05</date>
16
- <time>11:46:41</time>
17
- <contents><target name="magelocal"><dir name="Cardsave"><dir name="Cardsaveonlinepayments"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="1cff6196bd79d3989b960506cc87201e"/></dir></dir></dir><file name="Error.php" hash="660d3cbde48910ef271df9e05130a6d7"/><file name="Form.php" hash="ea5b3817c9607a94f4685d53d0b18569"/><file name="Info.php" hash="57a4bfec1a1c769de063be2b922f4a97"/><file name="Redirect.php" hash="b5439397d10caf4f07505566bde9522d"/><file name="Threedsecure.php" hash="9d75776f34c5acaf6ea265f35f302c69"/></dir><dir name="Helper"><file name="Data.php" hash="e024ec0479d1e8e7efcf4751b05194d6"/></dir><dir name="Model"><dir name="Common"><file name="GlobalErrors.php" hash="e0f9062ca2db4c85d17e6939f9bd7641"/><file name="ISOCountries.php" hash="6c59574f190f6a67e38578d876c14edf"/><file name="ISOCurrencies.php" hash="2568f980f09bd8a7d4beaf3d16456d28"/><file name="PaymentFormHelper.php" hash="4db3a71495e5e7f9e8cbb9911d8adf9c"/><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash="e7d13200c853536cf641bde7f714b54e"/><file name="SOAP.php" hash="2b966f946889c6f151b222c322d7a0ee"/><file name="TPG_Common.php" hash="0170a3c7f6a01faf9aee9b0f94da6d2a"/></dir></dir><file name="Direct.php" hash="ceec1e292df3c0c316533da0756e6ace"/><file name="Request.php" hash="370f028086d13ae1df470e93a67dea66"/><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="b2a7e887464ff91517dbb4fd62f13c66"/></dir></dir></dir><dir name="Source"><file name="HashMethod.php" hash="997928579b69d21ae9eebec698c715c6"/><file name="OrderStatus.php" hash="4c44f8ba1652f20d934aa200ed4c8d00"/><file name="PaymentAction.php" hash="3aab84053c69af1de2e743ee590fdf0c"/><file name="PaymentMode.php" hash="ea8af602bd09d54a123af64bc4b680d0"/><file name="ResultDeliveryMethod.php" hash="afb838319df715e604173d6aa143feab"/></dir></dir><dir name="controllers"><file name="PaymentController.php" hash="ac32fc8147445e4177960c3482ec4179"/></dir><dir name="etc"><file name="config.xml" hash="a2ccf758ed448c19a2d9cb95ddd13316"/><file name="system.xml" hash="67d9e6f182704f8c2e44b55229e2c8bf"/></dir><dir name="sql"><dir name="cardsaveonlinepayments_setup"><file name="mysql4-install-0.1.0.php" hash="bda643d24b75e0dc527dc2caa6d47689"/></dir></dir></dir><dir name="Checkout"><dir name="Block"><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="75a8a2961be74499d47ab398a8e1ba8a"/></dir></dir></dir><dir name="Model"><dir name="Type"><file name="Onepage.php" hash="2dc7e8f4e2b0292dc9160e4f9cf9ae5b"/></dir></dir><dir name="etc"><file name="config.xml" hash="9dbd58b6b32491d65e5c7d5850aa3420"/></dir></dir><dir name="Sales"><dir name="Model"><dir name="Order"><file name="Invoice.php" hash="9be99f3fbe1c4fe98fb110d3daa8afe6"/><file name="Payment.php" hash="10102812cd1906c0cceced21f88a78ff"/></dir><file name="Order.php" hash="e84594434822e321f271e3e463ddbcb9"/><dir name="Service"><file name="Quote.php" hash="a514922157b5690772d716c29f4a653e"/></dir></dir><dir name="etc"><file name="config.xml" hash="41f8d7978cb7e4cfffa0272d80e8f7bd"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="45978066fc7ee981dec117306a33bb02"/><file name="info.phtml" hash="9765a5eae50cb6fa21dcec22e7767e79"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><file name="cardsaveonlinepayments.xml" hash="65e413716658a000d659271cd174b1e2"/></dir><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="bf8cf94001d912f6d1e77b1d2b03cf6e"/><file name="info.phtml" hash="9765a5eae50cb6fa21dcec22e7767e79"/></dir><dir name="payment"><dir name="info"><file name="cc_cardsaveonlinepayments.phtml" hash="88065460669f1112779264bdbf710af4"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="d8c32fe9d0d9584ac03ff7148c18e24a"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/><file name="form.phtml" hash="d8c32fe9d0d9584ac03ff7148c18e24a"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="d8c32fe9d0d9584ac03ff7148c18e24a"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardsave_All.xml" hash="e1d59fd8c4d4b5d87607f43fecf47e59"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="cardsaveonlinepayments.js" hash="e7b2422644d39f0eb98e63d54a55ae4d"/></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><file name="cardsave_online.png" hash="d24a379083a48ade742bddda6aa09103"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="images"><file name="cardsave_online.png" hash="d24a379083a48ade742bddda6aa09103"/></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0</min><max>1.7.5</max></package></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cardsave_Cardsaveonlinepayments</name>
4
+ <version>1.14.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>CardSave Payment Extension (Official)</summary>
10
  <description>Supports all of the integration methods provided by CardSave and 3D Secure. Now updated for Magento v1.7.</description>
11
+ <notes>Added Multi-Currency support. New option added to configuration page to allow payments to be taken in customers chosen currency, or to force all payments through in the store base currency. Please Note: to accept payments using in a non-GBP currency, you must have a Multi-Currency Merchant Account - Please contact us to set this up if you do not have one.</notes>
 
 
12
  <authors><author><name>CardSave</name><user>CardSave</user><email>alistair.richardson@cardsave.net</email></author></authors>
13
+ <date>2013-05-08</date>
14
+ <time>15:11:55</time>
15
+ <contents><target name="magelocal"><dir name="Cardsave"><dir name="Cardsaveonlinepayments"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="1cff6196bd79d3989b960506cc87201e"/></dir></dir></dir><file name="Error.php" hash="660d3cbde48910ef271df9e05130a6d7"/><file name="Form.php" hash="ea5b3817c9607a94f4685d53d0b18569"/><file name="Info.php" hash="57a4bfec1a1c769de063be2b922f4a97"/><file name="Redirect.php" hash="b5439397d10caf4f07505566bde9522d"/><file name="Threedsecure.php" hash="9d75776f34c5acaf6ea265f35f302c69"/></dir><dir name="Helper"><file name="Data.php" hash="e024ec0479d1e8e7efcf4751b05194d6"/></dir><dir name="Model"><dir name="Common"><file name="GlobalErrors.php" hash="e0f9062ca2db4c85d17e6939f9bd7641"/><file name="ISOCountries.php" hash="6c59574f190f6a67e38578d876c14edf"/><file name="ISOCurrencies.php" hash="2568f980f09bd8a7d4beaf3d16456d28"/><file name="PaymentFormHelper.php" hash="f0c999f6683b2e8f7c1981a040505c52"/><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash="e7d13200c853536cf641bde7f714b54e"/><file name="SOAP.php" hash="2b966f946889c6f151b222c322d7a0ee"/><file name="TPG_Common.php" hash="0170a3c7f6a01faf9aee9b0f94da6d2a"/></dir></dir><file name="Direct.php" hash="c3b27f8d450812ac93d132054e0b5d64"/><file name="Request.php" hash="370f028086d13ae1df470e93a67dea66"/><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="b2a7e887464ff91517dbb4fd62f13c66"/></dir></dir></dir><dir name="Source"><file name="HashMethod.php" hash="997928579b69d21ae9eebec698c715c6"/><file name="OrderStatus.php" hash="4c44f8ba1652f20d934aa200ed4c8d00"/><file name="PaymentAction.php" hash="3aab84053c69af1de2e743ee590fdf0c"/><file name="PaymentMode.php" hash="ea8af602bd09d54a123af64bc4b680d0"/><file name="ResultDeliveryMethod.php" hash="afb838319df715e604173d6aa143feab"/></dir></dir><dir name="controllers"><file name="PaymentController.php" hash="ac32fc8147445e4177960c3482ec4179"/></dir><dir name="etc"><file name="config.xml" hash="41d10598438bb48fa5397cdbdc34b493"/><file name="system.xml" hash="09f1d7b4a9c36472b8c529a8485a2ba9"/></dir><dir name="sql"><dir name="cardsaveonlinepayments_setup"><file name="mysql4-install-0.1.0.php" hash="bda643d24b75e0dc527dc2caa6d47689"/></dir></dir></dir><dir name="Checkout"><dir name="Block"><dir name="Cart"><file name="Totals.php" hash="ca91395788c746c8eef3a4b4f09833f7"/></dir><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="75a8a2961be74499d47ab398a8e1ba8a"/></dir></dir></dir><dir name="Model"><dir name="Type"><file name="Onepage.php" hash="2dc7e8f4e2b0292dc9160e4f9cf9ae5b"/></dir></dir><dir name="etc"><file name="config.xml" hash="9dbd58b6b32491d65e5c7d5850aa3420"/></dir></dir><dir name="Sales"><dir name="Block"><dir name="Order"><file name="Totals.php" hash="ceeea63efb04baded1446aaaab94c825"/></dir></dir><dir name="Model"><dir name="Order"><file name="Invoice.php" hash="9be99f3fbe1c4fe98fb110d3daa8afe6"/><file name="Payment.php" hash="10102812cd1906c0cceced21f88a78ff"/></dir><file name="Order.php" hash="e84594434822e321f271e3e463ddbcb9"/><dir name="Service"><file name="Quote.php" hash="a514922157b5690772d716c29f4a653e"/></dir></dir><dir name="etc"><file name="config.xml" hash="41f8d7978cb7e4cfffa0272d80e8f7bd"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="45978066fc7ee981dec117306a33bb02"/><file name="info.phtml" hash="9765a5eae50cb6fa21dcec22e7767e79"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><file name="cardsaveonlinepayments.xml" hash="65e413716658a000d659271cd174b1e2"/></dir><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="bf8cf94001d912f6d1e77b1d2b03cf6e"/><file name="info.phtml" hash="9765a5eae50cb6fa21dcec22e7767e79"/></dir><dir name="payment"><dir name="info"><file name="cc_cardsaveonlinepayments.phtml" hash="88065460669f1112779264bdbf710af4"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="d8c32fe9d0d9584ac03ff7148c18e24a"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/><file name="form.phtml" hash="d8c32fe9d0d9584ac03ff7148c18e24a"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="d8c32fe9d0d9584ac03ff7148c18e24a"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardsave_All.xml" hash="e1d59fd8c4d4b5d87607f43fecf47e59"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="cardsaveonlinepayments.js" hash="e7b2422644d39f0eb98e63d54a55ae4d"/></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><file name="cardsave_online.png" hash="d24a379083a48ade742bddda6aa09103"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="images"><file name="cardsave_online.png" hash="d24a379083a48ade742bddda6aa09103"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0</min><max>1.7.5</max></package></required></dependencies>
18
  </package>