Cardgate_Cgp - Version 1.1.0

Version Notes

- Added payment fee options

Download this release

Release Info

Developer Cardgate BV
Extension Cardgate_Cgp
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.38 to 1.1.0

Files changed (51) hide show
  1. app/code/local/Cardgate/Cgp/Block/Form/Banktransfer.php +32 -42
  2. app/code/local/Cardgate/Cgp/Block/Form/Ideal.php +99 -101
  3. app/code/local/Cardgate/Cgp/Block/Form/Klarna.php +508 -490
  4. app/code/local/Cardgate/Cgp/Block/Form/Klarnaaccount.php +480 -479
  5. app/code/local/Cardgate/Cgp/Block/Paymentfee/Adminhtml/Sales/Order/Totals.php +31 -0
  6. app/code/local/Cardgate/Cgp/Block/Paymentfee/Checkout/Fee.php +78 -0
  7. app/code/local/Cardgate/Cgp/Block/Paymentfee/Creditmemo/Totals.php +30 -0
  8. app/code/local/Cardgate/Cgp/Block/Paymentfee/Invoice/Totals/Fee.php +30 -0
  9. app/code/local/Cardgate/Cgp/Block/Paymentfee/Order/Totals/Fee.php +30 -0
  10. app/code/local/Cardgate/Cgp/Block/Redirect.php +31 -37
  11. app/code/local/Cardgate/Cgp/Helper/Data.php +7 -18
  12. app/code/local/Cardgate/Cgp/Helper/Paymentfee.php +177 -0
  13. app/code/local/Cardgate/Cgp/Model/Adminhtml/System/Config/Source/Languages.php +53 -61
  14. app/code/local/Cardgate/Cgp/Model/Adminhtml/System/Config/Source/Modes.php +16 -24
  15. app/code/local/Cardgate/Cgp/Model/Base.php +439 -420
  16. app/code/local/Cardgate/Cgp/Model/Gateway/Abstract.php +620 -559
  17. app/code/local/Cardgate/Cgp/Model/Gateway/Americanexpress.php +9 -16
  18. app/code/local/Cardgate/Cgp/Model/Gateway/Banktransfer.php +11 -17
  19. app/code/local/Cardgate/Cgp/Model/Gateway/Cartebancaire.php +9 -16
  20. app/code/local/Cardgate/Cgp/Model/Gateway/Cartebleue.php +9 -16
  21. app/code/local/Cardgate/Cgp/Model/Gateway/Default.php +5 -15
  22. app/code/local/Cardgate/Cgp/Model/Gateway/Directdebit.php +9 -16
  23. app/code/local/Cardgate/Cgp/Model/Gateway/Giropay.php +9 -16
  24. app/code/local/Cardgate/Cgp/Model/Gateway/Ideal.php +11 -17
  25. app/code/local/Cardgate/Cgp/Model/Gateway/Klarna.php +30 -26
  26. app/code/local/Cardgate/Cgp/Model/Gateway/Klarnaaccount.php +30 -26
  27. app/code/local/Cardgate/Cgp/Model/Gateway/Maestro.php +9 -16
  28. app/code/local/Cardgate/Cgp/Model/Gateway/Mastercard.php +9 -16
  29. app/code/local/Cardgate/Cgp/Model/Gateway/Mistercash.php +9 -16
  30. app/code/local/Cardgate/Cgp/Model/Gateway/Paypal.php +9 -16
  31. app/code/local/Cardgate/Cgp/Model/Gateway/Przelewy24.php +9 -16
  32. app/code/local/Cardgate/Cgp/Model/Gateway/Sofortbanking.php +9 -16
  33. app/code/local/Cardgate/Cgp/Model/Gateway/Visa.php +9 -16
  34. app/code/local/Cardgate/Cgp/Model/Gateway/Vpay.php +9 -16
  35. app/code/local/Cardgate/Cgp/Model/Gateway/Webmoney.php +9 -16
  36. app/code/local/Cardgate/Cgp/Model/Observer.php +62 -61
  37. app/code/local/Cardgate/Cgp/Model/Paymentfee/Creditmemo/Total.php +68 -0
  38. app/code/local/Cardgate/Cgp/Model/Paymentfee/Invoice/Pdf/Total.php +96 -0
  39. app/code/local/Cardgate/Cgp/Model/Paymentfee/Invoice/Tax.php +125 -0
  40. app/code/local/Cardgate/Cgp/Model/Paymentfee/Invoice/Total.php +74 -0
  41. app/code/local/Cardgate/Cgp/Model/Paymentfee/Quote/Quote.php +46 -0
  42. app/code/local/Cardgate/Cgp/Model/Paymentfee/Quote/TaxTotal.php +61 -0
  43. app/code/local/Cardgate/Cgp/Model/Paymentfee/Quote/Total.php +137 -0
  44. app/code/local/Cardgate/Cgp/controllers/StandardController.php +190 -192
  45. app/code/local/Cardgate/Cgp/etc/adminhtml.xml +3 -13
  46. app/code/local/Cardgate/Cgp/etc/config.xml +113 -16
  47. app/code/local/Cardgate/Cgp/etc/system.xml +666 -33
  48. app/design/frontend/base/default/template/cardgate/cgp/checkout/fee.phtml +39 -0
  49. app/design/frontend/base/default/template/cardgate/cgp/form/klarna.phtml +4 -1
  50. app/locale/nl_NL/Cardgate_Cgp.csv +10 -4
  51. package.xml +9 -9
app/code/local/Cardgate/Cgp/Block/Form/Banktransfer.php CHANGED
@@ -1,48 +1,38 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Richard schoots, <support@cardgate.com>
15
- * @copyright Copyright (c) 2015 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Block_Form_Banktransfer extends Mage_Payment_Block_Form
20
- {
21
-
22
- protected function _construct()
23
- {
24
- parent::_construct();
25
- $this->setTemplate('cardgate/cgp/form/banktransfer.phtml');
26
- }
27
-
28
- /**
29
- * Return information payment object
30
- *
31
- * @return Mage_Payment_Model_Info
32
- */
33
- public function getInfoInstance()
34
- {
35
- return $this->getMethod()->getInfoInstance();
36
- }
37
-
38
- /**
39
- * Returns HTML options for select field with iDEAL banks
40
- *
41
- * @return string
42
- */
43
- public function getInstructions()
44
- {
45
- $settings = Mage::getStoreConfig( 'cgp/cgp_banktransfer' );
46
- return nl2br(trim($settings['instructions']));
47
- }
48
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Block_Form_Banktransfer extends Mage_Payment_Block_Form
10
+ {
11
+
12
+ protected function _construct ()
13
+ {
14
+ parent::_construct();
15
+ $this->setTemplate( 'cardgate/cgp/form/banktransfer.phtml' );
16
+ }
17
+
18
+ /**
19
+ * Return information payment object
20
+ *
21
+ * @return Mage_Payment_Model_Info
22
+ */
23
+ public function getInfoInstance ()
24
+ {
25
+ return $this->getMethod()->getInfoInstance();
26
+ }
27
+
28
+ /**
29
+ * Returns HTML options for select field with iDEAL banks
30
+ *
31
+ * @return string
32
+ */
33
+ public function getInstructions ()
34
+ {
35
+ $settings = Mage::getStoreConfig( 'cgp/cgp_banktransfer' );
36
+ return nl2br( trim( $settings['instructions'] ) );
37
+ }
38
  }
app/code/local/Cardgate/Cgp/Block/Form/Ideal.php CHANGED
@@ -1,109 +1,107 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Block_Form_Ideal extends Mage_Payment_Block_Form
20
- {
21
- protected $_banks = array(
22
- '0021' => 'Rabobank',
23
- '0031' => 'ABN Amro',
24
- '0091' => 'Friesland Bank',
25
- '0721' => 'ING',
26
- '0751' => 'SNS Bank',
27
- '0001' => '------ Additional Banks ------',
28
- '0161' => 'Van Lanschot Bank',
29
- '0511' => 'Triodos Bank',
30
- '0761' => 'ASN Bank',
31
- '0771' => 'SNS Regio Bank',
32
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
- protected function _construct()
35
- {
36
- parent::_construct();
37
- $this->setTemplate('cardgate/cgp/form/ideal.phtml');
38
- }
39
-
40
- /**
41
- * Return information payment object
42
- *
43
- * @return Mage_Payment_Model_Info
44
- */
45
- public function getInfoInstance()
46
- {
47
- return $this->getMethod()->getInfoInstance();
48
- }
49
-
50
- /**
51
- * Returns HTML options for select field with iDEAL banks
52
- *
53
- * @return string
54
- */
55
- public function getSelectField()
56
- {
57
- $a2 = array();
58
- $aBanks = $this->getBankOptions();
59
- foreach ($aBanks as $id => $name) {
60
- $a2[$id] = Mage::helper('cgp')->__($name);
61
- }
62
- $_code = $this->getMethodCode();
63
-
64
- $form = new Varien_Data_Form();
65
- $form->addField($_code.'_ideal_issuer', 'select', array(
66
- 'name' => 'payment[cgp][ideal_issuer_id]',
67
- 'class' => 'required-entry',
68
- 'label' => Mage::helper('cgp')->__('Select your bank'),
69
- 'values' => $a2,
70
- 'value' => '',
71
- 'required' => true,
72
- 'disabled' => false,
73
- ));
74
- return $form->getHtml();
75
- }
76
-
77
- /**
78
- * Fetch iDEAL bank options from CardGatePlus if possible and return as array.
79
- *
80
- * @return array
81
- */
82
 
83
- private function getBankOptions(){
84
- $url = 'https://gateway.cardgateplus.com/cache/idealDirectoryRabobank.dat';
85
- if( !function_exists('file_get_contents') ) {
86
- $result = false;
87
- } else {
88
- $result = file_get_contents($url);
89
- }
90
-
91
- $aBanks = array();
92
-
93
- if ($result) {
94
- $aBanks = unserialize($result);
95
- unset($aBanks[0]);
96
- $a2 = array();
97
- foreach ($aBanks as $id => $name) {
98
- if ($id==1) $id='0001';
99
- $a2[$id] = $name;
100
- }
101
- $aBanks = $a2;
102
- $aBanks = array_merge(array(''=>Mage::helper('cgp')->__('--Please select--')),$aBanks);
103
- }
104
- if (count($aBanks)< 1) {
105
- $aBanks = array_merge(array(''=>Mage::helper('cgp')->__('--Please select--')),$this->_banks);
106
- }
107
- return $aBanks;
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Block_Form_Ideal extends Mage_Payment_Block_Form
10
+ {
11
+
12
+ protected $_banks = array(
13
+ '0021' => 'Rabobank',
14
+ '0031' => 'ABN Amro',
15
+ '0091' => 'Friesland Bank',
16
+ '0721' => 'ING',
17
+ '0751' => 'SNS Bank',
18
+ '0001' => '------ Additional Banks ------',
19
+ '0161' => 'Van Lanschot Bank',
20
+ '0511' => 'Triodos Bank',
21
+ '0761' => 'ASN Bank',
22
+ '0771' => 'SNS Regio Bank'
23
+ );
24
+
25
+ protected function _construct ()
26
+ {
27
+ parent::_construct();
28
+ $this->setTemplate( 'cardgate/cgp/form/ideal.phtml' );
29
+ }
30
+
31
+ /**
32
+ * Return information payment object
33
+ *
34
+ * @return Mage_Payment_Model_Info
35
+ */
36
+ public function getInfoInstance ()
37
+ {
38
+ return $this->getMethod()->getInfoInstance();
39
+ }
40
 
41
+ /**
42
+ * Returns HTML options for select field with iDEAL banks
43
+ *
44
+ * @return string
45
+ */
46
+ public function getSelectField ()
47
+ {
48
+ $a2 = array();
49
+ $aBanks = $this->getBankOptions();
50
+ foreach ( $aBanks as $id => $name ) {
51
+ $a2[$id] = Mage::helper( 'cgp' )->__( $name );
52
+ }
53
+ $_code = $this->getMethodCode();
54
+
55
+ $form = new Varien_Data_Form();
56
+ $form->addField( $_code . '_ideal_issuer', 'select',
57
+ array(
58
+ 'name' => 'payment[cgp][ideal_issuer_id]',
59
+ 'class' => 'required-entry',
60
+ 'label' => Mage::helper( 'cgp' )->__( 'Select your bank' ),
61
+ 'values' => $a2,
62
+ 'value' => '',
63
+ 'required' => true,
64
+ 'disabled' => false
65
+ ) );
66
+ return $form->getHtml();
67
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
+ /**
70
+ * Fetch iDEAL bank options from CardGatePlus if possible and return as
71
+ * array.
72
+ *
73
+ * @return array
74
+ */
75
+ private function getBankOptions ()
76
+ {
77
+ $url = 'https://gateway.cardgateplus.com/cache/idealDirectoryRabobank.dat';
78
+ if ( ! function_exists( 'file_get_contents' ) ) {
79
+ $result = false;
80
+ } else {
81
+ $result = file_get_contents( $url );
82
+ }
83
+
84
+ $aBanks = array();
85
+
86
+ if ( $result ) {
87
+ $aBanks = unserialize( $result );
88
+ unset( $aBanks[0] );
89
+ $a2 = array();
90
+ foreach ( $aBanks as $id => $name ) {
91
+ if ( $id == 1 )
92
+ $id = '0001';
93
+ $a2[$id] = $name;
94
+ }
95
+ $aBanks = $a2;
96
+ $aBanks = array_merge( array(
97
+ '' => Mage::helper( 'cgp' )->__( '--Please select--' )
98
+ ), $aBanks );
99
+ }
100
+ if ( count( $aBanks ) < 1 ) {
101
+ $aBanks = array_merge( array(
102
+ '' => Mage::helper( 'cgp' )->__( '--Please select--' )
103
+ ), $this->_banks );
104
+ }
105
+ return $aBanks;
106
+ }
107
  }
app/code/local/Cardgate/Cgp/Block/Form/Klarna.php CHANGED
@@ -1,80 +1,75 @@
1
  <?php
2
 
3
  /**
4
- * Magento CardGatePlus payment extension
5
  *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- *
13
- * @category Mage
14
- * @package Cardgate_Cgp
15
- * @author Paul Saparov, <support@cardgate.com>
16
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
17
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
  */
19
- class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form {
20
-
21
- protected function _construct() {
22
- parent::_construct();
23
- $this->setTemplate( 'cardgate/cgp/form/klarna.phtml' );
24
- }
25
-
26
- /**
27
- * Return information payment object
28
- *
29
- * @return Mage_Payment_Model_Info
30
- */
31
- public function getInfoInstance() {
32
- return $this->getMethod()->getInfoInstance();
33
- }
34
-
35
- public function getYear() {
36
- $yr = 'Year';
37
- switch ( $this->getLocaleCode() ) {
38
- case 'de_AT':
39
- $yr = 'Jahr';
40
- break;
41
- case 'da_DK':
42
- $yr = 'Ar';
43
- break;
44
- case 'fi_FI':
45
- $yr = 'Vuosi';
46
- break;
47
- case 'de_DE':
48
- $yr = 'Jahr';
49
- break;
50
- case 'nl_NL';
51
- $yr = 'Jaar';
52
- break;
53
- case 'nb_NO':
54
- $yr = 'Ar';
55
- break;
56
- case 'sv_SE':
57
- $yr = 'Ar';
58
- break;
59
- }
60
-
61
- $str = '<option value="">' . $yr . '</option>';
62
- for ( $x = date( 'Y' ); $x >= 1900; $x-- ) {
63
- $str.='<option value="' . $x . '">' . $x . '</option/>';
64
- }
65
- return $str;
66
- }
67
-
68
- public function getMonth() {
69
-
70
- $str = '<option value="">Month</option>';
71
- for ( $x = 1; $x < 13; $x++ ) {
72
- $str.= '<option value="' . sprintf( "%02d", $x ) . '">' . date( 'F', mktime( 1, 1, 1, $x, 1, 1970 ) ) . '</option>';
73
- }
74
-
75
- switch ( $this->getLocaleCode() ) {
76
- case 'de_AT':
77
- $str = '<option value="">Monat</option>
 
 
 
 
 
78
  <option value="01">Januar</option>
79
  <option value="02">Februar</option>
80
  <option value="03">März</option>
@@ -87,9 +82,9 @@ class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form {
87
  <option value="10">Oktober</option>
88
  <option value="11">November</option>
89
  <option value="12">Dezember</option>';
90
- break;
91
- case 'da_DK':
92
- $str = '<option value="">Måned</option>
93
  <option value="01">Januar</option>
94
  <option value="02">Februar</option>
95
  <option value="03">Marts</option>
@@ -102,9 +97,9 @@ class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form {
102
  <option value="10">Oktober</option>
103
  <option value="11">November</option>
104
  <option value="12">December</option>';
105
- break;
106
- case 'fi_FI':
107
- $str = '<option value="">Kuukausi</option>
108
  <option value="01">Tammikuu</option>
109
  <option value="02">Helmikuu</option>
110
  <option value="03">Maaliskuu</option>
@@ -117,9 +112,9 @@ class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form {
117
  <option value="10">Lokakuu</option>
118
  <option value="11">Marraskuu</option>
119
  <option value="12">Joulukuu</option>';
120
- break;
121
- case 'de_DE':
122
- $str = '<option value="">Monat</option>
123
  <option value="01">Januar</option>
124
  <option value="02">Februar</option>
125
  <option value="03">März</option>
@@ -132,9 +127,9 @@ class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form {
132
  <option value="10">Oktober</option>
133
  <option value="11">November</option>
134
  <option value="12">Dezember</option>';
135
- break;
136
- case 'nl_NL';
137
- $str = '<option value="">Maand</option>
138
  <option value="01">januari</option>
139
  <option value="02">februari</option>
140
  <option value="03">maart</option>
@@ -147,9 +142,9 @@ class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form {
147
  <option value="10">oktober</option>
148
  <option value="11">november</option>
149
  <option value="12">december</option>';
150
- break;
151
- case 'nb_NO':
152
- $str = '<option value="">Måned</option>
153
  <option value="01">Januar</option>
154
  <option value="02">Februar</option>
155
  <option value="03">Mars</option>
@@ -162,9 +157,9 @@ class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form {
162
  <option value="10">Oktober</option>
163
  <option value="11">November</option>
164
  <option value="12">Desember</option>';
165
- break;
166
- case 'sv_SE':
167
- $str = '<option value="">Månad</option>
168
  <option value="01">januari</option>
169
  <option value="02">februari</option>
170
  <option value="03">mars</option>
@@ -177,375 +172,391 @@ class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form {
177
  <option value="10">oktober</option>
178
  <option value="11">november</option>
179
  <option value="12">december</option>';
180
- break;
181
- }
182
-
183
- return $str;
184
- }
185
-
186
- public function getDay() {
187
- $day = 'Day';
188
- switch ( $this->getLocaleCode() ) {
189
- case 'de_AT':
190
- $day = 'Tag';
191
- break;
192
- case 'da_DK':
193
- $day = 'Dag';
194
- break;
195
- case 'fi_FI':
196
- $day = 'Päivä';
197
- break;
198
- case 'de_DE':
199
- $day = 'Tag';
200
- break;
201
- case 'nl_NL';
202
- $day = 'Dag';
203
- break;
204
- case 'nb_NO':
205
- $day = 'Dag';
206
- break;
207
- case 'sv_SE':
208
- $day = 'Dag';
209
- break;
210
- }
211
-
212
- $str = '<option value="">' . $day . '</option>';
213
- for ( $x = 1; $x <= 31; $x++ ) {
214
- $str.= '<option value="' . sprintf( "%02d", $x ) . '">' . sprintf( "%02d", $x ) . '</option>';
215
- }
216
- return $str;
217
- }
218
-
219
- public function getLanguage() {
220
- $str = '<option value="de">Austrian</option>
 
 
221
  <option value="da">Danisch</option>
222
  <option value="fi">Finnisch</option>
223
  <option selected="selected" value="de">German</option>
224
  <option value="nl">Dutch</option>
225
  <option value="nb">Norwegian</option>
226
  <option value="sv">Swedisch</option>';
227
-
228
- switch ( $this->getLocaleCode() ) {
229
- case 'de_AT':
230
- $str = '<option selected="selected" value="de">Österreichisch</option>
231
  <option value="da">Dänisch</option>
232
  <option value="fi">Finnisch</option>
233
  <option value="de">Deutsch</option>
234
  <option value="nl">Holländisch</option>
235
  <option value="nb">Norwegisch</option>
236
  <option value="sv">Schwedisch</option>';
237
- break;
238
- case 'da_DK':
239
- $str = '<option value="de">østrigsk</option>
240
  <option selected="selected" value="da">Dansk</option>
241
  <option value="fi">Finsk</option>
242
  <option value="de">Tysk</option>
243
  <option value="nl">Hollandsk</option>
244
  <option value="nb">Norwegian</option>
245
  <option value="sv">Svensk</option>';
246
- break;
247
- case 'fi_FI':
248
- $str = '<option value="de">østrigsk</option>
249
  <option value="da">Dansk</option>
250
  <option selected="selected" value="fi">Finsk</option>
251
  <option value="de">German</option>
252
  <option value="nl">Hollandsk</option>
253
  <option value="nb">Norja</option>
254
  <option value="sv">Ruotsi</option>';
255
- break;
256
- case 'de_DE':
257
- $str = '<option value="de">Österreichisch</option>
258
  <option value="da">Dänisch</option>
259
  <option value="fi">Finnisch</option>
260
  <option selected="selected" value="de">Deutsch</option>
261
  <option value="nl">Holländisch</option>
262
  <option value="nb">Norwegisch</option>
263
  <option value="sv">Schwedisch</option>';
264
- break;
265
- case 'nl_NL';
266
- $str = '<option value="de">Oostenrijks</option>
267
  <option value="da">Deens</option>
268
  <option value="fi">Fins</option>
269
  <option value="de">Duits</option>
270
  <option selected="selected" value="nl">Nederlands</option>
271
  <option value="nb">Norweegs</option>
272
  <option value="sv">Zweeds</option>';
273
- break;
274
- case 'nb_NO':
275
- $str = '<option value="de">østerriksk</option>
276
  <option value="da">Dansk</option>
277
  <option value="fi">Finsk</option>
278
  <option value="de">Tyske</option>
279
  <option value="nl">Dutch</option>
280
  <option selected="selected" value="nb">Norsk</option>
281
  <option value="sv">Svensk</option>';
282
- break;
283
- case 'sv_SE':
284
- $str = '<option value="de">österrikiska</option>
285
  <option value="da">Dansk</option>
286
  <option value="fi">Finska</option>
287
  <option value="de">Tysk</option>
288
  <option value="nl">Holländare</option>
289
  <option value="nb">Norska</option>
290
  <option selected="selected" value="sv">Svenska</option>';
291
- break;
292
- }
293
- return $str;
294
- }
295
-
296
- public function getGenderLabel() {
297
- switch ( $this->getLocaleCode() ) {
298
- case 'de_AT':
299
- return 'Geslecht';
300
- break;
301
- case 'da_DK':
302
- return 'Køn';
303
- break;
304
- case 'fi_FI':
305
- return 'Sukupuoli';
306
- break;
307
- case 'de_DE':
308
- return 'Geschlecht';
309
- break;
310
- case 'nl_NL';
311
- return 'Geslacht';
312
- break;
313
- case 'nb_NO':
314
- return 'Kjønn';
315
- break;
316
- case 'sv_SE':
317
- return 'Kön';
318
- break;
319
- }
320
- return Mage::helper( 'cgp' )->__( 'Gender' );
321
- }
322
-
323
- public function getMaleLabel() {
324
- switch ( $this->getLocaleCode() ) {
325
- case 'de_AT':
326
- return 'Mann';
327
- break;
328
- case 'da_DK':
329
- return 'Mand';
330
- break;
331
- case 'fi_FI':
332
- return 'Mies';
333
- break;
334
- case 'de_DE':
335
- return 'Mann';
336
- break;
337
- case 'nl_NL';
338
- return 'Man';
339
- break;
340
- case 'nb_NO':
341
- return 'Mann';
342
- break;
343
- case 'sv_SE':
344
- return 'Man';
345
- break;
346
- }
347
- return Mage::helper( 'cgp' )->__( 'Male' );
348
- }
349
-
350
- public function getFemaleLabel() {
351
- switch ( $this->getLocaleCode() ) {
352
- case 'de_AT':
353
- return 'Frau';
354
- break;
355
- case 'da_DK':
356
- return 'Kvinde';
357
- break;
358
- case 'fi_FI':
359
- return 'Nainen';
360
- break;
361
- case 'de_DE':
362
- return 'Frau';
363
- break;
364
- case 'nl_NL';
365
- return 'Vrouw';
366
- break;
367
- case 'nb_NO':
368
- return 'Kvinne';
369
- break;
370
- case 'sv_SE':
371
- return 'Kvinna';
372
- break;
373
- }
374
- return Mage::helper( 'cgp' )->__( 'Female' );
375
- }
376
-
377
- public function getBirthdayLabel() {
378
- switch ( $this->getLocaleCode() ) {
379
- case 'de_AT':
380
- return 'Geburtsdatum';
381
- break;
382
- case 'da_DK':
383
- return 'Fødselsdag';
384
- break;
385
- case 'fi_FI':
386
- return 'Syntymäpäivä';
387
- break;
388
- case 'de_DE':
389
- return 'Geburtsdatum';
390
- break;
391
- case 'nl_NL';
392
- return 'Geboortedatum';
393
- break;
394
- case 'nb_NO':
395
- return 'Bursdag';
396
- break;
397
- case 'sv_SE':
398
- return 'Födelsedag';
399
- break;
400
- }
401
- return Mage::helper( 'cgp' )->__( 'Birthday' );
402
- }
403
-
404
- public function getLanguageLabel() {
405
- switch ( $this->getLocaleCode() ) {
406
- case 'de_AT':
407
- return 'Sprache';
408
- break;
409
- case 'da_DK':
410
- return 'Sprog';
411
- break;
412
- case 'fi_FI':
413
- return 'Kieli';
414
- break;
415
- case 'de_DE':
416
- return 'Sprache';
417
- break;
418
- case 'nl_NL';
419
- return 'Taal';
420
- break;
421
- case 'nb_NO':
422
- return 'Språk';
423
- break;
424
- case 'sv_SE':
425
- return 'Språk';
426
- break;
427
- }
428
- }
429
-
430
- public function getPersonalNumberLabel() {
431
- switch ( $this->getLocaleCode() ) {
432
- case 'de_AT':
433
- return '';
434
- break;
435
- case 'da_DK':
436
- return 'Personnummer';
437
- break;
438
- case 'fi_FI':
439
- return 'Henkilötunnus';
440
- break;
441
- case 'de_DE':
442
- return '';
443
- break;
444
- case 'nl_NL';
445
- return '';
446
- break;
447
- case 'nb_NO':
448
- return 'Fødselsnummer';
449
- break;
450
- case 'sv_SE':
451
- return 'Personnummer';
452
- break;
453
- }
454
- }
455
-
456
- public function isEU() {
457
- switch ( $this->getLocaleCode() ) {
458
- case 'de_AT':
459
- return true;
460
- break;
461
- case 'da_DK':
462
- return false;
463
- break;
464
- case 'fi_FI':
465
- return false;
466
- break;
467
- case 'de_DE':
468
- return true;
469
- break;
470
- case 'nl_NL';
471
- return true;
472
- break;
473
- case 'nb_NO':
474
- return false;
475
- break;
476
- case 'sv_SE':
477
- return false;
478
- break;
479
- }
480
- }
481
-
482
- public function beginIsEu() {
483
- if ( $this->isEU() ) {
484
- return '';
485
- } else {
486
- return '<!--';
487
- }
488
- }
489
-
490
- public function endIsEu() {
491
- if ( $this->isEU() ) {
492
- return '';
493
- } else {
494
- return '-->';
495
- }
496
- }
497
-
498
- public function beginIsNotEu() {
499
- if ( !$this->isEU() ) {
500
- return '';
501
- } else {
502
- return '<!--';
503
- }
504
- }
505
-
506
- public function endIsNotEu() {
507
- if ( !$this->isEU() ) {
508
- return '';
509
- } else {
510
- return '-->';
511
- }
512
- }
513
-
514
- public function getLocaleCode() {
515
-
516
- $country = Mage::getSingleton( 'checkout/session' )->getQuote()->getBillingAddress()->getCountry();
517
-
518
- switch ( $country ) {
519
- case 'AT':
520
- return 'de_AT';
521
- break;
522
- case 'DK':
523
- return 'da_DK';
524
- break;
525
- case 'FI':
526
- return 'fi_FI';
527
- break;
528
- case 'DE':
529
- return 'de_DE';
530
- break;
531
- case 'NL';
532
- return 'nl_NL';
533
- break;
534
- case 'NO':
535
- return 'nb_NO';
536
- break;
537
- case 'SE':
538
- return 'sv_SE';
539
- break;
540
- default:
541
- return 'not_klarna';
542
- }
543
- }
544
-
545
- public function getGermanNotice() {
546
- $locale = $this->getLocaleCode();
547
- if ( strpos( $locale, 'de_' ) === 0 ) {
548
- $str = '<br>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
549
  <div style="float:left;margin-top:5px;">
550
  <input
551
  type="checkbox"
@@ -556,94 +567,101 @@ class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form {
556
  />
557
  Mit der Datenverarbeitung der für die Abwicklungdes Rechnungskaufes und einer Identitäts-und Bonitätsprüfung erforderlichen Daten durch Klarna bin ich einverstanden. Meine <span id="consent02"></span> kann ich jederzeit mit Wirkung für die Zukunft widerrufen. Es gelten die AGB des Händlers. <br>
558
  </div>';
559
- } else {
560
- $str = "";
561
- }
562
- return $str;
563
- }
564
-
565
- public function getKlarnaInvoiceTerms() {
566
-
567
- $str = "new Klarna.Terms.Invoice({
568
  el: 'invoice02',
569
  eid: '" . $this->getKlarnaEid() . "',
570
  locale: '" . $this->getLocaleCode() . "',
571
  charge: 0,
572
  type: 'desktop'
573
  });";
574
- return $str;
575
- }
576
-
577
- public function getKlarnaConsent() {
578
- $str = ' ';
579
- $locale = $this->getLocaleCode();
580
- if ( strpos( $locale, 'de_' ) === 0 ) {
581
- $str = "new Klarna.Terms.Consent({
 
582
  el: 'consent02',
583
  eid: '" . $this->getKlarnaEid() . "',
584
  locale: '" . $this->getLocaleCode() . "',
585
  type: 'desktop'
586
  });";
587
- }
588
- return $str;
589
- }
590
-
591
- public function getKlarnaEid() {
592
- $settings = Mage::getStoreConfig( 'cgp/cgp_klarna' );
593
- return $settings['klarna_eid'];
594
- }
595
-
596
- public function getKlarnaLogoUrl() {
597
-
598
- $str = 'https://cdn.klarna.com/public/images/';
599
-
600
- $country = substr( $this->getLocaleCode(), 3 );
601
- $str .= $country;
602
- $str .='/badges/v1/invoice/';
603
- $str .= $country;
604
- $str .= '_invoice_badge_std_blue.png?width=125&eid=';
605
- $str .= $this->getKlarnaEid();
606
-
607
- return $str;
608
- }
609
-
610
- public function getInvoiceFeeNotice() {
611
- $str = '';
612
- $settings = Mage::getStoreConfig( 'cgp/cgp_klarna' );
613
- $fee = (isset($settings['klarna_invoice_fee_ex'])?$settings['klarna_invoice_fee_ex']:0);
614
-
615
- if ( $fee > 0 ) {
616
-
617
- $country = Mage::getSingleton( 'checkout/session' )->getQuote()->getBillingAddress()->getCountry();
618
-
619
- switch ( $country ) {
620
- case 'AT':
621
- $str = 'Zusätzliche Klarna Menge';
622
- break;
623
- case 'DK':
624
- $str = 'Ekstra Klarna beløb';
625
- break;
626
- case 'FI':
627
- $str = 'Extra Klarna määrä';
628
- break;
629
- case 'DE':
630
- $str = 'Zusätzliche Klarna Menge';
631
- break;
632
- case 'NL';
633
- $str = 'Extra Klarna bedrag';
634
- break;
635
- case 'NO':
636
- $str = 'Ekstra Klarna beløp';
637
- break;
638
- case 'SE':
639
- $str = 'Extra Klarna belopp';
640
- break;
641
- default:
642
- $str = 'Extra Klarna invoice Fee';
643
- }
644
- $str = '<br><br>'.$str.': ' . Mage::helper( 'core' )->currency( $fee, true, false );
645
- }
646
- return $str;
647
- }
648
-
 
 
 
 
 
 
649
  }
1
  <?php
2
 
3
  /**
4
+ * Magento CardGate payment extension
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
 
 
8
  */
9
+ class Cardgate_Cgp_Block_Form_Klarna extends Mage_Payment_Block_Form
10
+ {
11
+
12
+ protected function _construct ()
13
+ {
14
+ parent::_construct();
15
+ $this->setTemplate( 'cardgate/cgp/form/klarna.phtml' );
16
+ }
17
+
18
+ /**
19
+ * Return information payment object
20
+ *
21
+ * @return Mage_Payment_Model_Info
22
+ */
23
+ public function getInfoInstance ()
24
+ {
25
+ return $this->getMethod()->getInfoInstance();
26
+ }
27
+
28
+ public function getYear ()
29
+ {
30
+ $yr = 'Year';
31
+ switch ( $this->getLocaleCode() ) {
32
+ case 'de_AT':
33
+ $yr = 'Jahr';
34
+ break;
35
+ case 'da_DK':
36
+ $yr = 'Ar';
37
+ break;
38
+ case 'fi_FI':
39
+ $yr = 'Vuosi';
40
+ break;
41
+ case 'de_DE':
42
+ $yr = 'Jahr';
43
+ break;
44
+ case 'nl_NL':
45
+ $yr = 'Jaar';
46
+ break;
47
+ case 'nb_NO':
48
+ $yr = 'Ar';
49
+ break;
50
+ case 'sv_SE':
51
+ $yr = 'Ar';
52
+ break;
53
+ }
54
+
55
+ $str = '<option value="">' . $yr . '</option>';
56
+ for ( $x = date( 'Y' ); $x >= 1900; $x -- ) {
57
+ $str .= '<option value="' . $x . '">' . $x . '</option/>';
58
+ }
59
+ return $str;
60
+ }
61
+
62
+ public function getMonth ()
63
+ {
64
+ $str = '<option value="">Month</option>';
65
+ for ( $x = 1; $x < 13; $x ++ ) {
66
+ $str .= '<option value="' . sprintf( "%02d", $x ) . '">' . date( 'F', mktime( 1, 1, 1, $x, 1, 1970 ) ) .
67
+ '</option>';
68
+ }
69
+
70
+ switch ( $this->getLocaleCode() ) {
71
+ case 'de_AT':
72
+ $str = '<option value="">Monat</option>
73
  <option value="01">Januar</option>
74
  <option value="02">Februar</option>
75
  <option value="03">März</option>
82
  <option value="10">Oktober</option>
83
  <option value="11">November</option>
84
  <option value="12">Dezember</option>';
85
+ break;
86
+ case 'da_DK':
87
+ $str = '<option value="">Måned</option>
88
  <option value="01">Januar</option>
89
  <option value="02">Februar</option>
90
  <option value="03">Marts</option>
97
  <option value="10">Oktober</option>
98
  <option value="11">November</option>
99
  <option value="12">December</option>';
100
+ break;
101
+ case 'fi_FI':
102
+ $str = '<option value="">Kuukausi</option>
103
  <option value="01">Tammikuu</option>
104
  <option value="02">Helmikuu</option>
105
  <option value="03">Maaliskuu</option>
112
  <option value="10">Lokakuu</option>
113
  <option value="11">Marraskuu</option>
114
  <option value="12">Joulukuu</option>';
115
+ break;
116
+ case 'de_DE':
117
+ $str = '<option value="">Monat</option>
118
  <option value="01">Januar</option>
119
  <option value="02">Februar</option>
120
  <option value="03">März</option>
127
  <option value="10">Oktober</option>
128
  <option value="11">November</option>
129
  <option value="12">Dezember</option>';
130
+ break;
131
+ case 'nl_NL':
132
+ $str = '<option value="">Maand</option>
133
  <option value="01">januari</option>
134
  <option value="02">februari</option>
135
  <option value="03">maart</option>
142
  <option value="10">oktober</option>
143
  <option value="11">november</option>
144
  <option value="12">december</option>';
145
+ break;
146
+ case 'nb_NO':
147
+ $str = '<option value="">Måned</option>
148
  <option value="01">Januar</option>
149
  <option value="02">Februar</option>
150
  <option value="03">Mars</option>
157
  <option value="10">Oktober</option>
158
  <option value="11">November</option>
159
  <option value="12">Desember</option>';
160
+ break;
161
+ case 'sv_SE':
162
+ $str = '<option value="">Månad</option>
163
  <option value="01">januari</option>
164
  <option value="02">februari</option>
165
  <option value="03">mars</option>
172
  <option value="10">oktober</option>
173
  <option value="11">november</option>
174
  <option value="12">december</option>';
175
+ break;
176
+ }
177
+
178
+ return $str;
179
+ }
180
+
181
+ public function getDay ()
182
+ {
183
+ $day = 'Day';
184
+ switch ( $this->getLocaleCode() ) {
185
+ case 'de_AT':
186
+ $day = 'Tag';
187
+ break;
188
+ case 'da_DK':
189
+ $day = 'Dag';
190
+ break;
191
+ case 'fi_FI':
192
+ $day = 'Päivä';
193
+ break;
194
+ case 'de_DE':
195
+ $day = 'Tag';
196
+ break;
197
+ case 'nl_NL':
198
+ $day = 'Dag';
199
+ break;
200
+ case 'nb_NO':
201
+ $day = 'Dag';
202
+ break;
203
+ case 'sv_SE':
204
+ $day = 'Dag';
205
+ break;
206
+ }
207
+
208
+ $str = '<option value="">' . $day . '</option>';
209
+ for ( $x = 1; $x <= 31; $x ++ ) {
210
+ $str .= '<option value="' . sprintf( "%02d", $x ) . '">' . sprintf( "%02d", $x ) . '</option>';
211
+ }
212
+ return $str;
213
+ }
214
+
215
+ public function getLanguage ()
216
+ {
217
+ $str = '<option value="de">Austrian</option>
218
  <option value="da">Danisch</option>
219
  <option value="fi">Finnisch</option>
220
  <option selected="selected" value="de">German</option>
221
  <option value="nl">Dutch</option>
222
  <option value="nb">Norwegian</option>
223
  <option value="sv">Swedisch</option>';
224
+
225
+ switch ( $this->getLocaleCode() ) {
226
+ case 'de_AT':
227
+ $str = '<option selected="selected" value="de">Österreichisch</option>
228
  <option value="da">Dänisch</option>
229
  <option value="fi">Finnisch</option>
230
  <option value="de">Deutsch</option>
231
  <option value="nl">Holländisch</option>
232
  <option value="nb">Norwegisch</option>
233
  <option value="sv">Schwedisch</option>';
234
+ break;
235
+ case 'da_DK':
236
+ $str = '<option value="de">østrigsk</option>
237
  <option selected="selected" value="da">Dansk</option>
238
  <option value="fi">Finsk</option>
239
  <option value="de">Tysk</option>
240
  <option value="nl">Hollandsk</option>
241
  <option value="nb">Norwegian</option>
242
  <option value="sv">Svensk</option>';
243
+ break;
244
+ case 'fi_FI':
245
+ $str = '<option value="de">østrigsk</option>
246
  <option value="da">Dansk</option>
247
  <option selected="selected" value="fi">Finsk</option>
248
  <option value="de">German</option>
249
  <option value="nl">Hollandsk</option>
250
  <option value="nb">Norja</option>
251
  <option value="sv">Ruotsi</option>';
252
+ break;
253
+ case 'de_DE':
254
+ $str = '<option value="de">Österreichisch</option>
255
  <option value="da">Dänisch</option>
256
  <option value="fi">Finnisch</option>
257
  <option selected="selected" value="de">Deutsch</option>
258
  <option value="nl">Holländisch</option>
259
  <option value="nb">Norwegisch</option>
260
  <option value="sv">Schwedisch</option>';
261
+ break;
262
+ case 'nl_NL':
263
+ $str = '<option value="de">Oostenrijks</option>
264
  <option value="da">Deens</option>
265
  <option value="fi">Fins</option>
266
  <option value="de">Duits</option>
267
  <option selected="selected" value="nl">Nederlands</option>
268
  <option value="nb">Norweegs</option>
269
  <option value="sv">Zweeds</option>';
270
+ break;
271
+ case 'nb_NO':
272
+ $str = '<option value="de">østerriksk</option>
273
  <option value="da">Dansk</option>
274
  <option value="fi">Finsk</option>
275
  <option value="de">Tyske</option>
276
  <option value="nl">Dutch</option>
277
  <option selected="selected" value="nb">Norsk</option>
278
  <option value="sv">Svensk</option>';
279
+ break;
280
+ case 'sv_SE':
281
+ $str = '<option value="de">österrikiska</option>
282
  <option value="da">Dansk</option>
283
  <option value="fi">Finska</option>
284
  <option value="de">Tysk</option>
285
  <option value="nl">Holländare</option>
286
  <option value="nb">Norska</option>
287
  <option selected="selected" value="sv">Svenska</option>';
288
+ break;
289
+ }
290
+ return $str;
291
+ }
292
+
293
+ public function getGenderLabel ()
294
+ {
295
+ switch ( $this->getLocaleCode() ) {
296
+ case 'de_AT':
297
+ return 'Geslecht';
298
+ break;
299
+ case 'da_DK':
300
+ return 'Køn';
301
+ break;
302
+ case 'fi_FI':
303
+ return 'Sukupuoli';
304
+ break;
305
+ case 'de_DE':
306
+ return 'Geschlecht';
307
+ break;
308
+ case 'nl_NL':
309
+ return 'Geslacht';
310
+ break;
311
+ case 'nb_NO':
312
+ return 'Kjønn';
313
+ break;
314
+ case 'sv_SE':
315
+ return 'Kön';
316
+ break;
317
+ }
318
+ return Mage::helper( 'cgp' )->__( 'Gender' );
319
+ }
320
+
321
+ public function getMaleLabel ()
322
+ {
323
+ switch ( $this->getLocaleCode() ) {
324
+ case 'de_AT':
325
+ return 'Mann';
326
+ break;
327
+ case 'da_DK':
328
+ return 'Mand';
329
+ break;
330
+ case 'fi_FI':
331
+ return 'Mies';
332
+ break;
333
+ case 'de_DE':
334
+ return 'Mann';
335
+ break;
336
+ case 'nl_NL':
337
+ return 'Man';
338
+ break;
339
+ case 'nb_NO':
340
+ return 'Mann';
341
+ break;
342
+ case 'sv_SE':
343
+ return 'Man';
344
+ break;
345
+ }
346
+ return Mage::helper( 'cgp' )->__( 'Male' );
347
+ }
348
+
349
+ public function getFemaleLabel ()
350
+ {
351
+ switch ( $this->getLocaleCode() ) {
352
+ case 'de_AT':
353
+ return 'Frau';
354
+ break;
355
+ case 'da_DK':
356
+ return 'Kvinde';
357
+ break;
358
+ case 'fi_FI':
359
+ return 'Nainen';
360
+ break;
361
+ case 'de_DE':
362
+ return 'Frau';
363
+ break;
364
+ case 'nl_NL':
365
+ return 'Vrouw';
366
+ break;
367
+ case 'nb_NO':
368
+ return 'Kvinne';
369
+ break;
370
+ case 'sv_SE':
371
+ return 'Kvinna';
372
+ break;
373
+ }
374
+ return Mage::helper( 'cgp' )->__( 'Female' );
375
+ }
376
+
377
+ public function getBirthdayLabel ()
378
+ {
379
+ switch ( $this->getLocaleCode() ) {
380
+ case 'de_AT':
381
+ return 'Geburtsdatum';
382
+ break;
383
+ case 'da_DK':
384
+ return 'Fødselsdag';
385
+ break;
386
+ case 'fi_FI':
387
+ return 'Syntymäpäivä';
388
+ break;
389
+ case 'de_DE':
390
+ return 'Geburtsdatum';
391
+ break;
392
+ case 'nl_NL':
393
+ return 'Geboortedatum';
394
+ break;
395
+ case 'nb_NO':
396
+ return 'Bursdag';
397
+ break;
398
+ case 'sv_SE':
399
+ return 'Födelsedag';
400
+ break;
401
+ }
402
+ return Mage::helper( 'cgp' )->__( 'Birthday' );
403
+ }
404
+
405
+ public function getLanguageLabel ()
406
+ {
407
+ switch ( $this->getLocaleCode() ) {
408
+ case 'de_AT':
409
+ return 'Sprache';
410
+ break;
411
+ case 'da_DK':
412
+ return 'Sprog';
413
+ break;
414
+ case 'fi_FI':
415
+ return 'Kieli';
416
+ break;
417
+ case 'de_DE':
418
+ return 'Sprache';
419
+ break;
420
+ case 'nl_NL':
421
+ return 'Taal';
422
+ break;
423
+ case 'nb_NO':
424
+ return 'Språk';
425
+ break;
426
+ case 'sv_SE':
427
+ return 'Språk';
428
+ break;
429
+ }
430
+ }
431
+
432
+ public function getPersonalNumberLabel ()
433
+ {
434
+ switch ( $this->getLocaleCode() ) {
435
+ case 'de_AT':
436
+ return '';
437
+ break;
438
+ case 'da_DK':
439
+ return 'Personnummer';
440
+ break;
441
+ case 'fi_FI':
442
+ return 'Henkilötunnus';
443
+ break;
444
+ case 'de_DE':
445
+ return '';
446
+ break;
447
+ case 'nl_NL':
448
+ return '';
449
+ break;
450
+ case 'nb_NO':
451
+ return 'Fødselsnummer';
452
+ break;
453
+ case 'sv_SE':
454
+ return 'Personnummer';
455
+ break;
456
+ }
457
+ }
458
+
459
+ public function isEU ()
460
+ {
461
+ switch ( $this->getLocaleCode() ) {
462
+ case 'de_AT':
463
+ return true;
464
+ break;
465
+ case 'da_DK':
466
+ return false;
467
+ break;
468
+ case 'fi_FI':
469
+ return false;
470
+ break;
471
+ case 'de_DE':
472
+ return true;
473
+ break;
474
+ case 'nl_NL':
475
+ return true;
476
+ break;
477
+ case 'nb_NO':
478
+ return false;
479
+ break;
480
+ case 'sv_SE':
481
+ return false;
482
+ break;
483
+ }
484
+ }
485
+
486
+ public function beginIsEu ()
487
+ {
488
+ if ( $this->isEU() ) {
489
+ return '';
490
+ } else {
491
+ return '<!--';
492
+ }
493
+ }
494
+
495
+ public function endIsEu ()
496
+ {
497
+ if ( $this->isEU() ) {
498
+ return '';
499
+ } else {
500
+ return '-->';
501
+ }
502
+ }
503
+
504
+ public function beginIsNotEu ()
505
+ {
506
+ if ( ! $this->isEU() ) {
507
+ return '';
508
+ } else {
509
+ return '<!--';
510
+ }
511
+ }
512
+
513
+ public function endIsNotEu ()
514
+ {
515
+ if ( ! $this->isEU() ) {
516
+ return '';
517
+ } else {
518
+ return '-->';
519
+ }
520
+ }
521
+
522
+ public function getLocaleCode ()
523
+ {
524
+ $country = Mage::getSingleton( 'checkout/session' )->getQuote()
525
+ ->getBillingAddress()
526
+ ->getCountry();
527
+
528
+ switch ( $country ) {
529
+ case 'AT':
530
+ return 'de_AT';
531
+ break;
532
+ case 'DK':
533
+ return 'da_DK';
534
+ break;
535
+ case 'FI':
536
+ return 'fi_FI';
537
+ break;
538
+ case 'DE':
539
+ return 'de_DE';
540
+ break;
541
+ case 'NL':
542
+ return 'nl_NL';
543
+ break;
544
+ case 'NO':
545
+ return 'nb_NO';
546
+ break;
547
+ case 'SE':
548
+ return 'sv_SE';
549
+ break;
550
+ default:
551
+ return 'not_klarna';
552
+ }
553
+ }
554
+
555
+ public function getGermanNotice ()
556
+ {
557
+ $locale = $this->getLocaleCode();
558
+ if ( strpos( $locale, 'de_' ) === 0 ) {
559
+ $str = '<br>
560
  <div style="float:left;margin-top:5px;">
561
  <input
562
  type="checkbox"
567
  />
568
  Mit der Datenverarbeitung der für die Abwicklungdes Rechnungskaufes und einer Identitäts-und Bonitätsprüfung erforderlichen Daten durch Klarna bin ich einverstanden. Meine <span id="consent02"></span> kann ich jederzeit mit Wirkung für die Zukunft widerrufen. Es gelten die AGB des Händlers. <br>
569
  </div>';
570
+ } else {
571
+ $str = "";
572
+ }
573
+ return $str;
574
+ }
575
+
576
+ public function getKlarnaInvoiceTerms ()
577
+ {
578
+ $str = "new Klarna.Terms.Invoice({
579
  el: 'invoice02',
580
  eid: '" . $this->getKlarnaEid() . "',
581
  locale: '" . $this->getLocaleCode() . "',
582
  charge: 0,
583
  type: 'desktop'
584
  });";
585
+ return $str;
586
+ }
587
+
588
+ public function getKlarnaConsent ()
589
+ {
590
+ $str = ' ';
591
+ $locale = $this->getLocaleCode();
592
+ if ( strpos( $locale, 'de_' ) === 0 ) {
593
+ $str = "new Klarna.Terms.Consent({
594
  el: 'consent02',
595
  eid: '" . $this->getKlarnaEid() . "',
596
  locale: '" . $this->getLocaleCode() . "',
597
  type: 'desktop'
598
  });";
599
+ }
600
+ return $str;
601
+ }
602
+
603
+ public function getKlarnaEid ()
604
+ {
605
+ $settings = Mage::getStoreConfig( 'cgp/cgp_klarna' );
606
+ return $settings['klarna_eid'];
607
+ }
608
+
609
+ public function getKlarnaLogoUrl ()
610
+ {
611
+ $str = 'https://cdn.klarna.com/public/images/';
612
+
613
+ $country = substr( $this->getLocaleCode(), 3 );
614
+ $str .= $country;
615
+ $str .= '/badges/v1/invoice/';
616
+ $str .= $country;
617
+ $str .= '_invoice_badge_std_blue.png?width=125&eid=';
618
+ $str .= $this->getKlarnaEid();
619
+
620
+ return $str;
621
+ }
622
+
623
+ // TODO: To remove
624
+ /*
625
+ public function getInvoiceFeeNotice ()
626
+ {
627
+ $str = '';
628
+ $settings = Mage::getStoreConfig( 'cgp/cgp_klarna' );
629
+ $fee = ( isset( $settings['klarna_invoice_fee_ex'] ) ? $settings['klarna_invoice_fee_ex'] : 0 );
630
+
631
+ if ( $fee > 0 ) {
632
+
633
+ $country = Mage::getSingleton( 'checkout/session' )->getQuote()
634
+ ->getBillingAddress()
635
+ ->getCountry();
636
+
637
+ switch ( $country ) {
638
+ case 'AT':
639
+ $str = 'Zusätzliche Klarna Menge';
640
+ break;
641
+ case 'DK':
642
+ $str = 'Ekstra Klarna beløb';
643
+ break;
644
+ case 'FI':
645
+ $str = 'Extra Klarna määrä';
646
+ break;
647
+ case 'DE':
648
+ $str = 'Zusätzliche Klarna Menge';
649
+ break;
650
+ case 'NL':
651
+ $str = 'Extra Klarna bedrag';
652
+ break;
653
+ case 'NO':
654
+ $str = 'Ekstra Klarna beløp';
655
+ break;
656
+ case 'SE':
657
+ $str = 'Extra Klarna belopp';
658
+ break;
659
+ default:
660
+ $str = 'Extra Klarna invoice Fee';
661
+ }
662
+ $str = '<br><br>' . $str . ': ' . Mage::helper( 'core' )->currency( $fee, true, false );
663
+ }
664
+ return $str;
665
+ }
666
+ */
667
  }
app/code/local/Cardgate/Cgp/Block/Form/Klarnaaccount.php CHANGED
@@ -1,83 +1,75 @@
1
  <?php
2
 
3
  /**
4
- * Magento CardGatePlus payment extension
5
  *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- *
13
- * @category Mage
14
- * @package Cardgate_Cgp
15
- * @author Paul Saparov, <support@cardgate.com>
16
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
17
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
  */
19
- class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form {
20
-
21
- protected function _construct() {
22
-
23
- parent::_construct();
24
- $this->setTemplate( 'cardgate/cgp/form/klarnaaccount.phtml' );
25
- }
26
-
27
- /**
28
- * Return information payment object
29
- *
30
- * @return Mage_Payment_Model_Info
31
- */
32
- public function getInfoInstance() {
33
-
34
- return $this->getMethod()->getInfoInstance();
35
- }
36
-
37
- public function getYear() {
38
-
39
- $yr = 'Year';
40
- switch ( $this->getLocaleCode() ) {
41
- case 'de_AT':
42
- $yr = 'Jahr';
43
- break;
44
- case 'da_DK':
45
- $yr = 'Ar';
46
- break;
47
- case 'fi_FI':
48
- $yr = 'Vuosi';
49
- break;
50
- case 'de_DE':
51
- $yr = 'Jahr';
52
- break;
53
- case 'nl_NL';
54
- $yr = 'Jaar';
55
- break;
56
- case 'nb_NO':
57
- $yr = 'Ar';
58
- break;
59
- case 'sv_SE':
60
- $yr = 'Ar';
61
- break;
62
- }
63
-
64
- $str = '<option value="">' . $yr . '</option>';
65
- for ( $x = date( 'Y' ); $x >= 1900; $x-- ) {
66
- $str.='<option value="' . $x . '">' . $x . '</option/>';
67
- }
68
- return $str;
69
- }
70
-
71
- public function getMonth() {
72
-
73
- $str = '<option value="">Month</option>';
74
- for ( $x = 1; $x < 13; $x++ ) {
75
- $str.= '<option value="' . sprintf( "%02d", $x ) . '">' . date( 'F', mktime( 1, 1, 1, $x, 1, 1970 ) ) . '</option>';
76
- }
77
-
78
- switch ( $this->getLocaleCode() ) {
79
- case 'de_AT':
80
- $str = '<option value="">Monat</option>
 
 
81
  <option value="01">Januar</option>
82
  <option value="02">Februar</option>
83
  <option value="03">März</option>
@@ -90,9 +82,9 @@ class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form {
90
  <option value="10">Oktober</option>
91
  <option value="11">November</option>
92
  <option value="12">Dezember</option>';
93
- break;
94
- case 'da_DK':
95
- $str = '<option value="">Måned</option>
96
  <option value="01">Januar</option>
97
  <option value="02">Februar</option>
98
  <option value="03">Marts</option>
@@ -105,9 +97,9 @@ class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form {
105
  <option value="10">Oktober</option>
106
  <option value="11">November</option>
107
  <option value="12">December</option>';
108
- break;
109
- case 'fi_FI':
110
- $str = '<option value="">Kuukausi</option>
111
  <option value="01">Tammikuu</option>
112
  <option value="02">Helmikuu</option>
113
  <option value="03">Maaliskuu</option>
@@ -120,9 +112,9 @@ class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form {
120
  <option value="10">Lokakuu</option>
121
  <option value="11">Marraskuu</option>
122
  <option value="12">Joulukuu</option>';
123
- break;
124
- case 'de_DE':
125
- $str = '<option value="">Monat</option>
126
  <option value="01">Januar</option>
127
  <option value="02">Februar</option>
128
  <option value="03">März</option>
@@ -135,9 +127,9 @@ class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form {
135
  <option value="10">Oktober</option>
136
  <option value="11">November</option>
137
  <option value="12">Dezember</option>';
138
- break;
139
- case 'nl_NL';
140
- $str = '<option value="">Maand</option>
141
  <option value="01">januari</option>
142
  <option value="02">februari</option>
143
  <option value="03">maart</option>
@@ -150,9 +142,9 @@ class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form {
150
  <option value="10">oktober</option>
151
  <option value="11">november</option>
152
  <option value="12">december</option>';
153
- break;
154
- case 'nb_NO':
155
- $str = '<option value="">Måned</option>
156
  <option value="01">Januar</option>
157
  <option value="02">Februar</option>
158
  <option value="03">Mars</option>
@@ -165,9 +157,9 @@ class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form {
165
  <option value="10">Oktober</option>
166
  <option value="11">November</option>
167
  <option value="12">Desember</option>';
168
- break;
169
- case 'sv_SE':
170
- $str = '<option value="">Månad</option>
171
  <option value="01">januari</option>
172
  <option value="02">februari</option>
173
  <option value="03">mars</option>
@@ -180,383 +172,392 @@ class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form {
180
  <option value="10">oktober</option>
181
  <option value="11">november</option>
182
  <option value="12">december</option>';
183
- break;
184
- }
185
-
186
- return $str;
187
- }
188
-
189
- public function getDay() {
190
-
191
- $day = 'Day';
192
- switch ( $this->getLocaleCode() ) {
193
- case 'de_AT':
194
- $day = 'Tag';
195
- break;
196
- case 'da_DK':
197
- $day = 'Dag';
198
- break;
199
- case 'fi_FI':
200
- $day = 'Päivä';
201
- break;
202
- case 'de_DE':
203
- $day = 'Tag';
204
- break;
205
- case 'nl_NL';
206
- $day = 'Dag';
207
- break;
208
- case 'nb_NO':
209
- $day = 'Dag';
210
- break;
211
- case 'sv_SE':
212
- $day = 'Dag';
213
- break;
214
- }
215
-
216
- $str = '<option value="">' . $day . '</option>';
217
- for ( $x = 1; $x <= 31; $x++ ) {
218
- $str.= '<option value="' . sprintf( "%02d", $x ) . '">' . sprintf( "%02d", $x ) . '</option>';
219
- }
220
- return $str;
221
- }
222
-
223
- public function getLanguage() {
224
- $str = '<option value="de">Austrian</option>
 
225
  <option value="da">Danisch</option>
226
  <option value="fi">Finnisch</option>
227
  <option selected="selected" value="de">German</option>
228
  <option value="nl">Dutch</option>
229
  <option value="nb">Norwegian</option>
230
  <option value="sv">Swedisch</option>';
231
-
232
- switch ( $this->getLocaleCode() ) {
233
- case 'de_AT':
234
- $str = '<option selected="selected" value="de">Österreichisch</option>
235
  <option value="da">Dänisch</option>
236
  <option value="fi">Finnisch</option>
237
  <option value="de">Deutsch</option>
238
  <option value="nl">Holländisch</option>
239
  <option value="nb">Norwegisch</option>
240
  <option value="sv">Schwedisch</option>';
241
- break;
242
- case 'da_DK':
243
- $str = '<option value="de">østrigsk</option>
244
  <option selected="selected" value="da">Dansk</option>
245
  <option value="fi">Finsk</option>
246
  <option value="de">Tysk</option>
247
  <option value="nl">Hollandsk</option>
248
  <option value="nb">Norwegian</option>
249
  <option value="sv">Svensk</option>';
250
- break;
251
- case 'fi_FI':
252
- $str = '<option value="de">østrigsk</option>
253
  <option value="da">Dansk</option>
254
  <option selected="selected" value="fi">Finsk</option>
255
  <option value="de">German</option>
256
  <option value="nl">Hollandsk</option>
257
  <option value="nb">Norja</option>
258
  <option value="sv">Ruotsi</option>';
259
- break;
260
- case 'de_DE':
261
- $str = '<option value="de">Österreichisch</option>
262
  <option value="da">Dänisch</option>
263
  <option value="fi">Finnisch</option>
264
  <option selected="selected" value="de">Deutsch</option>
265
  <option value="nl">Holländisch</option>
266
  <option value="nb">Norwegisch</option>
267
  <option value="sv">Schwedisch</option>';
268
- break;
269
- case 'nl_NL';
270
- $str = '<option value="de">Oostenrijks</option>
271
  <option value="da">Deens</option>
272
  <option value="fi">Fins</option>
273
  <option value="de">Duits</option>
274
  <option selected="selected" value="nl">Nederlands</option>
275
  <option value="nb">Norweegs</option>
276
  <option value="sv">Zweeds</option>';
277
- break;
278
- case 'nb_NO':
279
- $str = '<option value="de">østerriksk</option>
280
  <option value="da">Dansk</option>
281
  <option value="fi">Finsk</option>
282
  <option value="de">Tyske</option>
283
  <option value="nl">Dutch</option>
284
  <option selected="selected" value="nb">Norsk</option>
285
  <option value="sv">Svensk</option>';
286
- break;
287
- case 'sv_SE':
288
- $str = '<option value="de">österrikiska</option>
289
  <option value="da">Dansk</option>
290
  <option value="fi">Finska</option>
291
  <option value="de">Tysk</option>
292
  <option value="nl">Holländare</option>
293
  <option value="nb">Norska</option>
294
  <option selected="selected" value="sv">Svenska</option>';
295
- break;
296
- }
297
- return $str;
298
- }
299
-
300
- public function getGenderLabel() {
301
-
302
- switch ( $this->getLocaleCode() ) {
303
- case 'de_AT':
304
- return 'Geslecht';
305
- break;
306
- case 'da_DK':
307
- return 'Køn';
308
- break;
309
- case 'fi_FI':
310
- return 'Sukupuoli';
311
- break;
312
- case 'de_DE':
313
- return 'Geschlecht';
314
- break;
315
- case 'nl_NL';
316
- return 'Geslacht';
317
- break;
318
- case 'nb_NO':
319
- return 'Kjønn';
320
- break;
321
- case 'sv_SE':
322
- return 'Kön';
323
- break;
324
- }
325
- return Mage::helper( 'cgp' )->__( 'Gender' );
326
- }
327
-
328
- public function getMaleLabel() {
329
-
330
- switch ( $this->getLocaleCode() ) {
331
- case 'de_AT':
332
- return 'Mann';
333
- break;
334
- case 'da_DK':
335
- return 'Mand';
336
- break;
337
- case 'fi_FI':
338
- return 'Mies';
339
- break;
340
- case 'de_DE':
341
- return 'Mann';
342
- break;
343
- case 'nl_NL';
344
- return 'Man';
345
- break;
346
- case 'nb_NO':
347
- return 'Mann';
348
- break;
349
- case 'sv_SE':
350
- return 'Man';
351
- break;
352
- }
353
- return Mage::helper( 'cgp' )->__( 'Male' );
354
- }
355
-
356
- public function getFemaleLabel() {
357
-
358
- switch ( $this->getLocaleCode() ) {
359
- case 'de_AT':
360
- return 'Frau';
361
- break;
362
- case 'da_DK':
363
- return 'Kvinde';
364
- break;
365
- case 'fi_FI':
366
- return 'Nainen';
367
- break;
368
- case 'de_DE':
369
- return 'Frau';
370
- break;
371
- case 'nl_NL';
372
- return 'Vrouw';
373
- break;
374
- case 'nb_NO':
375
- return 'Kvinne';
376
- break;
377
- case 'sv_SE':
378
- return 'Kvinna';
379
- break;
380
- }
381
- return Mage::helper( 'cgp' )->__( 'Female' );
382
- }
383
-
384
- public function getLanguageLabel() {
385
- $locale = $this->getLocaleCode();
386
- switch ( $this->getLocaleCode() ) {
387
- case 'de_AT':
388
- return 'Sprache';
389
- break;
390
- case 'da_DK':
391
- return 'Sprog';
392
- break;
393
- case 'fi_FI':
394
- return 'Kieli';
395
- break;
396
- case 'de_DE':
397
- return 'Sprache';
398
- break;
399
- case 'nl_NL';
400
- return 'Taal';
401
- break;
402
- case 'nb_NO':
403
- return 'Språk';
404
- break;
405
- case 'sv_SE':
406
- return 'Språk';
407
- break;
408
- }
409
- }
410
-
411
- public function getPersonalNumberLabel() {
412
- switch ( $this->getLocaleCode() ) {
413
- case 'de_AT':
414
- return '';
415
- break;
416
- case 'da_DK':
417
- return 'Personnummer';
418
- break;
419
- case 'fi_FI':
420
- return 'Henkilötunnus';
421
- break;
422
- case 'de_DE':
423
- return '';
424
- break;
425
- case 'nl_NL';
426
- return '';
427
- break;
428
- case 'nb_NO':
429
- return 'Fødselsnummer';
430
- break;
431
- case 'sv_SE':
432
- return 'Personnummer';
433
- break;
434
- }
435
- }
436
-
437
- public function isEU() {
438
- switch ( $this->getLocaleCode() ) {
439
- case 'de_AT':
440
- return true;
441
- break;
442
- case 'da_DK':
443
- return false;
444
- break;
445
- case 'fi_FI':
446
- return false;
447
- break;
448
- case 'de_DE':
449
- return true;
450
- break;
451
- case 'nl_NL';
452
- return true;
453
- break;
454
- case 'nb_NO':
455
- return false;
456
- break;
457
- case 'sv_SE':
458
- return false;
459
- break;
460
- }
461
- }
462
-
463
- public function beginIsEu() {
464
- if ( $this->isEU() ) {
465
- return '';
466
- } else {
467
- return '<!--';
468
- }
469
- }
470
-
471
- public function endIsEu() {
472
- if ( $this->isEU() ) {
473
- return '';
474
- } else {
475
- return '-->';
476
- }
477
- }
478
-
479
- public function beginIsNotEu() {
480
- if ( !$this->isEU() ) {
481
- return '';
482
- } else {
483
- return '<!--';
484
- }
485
- }
486
-
487
- public function endIsNotEu() {
488
- if ( !$this->isEU() ) {
489
- return '';
490
- } else {
491
- return '-->';
492
- }
493
- }
494
-
495
-
496
- public function getBirthdayLabel() {
497
-
498
- switch ( $this->getLocaleCode() ) {
499
- case 'de_AT':
500
- return 'Geburtsdatum';
501
- break;
502
- case 'da_DK':
503
- return 'Fødselsdag';
504
- break;
505
- case 'fi_FI':
506
- return 'Syntymäpäivä';
507
- break;
508
- case 'de_DE':
509
- return 'Geburtsdatum';
510
- break;
511
- case 'nl_NL';
512
- return 'Geboortedatum';
513
- break;
514
- case 'nb_NO':
515
- return 'Bursdag';
516
- break;
517
- case 'sv_SE':
518
- return 'Födelsedag';
519
- break;
520
- }
521
- return Mage::helper( 'cgp' )->__( 'Birthday' );
522
- }
523
-
524
- public function getLocaleCode() {
525
-
526
- $country = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getCountry();
527
-
528
- switch ( $country ) {
529
- case 'AT':
530
- return 'de_AT';
531
- break;
532
- case 'DK':
533
- return 'da_DK';
534
- break;
535
- case 'FI':
536
- return 'fi_FI';
537
- break;
538
- case 'DE':
539
- return 'de_DE';
540
- break;
541
- case 'NL';
542
- return 'nl_NL';
543
- break;
544
- case 'NO':
545
- return 'nb_NO';
546
- break;
547
- case 'SE':
548
- return 'sv_SE';
549
- break;
550
- default:
551
- return 'not_klarna';
552
- }
553
- }
554
-
555
- public function getGermanNotice() {
556
-
557
- $locale = $this->getLocaleCode();
558
- if ( strpos( $locale, 'de_' ) === 0 ) {
559
- $str = '<br>
 
 
 
 
 
 
 
 
560
  <div style="float:left;margin-top:5px;">
561
  <input
562
  type="checkbox"
@@ -567,71 +568,71 @@ class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form {
567
  />
568
  Mit der Datenverarbeitung der für die Abwicklungdes Rechnungskaufes und einer Identitäts-und Bonitätsprüfung erforderlichen Daten durch Klarna bin ich einverstanden. Meine <span id="consent01"></span> kann ich jederzeit mit Wirkung für die Zukunft widerrufen. Es gelten die AGB des Händlers. <br>
569
  </div>';
570
- } else {
571
- $str = "";
572
- }
573
- return $str;
574
- }
575
-
576
- public function getKlarnaAccountTerms() {
577
-
578
- switch ( $this->getLocaleCode() ) {
579
- case 'de_AT':
580
- return '';
581
- break;
582
- case 'da_DK':
583
- break;
584
- case 'fi_FI':
585
- break;
586
- case 'de_DE':
587
- break;
588
- case 'nl_NL';
589
- break;
590
- case 'nb_NO':
591
- break;
592
- case 'sv_SE':
593
- break;
594
- }
595
-
596
- $str = "new Klarna.Terms.Account({
597
  el: 'account01',
598
  eid: '" . $this->getKlarnaAccountEid() . "',
599
  locale: '" . $this->getLocaleCode() . "',
600
  type: 'desktop'
601
  });";
602
- return $str;
603
- }
604
-
605
- public function getKlarnaAccountConsent() {
606
- $str = ' ';
607
- $locale = $this->getLocaleCode();
608
- if ( strpos( $locale, 'de_' ) === 0 ) {
609
- $str = "new Klarna.Terms.Consent({
 
610
  el: 'consent01',
611
  eid: '" . $this->getKlarnaAccountEid() . "',
612
  locale: '" . $this->getLocaleCode() . "',
613
  type: 'desktop'
614
  });";
615
- }
616
- return $str;
617
- }
618
-
619
- public function getKlarnaAccountEid() {
620
-
621
- $settings = Mage::getStoreConfig( 'cgp/cgp_klarnaaccount');
622
- return $settings['klarna_eid'];
623
- }
624
-
625
- public function getKlarnaAccountLogoUrl() {
626
-
627
- $str = 'https://cdn.klarna.com/public/images/';
628
- $country = substr( $this->getLocaleCode(), 3 );
629
- $str .= $country;
630
- $str .='/badges/v1/account/';
631
- $str .= $country;
632
- $str .= '_account_badge_std_blue.png?width=125&eid=';
633
- $str .= $this->getKlarnaAccountEid();
634
- return $str;
635
- }
636
-
637
  }
1
  <?php
2
 
3
  /**
4
+ * Magento CardGate payment extension
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
 
 
8
  */
9
+ class Cardgate_Cgp_Block_Form_Klarnaaccount extends Mage_Payment_Block_Form
10
+ {
11
+
12
+ protected function _construct ()
13
+ {
14
+ parent::_construct();
15
+ $this->setTemplate( 'cardgate/cgp/form/klarnaaccount.phtml' );
16
+ }
17
+
18
+ /**
19
+ * Return information payment object
20
+ *
21
+ * @return Mage_Payment_Model_Info
22
+ */
23
+ public function getInfoInstance ()
24
+ {
25
+ return $this->getMethod()->getInfoInstance();
26
+ }
27
+
28
+ public function getYear ()
29
+ {
30
+ $yr = 'Year';
31
+ switch ( $this->getLocaleCode() ) {
32
+ case 'de_AT':
33
+ $yr = 'Jahr';
34
+ break;
35
+ case 'da_DK':
36
+ $yr = 'Ar';
37
+ break;
38
+ case 'fi_FI':
39
+ $yr = 'Vuosi';
40
+ break;
41
+ case 'de_DE':
42
+ $yr = 'Jahr';
43
+ break;
44
+ case 'nl_NL':
45
+ $yr = 'Jaar';
46
+ break;
47
+ case 'nb_NO':
48
+ $yr = 'Ar';
49
+ break;
50
+ case 'sv_SE':
51
+ $yr = 'Ar';
52
+ break;
53
+ }
54
+
55
+ $str = '<option value="">' . $yr . '</option>';
56
+ for ( $x = date( 'Y' ); $x >= 1900; $x -- ) {
57
+ $str .= '<option value="' . $x . '">' . $x . '</option/>';
58
+ }
59
+ return $str;
60
+ }
61
+
62
+ public function getMonth ()
63
+ {
64
+ $str = '<option value="">Month</option>';
65
+ for ( $x = 1; $x < 13; $x ++ ) {
66
+ $str .= '<option value="' . sprintf( "%02d", $x ) . '">' . date( 'F', mktime( 1, 1, 1, $x, 1, 1970 ) ) .
67
+ '</option>';
68
+ }
69
+
70
+ switch ( $this->getLocaleCode() ) {
71
+ case 'de_AT':
72
+ $str = '<option value="">Monat</option>
73
  <option value="01">Januar</option>
74
  <option value="02">Februar</option>
75
  <option value="03">März</option>
82
  <option value="10">Oktober</option>
83
  <option value="11">November</option>
84
  <option value="12">Dezember</option>';
85
+ break;
86
+ case 'da_DK':
87
+ $str = '<option value="">Måned</option>
88
  <option value="01">Januar</option>
89
  <option value="02">Februar</option>
90
  <option value="03">Marts</option>
97
  <option value="10">Oktober</option>
98
  <option value="11">November</option>
99
  <option value="12">December</option>';
100
+ break;
101
+ case 'fi_FI':
102
+ $str = '<option value="">Kuukausi</option>
103
  <option value="01">Tammikuu</option>
104
  <option value="02">Helmikuu</option>
105
  <option value="03">Maaliskuu</option>
112
  <option value="10">Lokakuu</option>
113
  <option value="11">Marraskuu</option>
114
  <option value="12">Joulukuu</option>';
115
+ break;
116
+ case 'de_DE':
117
+ $str = '<option value="">Monat</option>
118
  <option value="01">Januar</option>
119
  <option value="02">Februar</option>
120
  <option value="03">März</option>
127
  <option value="10">Oktober</option>
128
  <option value="11">November</option>
129
  <option value="12">Dezember</option>';
130
+ break;
131
+ case 'nl_NL':
132
+ $str = '<option value="">Maand</option>
133
  <option value="01">januari</option>
134
  <option value="02">februari</option>
135
  <option value="03">maart</option>
142
  <option value="10">oktober</option>
143
  <option value="11">november</option>
144
  <option value="12">december</option>';
145
+ break;
146
+ case 'nb_NO':
147
+ $str = '<option value="">Måned</option>
148
  <option value="01">Januar</option>
149
  <option value="02">Februar</option>
150
  <option value="03">Mars</option>
157
  <option value="10">Oktober</option>
158
  <option value="11">November</option>
159
  <option value="12">Desember</option>';
160
+ break;
161
+ case 'sv_SE':
162
+ $str = '<option value="">Månad</option>
163
  <option value="01">januari</option>
164
  <option value="02">februari</option>
165
  <option value="03">mars</option>
172
  <option value="10">oktober</option>
173
  <option value="11">november</option>
174
  <option value="12">december</option>';
175
+ break;
176
+ }
177
+
178
+ return $str;
179
+ }
180
+
181
+ public function getDay ()
182
+ {
183
+ $day = 'Day';
184
+ switch ( $this->getLocaleCode() ) {
185
+ case 'de_AT':
186
+ $day = 'Tag';
187
+ break;
188
+ case 'da_DK':
189
+ $day = 'Dag';
190
+ break;
191
+ case 'fi_FI':
192
+ $day = 'Päivä';
193
+ break;
194
+ case 'de_DE':
195
+ $day = 'Tag';
196
+ break;
197
+ case 'nl_NL':
198
+ $day = 'Dag';
199
+ break;
200
+ case 'nb_NO':
201
+ $day = 'Dag';
202
+ break;
203
+ case 'sv_SE':
204
+ $day = 'Dag';
205
+ break;
206
+ }
207
+
208
+ $str = '<option value="">' . $day . '</option>';
209
+ for ( $x = 1; $x <= 31; $x ++ ) {
210
+ $str .= '<option value="' . sprintf( "%02d", $x ) . '">' . sprintf( "%02d", $x ) . '</option>';
211
+ }
212
+ return $str;
213
+ }
214
+
215
+ public function getLanguage ()
216
+ {
217
+ $str = '<option value="de">Austrian</option>
218
  <option value="da">Danisch</option>
219
  <option value="fi">Finnisch</option>
220
  <option selected="selected" value="de">German</option>
221
  <option value="nl">Dutch</option>
222
  <option value="nb">Norwegian</option>
223
  <option value="sv">Swedisch</option>';
224
+
225
+ switch ( $this->getLocaleCode() ) {
226
+ case 'de_AT':
227
+ $str = '<option selected="selected" value="de">Österreichisch</option>
228
  <option value="da">Dänisch</option>
229
  <option value="fi">Finnisch</option>
230
  <option value="de">Deutsch</option>
231
  <option value="nl">Holländisch</option>
232
  <option value="nb">Norwegisch</option>
233
  <option value="sv">Schwedisch</option>';
234
+ break;
235
+ case 'da_DK':
236
+ $str = '<option value="de">østrigsk</option>
237
  <option selected="selected" value="da">Dansk</option>
238
  <option value="fi">Finsk</option>
239
  <option value="de">Tysk</option>
240
  <option value="nl">Hollandsk</option>
241
  <option value="nb">Norwegian</option>
242
  <option value="sv">Svensk</option>';
243
+ break;
244
+ case 'fi_FI':
245
+ $str = '<option value="de">østrigsk</option>
246
  <option value="da">Dansk</option>
247
  <option selected="selected" value="fi">Finsk</option>
248
  <option value="de">German</option>
249
  <option value="nl">Hollandsk</option>
250
  <option value="nb">Norja</option>
251
  <option value="sv">Ruotsi</option>';
252
+ break;
253
+ case 'de_DE':
254
+ $str = '<option value="de">Österreichisch</option>
255
  <option value="da">Dänisch</option>
256
  <option value="fi">Finnisch</option>
257
  <option selected="selected" value="de">Deutsch</option>
258
  <option value="nl">Holländisch</option>
259
  <option value="nb">Norwegisch</option>
260
  <option value="sv">Schwedisch</option>';
261
+ break;
262
+ case 'nl_NL':
263
+ $str = '<option value="de">Oostenrijks</option>
264
  <option value="da">Deens</option>
265
  <option value="fi">Fins</option>
266
  <option value="de">Duits</option>
267
  <option selected="selected" value="nl">Nederlands</option>
268
  <option value="nb">Norweegs</option>
269
  <option value="sv">Zweeds</option>';
270
+ break;
271
+ case 'nb_NO':
272
+ $str = '<option value="de">østerriksk</option>
273
  <option value="da">Dansk</option>
274
  <option value="fi">Finsk</option>
275
  <option value="de">Tyske</option>
276
  <option value="nl">Dutch</option>
277
  <option selected="selected" value="nb">Norsk</option>
278
  <option value="sv">Svensk</option>';
279
+ break;
280
+ case 'sv_SE':
281
+ $str = '<option value="de">österrikiska</option>
282
  <option value="da">Dansk</option>
283
  <option value="fi">Finska</option>
284
  <option value="de">Tysk</option>
285
  <option value="nl">Holländare</option>
286
  <option value="nb">Norska</option>
287
  <option selected="selected" value="sv">Svenska</option>';
288
+ break;
289
+ }
290
+ return $str;
291
+ }
292
+
293
+ public function getGenderLabel ()
294
+ {
295
+ switch ( $this->getLocaleCode() ) {
296
+ case 'de_AT':
297
+ return 'Geslecht';
298
+ break;
299
+ case 'da_DK':
300
+ return 'Køn';
301
+ break;
302
+ case 'fi_FI':
303
+ return 'Sukupuoli';
304
+ break;
305
+ case 'de_DE':
306
+ return 'Geschlecht';
307
+ break;
308
+ case 'nl_NL':
309
+ return 'Geslacht';
310
+ break;
311
+ case 'nb_NO':
312
+ return 'Kjønn';
313
+ break;
314
+ case 'sv_SE':
315
+ return 'Kön';
316
+ break;
317
+ }
318
+ return Mage::helper( 'cgp' )->__( 'Gender' );
319
+ }
320
+
321
+ public function getMaleLabel ()
322
+ {
323
+ switch ( $this->getLocaleCode() ) {
324
+ case 'de_AT':
325
+ return 'Mann';
326
+ break;
327
+ case 'da_DK':
328
+ return 'Mand';
329
+ break;
330
+ case 'fi_FI':
331
+ return 'Mies';
332
+ break;
333
+ case 'de_DE':
334
+ return 'Mann';
335
+ break;
336
+ case 'nl_NL':
337
+ return 'Man';
338
+ break;
339
+ case 'nb_NO':
340
+ return 'Mann';
341
+ break;
342
+ case 'sv_SE':
343
+ return 'Man';
344
+ break;
345
+ }
346
+ return Mage::helper( 'cgp' )->__( 'Male' );
347
+ }
348
+
349
+ public function getFemaleLabel ()
350
+ {
351
+ switch ( $this->getLocaleCode() ) {
352
+ case 'de_AT':
353
+ return 'Frau';
354
+ break;
355
+ case 'da_DK':
356
+ return 'Kvinde';
357
+ break;
358
+ case 'fi_FI':
359
+ return 'Nainen';
360
+ break;
361
+ case 'de_DE':
362
+ return 'Frau';
363
+ break;
364
+ case 'nl_NL':
365
+ return 'Vrouw';
366
+ break;
367
+ case 'nb_NO':
368
+ return 'Kvinne';
369
+ break;
370
+ case 'sv_SE':
371
+ return 'Kvinna';
372
+ break;
373
+ }
374
+ return Mage::helper( 'cgp' )->__( 'Female' );
375
+ }
376
+
377
+ public function getLanguageLabel ()
378
+ {
379
+ $locale = $this->getLocaleCode();
380
+ switch ( $this->getLocaleCode() ) {
381
+ case 'de_AT':
382
+ return 'Sprache';
383
+ break;
384
+ case 'da_DK':
385
+ return 'Sprog';
386
+ break;
387
+ case 'fi_FI':
388
+ return 'Kieli';
389
+ break;
390
+ case 'de_DE':
391
+ return 'Sprache';
392
+ break;
393
+ case 'nl_NL':
394
+ return 'Taal';
395
+ break;
396
+ case 'nb_NO':
397
+ return 'Språk';
398
+ break;
399
+ case 'sv_SE':
400
+ return 'Språk';
401
+ break;
402
+ }
403
+ }
404
+
405
+ public function getPersonalNumberLabel ()
406
+ {
407
+ switch ( $this->getLocaleCode() ) {
408
+ case 'de_AT':
409
+ return '';
410
+ break;
411
+ case 'da_DK':
412
+ return 'Personnummer';
413
+ break;
414
+ case 'fi_FI':
415
+ return 'Henkilötunnus';
416
+ break;
417
+ case 'de_DE':
418
+ return '';
419
+ break;
420
+ case 'nl_NL':
421
+ return '';
422
+ break;
423
+ case 'nb_NO':
424
+ return 'Fødselsnummer';
425
+ break;
426
+ case 'sv_SE':
427
+ return 'Personnummer';
428
+ break;
429
+ }
430
+ }
431
+
432
+ public function isEU ()
433
+ {
434
+ switch ( $this->getLocaleCode() ) {
435
+ case 'de_AT':
436
+ return true;
437
+ break;
438
+ case 'da_DK':
439
+ return false;
440
+ break;
441
+ case 'fi_FI':
442
+ return false;
443
+ break;
444
+ case 'de_DE':
445
+ return true;
446
+ break;
447
+ case 'nl_NL':
448
+ return true;
449
+ break;
450
+ case 'nb_NO':
451
+ return false;
452
+ break;
453
+ case 'sv_SE':
454
+ return false;
455
+ break;
456
+ }
457
+ }
458
+
459
+ public function beginIsEu ()
460
+ {
461
+ if ( $this->isEU() ) {
462
+ return '';
463
+ } else {
464
+ return '<!--';
465
+ }
466
+ }
467
+
468
+ public function endIsEu ()
469
+ {
470
+ if ( $this->isEU() ) {
471
+ return '';
472
+ } else {
473
+ return '-->';
474
+ }
475
+ }
476
+
477
+ public function beginIsNotEu ()
478
+ {
479
+ if ( ! $this->isEU() ) {
480
+ return '';
481
+ } else {
482
+ return '<!--';
483
+ }
484
+ }
485
+
486
+ public function endIsNotEu ()
487
+ {
488
+ if ( ! $this->isEU() ) {
489
+ return '';
490
+ } else {
491
+ return '-->';
492
+ }
493
+ }
494
+
495
+ public function getBirthdayLabel ()
496
+ {
497
+ switch ( $this->getLocaleCode() ) {
498
+ case 'de_AT':
499
+ return 'Geburtsdatum';
500
+ break;
501
+ case 'da_DK':
502
+ return 'Fødselsdag';
503
+ break;
504
+ case 'fi_FI':
505
+ return 'Syntymäpäivä';
506
+ break;
507
+ case 'de_DE':
508
+ return 'Geburtsdatum';
509
+ break;
510
+ case 'nl_NL':
511
+ return 'Geboortedatum';
512
+ break;
513
+ case 'nb_NO':
514
+ return 'Bursdag';
515
+ break;
516
+ case 'sv_SE':
517
+ return 'Födelsedag';
518
+ break;
519
+ }
520
+ return Mage::helper( 'cgp' )->__( 'Birthday' );
521
+ }
522
+
523
+ public function getLocaleCode ()
524
+ {
525
+ $country = Mage::getSingleton( 'checkout/session' )->getQuote()
526
+ ->getBillingAddress()
527
+ ->getCountry();
528
+
529
+ switch ( $country ) {
530
+ case 'AT':
531
+ return 'de_AT';
532
+ break;
533
+ case 'DK':
534
+ return 'da_DK';
535
+ break;
536
+ case 'FI':
537
+ return 'fi_FI';
538
+ break;
539
+ case 'DE':
540
+ return 'de_DE';
541
+ break;
542
+ case 'NL':
543
+ return 'nl_NL';
544
+ break;
545
+ case 'NO':
546
+ return 'nb_NO';
547
+ break;
548
+ case 'SE':
549
+ return 'sv_SE';
550
+ break;
551
+ default:
552
+ return 'not_klarna';
553
+ }
554
+ }
555
+
556
+ public function getGermanNotice ()
557
+ {
558
+ $locale = $this->getLocaleCode();
559
+ if ( strpos( $locale, 'de_' ) === 0 ) {
560
+ $str = '<br>
561
  <div style="float:left;margin-top:5px;">
562
  <input
563
  type="checkbox"
568
  />
569
  Mit der Datenverarbeitung der für die Abwicklungdes Rechnungskaufes und einer Identitäts-und Bonitätsprüfung erforderlichen Daten durch Klarna bin ich einverstanden. Meine <span id="consent01"></span> kann ich jederzeit mit Wirkung für die Zukunft widerrufen. Es gelten die AGB des Händlers. <br>
570
  </div>';
571
+ } else {
572
+ $str = "";
573
+ }
574
+ return $str;
575
+ }
576
+
577
+ public function getKlarnaAccountTerms ()
578
+ {
579
+ switch ( $this->getLocaleCode() ) {
580
+ case 'de_AT':
581
+ return '';
582
+ break;
583
+ case 'da_DK':
584
+ break;
585
+ case 'fi_FI':
586
+ break;
587
+ case 'de_DE':
588
+ break;
589
+ case 'nl_NL':
590
+ break;
591
+ case 'nb_NO':
592
+ break;
593
+ case 'sv_SE':
594
+ break;
595
+ }
596
+
597
+ $str = "new Klarna.Terms.Account({
598
  el: 'account01',
599
  eid: '" . $this->getKlarnaAccountEid() . "',
600
  locale: '" . $this->getLocaleCode() . "',
601
  type: 'desktop'
602
  });";
603
+ return $str;
604
+ }
605
+
606
+ public function getKlarnaAccountConsent ()
607
+ {
608
+ $str = ' ';
609
+ $locale = $this->getLocaleCode();
610
+ if ( strpos( $locale, 'de_' ) === 0 ) {
611
+ $str = "new Klarna.Terms.Consent({
612
  el: 'consent01',
613
  eid: '" . $this->getKlarnaAccountEid() . "',
614
  locale: '" . $this->getLocaleCode() . "',
615
  type: 'desktop'
616
  });";
617
+ }
618
+ return $str;
619
+ }
620
+
621
+ public function getKlarnaAccountEid ()
622
+ {
623
+ $settings = Mage::getStoreConfig( 'cgp/cgp_klarnaaccount' );
624
+ return $settings['klarna_eid'];
625
+ }
626
+
627
+ public function getKlarnaAccountLogoUrl ()
628
+ {
629
+ $str = 'https://cdn.klarna.com/public/images/';
630
+ $country = substr( $this->getLocaleCode(), 3 );
631
+ $str .= $country;
632
+ $str .= '/badges/v1/account/';
633
+ $str .= $country;
634
+ $str .= '_account_badge_std_blue.png?width=125&eid=';
635
+ $str .= $this->getKlarnaAccountEid();
636
+ return $str;
637
+ }
 
638
  }
app/code/local/Cardgate/Cgp/Block/Paymentfee/Adminhtml/Sales/Order/Totals.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+ class Cardgate_Cgp_Block_Paymentfee_Adminhtml_Sales_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
10
+ {
11
+
12
+ /**
13
+ * Initialize order totals
14
+ *
15
+ * @return Mage_Sales_Block_Order_Totals
16
+ */
17
+ protected function _initTotals ()
18
+ {
19
+ parent::_initTotals();
20
+ $payment = $this->getOrder()->getPayment();
21
+ if ( substr( $payment->getMethod(), 0, 3 ) != "cgp" ) {
22
+ return $this;
23
+ }
24
+ $info = $payment->getMethodInstance()->getInfoInstance();
25
+ if ( ! $info->getAdditionalInformation( "invoice_fee" ) ) {
26
+ return $this;
27
+ }
28
+
29
+ return Mage::helper( 'cgp/paymentfee' )->addToBlock( $this );
30
+ }
31
+ }
app/code/local/Cardgate/Cgp/Block/Paymentfee/Checkout/Fee.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+
10
+ class Cardgate_Cgp_Block_Paymentfee_Checkout_Fee extends Mage_Checkout_Block_Total_Default
11
+ {
12
+
13
+ protected $_template = 'cardgate/cgp/checkout/fee.phtml';
14
+
15
+ /**
16
+ * Get Payment fee including tax
17
+ *
18
+ * @return float
19
+ */
20
+ public function getInvoiceFeeIncludeTax ()
21
+ {
22
+ return $this->getTotal()
23
+ ->getAddress()
24
+ ->getInvoiceFee();
25
+ }
26
+
27
+ /**
28
+ * Get Payment fee excluding tax
29
+ *
30
+ * @return float
31
+ */
32
+ public function getInvoiceFeeExcludeTax ()
33
+ {
34
+ return $this->getTotal()
35
+ ->getAddress()
36
+ ->getInvoiceFeeExcludedVat();
37
+ }
38
+
39
+ /**
40
+ * Checks if including and excluding tax prices should be shown
41
+ *
42
+ * @return bool
43
+ */
44
+ public function displayBoth ()
45
+ {
46
+ return Mage::helper( "tax" )->displayCartBothPrices();
47
+ }
48
+
49
+ /**
50
+ * Checks if including tax price should be shown
51
+ *
52
+ * @return bool
53
+ */
54
+ public function displayIncludeTax ()
55
+ {
56
+ return Mage::helper( "tax" )->displayCartPriceInclTax();
57
+ }
58
+
59
+ /**
60
+ * Get the label for "excluding tax"
61
+ *
62
+ * @return string
63
+ */
64
+ public function getExcludeTaxLabel ()
65
+ {
66
+ return Mage::helper( "tax" )->getIncExcTaxLabel( false );
67
+ }
68
+
69
+ /**
70
+ * Get the label for "including tax"
71
+ *
72
+ * @return string
73
+ */
74
+ public function getIncludeTaxLabel ()
75
+ {
76
+ return Mage::helper( "tax" )->getIncExcTaxLabel( true );
77
+ }
78
+ }
app/code/local/Cardgate/Cgp/Block/Paymentfee/Creditmemo/Totals.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+ class Cardgate_Cgp_Block_Paymentfee_Creditmemo_Totals extends Mage_Sales_Block_Order_Creditmemo_Totals
10
+ {
11
+
12
+ /**
13
+ * Initialize order totals
14
+ *
15
+ * @return Mage_Sales_Block_Order_Creditmemo_Totals
16
+ */
17
+ protected function _initTotals ()
18
+ {
19
+ parent::_initTotals();
20
+ $payment = $this->getOrder()->getPayment();
21
+ if ( substr( $payment->getMethod(), 0, 3 ) != "cgp" ) {
22
+ return $this;
23
+ }
24
+ $info = $payment->getMethodInstance()->getInfoInstance();
25
+ if ( ! $info->getAdditionalInformation( "invoice_fee" ) ) {
26
+ return $this;
27
+ }
28
+ return Mage::helper( 'cgp/paymentfee' )->addToBlock( $this );
29
+ }
30
+ }
app/code/local/Cardgate/Cgp/Block/Paymentfee/Invoice/Totals/Fee.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+ class Cardgate_Cgp_Block_Paymentfee_Invoice_Totals_Fee extends Mage_Sales_Block_Order_Invoice_Totals
10
+ {
11
+
12
+ /**
13
+ * Initialize order totals
14
+ *
15
+ * @return Mage_Sales_Block_Order_Invoice_Totals
16
+ */
17
+ public function _initTotals ()
18
+ {
19
+ parent::_initTotals();
20
+ $payment = $this->getOrder()->getPayment();
21
+ if ( substr( $payment->getMethod(), 0, 3 ) != "cgp" ) {
22
+ return $this;
23
+ }
24
+ $info = $payment->getMethodInstance()->getInfoInstance();
25
+ if ( ! $info->getAdditionalInformation( "invoice_fee" ) ) {
26
+ return $this;
27
+ }
28
+ return Mage::helper( 'cgp/paymentfee' )->addToBlock( $this );
29
+ }
30
+ }
app/code/local/Cardgate/Cgp/Block/Paymentfee/Order/Totals/Fee.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+ class Cardgate_Cgp_Block_Paymentfee_Order_Totals_Fee extends Mage_Sales_Block_Order_Totals
10
+ {
11
+
12
+ /**
13
+ * Initialize order totals
14
+ *
15
+ * @return Mage_Sales_Block_Order_Totals
16
+ */
17
+ public function _initTotals ()
18
+ {
19
+ parent::_initTotals();
20
+ $payment = $this->getOrder()->getPayment();
21
+ if ( substr( $payment->getMethod(), 0, 3 ) != "cgp" ) {
22
+ return $this;
23
+ }
24
+ $info = $payment->getMethodInstance()->getInfoInstance();
25
+ if ( ! $info->getAdditionalInformation( "invoice_fee" ) ) {
26
+ return $this;
27
+ }
28
+ return Mage::helper( 'cgp/paymentfee' )->addToBlock( $this );
29
+ }
30
+ }
app/code/local/Cardgate/Cgp/Block/Redirect.php CHANGED
@@ -1,43 +1,37 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
  *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Block_Redirect extends Mage_Core_Block_Template
20
- {
21
- protected function _construct()
22
- {
23
- $this->setTemplate('cardgate/cgp/redirect.phtml');
24
- }
25
-
26
- public function getForm()
27
- {
28
- $model = Mage::getModel(Mage::registry('cgp_model'));
29
- Mage::unregister('cgp_model');
30
-
31
- $form = new Varien_Data_Form();
32
- $form->setAction($model->getGatewayUrl())
33
- ->setId('cardgateplus_checkout')
34
- ->setName('cardgateplus_checkout')
35
- ->setMethod('POST')
36
- ->setUseContainer(true);
37
-
38
- foreach ($model->getCheckoutFormFields() as $field => $value) {
39
- $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
40
- }
41
- return $form->getHtml();
42
- }
 
 
 
 
43
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
 
 
 
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Block_Redirect extends Mage_Core_Block_Template
10
+ {
11
+
12
+ protected function _construct ()
13
+ {
14
+ $this->setTemplate( 'cardgate/cgp/redirect.phtml' );
15
+ }
16
+
17
+ public function getForm ()
18
+ {
19
+ $model = Mage::getModel( Mage::registry( 'cgp_model' ) );
20
+ Mage::unregister( 'cgp_model' );
21
+
22
+ $form = new Varien_Data_Form();
23
+ $form->setAction( $model->getGatewayUrl() )
24
+ ->setId( 'cardgateplus_checkout' )
25
+ ->setName( 'cardgateplus_checkout' )
26
+ ->setMethod( 'POST' )
27
+ ->setUseContainer( true );
28
+
29
+ foreach ( $model->getCheckoutFormFields() as $field => $value ) {
30
+ $form->addField( $field, 'hidden', array(
31
+ 'name' => $field,
32
+ 'value' => $value
33
+ ) );
34
+ }
35
+ return $form->getHtml();
36
+ }
37
  }
app/code/local/Cardgate/Cgp/Helper/Data.php CHANGED
@@ -1,32 +1,21 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
  *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Helper_Data extends Mage_Core_Helper_Abstract
20
  {
 
21
  /**
22
  * Check if OneStepCheckout is activated or not
23
  *
24
  * @return bool
25
  */
26
- public function isOneStepCheckout()
27
  {
28
- return (bool) Mage::getStoreConfig(
29
- 'onestepcheckout/general/rewrite_checkout_links'
30
- );
31
  }
32
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
 
 
 
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Helper_Data extends Mage_Core_Helper_Abstract
10
  {
11
+
12
  /**
13
  * Check if OneStepCheckout is activated or not
14
  *
15
  * @return bool
16
  */
17
+ public function isOneStepCheckout ()
18
  {
19
+ return ( bool ) Mage::getStoreConfig( 'onestepcheckout/general/rewrite_checkout_links' );
 
 
20
  }
21
  }
app/code/local/Cardgate/Cgp/Helper/Paymentfee.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+ class Cardgate_Cgp_Helper_Paymentfee extends Mage_Payment_Helper_Data
10
+ {
11
+
12
+ /**
13
+ * Get payment fee
14
+ * Return array with payment fee's information
15
+ *
16
+ * @return array
17
+ */
18
+ public function getPaymentFeeArray ( $paymentcode, $quote )
19
+ {
20
+ $inctax = Mage::getStoreConfig( 'cgp/' . $paymentcode . '/payment_fee_inc_ex' );
21
+ $paymentfee = Mage::getStoreConfig( 'cgp/' . $paymentcode . '/payment_fee' );
22
+ $paymentfee_taxclass = Mage::getStoreConfig( 'cgp/' . $paymentcode . '/payment_fee_tax' );
23
+
24
+ if ( $paymentfee == '' ) {
25
+ Mage::getSingleton( 'core/session' )->setCgpFeeInc( 0 );
26
+ return;
27
+ }
28
+
29
+ if ( Mage::getSingleton( 'core/session' )->getCgpTotal() > 0 ) {
30
+ if ( $quote->getGrandTotal() > 0 &&
31
+ Mage::getSingleton( 'core/session' )->getCgpTotal() != $quote->getGrandTotal() ) {
32
+ Mage::getSingleton( 'core/session' )->setCgpTotal( $quote->getGrandTotal() );
33
+ $order_total = Mage::getSingleton( 'core/session' )->getCgpTotal();
34
+ }
35
+ $order_total = Mage::getSingleton( 'core/session' )->getCgpTotal();
36
+ } else {
37
+ Mage::getSingleton( 'core/session' )->setCgpTotal( $quote->getGrandTotal() );
38
+ $order_total = $quote->getGrandTotal();
39
+ }
40
+
41
+ if ( strpos( $paymentfee, ';' ) > 0 ) {
42
+ $fees = explode( ";", $paymentfee );
43
+ $charge = 0;
44
+ if ( $fees[0] > 0 )
45
+ $charge += $fees[0];
46
+ else
47
+ $charge += $order_total * ( ( $fees[0] * - 1 ) / 100.0 );
48
+
49
+ if ( $fees[1] > 0 )
50
+ $charge += $fees[1];
51
+ else
52
+ $charge += $order_total * ( ( $fees[1] * - 1 ) / 100.0 );
53
+ } else
54
+ if ( $paymentfee > 0 ) {
55
+ $charge = $paymentfee;
56
+ } else
57
+ if ( $paymentfee < 0 ) {
58
+ $charge = $order_total * ( ( $paymentfee * - 1 ) / 100.0 );
59
+ }
60
+
61
+ $address = $quote->getShippingAddress();
62
+ $taxClassId = $quote->getCustomerTaxClassId();
63
+
64
+ $store = Mage::app()->getStore();
65
+ $calc = Mage::getSingleton( 'tax/calculation' );
66
+ $rateRequest = $calc->getRateRequest( $address, $address, $taxClassId, $store );
67
+ $rateRequest->setProductClassId( $paymentfee_taxclass );
68
+ $rate = $calc->getRate( $rateRequest );
69
+
70
+ if ( $inctax == '1' ) {
71
+ $value = $calc->calcTaxAmount( $charge, $rate, true, false );
72
+ $excl = ( $charge - $value );
73
+ $feeArray = array(
74
+ 'excl' => $excl,
75
+ 'base_excl' => $this->calcBaseValue( $excl ),
76
+ 'incl' => $charge,
77
+ 'base_incl' => $this->calcBaseValue( $charge ),
78
+ 'taxamount' => $value,
79
+ 'base_taxamount' => $this->calcBaseValue( $value ),
80
+ 'rate' => $rate
81
+ );
82
+ } else {
83
+ // Fee entered without tax
84
+ $value = $calc->calcTaxAmount( $charge, $rate, false, false );
85
+ $incl = ( $charge + $value );
86
+
87
+ $feeArray = array(
88
+ 'excl' => $charge,
89
+ 'base_excl' => $this->calcBaseValue( $charge ),
90
+ 'incl' => $incl,
91
+ 'base_incl' => $this->calcBaseValue( $incl ),
92
+ 'taxamount' => $value,
93
+ 'base_taxamount' => $this->calcBaseValue( $value ),
94
+ 'rate' => $rate
95
+ );
96
+ }
97
+
98
+ Mage::getSingleton( 'core/session' )->setCgpFeeInc( $feeArray['incl'] );
99
+
100
+ return $feeArray;
101
+ }
102
+
103
+ public function addToBlock ( $block )
104
+ {
105
+ $order = $block->getOrder();
106
+ $info = $order->getPayment()
107
+ ->getMethodInstance()
108
+ ->getInfoInstance();
109
+ $storeId = Mage::app()->getStore()->getId();
110
+ $taxOption = Mage::getStoreConfig( "tax/sales_display/shipping", $storeId );
111
+ $country = $order->getShippingAddress()->getCountry();
112
+ $label = Mage::getStoreConfig( 'cgp/' . $order->getPayment()->getMethod() . '/payment_fee_label' );
113
+ if ( $label == '' )
114
+ $label = 'Paymentmethod costs';
115
+
116
+ $paymentFee = $info->getAdditionalInformation( 'invoice_fee' );
117
+ $basePaymentFee = $info->getAdditionalInformation( 'base_invoice_fee' );
118
+ $paymentFeeExcludingVat = $info->getAdditionalInformation( 'invoice_fee_exluding_vat' );
119
+ $basePaymentFeeExcludingVat = $info->getAdditionalInformation( 'base_invoice_fee_exluding_vat' );
120
+
121
+ /**
122
+ * Tax Options:
123
+ * 1 : Show exluding tax
124
+ * 2 : Show including tax
125
+ * 3 : Show both
126
+ */
127
+
128
+ if ( ( $taxOption === '1' ) || ( $taxOption === '3' ) ) {
129
+ //$label = Mage::getStoreConfig( 'cgp/' . $order->getPayment()->getMethod() . '/payment_fee_label' );
130
+ $fee = new Varien_Object();
131
+ $fee->setCode( 'invoice_fee_excl' );
132
+ if ( $taxOption == '3' ) {
133
+ $label .= ' (Excl.Tax)';
134
+ }
135
+ $fee->setLabel( $label );
136
+ $fee->setBaseValue( $basePaymentFeeExcludingVat );
137
+ $fee->setValue( $paymentFeeExcludingVat );
138
+ $block->addTotalBefore( $fee, 'shipping' );
139
+ }
140
+ if ( ( $taxOption === '2' ) || ( $taxOption === '3' ) ) {
141
+ //$label = Mage::getStoreConfig( 'cgp/' . $order->getPayment()->getMethod() . '/payment_fee_label' );
142
+ $fee = new Varien_Object();
143
+ $fee->setCode( 'invoice_fee_incl' );
144
+ if ( $taxOption == '3' ) {
145
+ $label .= ' (Incl.Tax)';
146
+ }
147
+ $fee->setLabel( $label );
148
+ $fee->setBaseValue( $basePaymentFee );
149
+ $fee->setValue( $paymentFee );
150
+ $block->addTotalBefore( $fee, 'shipping' );
151
+ }
152
+ return $block;
153
+ }
154
+
155
+ /**
156
+ * Calculate rates currency rates for base values.
157
+ *
158
+ * @param float $value value to calculate on
159
+ *
160
+ * @return float
161
+ */
162
+ private function calcBaseValue ( $value )
163
+ {
164
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
165
+ $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
166
+
167
+ if ( $currentCurrencyCode !== $baseCurrencyCode ) {
168
+ $currencyModel = Mage::getModel( 'directory/currency' );
169
+ $currencyRates = $currencyModel->getCurrencyRates( $baseCurrencyCode, array(
170
+ $currentCurrencyCode
171
+ ) );
172
+ return ( $value / $currencyRates[$currentCurrencyCode] );
173
+ }
174
+ return $value;
175
+ }
176
+ }
177
+ ?>
app/code/local/Cardgate/Cgp/Model/Adminhtml/System/Config/Source/Languages.php CHANGED
@@ -1,69 +1,61 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
  *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Adminhtml_System_Config_Source_Languages
20
  {
21
- public function toOptionArray() {
22
- return array(
23
- array(
24
- "value" => "nl",
25
- "label" => Mage::helper("cgp")->__('Dutch')
26
- ),
27
- array(
28
- "value" => "en",
29
- "label" => Mage::helper("cgp")->__('English')
30
- ),
31
- array(
32
- "value" => "de",
33
- "label" => Mage::helper("cgp")->__('German')
34
- ),
35
- array(
36
- "value" => "fr",
37
- "label" => Mage::helper("cgp")->__('French')
38
- ),
39
- array(
40
- "value" => "es",
41
- "label" => Mage::helper("cgp")->__('Spanish')
42
- ),
43
- array(
44
- "value" => "gr",
45
- "label" => Mage::helper("cgp")->__('Greek')
46
- ),
47
- array(
48
- "value" => "hr",
49
- "label" => Mage::helper("cgp")->__('Croatian')
50
- ),
51
- array(
52
- "value" => "it",
53
- "label" => Mage::helper("cgp")->__('Italian')
54
- ),
55
- array(
56
- "value" => "cz",
57
- "label" => Mage::helper("cgp")->__('Czech')
58
- ),
59
- array(
60
- "value" => "ru",
61
- "label" => Mage::helper("cgp")->__('Russian')
62
- ),
63
- array(
64
- "value" => "se",
65
- "label" => Mage::helper("cgp")->__('Swedish')
66
- ),
67
- );
 
 
68
  }
69
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
 
 
 
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Adminhtml_System_Config_Source_Languages
10
  {
11
+
12
+ public function toOptionArray ()
13
+ {
14
+ return array(
15
+ array(
16
+ "value" => "nl",
17
+ "label" => Mage::helper( "cgp" )->__( 'Dutch' )
18
+ ),
19
+ array(
20
+ "value" => "en",
21
+ "label" => Mage::helper( "cgp" )->__( 'English' )
22
+ ),
23
+ array(
24
+ "value" => "de",
25
+ "label" => Mage::helper( "cgp" )->__( 'German' )
26
+ ),
27
+ array(
28
+ "value" => "fr",
29
+ "label" => Mage::helper( "cgp" )->__( 'French' )
30
+ ),
31
+ array(
32
+ "value" => "es",
33
+ "label" => Mage::helper( "cgp" )->__( 'Spanish' )
34
+ ),
35
+ array(
36
+ "value" => "gr",
37
+ "label" => Mage::helper( "cgp" )->__( 'Greek' )
38
+ ),
39
+ array(
40
+ "value" => "hr",
41
+ "label" => Mage::helper( "cgp" )->__( 'Croatian' )
42
+ ),
43
+ array(
44
+ "value" => "it",
45
+ "label" => Mage::helper( "cgp" )->__( 'Italian' )
46
+ ),
47
+ array(
48
+ "value" => "cz",
49
+ "label" => Mage::helper( "cgp" )->__( 'Czech' )
50
+ ),
51
+ array(
52
+ "value" => "ru",
53
+ "label" => Mage::helper( "cgp" )->__( 'Russian' )
54
+ ),
55
+ array(
56
+ "value" => "se",
57
+ "label" => Mage::helper( "cgp" )->__( 'Swedish' )
58
+ )
59
+ );
60
  }
61
  }
app/code/local/Cardgate/Cgp/Model/Adminhtml/System/Config/Source/Modes.php CHANGED
@@ -1,33 +1,25 @@
1
  <?php
 
2
  /**
3
- * Magento Carg Gate Plus payment extension
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
  *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Adminhtml_System_Config_Source_Modes
20
  {
21
- public function toOptionArray() {
22
- return array(
23
- array(
24
- "value" => "test",
25
- "label" => Mage::helper("cgp")->__("Test Mode")
26
- ),
27
- array(
28
- "value" => "live",
29
- "label" => Mage::helper("cgp")->__("Live Mode")
30
- ),
 
 
31
  );
32
  }
33
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
 
 
 
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Adminhtml_System_Config_Source_Modes
10
  {
11
+
12
+ public function toOptionArray ()
13
+ {
14
+ return array(
15
+ array(
16
+ "value" => "test",
17
+ "label" => Mage::helper( "cgp" )->__( "Test Mode" )
18
+ ),
19
+ array(
20
+ "value" => "live",
21
+ "label" => Mage::helper( "cgp" )->__( "Live Mode" )
22
+ )
23
  );
24
  }
25
  }
app/code/local/Cardgate/Cgp/Model/Base.php CHANGED
@@ -1,426 +1,445 @@
1
  <?php
2
 
3
  /**
4
- * Magento CardGatePlus payment extension
5
  *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- *
13
- * @category Mage
14
- * @package Cardgate_Cgp
15
- * @author Paul Saparov, <support@cardgate.com>
16
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
17
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
  */
19
- class Cardgate_Cgp_Model_Base extends Varien_Object {
20
-
21
- protected $_callback;
22
- protected $_config = null;
23
- protected $_isLocked = false;
24
- protected $_logFileName = "cardgateplus.log";
25
-
26
- /**
27
- * Initialize basic cgp settings
28
- */
29
- public function _construct() {
30
- $this->_config = Mage::getStoreConfig( 'cgp/settings' );
31
- }
32
-
33
- /**
34
- * Retrieve config value
35
- *
36
- * @param string $field
37
- * @return mixed
38
- */
39
- public function getConfigData( $field ) {
40
- if ( isset( $this->_config[$field] ) ) {
41
- return $this->_config[$field];
42
- } else {
43
- return false;
44
- }
45
- }
46
-
47
- /**
48
- * Set callback data
49
- *
50
- * @param array $data
51
- * @return Cardgate_Cgp_Model_Base
52
- */
53
- public function setCallbackData( $data ) {
54
- $this->_callback = $data;
55
- return $this;
56
- }
57
-
58
- /**
59
- * Get callback data
60
- *
61
- * @param string $field
62
- * @return string
63
- */
64
- public function getCallbackData( $field = null ) {
65
- if ( $field === null ) {
66
- return $this->_callback;
67
- } else {
68
- return @$this->_callback[$field];
69
- }
70
- }
71
-
72
- /**
73
- * If the debug mode is enabled
74
- *
75
- * @return bool
76
- */
77
- public function isDebug() {
78
- return $this->getConfigData( 'debug' );
79
- }
80
-
81
- /**
82
- * If the test mode is enabled
83
- *
84
- * @return bool
85
- */
86
- public function isTest() {
87
- return ($this->getConfigData( 'test_mode' ) == "test");
88
- }
89
-
90
- /**
91
- * Log data into the logfile
92
- *
93
- * @param string $msg
94
- * @return void
95
- */
96
- public function log( $msg ) {
97
- if ( $this->getConfigData( 'debug' ) ) {
98
- Mage::log( $msg, null, $this->_logFileName );
99
- }
100
- }
101
-
102
- /**
103
- * Create lock file
104
- *
105
- * @return Cardgate_Cgp_Model_Base
106
- */
107
- public function lock() {
108
- $varDir = Mage::getConfig()->getVarDir( 'locks' );
109
- $lockFilename = $varDir . DS . $this->getCallbackData( 'ref' ) . '.lock';
110
- $fp = @fopen( $lockFilename, 'x' );
111
-
112
- if ( $fp ) {
113
- $this->_isLocked = true;
114
- $pid = getmypid();
115
- $now = date( 'Y-m-d H:i:s' );
116
- fwrite( $fp, "Locked by $pid at $now\n" );
117
- }
118
-
119
- return $this;
120
- }
121
-
122
- /**
123
- * Unlock file
124
- *
125
- * @return Cardgate_Cgp_Model_Base
126
- */
127
- public function unlock() {
128
- $this->_isLocked = false;
129
- $varDir = Mage::getConfig()->getVarDir( 'locks' );
130
- $lockFilename = $varDir . DS . $this->getCallbackData( 'ref' ) . '.lock';
131
- unlink( $lockFilename );
132
-
133
- return $this;
134
- }
135
-
136
- /**
137
- * Create and mail invoice
138
- *
139
- * @param Mage_Sales_Model_Order $order
140
- * @return boolean
141
- */
142
- protected function createInvoice( Mage_Sales_Model_Order $order ) {
143
- if ( $order->canInvoice() && !$order->hasInvoices() ) {
144
- $invoice = $order->prepareInvoice();
145
- $invoice->register();
146
- if ( $invoice->canCapture() ) {
147
- $invoice->capture();
148
- }
149
- $invoice->save();
150
-
151
- Mage::getModel( "core/resource_transaction" )
152
- ->addObject( $invoice )
153
- ->addObject( $invoice->getOrder() )
154
- ->save();
155
-
156
- $mail_invoice = $this->getConfigData( "mail_invoice" );
157
- if ( $mail_invoice ) {
158
- $invoice->setEmailSent( true );
159
- $invoice->save();
160
- $invoice->sendEmail();
161
- }
162
-
163
- $statusMessage = $mail_invoice ? "Invoice # %s created and send to customer." : "Invoice # %s created.";
164
- $order->addStatusToHistory(
165
- $order->getStatus(), Mage::helper( "cgp" )->__( $statusMessage, $invoice->getIncrementId(), $mail_invoice )
166
- );
167
-
168
- return true;
169
- }
170
-
171
- return false;
172
- }
173
-
174
- /**
175
- * Notify shop owners on failed invoicing creation
176
- *
177
- * @param Mage_Sales_Model_Order $order
178
- * @return void
179
- */
180
- protected function eventInvoicingFailed( $order ) {
181
- $storeId = $order->getStore()->getId();
182
-
183
- $ident = Mage::getStoreConfig( 'cgp/settings/notification_email' );
184
- $sender_email = Mage::getStoreConfig( 'trans_email/ident_general/email', $storeId );
185
- $sender_name = Mage::getStoreConfig( 'trans_email/ident_general/name', $storeId );
186
- $recipient_email = Mage::getStoreConfig( 'trans_email/ident_' . $ident . '/email', $storeId );
187
- $recipient_name = Mage::getStoreConfig( 'trans_email/ident_' . $ident . '/name', $storeId );
188
-
189
- $mail = new Zend_Mail();
190
- $mail->setFrom( $sender_email, $sender_name );
191
- $mail->addTo( $recipient_email, $recipient_name );
192
- $mail->setSubject( Mage::helper( "cgp" )->__( 'Automatic invoice creation failed' ) );
193
- $mail->setBodyText( Mage::helper( "cgp" )->__( 'Magento was unable to create an invoice for Order # %s after a successful payment via Card Gate Plus (transaction # %s)', $order->getIncrementId(), $this->getCallbackData( 'transaction_id' ) ) );
194
- $mail->setBodyHtml( Mage::helper( "cgp" )->__( 'Magento was unable to create an invoice for <b>Order # %s</b> after a successful payment via Card Gate Plus <b>(transaction # %s)</b>', $order->getIncrementId(), $this->getCallbackData( 'transaction_id' ) ) );
195
- $mail->send();
196
- }
197
-
198
- /**
199
- * Returns true if the amounts match
200
- *
201
- * @param Mage_Sales_Model_Order $order
202
- * @return boolean
203
- */
204
- protected function validateAmount( Mage_Sales_Model_Order $order ) {
205
- $amountInCents = ( int ) sprintf( '%.0f', $order->getGrandTotal() * 100 );
206
- $callbackAmount = ( int ) $this->getCallbackData( 'amount' );
207
-
208
- if ( ($amountInCents != $callbackAmount) AND ( abs( $callbackAmount - $amountInCents ) > 1) ) {
209
- $this->log( 'OrderID: ' . $order->getId() . ' do not match amounts. Sent ' . $amountInCents . ', received: ' . $callbackAmount );
210
- $statusMessage = Mage::helper( "cgp" )->__( "Hacker attempt: Order total amount does not match CardGatePlus's gross total amount!" );
211
- $order->addStatusToHistory( $order->getStatus(), $statusMessage );
212
- $order->save();
213
- return false;
214
- }
215
-
216
- return true;
217
- }
218
-
219
- /**
220
- * Process callback for all transactions
221
- *
222
- * @return void
223
- */
224
- public function processCallback() {
225
- $id = $this->getCallbackData( 'ref' );
226
- $order = Mage::getModel( 'sales/order' );
227
- $order->loadByIncrementId( $id );
228
-
229
- // Log callback data
230
- $this->log( 'Receiving callback data:' );
231
- $this->log( $this->getCallbackData() );
232
-
233
- // Validate amount
234
- if ( !$this->validateAmount( $order ) ) {
235
- $this->log( 'Amount validation failed!' );
236
- exit();
237
- }
238
-
239
- $statusPending = $this->getConfigData( "pending_status" );
240
- $statusComplete = $this->getConfigData( "complete_status" );
241
- $statusFailed = $this->getConfigData( "failed_status" );
242
- $statusFraud = $this->getConfigData( "fraud_status" );
243
- $autocreateInvoice = $this->getConfigData( "autocreate_invoice" );
244
- $evInvoicingFailed = $this->getConfigData( "event_invoicing_failed" );
245
-
246
- $complete = false;
247
- $canceled = false;
248
- $newState = null;
249
- $newStatus = true;
250
- $statusMessage = '';
251
- switch ( $this->getCallbackData( 'status_id' ) ) {
252
- case "0":
253
- $complete = false;
254
- $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
255
- $newStatus = $statusPending;
256
- $statusMessage = Mage::helper( 'cgp' )->__( 'Payment sucessfully authorised.' );
257
- break;
258
- case "100":
259
- $complete = false;
260
- $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
261
- $newStatus = $statusPending;
262
- $statusMessage = Mage::helper( 'cgp' )->__( 'Payment sucessfully authorised.' );
263
- break;
264
- case "200":
265
- $complete = true;
266
- $newState = Mage_Sales_Model_Order::STATE_PROCESSING;
267
- $newStatus = $statusComplete;
268
- $statusMessage = Mage::helper( 'cgp' )->__( 'Payment complete.' );
269
- break;
270
- case "300":
271
- $canceled = true;
272
- $newState = Mage_Sales_Model_Order::STATE_CANCELED;
273
- $newStatus = $statusFailed;
274
- $statusMessage = Mage::helper( 'cgp' )->__( 'Payment failed.' );
275
- break;
276
- case "301":
277
- $canceled = true;
278
- $newState = Mage_Sales_Model_Order::STATE_CANCELED;
279
- $newStatus = $statusFraud;
280
- $statusMessage = Mage::helper( 'cgp' )->__( 'Transaction failed, payment is fraud.' );
281
- break;
282
- case "308":
283
- $canceled = true;
284
- $newState = Mage_Sales_Model_Order::STATE_CANCELED;
285
- $newStatus = $statusFailed;
286
- $statusMessage = Mage::helper( 'cgp' )->__( 'Payment expired.' );
287
- break;
288
- case "309":
289
- $canceled = true;
290
- $newState = Mage_Sales_Model_Order::STATE_CANCELED;
291
- $newStatus = $statusFailed;
292
- $statusMessage = Mage::helper( 'cgp' )->__( 'Payment canceled by user.' );
293
- break;
294
- case "700":
295
- // Banktransfer pending status
296
- $complete = false;
297
- $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
298
- $newStatus = $statusPending;
299
- $statusMessage = Mage::helper( 'cgp' )->__( 'Transaction pending: Waiting for customer action.' );
300
- $order->sendNewOrderEmail();
301
- $order->addStatusToHistory( $order->getStatus(), $statusMessage, true );
302
- $order->save();
303
- break;
304
- case "701":
305
- // Direct debit pending status
306
- $complete = false;
307
- $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
308
- $newStatus = $statusPending;
309
- $statusMessage = Mage::helper( 'cgp' )->__( 'Transaction pending: Waiting for confirmation.' );
310
- $order->sendNewOrderEmail();
311
- $order->addStatusToHistory( $order->getStatus(), $statusMessage, true );
312
- $order->save();
313
- break;
314
- default:
315
- $msg = 'Status not recognised: ' . $this->getCallbackData( 'status' );
316
- $this->log( $msg );
317
- die( $msg );
318
- }
319
- // Update only certain states
320
- $canUpdate = false;
321
- $undoCancel = false;
322
- if ( $order->getState() == Mage_Sales_Model_Order::STATE_NEW ||
323
- $order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT ||
324
- $order->getState() == Mage_Sales_Model_Order::STATE_CANCELED ) {
325
- $canUpdate = true;
326
- }
327
-
328
- foreach ( $order->getStatusHistoryCollection( true ) as $_item ) {
329
- // Don't update order status if the payment is complete
330
- if ( $_item->getStatusLabel() == ucfirst( $statusComplete ) ) {
331
- $canUpdate = false;
332
- // Uncancel an order if the payment is considered complete
333
- } elseif ( ($_item->getStatusLabel() == ucfirst( $statusFailed )) ||
334
- ($_item->getStatusLabel() == ucfirst( $statusFraud )) ) {
335
- $undoCancel = true;
336
- }
337
- }
338
-
339
- // increase inventory if the payment failed
340
- if ( $canUpdate && !$complete && $canceled && $order->getStatus() != Mage_Sales_Model_Order::STATE_CANCELED ) {
341
- foreach ( $order->getAllItems() as $_item ) {
342
- $qty = $_item->getQtyOrdered();
343
- $stockItem = Mage::getModel( 'cataloginventory/stock_item' )->loadByProduct( $_item->getProductId() );
344
- $stockItemId = $stockItem->getId();
345
- $stock = array();
346
- // then set product's stock data to update
347
- if ( !$stockItemId ) {
348
- $stockItem->setData( 'product_id', $product->getId() );
349
- $stockItem->setData( 'stock_id', 1 );
350
- } else {
351
- $stock = $stockItem->getData();
352
- }
353
-
354
- $oldQty = $stockItem->getData( 'qty' );
355
- $stockItem->setData( 'qty', $oldQty + $qty );
356
- // call save() method to save your product with updated data
357
- try {
358
- $stockItem->save();
359
- // $product->save($p);
360
- } catch ( Exception $ex ) {
361
- // handle the error here!!
362
- }
363
- }
364
- }
365
-
366
- // Lock
367
- $this->lock();
368
-
369
- // Uncancel order if necessary
370
- if ( $undoCancel ) {
371
- foreach ( $order->getAllItems() as $_item ) {
372
- if ( $_item->getQtyCanceled() > 0 )
373
- $_item->setQtyCanceled( 0 )->save();
374
- if ( $_item->getQtyInvoiced() > 0 )
375
- $_item->setQtyInvoiced( 0 )->save();
376
- }
377
-
378
- $order->setBaseDiscountCanceled( 0 )
379
- ->setBaseShippingCanceled( 0 )
380
- ->setBaseSubtotalCanceled( 0 )
381
- ->setBaseTaxCanceled( 0 )
382
- ->setBaseTotalCanceled( 0 )
383
- ->setDiscountCanceled( 0 )
384
- ->setShippingCanceled( 0 )
385
- ->setSubtotalCanceled( 0 )
386
- ->setTaxCanceled( 0 )
387
- ->setTotalCanceled( 0 );
388
- }
389
-
390
- // Update the status if changed
391
- if ( $canUpdate && (($newState != $order->getState()) || ($newStatus != $order->getStatus())) ) {
392
-
393
- // Create an invoice when the payment is completed
394
- if ( $complete && !$canceled && $autocreateInvoice ) {
395
- $invoiceCreated = $this->createInvoice( $order );
396
- if ( $invoiceCreated ) {
397
- $this->log( "Creating invoice for order ID: $id." );
398
- } else {
399
- $this->log( "Unable to create invoice for order ID: $id." );
400
- }
401
-
402
- // Send notification
403
- if ( !$invoiceCreated && $evInvoicingFailed ) {
404
- $this->eventInvoicingFailed( $order );
405
- }
406
- }
407
-
408
- // Set order state and status
409
- $order->setState( $newState, $newStatus, $statusMessage );
410
- $this->log( "Changing state to '$newState' with message '$statusMessage' for order ID: $id." );
411
-
412
- // Send new order e-mail
413
- if ( $complete && !$canceled && !$order->getEmailSent() ) {
414
- $order->sendNewOrderEmail();
415
- $order->setEmailSent( true );
416
- }
417
-
418
- // Save order status changes
419
- $order->save();
420
- }
421
-
422
- // Unlock
423
- $this->unlock();
424
- }
425
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
  }
1
  <?php
2
 
3
  /**
4
+ * Magento CardGate payment extension
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
 
 
8
  */
9
+ class Cardgate_Cgp_Model_Base extends Varien_Object
10
+ {
11
+
12
+ protected $_callback;
13
+
14
+ protected $_config = null;
15
+
16
+ protected $_isLocked = false;
17
+
18
+ protected $_logFileName = "cardgateplus.log";
19
+
20
+ /**
21
+ * Initialize basic cgp settings
22
+ */
23
+ public function _construct ()
24
+ {
25
+ $this->_config = Mage::getStoreConfig( 'cgp/settings' );
26
+ }
27
+
28
+ /**
29
+ * Retrieve config value
30
+ *
31
+ * @param string $field
32
+ * @return mixed
33
+ */
34
+ public function getConfigData ( $field )
35
+ {
36
+ if ( isset( $this->_config[$field] ) ) {
37
+ return $this->_config[$field];
38
+ } else {
39
+ return false;
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Set callback data
45
+ *
46
+ * @param array $data
47
+ * @return Cardgate_Cgp_Model_Base
48
+ */
49
+ public function setCallbackData ( $data )
50
+ {
51
+ $this->_callback = $data;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Get callback data
57
+ *
58
+ * @param string $field
59
+ * @return string
60
+ */
61
+ public function getCallbackData ( $field = null )
62
+ {
63
+ if ( $field === null ) {
64
+ return $this->_callback;
65
+ } else {
66
+ return @$this->_callback[$field];
67
+ }
68
+ }
69
+
70
+ /**
71
+ * If the debug mode is enabled
72
+ *
73
+ * @return bool
74
+ */
75
+ public function isDebug ()
76
+ {
77
+ return $this->getConfigData( 'debug' );
78
+ }
79
+
80
+ /**
81
+ * If the test mode is enabled
82
+ *
83
+ * @return bool
84
+ */
85
+ public function isTest ()
86
+ {
87
+ return ( $this->getConfigData( 'test_mode' ) == "test" );
88
+ }
89
+
90
+ /**
91
+ * Log data into the logfile
92
+ *
93
+ * @param string $msg
94
+ * @return void
95
+ */
96
+ public function log ( $msg )
97
+ {
98
+ if ( $this->getConfigData( 'debug' ) ) {
99
+ Mage::log( $msg, null, $this->_logFileName );
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Create lock file
105
+ *
106
+ * @return Cardgate_Cgp_Model_Base
107
+ */
108
+ public function lock ()
109
+ {
110
+ $varDir = Mage::getConfig()->getVarDir( 'locks' );
111
+ $lockFilename = $varDir . DS . $this->getCallbackData( 'ref' ) . '.lock';
112
+ $fp = @fopen( $lockFilename, 'x' );
113
+
114
+ if ( $fp ) {
115
+ $this->_isLocked = true;
116
+ $pid = getmypid();
117
+ $now = date( 'Y-m-d H:i:s' );
118
+ fwrite( $fp, "Locked by $pid at $now\n" );
119
+ }
120
+
121
+ return $this;
122
+ }
123
+
124
+ /**
125
+ * Unlock file
126
+ *
127
+ * @return Cardgate_Cgp_Model_Base
128
+ */
129
+ public function unlock ()
130
+ {
131
+ $this->_isLocked = false;
132
+ $varDir = Mage::getConfig()->getVarDir( 'locks' );
133
+ $lockFilename = $varDir . DS . $this->getCallbackData( 'ref' ) . '.lock';
134
+ unlink( $lockFilename );
135
+
136
+ return $this;
137
+ }
138
+
139
+ /**
140
+ * Create and mail invoice
141
+ *
142
+ * @param Mage_Sales_Model_Order $order
143
+ * @return boolean
144
+ */
145
+ protected function createInvoice ( Mage_Sales_Model_Order $order )
146
+ {
147
+ if ( $order->canInvoice() && ! $order->hasInvoices() ) {
148
+ $invoice = $order->prepareInvoice();
149
+ $invoice->register();
150
+ if ( $invoice->canCapture() ) {
151
+ $invoice->capture();
152
+ }
153
+
154
+ $invoice->save();
155
+
156
+ Mage::getModel( "core/resource_transaction" )->addObject( $invoice )
157
+ ->addObject( $invoice->getOrder() )
158
+ ->save();
159
+
160
+ $mail_invoice = $this->getConfigData( "mail_invoice" );
161
+ if ( $mail_invoice ) {
162
+ $invoice->setEmailSent( true );
163
+ $invoice->save();
164
+ $invoice->sendEmail();
165
+ }
166
+
167
+ $statusMessage = $mail_invoice ? "Invoice # %s created and send to customer." : "Invoice # %s created.";
168
+ $order->addStatusToHistory( $order->getStatus(),
169
+ Mage::helper( "cgp" )->__( $statusMessage, $invoice->getIncrementId(), $mail_invoice ) );
170
+
171
+ return true;
172
+ }
173
+
174
+ return false;
175
+ }
176
+
177
+ /**
178
+ * Notify shop owners on failed invoicing creation
179
+ *
180
+ * @param Mage_Sales_Model_Order $order
181
+ * @return void
182
+ */
183
+ protected function eventInvoicingFailed ( $order )
184
+ {
185
+ $storeId = $order->getStore()->getId();
186
+
187
+ $ident = Mage::getStoreConfig( 'cgp/settings/notification_email' );
188
+ $sender_email = Mage::getStoreConfig( 'trans_email/ident_general/email', $storeId );
189
+ $sender_name = Mage::getStoreConfig( 'trans_email/ident_general/name', $storeId );
190
+ $recipient_email = Mage::getStoreConfig( 'trans_email/ident_' . $ident . '/email', $storeId );
191
+ $recipient_name = Mage::getStoreConfig( 'trans_email/ident_' . $ident . '/name', $storeId );
192
+
193
+ $mail = new Zend_Mail();
194
+ $mail->setFrom( $sender_email, $sender_name );
195
+ $mail->addTo( $recipient_email, $recipient_name );
196
+ $mail->setSubject( Mage::helper( "cgp" )->__( 'Automatic invoice creation failed' ) );
197
+ $mail->setBodyText(
198
+ Mage::helper( "cgp" )->__(
199
+ 'Magento was unable to create an invoice for Order # %s after a successful payment via Card Gate (transaction # %s)',
200
+ $order->getIncrementId(), $this->getCallbackData( 'transaction_id' ) ) );
201
+ $mail->setBodyHtml(
202
+ Mage::helper( "cgp" )->__(
203
+ 'Magento was unable to create an invoice for <b>Order # %s</b> after a successful payment via Card Gate <b>(transaction # %s)</b>',
204
+ $order->getIncrementId(), $this->getCallbackData( 'transaction_id' ) ) );
205
+ $mail->send();
206
+ }
207
+
208
+ /**
209
+ * Returns true if the amounts match
210
+ *
211
+ * @param Mage_Sales_Model_Order $order
212
+ * @return boolean
213
+ */
214
+ protected function validateAmount ( Mage_Sales_Model_Order $order )
215
+ {
216
+ $amountInCents = ( int ) sprintf( '%.0f', $order->getGrandTotal() * 100 );
217
+ $callbackAmount = ( int ) $this->getCallbackData( 'amount' );
218
+
219
+ if ( ( $amountInCents != $callbackAmount ) and ( abs( $callbackAmount - $amountInCents ) > 1 ) ) {
220
+ $this->log(
221
+ 'OrderID: ' . $order->getId() . ' do not match amounts. Sent ' . $amountInCents . ', received: ' .
222
+ $callbackAmount );
223
+ $statusMessage = Mage::helper( "cgp" )->__(
224
+ "Hacker attempt: Order total amount does not match CardGate's gross total amount!" );
225
+ $order->addStatusToHistory( $order->getStatus(), $statusMessage );
226
+ $order->save();
227
+ return false;
228
+ }
229
+
230
+ return true;
231
+ }
232
+
233
+ /**
234
+ * Process callback for all transactions
235
+ *
236
+ * @return void
237
+ */
238
+ public function processCallback ()
239
+ {
240
+ $id = $this->getCallbackData( 'ref' );
241
+ $order = Mage::getModel( 'sales/order' );
242
+ $order->loadByIncrementId( $id );
243
+
244
+ // Log callback data
245
+ $this->log( 'Receiving callback data:' );
246
+ $this->log( $this->getCallbackData() );
247
+
248
+ // Validate amount
249
+ if ( ! $this->validateAmount( $order ) ) {
250
+ $this->log( 'Amount validation failed!' );
251
+ exit();
252
+ }
253
+
254
+ $statusPending = $this->getConfigData( "pending_status" );
255
+ $statusComplete = $this->getConfigData( "complete_status" );
256
+ $statusFailed = $this->getConfigData( "failed_status" );
257
+ $statusFraud = $this->getConfigData( "fraud_status" );
258
+ $autocreateInvoice = $this->getConfigData( "autocreate_invoice" );
259
+ $evInvoicingFailed = $this->getConfigData( "event_invoicing_failed" );
260
+
261
+ $complete = false;
262
+ $canceled = false;
263
+ $newState = null;
264
+ $newStatus = true;
265
+ $statusMessage = '';
266
+
267
+ $this->log(
268
+ "Got: {$statusPending}/{$statusComplete}/{$statusFailed}/{$statusFraud}/{$autocreateInvoice}/{$evInvoicingFailed} : " .
269
+ $this->getCallbackData( 'status_id' ) );
270
+
271
+ switch ( $this->getCallbackData( 'status_id' ) ) {
272
+ case "0":
273
+ $complete = false;
274
+ $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
275
+ $newStatus = $statusPending;
276
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Payment sucessfully authorised.' );
277
+ break;
278
+ case "100":
279
+ $complete = false;
280
+ $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
281
+ $newStatus = $statusPending;
282
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Payment sucessfully authorised.' );
283
+ break;
284
+ case "200":
285
+ $complete = true;
286
+ $newState = Mage_Sales_Model_Order::STATE_PROCESSING;
287
+ $newStatus = $statusComplete;
288
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Payment complete.' );
289
+ break;
290
+ case "300":
291
+ $canceled = true;
292
+ $newState = Mage_Sales_Model_Order::STATE_CANCELED;
293
+ $newStatus = $statusFailed;
294
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Payment failed.' );
295
+ break;
296
+ case "301":
297
+ $canceled = true;
298
+ $newState = Mage_Sales_Model_Order::STATE_CANCELED;
299
+ $newStatus = $statusFraud;
300
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Transaction failed, payment is fraud.' );
301
+ break;
302
+ case "308":
303
+ $canceled = true;
304
+ $newState = Mage_Sales_Model_Order::STATE_CANCELED;
305
+ $newStatus = $statusFailed;
306
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Payment expired.' );
307
+ break;
308
+ case "309":
309
+ $canceled = true;
310
+ $newState = Mage_Sales_Model_Order::STATE_CANCELED;
311
+ $newStatus = $statusFailed;
312
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Payment canceled by user.' );
313
+ break;
314
+ case "700":
315
+ // Banktransfer pending status
316
+ $complete = false;
317
+ $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
318
+ $newStatus = $statusPending;
319
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Transaction pending: Waiting for customer action.' );
320
+ $order->sendNewOrderEmail();
321
+ $order->addStatusToHistory( $order->getStatus(), $statusMessage, true );
322
+ $order->save();
323
+ break;
324
+ case "701":
325
+ // Direct debit pending status
326
+ $complete = false;
327
+ $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
328
+ $newStatus = $statusPending;
329
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Transaction pending: Waiting for confirmation.' );
330
+ $order->sendNewOrderEmail();
331
+ $order->addStatusToHistory( $order->getStatus(), $statusMessage, true );
332
+ $order->save();
333
+ break;
334
+ default:
335
+ $msg = 'Status not recognised: ' . $this->getCallbackData( 'status' );
336
+ $this->log( $msg );
337
+ die( $msg );
338
+ }
339
+ // Update only certain states
340
+ $canUpdate = false;
341
+ $undoCancel = false;
342
+ if ( $order->getState() == Mage_Sales_Model_Order::STATE_NEW ||
343
+ $order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT ||
344
+ $order->getState() == Mage_Sales_Model_Order::STATE_CANCELED ) {
345
+ $canUpdate = true;
346
+ }
347
+
348
+ foreach ( $order->getStatusHistoryCollection( true ) as $_item ) {
349
+ // Don't update order status if the payment is complete
350
+ if ( $_item->getStatusLabel() == ucfirst( $statusComplete ) ) {
351
+ $canUpdate = false;
352
+ // Uncancel an order if the payment is considered complete
353
+ } elseif ( ( $_item->getStatusLabel() == ucfirst( $statusFailed ) ) ||
354
+ ( $_item->getStatusLabel() == ucfirst( $statusFraud ) ) ) {
355
+ $undoCancel = true;
356
+ }
357
+ }
358
+
359
+ // increase inventory if the payment failed
360
+ if ( $canUpdate && ! $complete && $canceled && $order->getStatus() != Mage_Sales_Model_Order::STATE_CANCELED ) {
361
+ foreach ( $order->getAllItems() as $_item ) {
362
+ $qty = $_item->getQtyOrdered();
363
+ $stockItem = Mage::getModel( 'cataloginventory/stock_item' )->loadByProduct( $_item->getProductId() );
364
+ $stockItemId = $stockItem->getId();
365
+ $stock = array();
366
+ // then set product's stock data to update
367
+ if ( ! $stockItemId ) {
368
+ // FIXME: This cant work!
369
+ $stockItem->setData( 'product_id', $product->getId() );
370
+ $stockItem->setData( 'stock_id', 1 );
371
+ } else {
372
+ $stock = $stockItem->getData();
373
+ }
374
+
375
+ $oldQty = $stockItem->getData( 'qty' );
376
+ $stockItem->setData( 'qty', $oldQty + $qty );
377
+ // call save() method to save your product with updated data
378
+ try {
379
+ $stockItem->save();
380
+ // $product->save($p);
381
+ } catch ( Exception $ex ) {
382
+ // handle the error here!!
383
+ }
384
+ }
385
+ }
386
+
387
+ // Lock
388
+ $this->lock();
389
+
390
+ // Uncancel order if necessary
391
+ if ( $undoCancel ) {
392
+ foreach ( $order->getAllItems() as $_item ) {
393
+ if ( $_item->getQtyCanceled() > 0 )
394
+ $_item->setQtyCanceled( 0 )->save();
395
+ if ( $_item->getQtyInvoiced() > 0 )
396
+ $_item->setQtyInvoiced( 0 )->save();
397
+ }
398
+
399
+ $order->setBaseDiscountCanceled( 0 )
400
+ ->setBaseShippingCanceled( 0 )
401
+ ->setBaseSubtotalCanceled( 0 )
402
+ ->setBaseTaxCanceled( 0 )
403
+ ->setBaseTotalCanceled( 0 )
404
+ ->setDiscountCanceled( 0 )
405
+ ->setShippingCanceled( 0 )
406
+ ->setSubtotalCanceled( 0 )
407
+ ->setTaxCanceled( 0 )
408
+ ->setTotalCanceled( 0 );
409
+ }
410
+
411
+ // Update the status if changed
412
+ if ( $canUpdate && ( ( $newState != $order->getState() ) || ( $newStatus != $order->getStatus() ) ) ) {
413
+ // Create an invoice when the payment is completed
414
+ if ( $complete && ! $canceled && $autocreateInvoice ) {
415
+ $invoiceCreated = $this->createInvoice( $order );
416
+ if ( $invoiceCreated ) {
417
+ $this->log( "Creating invoice for order ID: $id." );
418
+ } else {
419
+ $this->log( "Unable to create invoice for order ID: $id." );
420
+ }
421
+
422
+ // Send notification
423
+ if ( ! $invoiceCreated && $evInvoicingFailed ) {
424
+ $this->eventInvoicingFailed( $order );
425
+ }
426
+ }
427
+
428
+ // Set order state and status
429
+ $order->setState( $newState, $newStatus, $statusMessage );
430
+ $this->log( "Changing state to '$newState' with message '$statusMessage' for order ID: $id." );
431
+
432
+ // Send new order e-mail
433
+ if ( $complete && ! $canceled && ! $order->getEmailSent() ) {
434
+ $order->sendNewOrderEmail();
435
+ $order->setEmailSent( true );
436
+ }
437
+
438
+ // Save order status changes
439
+ $order->save();
440
+ }
441
+
442
+ // Unlock
443
+ $this->unlock();
444
+ }
445
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Abstract.php CHANGED
@@ -1,565 +1,626 @@
1
  <?php
2
 
3
  /**
4
- * Magento CardGatePlus payment extension
5
  *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- *
13
- * @category Mage
14
- * @package Cardgate_Cgp
15
- * @author Paul Saparov, <support@cardgate.com>
16
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
17
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
  */
19
- abstract class Cardgate_Cgp_Model_Gateway_Abstract extends Mage_Payment_Model_Method_Abstract {
20
-
21
- /**
22
- * Payment Method features
23
- *
24
- * @var mixed
25
- */
26
- protected $_module = 'cgp'; // config root (cgp or payment)
27
- protected $_code; // payment method code (used for loading settings)
28
- protected $_model; // payment model
29
-
30
- /**
31
- * CardGatePlus features
32
- *
33
- * @var mixed
34
- */
35
- protected $_url = 'https://gateway.cardgateplus.com/';
36
- protected $_test_url = 'http://gateway.cardgate.dev/';
37
- protected $_supportedCurrencies = array( 'EUR', 'USD', 'JPY', 'BGN', 'CZK',
38
- 'DKK', 'GBP', 'HUF', 'LTL', 'LVL',
39
- 'PLN', 'RON', 'SEK', 'CHF', 'NOK',
40
- 'HRK', 'RUB', 'TRY', 'AUD', 'BRL',
41
- 'CAD', 'CNY', 'HKD', 'IDR', 'ILS',
42
- 'INR', 'KRW', 'MXN', 'MYR', 'NZD',
43
- 'PHP', 'SGD', 'THB', 'ZAR' );
44
-
45
- /**
46
- * Mage_Payment_Model settings
47
- *
48
- * @var bool
49
- */
50
- protected $_isGateway = true;
51
- protected $_canAuthorize = true;
52
- protected $_canCapture = true;
53
- protected $_canUseInternal = false;
54
- protected $_canUseCheckout = true;
55
- protected $_canUseForMultishipping = false;
56
-
57
- /**
58
- * Return Gateway Url
59
- *
60
- * @return string
61
- */
62
- public function getGatewayUrl() {
63
- if ( $this->is_test_url() ) {
64
- return $this->_test_url;
65
- } else {
66
- return $this->_url;
67
- }
68
- }
69
-
70
- private function is_test_url() {
71
- $url = (isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http');
72
- $url .= '://';
73
- $url.= $_SERVER['SERVER_NAME'];
74
-
75
- if ( strpos( $url, 'dbcorp.nl' ) > 0 ) {
76
- return true;
77
- } else {
78
- return false;
79
- }
80
- }
81
-
82
- /**
83
- * Get plugin version to send to gateway (debugging purposes)
84
- *
85
- * @return string
86
- */
87
- public function getPluginVersion() {
88
- return ( string ) Mage::getConfig()->getNode( 'modules/Cardgate_Cgp/version' );
89
- }
90
-
91
- /**
92
- * Get checkout session namespace
93
- *
94
- * @return Mage_Checkout_Model_Session
95
- */
96
- public function getCheckout() {
97
- return Mage::getSingleton( 'checkout/session' );
98
- }
99
-
100
- /**
101
- * Get current quote
102
- *
103
- * @return Mage_Sales_Model_Quote
104
- */
105
- public function getQuote() {
106
- return $this->getCheckout()->getQuote();
107
- }
108
-
109
- /**
110
- * Get current order
111
- *
112
- * @return Mage_Sales_Model_Order
113
- */
114
- public function getOrder() {
115
- $order = Mage::getModel( 'sales/order' );
116
- $order->loadByIncrementId( $this->getCheckout()->getLastRealOrderId() );
117
- return $order;
118
- }
119
-
120
- /**
121
- * Magento tries to set the order from payment/, instead of cgp/
122
- *
123
- * @param Mage_Sales_Model_Order $order
124
- * @return void
125
- */
126
- public function setSortOrder( $order ) {
127
- $this->sort_order = $this->getConfigData( 'sort_order' );
128
- }
129
-
130
- /**
131
- * Append the current model to the URL
132
- *
133
- * @param string $url
134
- * @return string
135
- */
136
- function getModelUrl( $url ) {
137
- if ( !empty( $this->_model ) ) {
138
- $url .= '/model/' . $this->_model;
139
- }
140
- return Mage::getUrl( $url, array( '_secure' => true ) );
141
- }
142
-
143
- /**
144
- * Magento will use this for payment redirection
145
- *
146
- * @return string
147
- */
148
- public function getOrderPlaceRedirectUrl() {
149
- $_SESSION['cgp_formdata'] = $_POST;
150
- return $this->getModelUrl( 'cgp/standard/redirect' );
151
- }
152
-
153
- /**
154
- * Retrieve config value for store by path
155
- *
156
- * @param string $path
157
- * @param mixed $store
158
- * @return mixed
159
- */
160
- public function getConfigData( $field, $storeId = null ) {
161
- if ( $storeId === null ) {
162
- $storeId = $this->getStore();
163
- }
164
-
165
- $configSettings = Mage::getStoreConfig( $this->_module . '/settings', $storeId );
166
- $configGateway = Mage::getStoreConfig( $this->_module . '/' . $this->_code, $storeId );
167
- $config = array_merge( $configSettings, $configGateway );
168
-
169
- return @$config[$field];
170
- }
171
-
172
- /**
173
- * Validate if the currency code is supported by Card Gate Plus
174
- *
175
- * @return Cardgate_Cgp_Model_Abstract
176
- */
177
- public function validate() {
178
- parent::validate();
179
- $base = Mage::getSingleton( 'cgp/base' );
180
-
181
- $currency_code = $this->getQuote()->getBaseCurrencyCode();
182
- if ( empty( $currency_code ) ) {
183
- $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
184
- }
185
- if ( !in_array( $currency_code, $this->_supportedCurrencies ) ) {
186
- $base->log( 'Unacceptable currency code (' . $currency_code . ').' );
187
- Mage::throwException(
188
- Mage::helper( 'cgp' )->__( 'Selected currency code ' ) . $currency_code .
189
- Mage::helper( 'cgp' )->__( ' is not compatible with Card Gate Plus' ) );
190
- }
191
-
192
- return $this;
193
- }
194
-
195
- /**
196
- * Change order status
197
- *
198
- * @param Mage_Sales_Model_Order $order
199
- * @return void
200
- */
201
- protected function initiateTransactionStatus( $order ) {
202
- // Change order status
203
- $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
204
- $newStatus = $this->getConfigData( 'initialized_status' );
205
- $statusMessage = Mage::helper( 'cgp' )->__( 'Transaction started, waiting for payment.' );
206
- if ( $order->getState() != Mage_Sales_Model_Order::STATE_PROCESSING ) {
207
- $order->setState( $newState, $newStatus, $statusMessage );
208
- $order->save();
209
- }
210
- }
211
-
212
- /**
213
- * Generates checkout form fields
214
- *
215
- * @return array
216
- */
217
- public function getCheckoutFormFields() {
218
-
219
- $base = Mage::getSingleton( 'cgp/base' );
220
- $extra_data = $_SESSION['cgp_formdata']['payment']['cgp'];
221
-
222
- $order = $this->getOrder();
223
-
224
- if ( !$this->getConfigData( 'orderemail_at_payment' ) ) {
225
- $order->sendNewOrderEmail();
226
- $order->setEmailSent( true );
227
- }
228
- $customer = $order->getBillingAddress();
229
-
230
- $s_arr = array();
231
- $s_arr['language'] = $this->getConfigData( 'lang' );
232
-
233
- switch ( $this->_model ) {
234
- // CreditCards
235
- case 'visa':
236
- case 'mastercard':
237
- case 'americanexpress':
238
- case 'maestro':
239
- case 'cartebleue':
240
- case 'cartebancaire':
241
- case 'vpay':
242
- $s_arr['option'] = 'creditcard';
243
- break;
244
-
245
- // DIRECTebanking, Sofortbanking
246
- case 'sofortbanking':
247
- $s_arr['option'] = 'directebanking';
248
- break;
249
-
250
- // iDEAL
251
- case 'ideal':
252
- $s_arr['option'] = 'ideal';
253
- $s_arr['suboption'] = $extra_data['ideal_issuer_id'];
254
- break;
255
-
256
- // Giropay
257
- case 'giropay':
258
- $s_arr['option'] = 'giropay';
259
- break;
260
-
261
- // Mister Cash
262
- case 'mistercash':
263
- $s_arr['option'] = 'mistercash';
264
- break;
265
-
266
- // PayPal
267
- case 'paypal':
268
- $s_arr['option'] = 'paypal';
269
- break;
270
-
271
- // Webmoney
272
- case 'webmoney':
273
- $s_arr['option'] = 'webmoney';
274
- break;
275
-
276
- // Klarna
277
- case 'klarna':
278
- $s_arr['option'] = 'klarna';
279
- if ( isset( $extra_data['klarna-personal-number'] ) ) {
280
- $s_arr['dob'] = $extra_data['klarna-personal-number'];
281
- } else {
282
- $s_arr['dob'] = $extra_data['klarna-dob_day'] . '-' . $extra_data['klarna-dob_month'] . '-' . $extra_data['klarna-dob_year'];
283
- $s_arr['gender'] = $extra_data['klarna-gender'];
284
- }
285
- $s_arr['language'] = $extra_data['klarna-language'];
286
- $s_arr['account'] = 0;
287
-
288
- $cartitems = array();
289
-
290
- foreach ( $order->getAllItems() as $itemId => $item ) {
291
- // add item
292
- if ( $item->getQtyToInvoice() > 0 ) {
293
- $cartitem = array();
294
- $cartitem['qty'] = $item->getQtyToInvoice();
295
- $cartitem['id'] = $item->getSku();
296
- $cartitem['name'] = $item->getName();
297
- $cartitem['price'] = sprintf( '%01.2f', ( float ) $item->getPriceInclTax() );
298
-
299
- $item_tax = ( float ) $item->getData( 'tax_percent' );
300
- $cartitem['vat'] = $item_tax;
301
- //$cartitem['discount'] = sprintf( '%01.2f', $item->getData( 'discount_percent' ) );
302
- if ( $item_tax > 0 ) {
303
- $cartitem['flags'] = 32;
304
- } else {
305
- $cartitem['flags'] = 0;
306
- }
307
- $cartitems[] = $cartitem;
308
- }
309
- }
310
-
311
- if ( $order->getDiscountAmount() < 0 ) {
312
- $amount = $order->getDiscountAmount();
313
- $applyAfter = Mage::helper( 'tax' )->applyTaxAfterDiscount(
314
- $order->getStoreId()
315
- );
316
- if ( $applyAfter == true ) {
317
- //With this setting active the discount will not have the correct
318
- //value. We need to take each respective products rate and calculate
319
- //a new value.
320
- $amount = 0;
321
- foreach ( $order->getAllVisibleItems() as $product ) {
322
- $rate = $product->getTaxPercent();
323
- $newAmount = $product->getDiscountAmount() * (($rate / 100 ) + 1);
324
- $amount -= $newAmount;
325
- }
326
- //If the discount also extends to shipping
327
- $shippingDiscount = $order->getShippingDiscountAmount();
328
- if ( $shippingDiscount ) {
329
- $taxClass = Mage::getStoreConfig( 'tax/classes/shipping_tax_class' );
330
- $rate = $this->getTaxRate( $taxClass );
331
- $newAmount = $shippingDiscount * (($rate / 100 ) + 1);
332
- $amount -= $newAmount;
333
- }
334
- }
335
-
336
- $discount = array();
337
- $discount['qty'] = 1;
338
- $discount['id'] = '';
339
- $discount['name'] = 'Discount total';
340
- $discount['price'] = sprintf( '%01.2f', round( $amount, 2 ) );
341
- $discount['vat'] = 0;
342
- $discount['flags'] = 32;
343
-
344
- $cartitems[] = $discount;
345
- }
346
-
347
- $settings = Mage::getStoreConfig( 'cgp/cgp_klarna' );
348
- $handlingFee = (isset( $settings['klarna_invoice_fee_ex'] ) ? $settings['klarna_invoice_fee_ex'] : 0);
349
-
350
- //add shipping
351
- if ( $order->getShippingAmount() > 0 ) {
352
-
353
- $tax_info = $order->getFullTaxInfo();
354
-
355
- $flags = 8;
356
- if ( !isset( $tax_info[0]['percent'] ) ) {
357
- $tax_rate = 0;
358
- } else {
359
- $tax_rate = $tax_info[0]['percent'];
360
- $flags += 32;
361
- }
362
-
363
- if ( $handlingFee > 0 ) {
364
- $shippingText = 'Shipping fee + Klarna invoice fee';
365
- } else {
366
- $shippingText = 'Shipping fee';
367
- }
368
- $price = round( $order->getShippingAmount() * (1 + $tax_rate / 100), 2 );
369
- $shipping = array();
370
- $shipping['qty'] = 1;
371
- $shipping['id'] = '';
372
- $shipping['name'] = $shippingText;
373
- $shipping['price'] = sprintf( '%01.2f', $price );
374
-
375
- $shipping['flags'] = $flags;
376
- $shipping['vat'] = $tax_rate;
377
-
378
- $cartitems[] = $shipping;
379
- }
380
-
381
- $s_arr['cartitems'] = serialize( $cartitems );
382
-
383
- break;
384
-
385
- // Klarna
386
- case 'klarnaaccount':
387
- $s_arr['option'] = 'klarna';
388
-
389
- if ( isset( $extra_data['klarna-account-personal-number'] ) ) {
390
- $s_arr['dob'] = $extra_data['klarna-account-personal-number'];
391
- } else {
392
- $s_arr['dob'] = $extra_data['klarna-account-dob_day'] . '-' . $extra_data['klarna-account-dob_month'] . '-' . $extra_data['klarna-account-dob_year'];
393
- $s_arr['gender'] = $extra_data['klarna-account-gender'];
394
- }
395
- $s_arr['language'] = $extra_data['klarna-account-language'];
396
- $s_arr['account'] = 1;
397
-
398
- $cartitems = array();
399
- foreach ( $order->getAllItems() as $itemId => $item ) {
400
- if ( $item->getQtyToInvoice() > 0 ) {
401
- $cartitem = array();
402
- $cartitem['qty'] = $item->getQtyToInvoice();
403
- $cartitem['id'] = $item->getSku();
404
- $cartitem['name'] = $item->getName();
405
-
406
- $cartitem['price'] = sprintf( '%01.2f', ( float ) $item->getPriceInclTax() );
407
-
408
-
409
-
410
- $item_tax = ( float ) $item->getData( 'tax_percent' );
411
- $cartitem['vat'] = $item_tax;
412
- if ( $item_tax > 0 ) {
413
- $cartitem['flags'] = 32;
414
- } else {
415
- $cartitem['flags'] = 0;
416
- }
417
- $cartitems[] = $cartitem;
418
- }
419
- }
420
-
421
- if ( $order->getDiscountAmount() < 0 ) {
422
- $amount = $order->getDiscountAmount();
423
- $applyAfter = Mage::helper( 'tax' )->applyTaxAfterDiscount(
424
- $order->getStoreId()
425
- );
426
- if ( $applyAfter == true ) {
427
- //With this setting active the discount will not have the correct
428
- //value. We need to take each respective products rate and calculate
429
- //a new value.
430
- $amount = 0;
431
- foreach ( $order->getAllVisibleItems() as $product ) {
432
- $rate = $product->getTaxPercent();
433
- $newAmount = $product->getDiscountAmount() * (($rate / 100 ) + 1);
434
- $amount -= $newAmount;
435
- }
436
- //If the discount also extends to shipping
437
- $shippingDiscount = $order->getShippingDiscountAmount();
438
- if ( $shippingDiscount ) {
439
- $taxClass = Mage::getStoreConfig( 'tax/classes/shipping_tax_class' );
440
- $rate = $this->getTaxRate( $taxClass );
441
- $newAmount = $shippingDiscount * (($rate / 100 ) + 1);
442
- $amount -= $newAmount;
443
- }
444
- }
445
-
446
- $discount = array();
447
- $discount['qty'] = 1;
448
- $discount['id'] = '';
449
- $discount['name'] = 'Discount total';
450
- $discount['price'] = sprintf( '%01.2f', round( $amount, 2 ) );
451
- $discount['vat'] = 0;
452
- $discount['flags'] = 32;
453
-
454
- $cartitems[] = $discount;
455
- }
456
-
457
- //add shipping
458
- if ( $order->getShippingAmount() > 0 ) {
459
-
460
- $tax_info = $order->getFullTaxInfo();
461
-
462
- $flags = 8;
463
- if ( !isset( $tax_info[0]['percent'] ) ) {
464
- $tax_rate = 0;
465
- } else {
466
- $tax_rate = $tax_info[0]['percent'];
467
- $flags += 32;
468
- }
469
-
470
- if ( $handlingFee > 0 ) {
471
- $shippingText = 'Shipping fee + Klarna invoice fee';
472
- } else {
473
- $shippingText = 'Shipping fee';
474
- }
475
- $price = round( $order->getShippingAmount() * (1 + $tax_rate / 100), 2 );
476
- $shipping = array();
477
- $shipping['qty'] = 1;
478
- $shipping['id'] = '';
479
- $shipping['name'] = $shippingText;
480
- $shipping['price'] = sprintf( '%01.2f', $price );
481
-
482
- $shipping['flags'] = $flags;
483
- $shipping['vat'] = $tax_rate;
484
-
485
- $cartitems[] = $shipping;
486
- }
487
- $s_arr['cartitems'] = serialize( $cartitems );
488
- break;
489
-
490
- // Banktransfer
491
- case 'banktransfer':
492
- $s_arr['option'] = 'banktransfer';
493
- break;
494
-
495
- // Directdebit
496
- case 'directdebit':
497
- $s_arr['option'] = 'directdebit';
498
- break;
499
-
500
- // Przelewy24
501
- case 'przelewy24':
502
- $s_arr['option'] = 'przelewy24';
503
- break;
504
-
505
- // Default
506
- default:
507
- $s_arr['option'] = '';
508
- $s_arr['suboption'] = '';
509
- break;
510
- }
511
-
512
- // Add new state
513
- $this->initiateTransactionStatus( $order );
514
-
515
-
516
- $s_arr['siteid'] = $this->getConfigData( 'site_id' );
517
- $s_arr['ref'] = $order->getIncrementId();
518
- $s_arr['first_name'] = $customer->getFirstname();
519
- $s_arr['last_name'] = $customer->getLastname();
520
- $s_arr['email'] = $order->getCustomerEmail();
521
- $s_arr['address'] = $customer->getStreet( 1 ) .
522
- ($customer->getStreet( 2 ) ? ', ' . $customer->getStreet( 2 ) : '');
523
- $s_arr['city'] = $customer->getCity();
524
- $s_arr['country_code'] = $customer->getCountry();
525
- $s_arr['postal_code'] = $customer->getPostcode();
526
- $s_arr['phone_number'] = $customer->getTelephone();
527
- $s_arr['state'] = $customer->getRegionCode();
528
-
529
- if ( $this->getConfigData( 'use_backoffice_urls' ) == false ) {
530
- $s_arr['return_url'] = Mage::getUrl( 'cgp/standard/success/', array( '_secure' => true ) );
531
- $s_arr['return_url_failed'] = Mage::getUrl( 'cgp/standard/cancel/', array( '_secure' => true ) );
532
- }
533
-
534
- $s_arr['shop_version'] = 'Magento ' . Mage::getVersion();
535
- $s_arr['plugin_name'] = 'Cardgate_Cgp';
536
- $s_arr['plugin_version'] = $this->getPluginVersion();
537
- $s_arr['extra'] = $this->getCheckout()->getCardgateQuoteId();
538
-
539
- if ( $base->isTest() ) {
540
- $s_arr['test'] = '1';
541
- $hash_prefix = 'TEST';
542
- } else {
543
- $hash_prefix = '';
544
- }
545
-
546
- $s_arr['amount'] = sprintf( '%.0f', $order->getGrandTotal() * 100 );
547
- $s_arr['currency'] = $order->getOrderCurrencyCode();
548
- $s_arr['description'] = str_replace( '%id%', $order->getIncrementId(), $this->getConfigData( 'order_description' ) );
549
- $s_arr['hash'] = md5( $hash_prefix .
550
- $this->getConfigData( 'site_id' ) .
551
- $s_arr['amount'] .
552
- $s_arr['ref'] .
553
- $this->getConfigData( 'hash_key' ) );
554
-
555
- // Logging
556
- $base->log( 'Initiating a new transaction' );
557
- $base->log( 'Sending customer to Card Gate Plus with values:' );
558
- $base->log( 'URL = ' . $this->getGatewayUrl() );
559
- $base->log( $s_arr );
560
-
561
- $locale = Mage::app()->getLocale()->getLocaleCode();
562
- return $s_arr;
563
- }
564
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  }
1
  <?php
2
 
3
  /**
4
+ * Magento CardGate payment extension
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
 
 
8
  */
9
+ abstract class Cardgate_Cgp_Model_Gateway_Abstract extends Mage_Payment_Model_Method_Abstract
10
+ {
11
+
12
+ /**
13
+ * config root (cgp or payment)
14
+ *
15
+ * @var string
16
+ */
17
+ protected $_module = 'cgp';
18
+
19
+ /**
20
+ * payment method code (used for loading settings)
21
+ *
22
+ * @var string
23
+ */
24
+ protected $_code;
25
+
26
+ /**
27
+ * payment model
28
+ *
29
+ * @var string
30
+ */
31
+ protected $_model;
32
+
33
+ /**
34
+ * Paymentgateway URL
35
+ *
36
+ * @var string
37
+ */
38
+ protected $_url = 'https://gateway.cardgateplus.com/';
39
+
40
+ /**
41
+ * supported countries
42
+ *
43
+ * @var array
44
+ */
45
+ protected $_supportedCurrencies = array(
46
+ 'EUR',
47
+ 'USD',
48
+ 'JPY',
49
+ 'BGN',
50
+ 'CZK',
51
+ 'DKK',
52
+ 'GBP',
53
+ 'HUF',
54
+ 'LTL',
55
+ 'LVL',
56
+ 'PLN',
57
+ 'RON',
58
+ 'SEK',
59
+ 'CHF',
60
+ 'NOK',
61
+ 'HRK',
62
+ 'RUB',
63
+ 'TRY',
64
+ 'AUD',
65
+ 'BRL',
66
+ 'CAD',
67
+ 'CNY',
68
+ 'HKD',
69
+ 'IDR',
70
+ 'ILS',
71
+ 'INR',
72
+ 'KRW',
73
+ 'MXN',
74
+ 'MYR',
75
+ 'NZD',
76
+ 'PHP',
77
+ 'SGD',
78
+ 'THB',
79
+ 'ZAR'
80
+ );
81
+
82
+ /**
83
+ * Mage_Payment_Model settings
84
+ *
85
+ * @var bool
86
+ */
87
+ protected $_isGateway = true;
88
+
89
+ protected $_canAuthorize = true;
90
+
91
+ protected $_canCapture = true;
92
+
93
+ protected $_canUseInternal = false;
94
+
95
+ protected $_canUseCheckout = true;
96
+
97
+ protected $_canUseForMultishipping = false;
98
+
99
+ /**
100
+ * Return Gateway Url
101
+ *
102
+ * @return string
103
+ */
104
+ public function getGatewayUrl ()
105
+ {
106
+ if ( ! empty( $_SERVER['CGP_GATEWAY_URL'] ) ) {
107
+ return $_SERVER['CGP_GATEWAY_URL'];
108
+ } else {
109
+ return $this->_url;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Get plugin version to send to gateway (debugging purposes)
115
+ *
116
+ * @return string
117
+ */
118
+ public function getPluginVersion ()
119
+ {
120
+ return ( string ) Mage::getConfig()->getNode( 'modules/Cardgate_Cgp/version' );
121
+ }
122
+
123
+ /**
124
+ * Get checkout session namespace
125
+ *
126
+ * @return Mage_Checkout_Model_Session
127
+ */
128
+ public function getCheckout ()
129
+ {
130
+ return Mage::getSingleton( 'checkout/session' );
131
+ }
132
+
133
+ /**
134
+ * Get current quote
135
+ *
136
+ * @return Mage_Sales_Model_Quote
137
+ */
138
+ public function getQuote ()
139
+ {
140
+ return $this->getCheckout()->getQuote();
141
+ }
142
+
143
+ /**
144
+ * Get current order
145
+ *
146
+ * @return Mage_Sales_Model_Order
147
+ */
148
+ public function getOrder ()
149
+ {
150
+ $order = Mage::getModel( 'sales/order' );
151
+ $order->loadByIncrementId( $this->getCheckout()
152
+ ->getLastRealOrderId() );
153
+ return $order;
154
+ }
155
+
156
+ /**
157
+ * Magento tries to set the order from payment/, instead of cgp/
158
+ *
159
+ * @param Mage_Sales_Model_Order $order
160
+ * @return void
161
+ */
162
+ public function setSortOrder ( $order )
163
+ {
164
+ $this->sort_order = $this->getConfigData( 'sort_order' );
165
+ }
166
+
167
+ /**
168
+ * Append the current model to the URL
169
+ *
170
+ * @param string $url
171
+ * @return string
172
+ */
173
+ function getModelUrl ( $url )
174
+ {
175
+ if ( ! empty( $this->_model ) ) {
176
+ $url .= '/model/' . $this->_model;
177
+ }
178
+ return Mage::getUrl( $url, array(
179
+ '_secure' => true
180
+ ) );
181
+ }
182
+
183
+ /**
184
+ * Magento will use this for payment redirection
185
+ *
186
+ * @return string
187
+ */
188
+ public function getOrderPlaceRedirectUrl ()
189
+ {
190
+ $_SESSION['cgp_formdata'] = $_POST;
191
+ return $this->getModelUrl( 'cgp/standard/redirect' );
192
+ }
193
+
194
+ /**
195
+ * Retrieve config value for store by path
196
+ *
197
+ * @param string $path
198
+ * @param mixed $store
199
+ * @return mixed
200
+ */
201
+ public function getConfigData ( $field, $storeId = null )
202
+ {
203
+ if ( $storeId === null ) {
204
+ $storeId = $this->getStore();
205
+ }
206
+
207
+ $configSettings = Mage::getStoreConfig( $this->_module . '/settings', $storeId );
208
+ $configGateway = Mage::getStoreConfig( $this->_module . '/' . $this->_code, $storeId );
209
+ $config = array_merge( $configSettings, $configGateway );
210
+
211
+ return @$config[$field];
212
+ }
213
+
214
+ /**
215
+ * Validate if the currency code is supported by Card Gate Plus
216
+ *
217
+ * @return Cardgate_Cgp_Model_Abstract
218
+ */
219
+ public function validate ()
220
+ {
221
+ parent::validate();
222
+ $base = Mage::getSingleton( 'cgp/base' );
223
+
224
+ $currency_code = $this->getQuote()->getBaseCurrencyCode();
225
+ if ( empty( $currency_code ) ) {
226
+ $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
227
+ }
228
+ if ( ! in_array( $currency_code, $this->_supportedCurrencies ) ) {
229
+ $base->log( 'Unacceptable currency code (' . $currency_code . ').' );
230
+ Mage::throwException(
231
+ Mage::helper( 'cgp' )->__( 'Selected currency code ' ) . $currency_code .
232
+ Mage::helper( 'cgp' )->__( ' is not compatible with Card Gate Plus' ) );
233
+ }
234
+
235
+ return $this;
236
+ }
237
+
238
+ /**
239
+ * Change order status
240
+ *
241
+ * @param Mage_Sales_Model_Order $order
242
+ * @return void
243
+ */
244
+ protected function initiateTransactionStatus ( $order )
245
+ {
246
+ // Change order status
247
+ $newState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
248
+ $newStatus = $this->getConfigData( 'initialized_status' );
249
+ $statusMessage = Mage::helper( 'cgp' )->__( 'Transaction started, waiting for payment.' );
250
+ if ( $order->getState() != Mage_Sales_Model_Order::STATE_PROCESSING ) {
251
+ $order->setState( $newState, $newStatus, $statusMessage );
252
+ $order->save();
253
+ }
254
+ }
255
+
256
+ /**
257
+ * Generates checkout form fields
258
+ *
259
+ * @return array
260
+ */
261
+ public function getCheckoutFormFields ()
262
+ {
263
+ $base = Mage::getSingleton( 'cgp/base' );
264
+ $extra_data = $_SESSION['cgp_formdata']['payment']['cgp'];
265
+
266
+ $order = $this->getOrder();
267
+
268
+ if ( ! $this->getConfigData( 'orderemail_at_payment' ) ) {
269
+ $order->sendNewOrderEmail();
270
+ $order->setEmailSent( true );
271
+ }
272
+ $customer = $order->getBillingAddress();
273
+
274
+ $s_arr = array();
275
+ $s_arr['language'] = $this->getConfigData( 'lang' );
276
+
277
+ switch ( $this->_model ) {
278
+ // CreditCards
279
+ case 'visa':
280
+ case 'mastercard':
281
+ case 'americanexpress':
282
+ case 'maestro':
283
+ case 'cartebleue':
284
+ case 'cartebancaire':
285
+ case 'vpay':
286
+ $s_arr['option'] = 'creditcard';
287
+ break;
288
+
289
+ // DIRECTebanking, Sofortbanking
290
+ case 'sofortbanking':
291
+ $s_arr['option'] = 'directebanking';
292
+ break;
293
+
294
+ // iDEAL
295
+ case 'ideal':
296
+ $s_arr['option'] = 'ideal';
297
+ $s_arr['suboption'] = $extra_data['ideal_issuer_id'];
298
+ break;
299
+
300
+ // Giropay
301
+ case 'giropay':
302
+ $s_arr['option'] = 'giropay';
303
+ break;
304
+
305
+ // Mister Cash
306
+ case 'mistercash':
307
+ $s_arr['option'] = 'mistercash';
308
+ break;
309
+
310
+ // PayPal
311
+ case 'paypal':
312
+ $s_arr['option'] = 'paypal';
313
+ break;
314
+
315
+ // Webmoney
316
+ case 'webmoney':
317
+ $s_arr['option'] = 'webmoney';
318
+ break;
319
+
320
+ // Klarna
321
+ case 'klarna':
322
+ $s_arr['option'] = 'klarna';
323
+ if ( isset( $extra_data['klarna-personal-number'] ) ) {
324
+ $s_arr['dob'] = $extra_data['klarna-personal-number'];
325
+ } else {
326
+ $s_arr['dob'] = $extra_data['klarna-dob_day'] . '-' . $extra_data['klarna-dob_month'] . '-' .
327
+ $extra_data['klarna-dob_year'];
328
+ $s_arr['gender'] = $extra_data['klarna-gender'];
329
+ }
330
+ $s_arr['language'] = $extra_data['klarna-language'];
331
+ $s_arr['account'] = 0;
332
+
333
+ $cartitems = array();
334
+
335
+ foreach ( $order->getAllItems() as $itemId => $item ) {
336
+ // add item
337
+ if ( $item->getQtyToInvoice() > 0 ) {
338
+ $cartitem = array();
339
+ $cartitem['qty'] = $item->getQtyToInvoice();
340
+ $cartitem['id'] = $item->getSku();
341
+ $cartitem['name'] = $item->getName();
342
+ $cartitem['price'] = sprintf( '%01.2f', ( float ) $item->getPriceInclTax() );
343
+
344
+ $item_tax = ( float ) $item->getData( 'tax_percent' );
345
+ $cartitem['vat'] = $item_tax;
346
+ // $cartitem['discount'] = sprintf( '%01.2f',
347
+ // $item->getData( 'discount_percent' ) );
348
+ if ( $item_tax > 0 ) {
349
+ $cartitem['flags'] = 32;
350
+ } else {
351
+ $cartitem['flags'] = 0;
352
+ }
353
+ $cartitems[] = $cartitem;
354
+ }
355
+ }
356
+
357
+ if ( $order->getDiscountAmount() < 0 ) {
358
+ $amount = $order->getDiscountAmount();
359
+ $applyAfter = Mage::helper( 'tax' )->applyTaxAfterDiscount( $order->getStoreId() );
360
+ if ( $applyAfter == true ) {
361
+ // With this setting active the discount will not have
362
+ // the correct
363
+ // value. We need to take each respective products rate
364
+ // and calculate
365
+ // a new value.
366
+ $amount = 0;
367
+ foreach ( $order->getAllVisibleItems() as $product ) {
368
+ $rate = $product->getTaxPercent();
369
+ $newAmount = $product->getDiscountAmount() * ( ( $rate / 100 ) + 1 );
370
+ $amount -= $newAmount;
371
+ }
372
+ // If the discount also extends to shipping
373
+ $shippingDiscount = $order->getShippingDiscountAmount();
374
+ if ( $shippingDiscount ) {
375
+ $taxClass = Mage::getStoreConfig( 'tax/classes/shipping_tax_class' );
376
+ $rate = $this->getTaxRate( $taxClass );
377
+ $newAmount = $shippingDiscount * ( ( $rate / 100 ) + 1 );
378
+ $amount -= $newAmount;
379
+ }
380
+ }
381
+
382
+ $discount = array();
383
+ $discount['qty'] = 1;
384
+ $discount['id'] = '';
385
+ $discount['name'] = 'Discount total';
386
+ $discount['price'] = sprintf( '%01.2f', round( $amount, 2 ) );
387
+ $discount['vat'] = 0;
388
+ $discount['flags'] = 32;
389
+
390
+ $cartitems[] = $discount;
391
+ }
392
+
393
+ $settings = Mage::getStoreConfig( 'cgp/cgp_klarna' );
394
+
395
+ // add shipping
396
+ if ( $order->getShippingAmount() > 0 ) {
397
+
398
+ $tax_info = $order->getFullTaxInfo();
399
+
400
+ $flags = 8;
401
+ if ( ! isset( $tax_info[0]['percent'] ) ) {
402
+ $tax_rate = 0;
403
+ } else {
404
+ $tax_rate = $tax_info[0]['percent'];
405
+ $flags += 32;
406
+ }
407
+
408
+ $price = round( $order->getShippingAmount() * ( 1 + $tax_rate / 100 ), 2 );
409
+ $shipping = array();
410
+ $shipping['qty'] = 1;
411
+ $shipping['id'] = '';
412
+ $shipping['name'] = 'Shipping fee';
413
+ $shipping['price'] = sprintf( '%01.2f', $price );
414
+
415
+ $shipping['flags'] = $flags;
416
+ $shipping['vat'] = $tax_rate;
417
+
418
+ $cartitems[] = $shipping;
419
+ }
420
+
421
+ // add invoice fee
422
+ if ( $order->getPayment()->getAdditionalInformation('invoice_fee') > 0 ) {
423
+ $fee = array();
424
+ $fee['qty'] = 1;
425
+ $fee['id'] = '';
426
+ $fee['name'] = 'Invoice fee';
427
+ $fee['price'] = sprintf( '%01.2f', $order->getPayment()->getAdditionalInformation('invoice_fee') );
428
+ $fee['vat'] = $order->getPayment()->getAdditionalInformation('invoice_fee_rate');
429
+ $fee['flags'] = ( $fee['vat'] > 0 ) ? 32 : 0 ;
430
+ $cartitems[] = $fee;
431
+ }
432
+
433
+ $s_arr['cartitems'] = serialize( $cartitems );
434
+
435
+ //var_dump($order->getPayment()->getAdditionalInformation(), $cartitems); die();
436
+ break;
437
+
438
+ // Klarna
439
+ case 'klarnaaccount':
440
+ $s_arr['option'] = 'klarna';
441
+
442
+ if ( isset( $extra_data['klarna-account-personal-number'] ) ) {
443
+ $s_arr['dob'] = $extra_data['klarna-account-personal-number'];
444
+ } else {
445
+ $s_arr['dob'] = $extra_data['klarna-account-dob_day'] . '-' . $extra_data['klarna-account-dob_month'] .
446
+ '-' . $extra_data['klarna-account-dob_year'];
447
+ $s_arr['gender'] = $extra_data['klarna-account-gender'];
448
+ }
449
+ $s_arr['language'] = $extra_data['klarna-account-language'];
450
+ $s_arr['account'] = 1;
451
+
452
+ $cartitems = array();
453
+ foreach ( $order->getAllItems() as $itemId => $item ) {
454
+ if ( $item->getQtyToInvoice() > 0 ) {
455
+ $cartitem = array();
456
+ $cartitem['qty'] = $item->getQtyToInvoice();
457
+ $cartitem['id'] = $item->getSku();
458
+ $cartitem['name'] = $item->getName();
459
+
460
+ $cartitem['price'] = sprintf( '%01.2f', ( float ) $item->getPriceInclTax() );
461
+
462
+ $item_tax = ( float ) $item->getData( 'tax_percent' );
463
+ $cartitem['vat'] = $item_tax;
464
+ if ( $item_tax > 0 ) {
465
+ $cartitem['flags'] = 32;
466
+ } else {
467
+ $cartitem['flags'] = 0;
468
+ }
469
+ $cartitems[] = $cartitem;
470
+ }
471
+ }
472
+
473
+ if ( $order->getDiscountAmount() < 0 ) {
474
+ $amount = $order->getDiscountAmount();
475
+ $applyAfter = Mage::helper( 'tax' )->applyTaxAfterDiscount( $order->getStoreId() );
476
+ if ( $applyAfter == true ) {
477
+ // With this setting active the discount will not have
478
+ // the correct
479
+ // value. We need to take each respective products rate
480
+ // and calculate
481
+ // a new value.
482
+ $amount = 0;
483
+ foreach ( $order->getAllVisibleItems() as $product ) {
484
+ $rate = $product->getTaxPercent();
485
+ $newAmount = $product->getDiscountAmount() * ( ( $rate / 100 ) + 1 );
486
+ $amount -= $newAmount;
487
+ }
488
+ // If the discount also extends to shipping
489
+ $shippingDiscount = $order->getShippingDiscountAmount();
490
+ if ( $shippingDiscount ) {
491
+ $taxClass = Mage::getStoreConfig( 'tax/classes/shipping_tax_class' );
492
+ $rate = $this->getTaxRate( $taxClass );
493
+ $newAmount = $shippingDiscount * ( ( $rate / 100 ) + 1 );
494
+ $amount -= $newAmount;
495
+ }
496
+ }
497
+
498
+ $discount = array();
499
+ $discount['qty'] = 1;
500
+ $discount['id'] = '';
501
+ $discount['name'] = 'Discount total';
502
+ $discount['price'] = sprintf( '%01.2f', round( $amount, 2 ) );
503
+ $discount['vat'] = 0;
504
+ $discount['flags'] = 32;
505
+
506
+ $cartitems[] = $discount;
507
+ }
508
+
509
+ // add shipping
510
+ if ( $order->getShippingAmount() > 0 ) {
511
+
512
+ $tax_info = $order->getFullTaxInfo();
513
+
514
+ $flags = 8;
515
+ if ( ! isset( $tax_info[0]['percent'] ) ) {
516
+ $tax_rate = 0;
517
+ } else {
518
+ $tax_rate = $tax_info[0]['percent'];
519
+ $flags += 32;
520
+ }
521
+
522
+ $price = round( $order->getShippingAmount() * ( 1 + $tax_rate / 100 ), 2 );
523
+ $shipping = array();
524
+ $shipping['qty'] = 1;
525
+ $shipping['id'] = '';
526
+ $shipping['name'] = 'Shipping fee';
527
+ $shipping['price'] = sprintf( '%01.2f', $price );
528
+
529
+ $shipping['flags'] = $flags;
530
+ $shipping['vat'] = $tax_rate;
531
+
532
+ $cartitems[] = $shipping;
533
+ }
534
+
535
+ // add invoice fee
536
+ if ( $order->getPayment()->getAdditionalInformation('invoice_fee') > 0 ) {
537
+ $fee = array();
538
+ $fee['qty'] = 1;
539
+ $fee['id'] = '';
540
+ $fee['name'] = 'Invoice fee';
541
+ $fee['price'] = sprintf( '%01.2f', $order->getPayment()->getAdditionalInformation('invoice_fee') );
542
+ $fee['vat'] = $order->getPayment()->getAdditionalInformation('invoice_fee_rate');
543
+ $fee['flags'] = ( $fee['vat'] > 0 ) ? 32 : 0 ;
544
+ $cartitems[] = $fee;
545
+ }
546
+
547
+ $s_arr['cartitems'] = serialize( $cartitems );
548
+ break;
549
+
550
+ // Banktransfer
551
+ case 'banktransfer':
552
+ $s_arr['option'] = 'banktransfer';
553
+ break;
554
+
555
+ // Directdebit
556
+ case 'directdebit':
557
+ $s_arr['option'] = 'directdebit';
558
+ break;
559
+
560
+ // Przelewy24
561
+ case 'przelewy24':
562
+ $s_arr['option'] = 'przelewy24';
563
+ break;
564
+
565
+ // Default
566
+ default:
567
+ $s_arr['option'] = '';
568
+ $s_arr['suboption'] = '';
569
+ break;
570
+ }
571
+
572
+ // Add new state
573
+ $this->initiateTransactionStatus( $order );
574
+
575
+ $s_arr['siteid'] = $this->getConfigData( 'site_id' );
576
+ $s_arr['ref'] = $order->getIncrementId();
577
+ $s_arr['first_name'] = $customer->getFirstname();
578
+ $s_arr['last_name'] = $customer->getLastname();
579
+ $s_arr['email'] = $order->getCustomerEmail();
580
+ $s_arr['address'] = $customer->getStreet( 1 ) .
581
+ ( $customer->getStreet( 2 ) ? ', ' . $customer->getStreet( 2 ) : '' );
582
+ $s_arr['city'] = $customer->getCity();
583
+ $s_arr['country_code'] = $customer->getCountry();
584
+ $s_arr['postal_code'] = $customer->getPostcode();
585
+ $s_arr['phone_number'] = $customer->getTelephone();
586
+ $s_arr['state'] = $customer->getRegionCode();
587
+
588
+ if ( $this->getConfigData( 'use_backoffice_urls' ) == false ) {
589
+ $s_arr['return_url'] = Mage::getUrl( 'cgp/standard/success/', array(
590
+ '_secure' => true
591
+ ) );
592
+ $s_arr['return_url_failed'] = Mage::getUrl( 'cgp/standard/cancel/', array(
593
+ '_secure' => true
594
+ ) );
595
+ }
596
+
597
+ $s_arr['shop_version'] = 'Magento ' . Mage::getVersion();
598
+ $s_arr['plugin_name'] = 'Cardgate_Cgp';
599
+ $s_arr['plugin_version'] = $this->getPluginVersion();
600
+ $s_arr['extra'] = $this->getCheckout()->getCardgateQuoteId();
601
+
602
+ if ( $base->isTest() ) {
603
+ $s_arr['test'] = '1';
604
+ $hash_prefix = 'TEST';
605
+ } else {
606
+ $hash_prefix = '';
607
+ }
608
+
609
+ $s_arr['amount'] = sprintf( '%.0f', $order->getGrandTotal() * 100 );
610
+ $s_arr['currency'] = $order->getOrderCurrencyCode();
611
+ $s_arr['description'] = str_replace( '%id%', $order->getIncrementId(),
612
+ $this->getConfigData( 'order_description' ) );
613
+ $s_arr['hash'] = md5(
614
+ $hash_prefix . $this->getConfigData( 'site_id' ) . $s_arr['amount'] . $s_arr['ref'] .
615
+ $this->getConfigData( 'hash_key' ) );
616
+
617
+ // Logging
618
+ $base->log( 'Initiating a new transaction' );
619
+ $base->log( 'Sending customer to Card Gate Plus with values:' );
620
+ $base->log( 'URL = ' . $this->getGatewayUrl() );
621
+ $base->log( $s_arr );
622
+
623
+ $locale = Mage::app()->getLocale()->getLocaleCode();
624
+ return $s_arr;
625
+ }
626
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Americanexpress.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Americanexpress extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_americanexpress';
 
 
22
  protected $_model = 'americanexpress';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Americanexpress extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_americanexpress';
13
+
14
  protected $_model = 'americanexpress';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Banktransfer.php CHANGED
@@ -1,25 +1,19 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Banktransfer extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_banktransfer';
 
 
22
  protected $_model = 'banktransfer';
23
- protected $_canUseInternal = true;
24
- protected $_formBlockType = 'cgp/form_banktransfer';
 
 
25
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Banktransfer extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_banktransfer';
13
+
14
  protected $_model = 'banktransfer';
15
+
16
+ protected $_canUseInternal = true;
17
+
18
+ protected $_formBlockType = 'cgp/form_banktransfer';
19
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Cartebancaire.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Cartebancaire extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_cartebancaire';
 
 
22
  protected $_model = 'cartebancaire';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Cartebancaire extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_cartebancaire';
13
+
14
  protected $_model = 'cartebancaire';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Cartebleue.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Cartebleue extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_cartebleue';
 
 
22
  protected $_model = 'cartebleue';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Cartebleue extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_cartebleue';
13
+
14
  protected $_model = 'cartebleue';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Default.php CHANGED
@@ -1,22 +1,12 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Default extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- // Will redirect user to splash screen
22
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Default extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+ // Will redirect user to splash screen
12
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Directdebit.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Directdebit extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_directdebit';
 
 
22
  protected $_model = 'directdebit';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Directdebit extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_directdebit';
13
+
14
  protected $_model = 'directdebit';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Giropay.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Giropay extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_giropay';
 
 
22
  protected $_model = 'giropay';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Giropay extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_giropay';
13
+
14
  protected $_model = 'giropay';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Ideal.php CHANGED
@@ -1,25 +1,19 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Ideal extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_ideal';
 
 
22
  protected $_model = 'ideal';
23
- protected $_canUseInternal = true;
24
- protected $_formBlockType = 'cgp/form_ideal';
 
 
25
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Ideal extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_ideal';
13
+
14
  protected $_model = 'ideal';
15
+
16
+ protected $_canUseInternal = true;
17
+
18
+ protected $_formBlockType = 'cgp/form_ideal';
19
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Klarna.php CHANGED
@@ -1,35 +1,39 @@
1
  <?php
2
 
3
  /**
4
- * Magento CardGatePlus payment extension
5
  *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- *
13
- * @category Mage
14
- * @package Cardgate_Cgp
15
- * @author Paul Saparov, <support@cardgate.com>
16
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
17
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
  */
19
- class Cardgate_Cgp_Model_Gateway_Klarna extends Cardgate_Cgp_Model_Gateway_Abstract {
 
 
 
 
 
20
 
21
- protected $_code = 'cgp_klarna';
22
- protected $_model = 'klarna';
23
- protected $_formBlockType = 'cgp/form_klarna';
24
- protected $_canUseCheckout = false;
25
 
26
- public function __construct() {
27
- parent::__construct();
28
- $klarna_countries = array( 'AT', 'DK', 'FI', 'DE', 'NL', 'NO', 'SE' );
29
- $country = Mage::getSingleton( 'checkout/session' )->getQuote()->getBillingAddress()->getCountry();
30
- if ( isset( $country ) && in_array( $country, $klarna_countries ) ) {
31
- $this->_canUseCheckout = true;
32
- }
33
- }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
1
  <?php
2
 
3
  /**
4
+ * Magento CardGate payment extension
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
 
 
8
  */
9
+ class Cardgate_Cgp_Model_Gateway_Klarna extends Cardgate_Cgp_Model_Gateway_Abstract
10
+ {
11
+
12
+ protected $_code = 'cgp_klarna';
13
+
14
+ protected $_model = 'klarna';
15
 
16
+ protected $_formBlockType = 'cgp/form_klarna';
 
 
 
17
 
18
+ protected $_canUseCheckout = false;
 
 
 
 
 
 
 
19
 
20
+ public function __construct ()
21
+ {
22
+ parent::__construct();
23
+ $klarna_countries = array(
24
+ 'AT',
25
+ 'DK',
26
+ 'FI',
27
+ 'DE',
28
+ 'NL',
29
+ 'NO',
30
+ 'SE'
31
+ );
32
+ $country = Mage::getSingleton( 'checkout/session' )->getQuote()
33
+ ->getBillingAddress()
34
+ ->getCountry();
35
+ if ( isset( $country ) && in_array( $country, $klarna_countries ) ) {
36
+ $this->_canUseCheckout = true;
37
+ }
38
+ }
39
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Klarnaaccount.php CHANGED
@@ -1,36 +1,40 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
  *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Klarnaaccount extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_klarnaaccount';
 
 
22
  protected $_model = 'klarnaaccount';
 
23
  protected $_formBlockType = 'cgp/form_klarnaaccount';
24
- protected $_canUseCheckout = false;
25
-
26
- public function __construct() {
27
- parent::__construct();
28
- // This payment method is not used in Austria;
29
- $klarna_countries = array('DK','FI','DE','NL','NO','SE');
30
- $country = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getCountry();
31
- if (isset($country) && in_array($country,$klarna_countries)){
32
- $this->_canUseCheckout = true;
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
 
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
 
 
 
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Klarnaaccount extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_klarnaaccount';
13
+
14
  protected $_model = 'klarnaaccount';
15
+
16
  protected $_formBlockType = 'cgp/form_klarnaaccount';
17
+
18
+ protected $_canUseCheckout = false;
19
+
20
+ public function __construct ()
21
+ {
22
+ parent::__construct();
23
+ // This payment method is not used in Austria;
24
+ $klarna_countries = array(
25
+ 'DK',
26
+ 'FI',
27
+ 'DE',
28
+ 'NL',
29
+ 'NO',
30
+ 'SE'
31
+ );
32
+ $country = Mage::getSingleton( 'checkout/session' )->getQuote()
33
+ ->getBillingAddress()
34
+ ->getCountry();
35
+ if ( isset( $country ) && in_array( $country, $klarna_countries ) ) {
36
+ $this->_canUseCheckout = true;
37
+ }
38
+ }
39
  }
40
 
app/code/local/Cardgate/Cgp/Model/Gateway/Maestro.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Maestro extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_maestro';
 
 
22
  protected $_model = 'maestro';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Maestro extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_maestro';
13
+
14
  protected $_model = 'maestro';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Mastercard.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Mastercard extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_mastercard';
 
 
22
  protected $_model = 'mastercard';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Mastercard extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_mastercard';
13
+
14
  protected $_model = 'mastercard';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Mistercash.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Mistercash extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_mistercash';
 
 
22
  protected $_model = 'mistercash';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Mistercash extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_mistercash';
13
+
14
  protected $_model = 'mistercash';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Paypal.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Paypal extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_paypal';
 
 
22
  protected $_model = 'paypal';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Paypal extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_paypal';
13
+
14
  protected $_model = 'paypal';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Przelewy24.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Przelewy24 extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_przelewy24';
 
 
22
  protected $_model = 'przelewy24';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Przelewy24 extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_przelewy24';
13
+
14
  protected $_model = 'przelewy24';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Sofortbanking.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Sofortbanking extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_sofortbanking';
 
 
22
  protected $_model = 'sofortbanking';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Sofortbanking extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_sofortbanking';
13
+
14
  protected $_model = 'sofortbanking';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Visa.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Visa extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_visa';
 
 
22
  protected $_model = 'visa';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Visa extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_visa';
13
+
14
  protected $_model = 'visa';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Vpay.php CHANGED
@@ -1,24 +1,17 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Vpay extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_vpay';
 
 
22
  protected $_model = 'vpay';
23
- protected $_canUseInternal = true;
 
24
  }
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Vpay extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_vpay';
13
+
14
  protected $_model = 'vpay';
15
+
16
+ protected $_canUseInternal = true;
17
  }
app/code/local/Cardgate/Cgp/Model/Gateway/Webmoney.php CHANGED
@@ -1,25 +1,18 @@
1
  <?php
 
2
  /**
3
- * Magento CardGatePlus payment extension
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
- *
12
- * @category Mage
13
- * @package Cardgate_Cgp
14
- * @author Paul Saparov, <support@cardgate.com>
15
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
  */
18
-
19
  class Cardgate_Cgp_Model_Gateway_Webmoney extends Cardgate_Cgp_Model_Gateway_Abstract
20
  {
21
- protected $_code = 'cgp_webmoney';
 
 
22
  protected $_model = 'webmoney';
23
- protected $_canUseInternal = true;
 
24
  }
25
 
1
  <?php
2
+
3
  /**
4
+ * Magento CardGate payment extension
 
 
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
8
  */
 
9
  class Cardgate_Cgp_Model_Gateway_Webmoney extends Cardgate_Cgp_Model_Gateway_Abstract
10
  {
11
+
12
+ protected $_code = 'cgp_webmoney';
13
+
14
  protected $_model = 'webmoney';
15
+
16
+ protected $_canUseInternal = true;
17
  }
18
 
app/code/local/Cardgate/Cgp/Model/Observer.php CHANGED
@@ -1,69 +1,70 @@
1
  <?php
2
 
3
  /**
4
- * Event observer
5
  *
6
- * PHP Version 5.3
7
- *
8
- * @category Payment
9
- * @package Klarna_Module_Magento
10
- * @author MS Dev <ms.modules@klarna.com>
11
- * @license http://opensource.org/licenses/BSD-2-Clause BSD2
12
- * @link http://integration.klarna.com
13
  */
 
 
14
 
15
- /**
16
- * Class to observe and handle Magento events
17
- *
18
- * @category Payment
19
- * @package Klarna_Module_Magento
20
- * @author MS Dev <ms.modules@klarna.com>
21
- * @license http://opensource.org/licenses/BSD-2-Clause BSD2
22
- * @link http://integration.klarna.com
23
- */
24
- class Cardgate_Cgp_Model_Observer extends Mage_Core_Model_Abstract {
25
-
26
- public function salesQuoteCollectTotalsBefore( Varien_Event_Observer $observer ) {
27
- /** @var Mage_Sales_Model_Quote $quote */
28
- $quote = $observer->getQuote();
29
-
30
- if ( $quote->getCustomer()->getId() ) {
31
- $address = $quote->getCustomer()->getAddress();
32
-
33
- $payment = $quote->getPayment();
34
-
35
- try {
36
- /**
37
- * Instead of relying on hasMethodInstance which would not always
38
- * work when i.e the order total is reloaded with coupon codes, we
39
- * try to get the instance directly instead.
40
- */
41
- $p = $payment->getMethodInstance();
42
- } catch ( Mage_Core_Exception $e ) {
43
- return;
44
- }
45
- $paymentMethod = $p->getCode();
46
-
47
- // For Klarna invoice, add Invoice fee
48
- if ( $paymentMethod == 'cgp_klarna' ) {
49
-
50
- $settings = Mage::getStoreConfig( 'cgp/cgp_klarna', $quote->getStoreId() );
51
- $fee = floatval( $settings['klarna_invoice_fee_ex'] );
52
-
53
- $store = Mage::app()->getStore( $quote->getStoreId() );
54
- $carriers = Mage::getStoreConfig( 'carriers', $store );
55
-
56
- foreach ( $carriers as $carrierCode => $carrierConfig ) {
57
-
58
- // F for fixed, P for percentage
59
- $store->setConfig( "carriers/{$carrierCode}/handling_type", 'F' );
60
-
61
- // 0 for no fee, otherwise fixed of percentage value
62
- $handlingFee = $store->getConfig( "carriers/{$carrierCode}/handling_fee" );
63
- $store->setConfig( "carriers/{$carrierCode}/handling_fee", $handlingFee + $fee );
64
- }
65
- }
66
- }
67
- }
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  }
1
  <?php
2
 
3
  /**
4
+ * Magento CardGate payment extension
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
8
  */
9
+ class Cardgate_Cgp_Model_Observer extends Mage_Core_Model_Abstract
10
+ {
11
 
12
+ public function salesQuoteCollectTotalsAfter ( Varien_Event_Observer $observer )
13
+ {
14
+ $quote = $observer->getEvent()->getQuote();
15
+ $quote->setInvoiceFee( 0 );
16
+ $quote->setBaseInvoiceFee( 0 );
17
+ $quote->setInvoiceFeeExcludedVat( 0 );
18
+ $quote->setBaseInvoiceFeeExcludedVat( 0 );
19
+ $quote->setInvoiceTaxAmount( 0 );
20
+ $quote->setBaseInvoiceTaxAmount( 0 );
21
+ $quote->setInvoiceFeeRate( 0 );
22
+
23
+ foreach ( $quote->getAllAddresses() as $address ) {
24
+ $quote->setInvoiceFee( ( float ) $quote->getInvoiceFee() + $address->getInvoiceFee() );
25
+ $quote->setBaseInvoiceFee( ( float ) $quote->getBaseInvoiceFee() + $address->getBaseInvoiceFee() );
26
+
27
+ $quoteFeeExclVat = $quote->getInvoiceFeeExcludedVat();
28
+ $addressFeeExclCat = $address->getInvoiceFeeExcludedVat();
29
+ $quote->setInvoiceFeeExcludedVat( ( float ) $quoteFeeExclVat + $addressFeeExclCat );
30
+
31
+ $quoteBaseFeeExclVat = $quote->getBaseInvoiceFeeExcludedVat();
32
+ $addressBaseFeeExclVat = $address->getBaseInvoiceFeeExcludedVat();
33
+ $quote->setBaseInvoiceFeeExcludedVat( ( float ) $quoteBaseFeeExclVat + $addressBaseFeeExclVat );
34
+
35
+ $quoteFeeTaxAmount = $quote->getInvoiceTaxAmount();
36
+ $addressFeeTaxAmount = $address->getInvoiceTaxAmount();
37
+ $quote->setInvoiceTaxAmount( ( float ) $quoteFeeTaxAmount + $addressFeeTaxAmount );
38
+
39
+ $quoteBaseFeeTaxAmount = $quote->getBaseInvoiceTaxAmount();
40
+ $addressBaseFeeTaxAmount = $address->getBaseInvoiceTaxAmount();
41
+ $quote->setBaseInvoiceTaxAmount( ( float ) $quoteBaseFeeTaxAmount + $addressBaseFeeTaxAmount );
42
+ $quote->setInvoiceFeeRate( $address->getInvoiceFeeRate() );
43
+ }
44
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ public function salesOrderPaymentPlaceEnd ( Varien_Event_Observer $observer )
47
+ {
48
+ $payment = $observer->getPayment();
49
+
50
+ if ( substr( $payment->getMethodInstance()->getCode(), 0, 3 ) != 'cgp' ) {
51
+ return;
52
+ }
53
+
54
+ $info = $payment->getMethodInstance()->getInfoInstance();
55
+ $quote = Mage::getSingleton( 'checkout/session' )->getQuote();
56
+ if ( ! $quote->getId() ) {
57
+ $quote = Mage::getSingleton( 'adminhtml/session_quote' )->getQuote();
58
+ }
59
+
60
+ $info->setAdditionalInformation( 'invoice_fee', $quote->getInvoiceFee() );
61
+ $info->setAdditionalInformation( 'base_invoice_fee', $quote->getBaseInvoiceFee() );
62
+ $info->setAdditionalInformation( 'invoice_fee_exluding_vat', $quote->getInvoiceFeeExcludedVat() );
63
+ $info->setAdditionalInformation( 'base_invoice_fee_exluding_vat', $quote->getBaseInvoiceFeeExcludedVat() );
64
+ $info->setAdditionalInformation( 'invoice_tax_amount', $quote->getInvoiceTaxAmount() );
65
+ $info->setAdditionalInformation( 'base_invoice_tax_amount', $quote->getBaseInvoiceTaxAmount() );
66
+ $info->setAdditionalInformation( 'invoice_fee_rate', $quote->getInvoiceFeeRate() );
67
+
68
+ $info->save();
69
+ }
70
  }
app/code/local/Cardgate/Cgp/Model/Paymentfee/Creditmemo/Total.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento CardGate payment extension
4
+ *
5
+ * @category Mage
6
+ * @package Cardgate_Cgp
7
+ */
8
+
9
+ class Cardgate_Cgp_Model_Paymentfee_Creditmemo_Total extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
10
+ {
11
+
12
+ /**
13
+ * Collect the order total
14
+ *
15
+ * @param object $creditmemo The Creditmemo instance to collect from
16
+ *
17
+ * @return Mage_Sales_Model_Order_Creditmemo_Total_Abstract
18
+ */
19
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
20
+ {
21
+ $method = $creditmemo->getOrder()->getPayment()->getMethodInstance();
22
+
23
+ if (substr($method->getCode(), 0, 3) != 'cgp') {
24
+ return $this;
25
+ }
26
+
27
+ $info = $method->getInfoInstance();
28
+
29
+ if (!$info) {
30
+ return $this;
31
+ }
32
+
33
+ $invoiceFee = $info->getAdditionalInformation('invoice_fee');
34
+ $baseInvoiceFee = $info->getAdditionalInformation('base_invoice_fee');
35
+
36
+ if (!$invoiceFee) {
37
+ return $this;
38
+ }
39
+
40
+ $creditmemo->setBaseGrandTotal(
41
+ ($creditmemo->getBaseGrandTotal() + $baseInvoiceFee)
42
+ );
43
+ $creditmemo->setGrandTotal(
44
+ ($creditmemo->getGrandTotal() + $invoiceFee)
45
+ );
46
+
47
+ $creditmemo->setBaseInvoiceFee($baseInvoiceFee);
48
+ $creditmemo->setInvoiceFee($invoiceFee);
49
+
50
+ $tax = $info->getAdditionalInformation('invoice_tax_amount');
51
+ $baseTax = $info->getAdditionalInformation('base_invoice_tax_amount');
52
+
53
+ if (!$tax) {
54
+ return $this;
55
+ }
56
+
57
+ $creditmemo->setBaseTaxAmount(
58
+ $creditmemo->getBaseTaxAmount() + $baseTax
59
+ );
60
+ $creditmemo->setTaxAmount(
61
+ $creditmemo->getTaxAmount() + $tax
62
+ );
63
+
64
+
65
+
66
+ return $this;
67
+ }
68
+ }
app/code/local/Cardgate/Cgp/Model/Paymentfee/Invoice/Pdf/Total.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento CardGate payment extension
4
+ *
5
+ * @category Mage
6
+ * @package Cardgate_Cgp
7
+ */
8
+
9
+ class Cardgate_Model_Paymentfee_Invoice_Pdf_Total extends Mage_Sales_Model_Order_Pdf_Total_Default
10
+ {
11
+
12
+ /**
13
+ * Get array of arrays with totals information
14
+ *
15
+ * @return array
16
+ */
17
+ public function getTotalsForDisplay()
18
+ {
19
+ $fee = $this->getAmount();
20
+ $order = $this->getOrder();
21
+ $incl = $order->formatPriceTxt($fee['incl']);
22
+ $excl = $order->formatPriceTxt($fee['excl']);
23
+ if ($this->getAmountPrefix()) {
24
+ $incl = $this->getAmountPrefix() . $incl;
25
+ $excl = $this->getAmountPrefix() . $excl;
26
+ }
27
+
28
+ $storeId = Mage::app()->getStore()->getId();
29
+ $vatOption = Mage::getStoreConfig("tax/sales_display/shipping", $storeId);
30
+ $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
31
+ $label = Mage::getStoreConfig('cgp/'.$order->getPayment()->getMethod().'/payment_fee_label');
32
+ $totals = array();
33
+ /**
34
+ * 1 : Show exluding tax
35
+ * 2 : Show including tax
36
+ * 3 : Show both
37
+ */
38
+ if ($vatOption == '1' || $vatOption == '3') {
39
+ $total = array(
40
+ 'amount' => $excl,
41
+ 'font_size' => $fontSize
42
+ );
43
+ $exclLabel = $label;
44
+ if ($vatOption == '3') {
45
+ $exclLabel .= ' (Excl.Tax)';
46
+ }
47
+ $exclLabel .= ":";
48
+
49
+ $total['label'] = $exclLabel;
50
+ $totals[] = $total;
51
+ }
52
+ if ($vatOption == '2' || $vatOption == '3') {
53
+ $total = array(
54
+ 'amount' => $incl,
55
+ 'font_size' => $fontSize
56
+ );
57
+ $inclLabel = $label;
58
+ if ($vatOption == '3') {
59
+ $inclLabel .= ' (Incl.Tax)';
60
+ }
61
+ $inclLabel .= ":";
62
+ $total['label'] = $inclLabel;
63
+ $totals[] = $total;
64
+ }
65
+
66
+ return $totals;
67
+ }
68
+
69
+ /**
70
+ * Check if we can display total information in PDF
71
+ *
72
+ * @return bool
73
+ */
74
+ public function canDisplay()
75
+ {
76
+ $amount = $this->getAmount();
77
+ return ($amount["incl"] !== 0);
78
+ }
79
+
80
+ /**
81
+ * Get Total amount from source
82
+ *
83
+ * @return array
84
+ */
85
+ public function getAmount()
86
+ {
87
+ $payment = $this->getOrder()->getPayment();
88
+ $incl = $payment->getAdditionalInformation("invoice_fee");
89
+ $excl = $payment->getAdditionalInformation("invoice_fee_exluding_vat");
90
+ return array(
91
+ 'incl' => ($incl ? $incl : 0),
92
+ 'excl' => ($excl ? $excl : 0)
93
+ );
94
+ }
95
+
96
+ }
app/code/local/Cardgate/Cgp/Model/Paymentfee/Invoice/Tax.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento CardGate payment extension
4
+ *
5
+ * @category Mage
6
+ * @package Cardgate_Cgp
7
+ */
8
+
9
+
10
+ class Cardgate_Cgp_Model_Paymentfee_Invoice_Tax extends Mage_Sales_Model_Order_Invoice_Total_Abstract
11
+ {
12
+ /**
13
+ * Collect invoice tax amount
14
+ *
15
+ * @param Mage_Sales_Model_Order_Invoice $invoice
16
+ * @return Mage_Sales_Model_Order_Invoice_Total_Tax
17
+ */
18
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
19
+ {
20
+
21
+ $totalTax = 0;
22
+ $baseTotalTax = 0;
23
+ $totalHiddenTax = 0;
24
+ $baseTotalHiddenTax = 0;
25
+ $order = $invoice->getOrder();
26
+
27
+ /** @var $item Mage_Sales_Model_Order_Invoice_Item */
28
+ foreach ($invoice->getAllItems() as $item) {
29
+ $orderItem = $item->getOrderItem();
30
+ $orderItemQty = $orderItem->getQtyOrdered();
31
+
32
+ if ($orderItem->getTaxAmount() && $orderItemQty) {
33
+ if ($item->getOrderItem()->isDummy()) {
34
+ continue;
35
+ }
36
+
37
+ $tax = $orderItem->getTaxAmount() - $orderItem->getTaxInvoiced();
38
+ $baseTax = $orderItem->getBaseTaxAmount() - $orderItem->getBaseTaxInvoiced();
39
+ $hiddenTax = $orderItem->getHiddenTaxAmount() - $orderItem->getHiddenTaxInvoiced();
40
+ $baseHiddenTax = $orderItem->getBaseHiddenTaxAmount() - $orderItem->getBaseHiddenTaxInvoiced();
41
+ if (!$item->isLast()) {
42
+ $availableQty = $orderItemQty - $orderItem->getQtyInvoiced();
43
+ $tax = $invoice->roundPrice($tax / $availableQty * $item->getQty());
44
+ $baseTax = $invoice->roundPrice($baseTax / $availableQty * $item->getQty(), 'base');
45
+ $hiddenTax = $invoice->roundPrice($hiddenTax / $availableQty * $item->getQty());
46
+ $baseHiddenTax = $invoice->roundPrice($baseHiddenTax / $availableQty * $item->getQty(), 'base');
47
+ }
48
+
49
+ $item->setTaxAmount($tax);
50
+ $item->setBaseTaxAmount($baseTax);
51
+ $item->setHiddenTaxAmount($hiddenTax);
52
+ $item->setBaseHiddenTaxAmount($baseHiddenTax);
53
+
54
+ $totalTax += $tax;
55
+ $baseTotalTax += $baseTax;
56
+ $totalHiddenTax += $hiddenTax;
57
+ $baseTotalHiddenTax += $baseHiddenTax;
58
+ }
59
+ }
60
+
61
+ if ($this->_canIncludeShipping($invoice)) {
62
+ $totalTax += $order->getShippingTaxAmount();
63
+ $baseTotalTax += $order->getBaseShippingTaxAmount();
64
+ $totalHiddenTax += $order->getShippingHiddenTaxAmount();
65
+ $baseTotalHiddenTax += $order->getBaseShippingHiddenTaxAmount();
66
+ $invoice->setShippingTaxAmount($order->getShippingTaxAmount());
67
+ $invoice->setBaseShippingTaxAmount($order->getBaseShippingTaxAmount());
68
+ $invoice->setShippingHiddenTaxAmount($order->getShippingHiddenTaxAmount());
69
+ $invoice->setBaseShippingHiddenTaxAmount($order->getBaseShippingHiddenTaxAmount());
70
+ }
71
+ $allowedTax = $order->getTaxAmount() - $order->getTaxInvoiced();
72
+ $allowedBaseTax = $order->getBaseTaxAmount() - $order->getBaseTaxInvoiced();;
73
+ $allowedHiddenTax = $order->getHiddenTaxAmount() + $order->getShippingHiddenTaxAmount()
74
+ - $order->getHiddenTaxInvoiced() - $order->getShippingHiddenTaxInvoiced();
75
+ $allowedBaseHiddenTax = $order->getBaseHiddenTaxAmount() + $order->getBaseShippingHiddenTaxAmount()
76
+ - $order->getBaseHiddenTaxInvoiced() - $order->getBaseShippingHiddenTaxInvoiced();
77
+
78
+ // FIXME: YYY: This is defect. isLast() is failing when configurable products are added in the cart.
79
+ // This is surely failing but then again also working because of the min(a,b)...
80
+ if ($invoice->isLast()) {
81
+ $totalTax = $allowedTax;
82
+ $baseTotalTax = $allowedBaseTax;
83
+ $totalHiddenTax = $allowedHiddenTax;
84
+ $baseTotalHiddenTax = $allowedBaseHiddenTax;
85
+ } else {
86
+ $info = $order->getPayment()->getMethodInstance()->getInfoInstance();
87
+ $totalTax+= $info->getAdditionalInformation('invoice_tax_amount');
88
+ $baseTotalTax+= $info->getAdditionalInformation('base_invoice_tax_amount');
89
+
90
+ $totalTax = min($allowedTax, $totalTax);
91
+ $baseTotalTax = min($allowedBaseTax, $baseTotalTax);
92
+ $totalHiddenTax = min($allowedHiddenTax, $totalHiddenTax);
93
+ $baseTotalHiddenTax = min($allowedBaseHiddenTax, $baseTotalHiddenTax);
94
+ }
95
+
96
+ $invoice->setTaxAmount($totalTax);
97
+ $invoice->setBaseTaxAmount($baseTotalTax);
98
+ $invoice->setHiddenTaxAmount($totalHiddenTax);
99
+ $invoice->setBaseHiddenTaxAmount($baseTotalHiddenTax);
100
+
101
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $totalTax + $totalHiddenTax);
102
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseTotalTax + $baseTotalHiddenTax);
103
+
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * Check if shipping tax calculation can be included to current invoice
109
+ * @param Mage_Sales_Model_Order_Invoice $invoice
110
+ * @return boolean
111
+ */
112
+ protected function _canIncludeShipping($invoice)
113
+ {
114
+ $includeShippingTax = true;
115
+ /**
116
+ * Check shipping amount in previous invoices
117
+ */
118
+ foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) {
119
+ if ($previusInvoice->getShippingAmount() && !$previusInvoice->isCanceled()) {
120
+ $includeShippingTax = false;
121
+ }
122
+ }
123
+ return $includeShippingTax;
124
+ }
125
+ }
app/code/local/Cardgate/Cgp/Model/Paymentfee/Invoice/Total.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+ class Cardgate_Cgp_Model_Paymentfee_Invoice_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
10
+ {
11
+
12
+ /**
13
+ * Collect the order total
14
+ *
15
+ * @param object $invoice
16
+ * The invoice instance to collect from
17
+ *
18
+ * @return Mage_Sales_Model_Order_Invoice_Total_Abstract
19
+ */
20
+ public function collect ( Mage_Sales_Model_Order_Invoice $invoice )
21
+ {
22
+
23
+ $order = $invoice->getOrder();
24
+ $method = $order->getPayment()->getMethodInstance();
25
+
26
+ if ( substr( $method->getCode(), 0, 3 ) != 'cgp' ) {
27
+ return $this;
28
+ }
29
+
30
+ // Only collect the invoice fee if we do not have any recent invoices
31
+ if ( $invoice->getOrder()->hasInvoices() != 0 ) {
32
+ return $this;
33
+ }
34
+
35
+ $info = $method->getInfoInstance();
36
+
37
+ if ( ! $info ) {
38
+ return $this;
39
+ }
40
+
41
+ $invoiceFee = $info->getAdditionalInformation( 'invoice_fee' );
42
+ $baseInvoiceFee = $info->getAdditionalInformation( 'base_invoice_fee' );
43
+ $invoiceFeeExludingVat = $info->getAdditionalInformation( 'invoice_fee_exluding_vat' );
44
+ $baseInvoiceFeeExludingVat = $info->getAdditionalInformation( 'base_invoice_fee_exluding_vat' );
45
+
46
+ if ( ! $invoiceFee ) {
47
+ return $this;
48
+ }
49
+
50
+ // FIXME: YYY: This is defect. isLast() is failing when configurable products are added in the cart.
51
+ $invoice->setBaseGrandTotal( $invoice->getBaseGrandTotal() + $baseInvoiceFeeExludingVat );
52
+ $invoice->setGrandTotal( $invoice->getGrandTotal() + $invoiceFeeExludingVat );
53
+
54
+ /*if ( $invoice->isLast() ) {
55
+ // The tax for our invoice fee is already applied to the grand total
56
+ // at this point, so we only need to add the remaining amount
57
+ $invoice->setBaseGrandTotal( $invoice->getBaseGrandTotal() + $baseInvoiceFeeExludingVat );
58
+ $invoice->setGrandTotal( $invoice->getGrandTotal() + $invoiceFeeExludingVat );
59
+ } else {
60
+ // Our tax doesn't get picked up by the parent function so we need
61
+ // to add our complete invoice fee
62
+ $invoice->setBaseGrandTotal( $invoice->getBaseGrandTotal() + $baseInvoiceFee );
63
+ $invoice->setGrandTotal( $invoice->getGrandTotal() + $invoiceFee );
64
+ }*/
65
+
66
+ $invoice->setBaseInvoiceFee( $baseInvoiceFee );
67
+ $invoice->setInvoiceFee( $invoiceFee );
68
+
69
+ $order->setBaseInvoiceFeeInvoiced( $invoiceFeeExludingVat );
70
+ $order->setInvoiceFeeInvoiced( $invoiceFee );
71
+
72
+ return $this;
73
+ }
74
+ }
app/code/local/Cardgate/Cgp/Model/Paymentfee/Quote/Quote.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+
10
+ class Cardgate_Cgp_Model_Paymentfee_Quote_Quote extends Mage_Sales_Model_Quote
11
+ {
12
+
13
+ public function getTotals ()
14
+ {
15
+ $totals = parent::getTotals();
16
+
17
+
18
+
19
+ unset( $totals['cgp_tax'] );
20
+ $totalsIndex = array_keys( $totals );
21
+ if ( array_search( 'cgp_fee', $totalsIndex ) === false ) {
22
+ return $totals;
23
+ }
24
+ unset( $totalsIndex[array_search( 'cgp_fee', $totalsIndex )] );
25
+ $fee = $totals['cgp_fee'];
26
+ unset( $totals['cgp_fee'] );
27
+
28
+ $feeIndex = array_search( 'shipping', $totalsIndex );
29
+ if ( $feeIndex === false ) {
30
+ $feeIndex = array_search( 'subtotal', $totalsIndex ) + 1;
31
+ }
32
+
33
+ $sortedTotals = array();
34
+ $size = count( $totalsIndex );
35
+ for ( $i = 0; $i < $size; $i ++ ) {
36
+ if ( $i == $feeIndex ) {
37
+ $sortedTotals['cgp_fee'] = $fee;
38
+ }
39
+ $sortedTotals[array_shift( $totalsIndex )] = array_shift( $totals );
40
+ }
41
+
42
+ return $sortedTotals;
43
+ }
44
+ }
45
+
46
+
app/code/local/Cardgate/Cgp/Model/Paymentfee/Quote/TaxTotal.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+ class Cardgate_Cgp_Model_Paymentfee_Quote_TaxTotal extends Mage_Sales_Model_Quote_Address_Total_Tax
10
+ {
11
+
12
+ /**
13
+ * Collect the order total
14
+ *
15
+ * @param object $address
16
+ * The address instance to collect from
17
+ *
18
+ * @return Cardgate_Cgp_Model_Paymentfee_Quote_TaxTotal
19
+ */
20
+ public function collect ( Mage_Sales_Model_Quote_Address $address )
21
+ {
22
+ $quote = $address->getQuote();
23
+
24
+ if ( ! is_a( $quote, 'Cardgate_Cgp_Model_Paymentfee_Quote_Quote' ) ) {
25
+ throw new Exception( 'Plugin clash detected. ' . get_class( $quote ) );
26
+ }
27
+
28
+ if ( ( $quote->getId() == null ) || ( $address->getAddressType() != "shipping" ) ) {
29
+ return $this;
30
+ }
31
+
32
+ $payment = $quote->getPayment();
33
+
34
+ if ( ( substr( $payment->getMethod(), 0, 3 ) != 'cgp' ) && ( ! count( $quote->getPaymentsCollection() ) ||
35
+ ( ! $payment->hasMethodInstance() ) ) ) {
36
+ return $this;
37
+ }
38
+
39
+ $methodInstance = $payment->getMethodInstance();
40
+
41
+ if ( substr( $methodInstance->getCode(), 0, 3 ) != 'cgp' ) {
42
+ return $this;
43
+ }
44
+
45
+ $helper = Mage::helper( 'cgp/paymentfee' );
46
+
47
+ $fee = $helper->getPaymentFeeArray( $methodInstance->getCode(), $quote );
48
+
49
+ if ( ! is_array( $fee ) ) {
50
+ return $this;
51
+ }
52
+
53
+ $address->setTaxAmount( $address->getTaxAmount() + $fee['taxamount'] );
54
+ $address->setBaseTaxAmount( $address->getBaseTaxAmount() + $fee['base_taxamount'] );
55
+
56
+ $address->setInvoiceTaxAmount( $fee['taxamount'] );
57
+ $address->setBaseInvoiceTaxAmount( $fee['base_taxamount'] );
58
+
59
+ return $this;
60
+ }
61
+ }
app/code/local/Cardgate/Cgp/Model/Paymentfee/Quote/Total.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento CardGate payment extension
5
+ *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
8
+ */
9
+ class Cardgate_Cgp_Model_Paymentfee_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract
10
+ {
11
+
12
+ protected $address;
13
+
14
+ protected $paymentMethod;
15
+
16
+ /**
17
+ * Collect the order total
18
+ *
19
+ * @param object $address
20
+ * The address instance to collect from
21
+ *
22
+ * @return Cardgate_Cgp_Model_Paymentfee_Quote_Total
23
+ */
24
+ public function collect ( Mage_Sales_Model_Quote_Address $address )
25
+ {
26
+ if ( $address->getAddressType() != "shipping" ) {
27
+ return $this;
28
+ }
29
+
30
+ $this->address = $address;
31
+ $this->quote = $address->getQuote();
32
+ $this->payment = $this->quote->getPayment();
33
+
34
+ if ( ( substr( $this->payment->getMethod(), 0, 3 ) != 'cgp' ) ) {
35
+ return $this;
36
+ }
37
+
38
+ $this->_resetValues();
39
+
40
+ if ( $this->address->getQuote()->getId() == null ) {
41
+ return $this;
42
+ }
43
+
44
+ $items = $this->address->getAllItems();
45
+ if ( ! count( $items ) ) {
46
+ return $this;
47
+ }
48
+
49
+ if ( $this->payment->hasMethodInstance() ) {
50
+ $this->paymentMethod = $this->payment->getMethodInstance();
51
+ if ( substr( $this->paymentMethod->getCode(), 0, 3 ) == 'cgp' ) {
52
+ $this->_initInvoiceFee();
53
+ }
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Reset the invoice fee variables
59
+ *
60
+ * @return void
61
+ */
62
+ private function _resetValues ()
63
+ {
64
+ $this->address->setInvoiceFee( 0 );
65
+ $this->address->setBaseInvoiceFee( 0 );
66
+ $this->address->setInvoiceFeeExcludedVat( 0 );
67
+ $this->address->setBaseInvoiceFeeExcludedVat( 0 );
68
+ $this->address->setInvoiceTaxAmount( 0 );
69
+ $this->address->setBaseInvoiceTaxAmount( 0 );
70
+ $this->address->setInvoiceFeeRate( 0 );
71
+ }
72
+
73
+ /**
74
+ * Initialize the invoice fee variables on the address instance
75
+ *
76
+ * @return void
77
+ */
78
+ private function _initInvoiceFee ()
79
+ {
80
+ $helper = Mage::helper( 'cgp/paymentfee' );
81
+ $fee = $helper->getPaymentFeeArray( $this->payment->getMethodInstance()
82
+ ->getCode(), $this->quote );
83
+
84
+ $this->address->setBaseInvoiceFee( $fee['base_incl'] );
85
+ $this->address->setInvoiceFee( $fee['incl'] );
86
+ $this->address->setBaseInvoiceFeeExcludedVat( $fee['base_excl'] );
87
+ $this->address->setInvoiceFeeExcludedVat( $fee['excl'] );
88
+ $this->address->setBaseInvoiceTaxAmount( $fee['base_taxamount'] );
89
+ $this->address->setInvoiceTaxAmount( $fee['taxamount'] );
90
+ $this->address->setInvoiceFeeRate( $fee['rate'] );
91
+
92
+ // Add our invoice fee to the address totals
93
+ $this->address->setBaseGrandTotal( $this->address->getBaseGrandTotal() + $fee['base_incl'] );
94
+ $this->address->setGrandTotal( $this->address->getGrandTotal() + $fee['incl'] );
95
+ }
96
+
97
+ /**
98
+ * Add invoice fee total information to address
99
+ *
100
+ * @param object $address
101
+ * The address instance
102
+ *
103
+ * @return Cardgate_Cgp_Model_Paymentfee_Quote_Total
104
+ */
105
+ public function fetch ( Mage_Sales_Model_Quote_Address $address )
106
+ {
107
+ if ( $address->getAddressType() != "shipping" ) {
108
+ return $this;
109
+ }
110
+ $excl = $address->getInvoiceFeeExcludedVat();
111
+ $incl = $address->getInvoiceFee();
112
+ $country = $address->getCountry();
113
+ $storeId = Mage::app()->getStore()->getId();
114
+
115
+ $isOSCEnabled = Mage::getStoreConfig( 'onestepcheckout/general/rewrite_checkout_links', $storeId );
116
+ if ( $isOSCEnabled ) {
117
+ $OSCDisplayAmountsInclTax = Mage::getStoreConfig( 'onestepcheckout/general/display_tax_included', $storeId );
118
+ $value = ( $OSCDisplayAmountsInclTax ? $incl : $excl );
119
+ } else {
120
+ $value = $incl;
121
+ }
122
+
123
+ if ( $value != 0 ) {
124
+ $label = Mage::getStoreConfig(
125
+ 'cgp/' . $this->payment->getMethodInstance()
126
+ ->getCode() . '/payment_fee_label' );
127
+ if ( $label == '' ) $label = "Payment fee";
128
+ $address->addTotal(
129
+ array(
130
+ 'code' => $this->getCode(),
131
+ 'title' => $label,
132
+ 'value' => $value
133
+ ) );
134
+ }
135
+ return $this;
136
+ }
137
+ }
app/code/local/Cardgate/Cgp/controllers/StandardController.php CHANGED
@@ -1,198 +1,196 @@
1
  <?php
2
 
3
  /**
4
- * Magento CardGatePlus payment extension
5
  *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- *
13
- * @category Mage
14
- * @package Cardgate_Cgp
15
- * @author Paul Saparov, <support@cardgate.com>
16
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
17
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
  */
19
- class Cardgate_Cgp_StandardController extends Mage_Core_Controller_Front_Action {
20
-
21
- private $_gatewayModel;
22
-
23
- /**
24
- * Verify the callback
25
- *
26
- * @param array $data
27
- * @return boolean
28
- */
29
- protected function validate( $data ) {
30
- $base = Mage::getSingleton( 'cgp/base' );
31
-
32
- $hashString = ($data['is_test'] ? 'TEST' : '') .
33
- $data['transaction_id'] .
34
- $data['currency'] .
35
- $data['amount'] .
36
- $data['ref'] .
37
- $data['status'] .
38
- $base->getConfigData( 'hash_key' );
39
-
40
- if ( md5( $hashString ) == $data['hash'] ) {
41
- return true;
42
- }
43
-
44
- return false;
45
- }
46
-
47
- /**
48
- * Check if within the URL is param model
49
- * if not, return default gateway model
50
- * @return string
51
- */
52
- protected function getGatewayModel() {
53
- if ( $this->_gatewayModel ) {
54
- return $this->_gatewayModel;
55
- }
56
-
57
- $model = $this->getRequest()->getParam( 'model' );
58
- $model = preg_replace( '/[^[[:alnum:]]]+/', '', $model );
59
-
60
- if ( !empty( $model ) ) {
61
- return 'gateway_' . $model;
62
- } else {
63
- return 'gateway_default';
64
- }
65
- }
66
-
67
- /**
68
- * Redirect customer to the gateway using his prefered payment method
69
- */
70
- public function redirectAction() {
71
- $paymentModel = 'cgp/' . $this->getGatewayModel();
72
- Mage::register( 'cgp_model', $paymentModel );
73
-
74
- $session = Mage::getSingleton( 'checkout/session' );
75
- $session->setCardgateQuoteId( $session->getQuoteId() );
76
-
77
- $this->loadLayout();
78
- $block = $this->getLayout()->createBlock(
79
- 'Cardgate_Cgp_Block_Redirect'
80
- );
81
-
82
- $this->getLayout()->getBlock( 'content' )->append( $block );
83
- $this->renderLayout();
84
- }
85
-
86
- /**
87
- * After a failed transaction a customer will be send here
88
- */
89
- public function cancelAction() {
90
-
91
- switch ( $_REQUEST['cgpstatusid'] ) {
92
- case 0:
93
- $message = $this->__( 'Your payment is being evaluated by the bank. Please do not attempt to pay again, until your payment is either confirmed or denied by the bank.' );
94
- break;
95
- case 305:
96
- break;
97
- case 300:
98
- $message = $this->__( 'Your payment has failed. If you wish, you can try using a different payment method.' );
99
- break;
100
- }
101
- if ( isset( $message ) ) {
102
- Mage::getSingleton( 'core/session' )->addError( $message );
103
- }
104
-
105
- $base = Mage::getSingleton( 'cgp/base' );
106
- $session = Mage::getSingleton( 'checkout/session' );
107
- /*
108
- $order_id = $session->getLastRealOrderId();
109
- if ( $order_id ) {
110
- // if order has failed it is canceled via the control url and should not be canceled a second time
111
- $order = Mage::getSingleton( 'sales/order' )->loadByIncrementId( $order_id );
112
-
113
- if ( $order->getState() != Mage_Sales_Model_Order::STATE_CANCELED ) {
114
- $order->setState( $base->getConfigData( 'order_status_failed' ) );
115
- $order->cancel();
116
- $order->save();
117
- }
118
- }
119
-
120
- if ( $session->getCgpOnestepCheckout() == true ) {
121
- $quote = Mage::getModel( 'sales/quote' )->load( $session->getCgpOnestepQuoteId() );
122
- } else {
123
- $quote = Mage::getModel( 'sales/quote' )->load( $session->getCardgateQuoteId() );
124
- }
125
- */
126
- $quote = Mage::getModel( 'sales/quote' )->load( $session->getCardgateQuoteId() );
127
-
128
- if ( $quote->getId() ) {
129
- $quote->setIsActive( true );
130
- $quote->save();
131
- }
132
-
133
- // clear session flag so that it will redirect to the gateway, and not to cancel
134
- // $session->setCgpOnestepCheckout(false);
135
- $this->_redirect( 'checkout/cart' );
136
- }
137
-
138
- /**
139
- * After a successful transaction a customer will be send here
140
- */
141
- public function successAction() {
142
-
143
- $session = Mage::getSingleton( 'checkout/session' );
144
- $quote = Mage::getModel( 'sales/quote' )->load( $session->getCardgateQuoteId() );
145
- if ( $quote->getId() ) {
146
- $quote->setIsActive( false );
147
- $quote->delete();
148
- }
149
- // clear session flag so that next order will redirect to the gateway
150
- //$session->setCgpOnestepCheckout(false);
151
-
152
- $this->_redirect( 'checkout/onepage/success', array( '_secure' => true ) );
153
- }
154
-
155
- /**
156
- * Control URL called by gateway
157
- */
158
- public function controlAction() {
159
-
160
- $base = Mage::getModel( 'cgp/base' );
161
- $data = $this->getRequest()->getPost();
162
-
163
- // Verify callback hash
164
- if ( !$this->getRequest()->isPost() || !$this->validate( $data ) ) {
165
- $message = 'Callback hash validation failed!';
166
- $base->log( $message );
167
- echo $message;
168
- exit();
169
- }
170
-
171
- // Process callback
172
- $base->setCallbackData( $data )->processCallback();
173
-
174
- // Obtain quote and status
175
- $status = ( int ) $data['status'];
176
- $quote = Mage::getModel( 'sales/quote' )->load( $data['extra'] );
177
-
178
- // Set Mage_Sales_Model_Quote to inactive and delete
179
- if ( 200 <= $status && $status <= 299 ) {
180
-
181
- //$retain = $base->getConfigData('retain_cart_on_cancel');
182
- if ( $quote->getId() ) {
183
- $quote->setIsActive( false );
184
- $quote->delete();
185
- }
186
- // Set Mage_Sales_Model_Quote to active and save
187
- } else {
188
- if ( $quote->getId() ) {
189
- $quote->setIsActive( true );
190
- $quote->save();
191
- }
192
- }
193
-
194
- // Display transaction_id and status
195
- echo $data['transaction_id'] . '.' . $data['status'];
196
- }
197
-
 
 
 
 
 
 
 
 
198
  }
1
  <?php
2
 
3
  /**
4
+ * Magento CardGate payment extension
5
  *
6
+ * @category Mage
7
+ * @package Cardgate_Cgp
 
 
 
 
 
 
 
 
 
 
8
  */
9
+ class Cardgate_Cgp_StandardController extends Mage_Core_Controller_Front_Action
10
+ {
11
+
12
+ private $_gatewayModel;
13
+
14
+ /**
15
+ * Verify the callback
16
+ *
17
+ * @param array $data
18
+ * @return boolean
19
+ */
20
+ protected function validate ( $data )
21
+ {
22
+ $base = Mage::getSingleton( 'cgp/base' );
23
+
24
+ $hashString = ( $data['is_test'] ? 'TEST' : '' ) . $data['transaction_id'] . $data['currency'] . $data['amount'] .
25
+ $data['ref'] . $data['status'] . $base->getConfigData( 'hash_key' );
26
+
27
+ if ( md5( $hashString ) == $data['hash'] ) {
28
+ return true;
29
+ }
30
+
31
+ return false;
32
+ }
33
+
34
+ /**
35
+ * Check if within the URL is param model
36
+ * if not, return default gateway model
37
+ *
38
+ * @return string
39
+ */
40
+ protected function getGatewayModel ()
41
+ {
42
+ if ( $this->_gatewayModel ) {
43
+ return $this->_gatewayModel;
44
+ }
45
+
46
+ $model = $this->getRequest()->getParam( 'model' );
47
+ $model = preg_replace( '/[^[[:alnum:]]]+/', '', $model );
48
+
49
+ if ( ! empty( $model ) ) {
50
+ return 'gateway_' . $model;
51
+ } else {
52
+ return 'gateway_default';
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Redirect customer to the gateway using his prefered payment method
58
+ */
59
+ public function redirectAction ()
60
+ {
61
+ $paymentModel = 'cgp/' . $this->getGatewayModel();
62
+ Mage::register( 'cgp_model', $paymentModel );
63
+
64
+ $session = Mage::getSingleton( 'checkout/session' );
65
+ $session->setCardgateQuoteId( $session->getQuoteId() );
66
+
67
+ $this->loadLayout();
68
+ $block = $this->getLayout()->createBlock( 'Cardgate_Cgp_Block_Redirect' );
69
+
70
+ $this->getLayout()
71
+ ->getBlock( 'content' )
72
+ ->append( $block );
73
+ $this->renderLayout();
74
+ }
75
+
76
+ /**
77
+ * After a failed transaction a customer will be send here
78
+ */
79
+ public function cancelAction ()
80
+ {
81
+ switch ( $_REQUEST['cgpstatusid'] ) {
82
+ case 0:
83
+ $message = $this->__(
84
+ 'Your payment is being evaluated by the bank. Please do not attempt to pay again, until your payment is either confirmed or denied by the bank.' );
85
+ break;
86
+ case 305:
87
+ break;
88
+ case 300:
89
+ $message = $this->__(
90
+ 'Your payment has failed. If you wish, you can try using a different payment method.' );
91
+ break;
92
+ }
93
+ if ( isset( $message ) ) {
94
+ Mage::getSingleton( 'core/session' )->addError( $message );
95
+ }
96
+
97
+ $base = Mage::getSingleton( 'cgp/base' );
98
+ $session = Mage::getSingleton( 'checkout/session' );
99
+ /*
100
+ * $order_id = $session->getLastRealOrderId();
101
+ * if ( $order_id ) {
102
+ * // if order has failed it is canceled via the control url and should
103
+ * not be canceled a second time
104
+ * $order = Mage::getSingleton( 'sales/order' )->loadByIncrementId(
105
+ * $order_id );
106
+ *
107
+ * if ( $order->getState() != Mage_Sales_Model_Order::STATE_CANCELED ) {
108
+ * $order->setState( $base->getConfigData( 'order_status_failed' ) );
109
+ * $order->cancel();
110
+ * $order->save();
111
+ * }
112
+ * }
113
+ *
114
+ * if ( $session->getCgpOnestepCheckout() == true ) {
115
+ * $quote = Mage::getModel( 'sales/quote' )->load(
116
+ * $session->getCgpOnestepQuoteId() );
117
+ * } else {
118
+ * $quote = Mage::getModel( 'sales/quote' )->load(
119
+ * $session->getCardgateQuoteId() );
120
+ * }
121
+ */
122
+ $quote = Mage::getModel( 'sales/quote' )->load( $session->getCardgateQuoteId() );
123
+
124
+ if ( $quote->getId() ) {
125
+ $quote->setIsActive( true );
126
+ $quote->save();
127
+ }
128
+
129
+ // clear session flag so that it will redirect to the gateway, and not
130
+ // to cancel
131
+ // $session->setCgpOnestepCheckout(false);
132
+ $this->_redirect( 'checkout/cart' );
133
+ }
134
+
135
+ /**
136
+ * After a successful transaction a customer will be send here
137
+ */
138
+ public function successAction ()
139
+ {
140
+ $session = Mage::getSingleton( 'checkout/session' );
141
+ $quote = Mage::getModel( 'sales/quote' )->load( $session->getCardgateQuoteId() );
142
+ if ( $quote->getId() ) {
143
+ $quote->setIsActive( false );
144
+ $quote->delete();
145
+ }
146
+ // clear session flag so that next order will redirect to the gateway
147
+ // $session->setCgpOnestepCheckout(false);
148
+
149
+ $this->_redirect( 'checkout/onepage/success', array(
150
+ '_secure' => true
151
+ ) );
152
+ }
153
+
154
+ /**
155
+ * Control URL called by gateway
156
+ */
157
+ public function controlAction ()
158
+ {
159
+ $base = Mage::getModel( 'cgp/base' );
160
+ $data = $this->getRequest()->getPost();
161
+
162
+ // Verify callback hash
163
+ if ( ! $this->getRequest()->isPost() || ! $this->validate( $data ) ) {
164
+ $message = 'Callback hash validation failed!';
165
+ $base->log( $message );
166
+ echo $message;
167
+ exit();
168
+ }
169
+
170
+ // Process callback
171
+ $base->setCallbackData( $data )->processCallback();
172
+
173
+ // Obtain quote and status
174
+ $status = ( int ) $data['status'];
175
+ $quote = Mage::getModel( 'sales/quote' )->load( $data['extra'] );
176
+
177
+ // Set Mage_Sales_Model_Quote to inactive and delete
178
+ if ( 200 <= $status && $status <= 299 ) {
179
+
180
+ // $retain = $base->getConfigData('retain_cart_on_cancel');
181
+ if ( $quote->getId() ) {
182
+ $quote->setIsActive( false );
183
+ $quote->delete();
184
+ }
185
+ // Set Mage_Sales_Model_Quote to active and save
186
+ } else {
187
+ if ( $quote->getId() ) {
188
+ $quote->setIsActive( true );
189
+ $quote->save();
190
+ }
191
+ }
192
+
193
+ // Display transaction_id and status
194
+ echo $data['transaction_id'] . '.' . $data['status'];
195
+ }
196
  }
app/code/local/Cardgate/Cgp/etc/adminhtml.xml CHANGED
@@ -1,20 +1,10 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <!--
3
  /**
4
- * Magento Carg Gate Plus payment extension
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
  *
13
  * @category Mage
14
  * @package Cardgate_Cgp
15
- * @author Paul Saparov, <support@cardgate.com>
16
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
17
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
  */
19
  -->
20
  <config>
@@ -26,9 +16,9 @@
26
  <children>
27
  <config>
28
  <children>
29
- <cgp>
30
  <title>CardGate+ Settings</title>
31
- </cgp>
32
  </children>
33
  </config>
34
  </children>
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <!--
3
  /**
4
+ * Magento CardGate payment extension
 
 
 
 
 
 
 
5
  *
6
  * @category Mage
7
  * @package Cardgate_Cgp
 
 
 
8
  */
9
  -->
10
  <config>
16
  <children>
17
  <config>
18
  <children>
19
+ <cgp_options>
20
  <title>CardGate+ Settings</title>
21
+ </cgp_options>
22
  </children>
23
  </config>
24
  </children>
app/code/local/Cardgate/Cgp/etc/config.xml CHANGED
@@ -1,26 +1,16 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <!--
3
  /**
4
- * Magento CardGatePlus payment extension
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
  *
13
  * @category Mage
14
  * @package Cardgate_Cgp
15
- * @author Paul Saparov, <support@cardgate.com>
16
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
17
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
  */
19
  -->
20
  <config>
21
  <modules>
22
  <Cardgate_Cgp>
23
- <version>1.0.38</version>
24
  </Cardgate_Cgp>
25
  </modules>
26
 
@@ -29,6 +19,20 @@
29
  <cgp>
30
  <class>Cardgate_Cgp_Block</class>
31
  </cgp>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  </blocks>
33
  <helpers>
34
  <cgp>
@@ -39,7 +43,58 @@
39
  <cgp>
40
  <class>Cardgate_Cgp_Model</class>
41
  </cgp>
42
- </models>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  <resources>
44
  <cgp_setup>
45
  <setup>
@@ -61,19 +116,59 @@
61
  </cgp_write>
62
  </resources>
63
  <events>
64
- <sales_quote_collect_totals_before>
 
 
 
 
 
 
 
 
 
 
65
  <observers>
66
  <cgp>
67
  <type>singleton</type>
68
  <class>cgp/observer</class>
69
- <method>salesQuoteCollectTotalsBefore</method>
70
  </cgp>
71
  </observers>
72
- </sales_quote_collect_totals_before>
 
 
 
 
 
 
 
 
 
 
73
  </events>
74
  </global>
75
 
76
  <adminhtml>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  <translate>
78
  <modules>
79
  <Cardgate_Cgp>
@@ -336,4 +431,6 @@
336
  </cgp_przelewy24>
337
  </cgp>
338
  </default>
 
 
339
  </config>
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <!--
3
  /**
4
+ * Magento CardGate payment extension
 
 
 
 
 
 
 
5
  *
6
  * @category Mage
7
  * @package Cardgate_Cgp
 
 
 
8
  */
9
  -->
10
  <config>
11
  <modules>
12
  <Cardgate_Cgp>
13
+ <version>1.1.0</version>
14
  </Cardgate_Cgp>
15
  </modules>
16
 
19
  <cgp>
20
  <class>Cardgate_Cgp_Block</class>
21
  </cgp>
22
+ <adminhtml>
23
+ <rewrite>
24
+ <sales_order_totals>Cardgate_Cgp_Block_Paymentfee_Adminhtml_Sales_Order_Totals</sales_order_totals>
25
+ <sales_order_invoice_totals>Cardgate_Cgp_Block_Paymentfee_Adminhtml_Sales_Order_Totals</sales_order_invoice_totals>
26
+ <sales_order_creditmemo_totals>Cardgate_Cgp_Block_Paymentfee_Creditmemo_Totals</sales_order_creditmemo_totals>
27
+ </rewrite>
28
+ </adminhtml>
29
+ <sales>
30
+ <rewrite>
31
+ <order_creditmemo_totals>Cardgate_Cgp_Block_Paymentfee_Creditmemo_Totals</order_creditmemo_totals>
32
+ <order_invoice_totals>Cardgate_Cgp_Block_Paymentfee_Invoice_Totals_Fee</order_invoice_totals>
33
+ <order_totals>Cardgate_Cgp_Block_Paymentfee_Order_Totals_Fee</order_totals>
34
+ </rewrite>
35
+ </sales>
36
  </blocks>
37
  <helpers>
38
  <cgp>
43
  <cgp>
44
  <class>Cardgate_Cgp_Model</class>
45
  </cgp>
46
+ <sales>
47
+ <rewrite>Mage_Sales_Model_Order_Payment
48
+ <quote>Cardgate_Cgp_Model_Paymentfee_Quote_Quote</quote>
49
+ <order_invoice_total_tax>Cardgate_Cgp_Model_Paymentfee_Invoice_Tax</order_invoice_total_tax>
50
+ </rewrite>
51
+ </sales>
52
+ </models>
53
+ <sales>
54
+ <quote>
55
+ <totals>
56
+ <cgp_fee>
57
+ <class>cgp/paymentfee_quote_total</class>
58
+ <after>subtotal,discount,shipping</after>
59
+ <before>tax,grand_total</before>
60
+ <renderer>cgp/paymentfee_checkout_fee</renderer>
61
+ </cgp_fee>
62
+ <cgp_tax>
63
+ <class>cgp/paymentfee_quote_taxTotal</class>
64
+ <after>subtotal,discount,shipping,tax</after>
65
+ <before>grand_total</before>
66
+ </cgp_tax>
67
+ </totals>
68
+ </quote>
69
+ <order_creditmemo>
70
+ <totals>
71
+ <cgp_total>
72
+ <class>cgp/paymentfee_creditmemo_total</class>
73
+ <after>subtotal,discount,shipping,tax</after>
74
+ <before>cost_total,grand_total</before>
75
+ </cgp_total>
76
+ </totals>
77
+ </order_creditmemo>
78
+ <order_invoice>
79
+ <totals>
80
+ <cgp_total>
81
+ <class>cgp/paymentfee_invoice_total</class>
82
+ </cgp_total>
83
+ </totals>
84
+ </order_invoice>
85
+ </sales>
86
+ <pdf>
87
+ <totals>
88
+ <invoice_fee translate="title">
89
+ <title>Invoice fee</title>
90
+ <source_field>cgp</source_field>
91
+ <font_size>7</font_size>
92
+ <display_zero>1</display_zero>
93
+ <sort_order>550</sort_order>
94
+ <model>cgp/paymentfee_invoice_pdf_total</model>
95
+ </invoice_fee>
96
+ </totals>
97
+ </pdf>
98
  <resources>
99
  <cgp_setup>
100
  <setup>
116
  </cgp_write>
117
  </resources>
118
  <events>
119
+ <sales_quote_collect_totals_after>
120
+ <observers>
121
+ <cgp>
122
+ <type>singleton</type>
123
+ <class>cgp/observer</class>
124
+ <method>salesQuoteCollectTotalsAfter</method>
125
+ </cgp>
126
+ </observers>
127
+ </sales_quote_collect_totals_after>
128
+
129
+ <sales_order_payment_place_end>
130
  <observers>
131
  <cgp>
132
  <type>singleton</type>
133
  <class>cgp/observer</class>
134
+ <method>salesOrderPaymentPlaceEnd</method>
135
  </cgp>
136
  </observers>
137
+ </sales_order_payment_place_end>
138
+ <!--
139
+ <sales_order_load_after>
140
+ <observers>
141
+ <cgp>
142
+ <type>singleton</type>
143
+ <class>cgp/observer</class>
144
+ <method>salesOrderLoadAfter</method>
145
+ </cgp>
146
+ </observers>
147
+ </sales_order_load_after>-->
148
  </events>
149
  </global>
150
 
151
  <adminhtml>
152
+ <acl>
153
+ <resources>
154
+ <admin>
155
+ <children>
156
+ <system>
157
+ <children>
158
+ <config>
159
+ <children>
160
+ <cgp>
161
+ <title>CardGate Settings</title>
162
+ </cgp>
163
+ </children>
164
+ </config>
165
+ </children>
166
+ </system>
167
+ </children>
168
+ </admin>
169
+ </resources>
170
+ </acl>
171
+
172
  <translate>
173
  <modules>
174
  <Cardgate_Cgp>
431
  </cgp_przelewy24>
432
  </cgp>
433
  </default>
434
+
435
+
436
  </config>
app/code/local/Cardgate/Cgp/etc/system.xml CHANGED
@@ -1,26 +1,16 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <!--
3
  /**
4
- * Magento CardGatePlus payment extension
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
  *
13
  * @category Mage
14
  * @package Cardgate_Cgp
15
- * @author Paul Saparov, <support@cardgate.com>
16
- * @copyright Copyright (c) 2011 CardGatePlus B.V. (http://www.cardgateplus.com)
17
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
  */
19
  -->
20
  <config>
21
  <sections>
22
  <cgp module="cgp">
23
- <label>CardGatePlus </label>
24
  <class>cardgate-section</class>
25
  <header_css>cardgate-header</header_css>
26
  <tab>sales</tab>
@@ -33,7 +23,7 @@
33
  <settings translate="comment">
34
  <label>Settings</label>
35
  <comment><![CDATA[<strong>Note:</strong> Don't forget to set-up in the <a href='https://my.cardgate.com/' target='_blank'>Merchant Backoffice</a> a Control URL to 'http://www.yourdomain.com/cgp/standard/control/'.]]></comment>
36
- <sort_order>100</sort_order>
37
  <show_in_default>1</show_in_default>
38
  <show_in_website>1</show_in_website>
39
  <show_in_store>1</show_in_store>
@@ -269,6 +259,42 @@
269
  <show_in_website>1</show_in_website>
270
  <show_in_store>1</show_in_store>
271
  </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  </fields>
273
  </cgp_visa>
274
 
@@ -322,6 +348,42 @@
322
  <show_in_website>1</show_in_website>
323
  <show_in_store>1</show_in_store>
324
  </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  </fields>
326
  </cgp_mastercard>
327
 
@@ -375,6 +437,42 @@
375
  <show_in_website>1</show_in_website>
376
  <show_in_store>1</show_in_store>
377
  </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
  </fields>
379
  </cgp_americanexpress>
380
 
@@ -428,6 +526,42 @@
428
  <show_in_website>1</show_in_website>
429
  <show_in_store>1</show_in_store>
430
  </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  </fields>
432
  </cgp_maestro>
433
 
@@ -481,6 +615,42 @@
481
  <show_in_website>1</show_in_website>
482
  <show_in_store>1</show_in_store>
483
  </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  </fields>
485
  </cgp_cartebleue>
486
 
@@ -534,6 +704,42 @@
534
  <show_in_website>1</show_in_website>
535
  <show_in_store>1</show_in_store>
536
  </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
537
  </fields>
538
  </cgp_cartebancaire>
539
 
@@ -587,6 +793,42 @@
587
  <show_in_website>1</show_in_website>
588
  <show_in_store>1</show_in_store>
589
  </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
590
  </fields>
591
  </cgp_vpay>
592
 
@@ -639,7 +881,43 @@
639
  <show_in_default>1</show_in_default>
640
  <show_in_website>1</show_in_website>
641
  <show_in_store>1</show_in_store>
642
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
643
  </fields>
644
  </cgp_sofortbanking>
645
 
@@ -693,6 +971,42 @@
693
  <show_in_website>1</show_in_website>
694
  <show_in_store>1</show_in_store>
695
  </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
696
  </fields>
697
  </cgp_ideal>
698
 
@@ -745,7 +1059,43 @@
745
  <show_in_default>1</show_in_default>
746
  <show_in_website>1</show_in_website>
747
  <show_in_store>1</show_in_store>
748
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
749
  </fields>
750
  </cgp_mistercash>
751
 
@@ -798,7 +1148,43 @@
798
  <show_in_default>1</show_in_default>
799
  <show_in_website>1</show_in_website>
800
  <show_in_store>1</show_in_store>
801
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
802
  </fields>
803
  </cgp_paypal>
804
 
@@ -851,7 +1237,43 @@
851
  <show_in_default>1</show_in_default>
852
  <show_in_website>1</show_in_website>
853
  <show_in_store>1</show_in_store>
854
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855
  </fields>
856
  </cgp_webmoney>
857
 
@@ -887,16 +1309,7 @@
887
  <show_in_website>1</show_in_website>
888
  <show_in_store>1</show_in_store>
889
  </klarna_eid>
890
- <!--
891
- <klarna_invoice_fee_ex translate="label">
892
- <label>Invoice Fee (excl. VAT)</label>
893
- <frontend_type>text</frontend_type>
894
- <sort_order>30</sort_order>
895
- <show_in_default>1</show_in_default>
896
- <show_in_website>1</show_in_website>
897
- <show_in_store>1</show_in_store>
898
- </klarna_invoice_fee_ex>
899
- -->
900
  <allowspecific translate="label">
901
  <label>Payment from applicable countries</label>
902
  <frontend_type>allowspecific</frontend_type>
@@ -922,7 +1335,43 @@
922
  <show_in_default>1</show_in_default>
923
  <show_in_website>1</show_in_website>
924
  <show_in_store>1</show_in_store>
925
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
926
  </fields>
927
  </cgp_klarna>
928
 
@@ -983,7 +1432,43 @@
983
  <show_in_default>1</show_in_default>
984
  <show_in_website>1</show_in_website>
985
  <show_in_store>1</show_in_store>
986
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
987
  </fields>
988
  </cgp_klarnaaccount>
989
 
@@ -1036,9 +1521,46 @@
1036
  <show_in_default>1</show_in_default>
1037
  <show_in_website>1</show_in_website>
1038
  <show_in_store>1</show_in_store>
1039
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1040
  </fields>
1041
  </cgp_giropay>
 
1042
  <cgp_banktransfer translate="label" module="cgp">
1043
  <label>Bank Transfer</label>
1044
  <sort_order>350</sort_order>
@@ -1096,7 +1618,43 @@
1096
  <show_in_default>1</show_in_default>
1097
  <show_in_website>1</show_in_website>
1098
  <show_in_store>1</show_in_store>
1099
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1100
  </fields>
1101
  </cgp_banktransfer>
1102
 
@@ -1149,9 +1707,46 @@
1149
  <show_in_default>1</show_in_default>
1150
  <show_in_website>1</show_in_website>
1151
  <show_in_store>1</show_in_store>
1152
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1153
  </fields>
1154
  </cgp_directdebit>
 
1155
  <cgp_przelewy24 translate="label" module="cgp">
1156
  <label>Przelewy24</label>
1157
  <sort_order>370</sort_order>
@@ -1201,10 +1796,48 @@
1201
  <show_in_default>1</show_in_default>
1202
  <show_in_website>1</show_in_website>
1203
  <show_in_store>1</show_in_store>
1204
- </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1205
  </fields>
1206
  </cgp_przelewy24>
 
1207
  </groups>
1208
  </cgp>
 
1209
  </sections>
1210
  </config>
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <!--
3
  /**
4
+ * Magento CardGate payment extension
 
 
 
 
 
 
 
5
  *
6
  * @category Mage
7
  * @package Cardgate_Cgp
 
 
 
8
  */
9
  -->
10
  <config>
11
  <sections>
12
  <cgp module="cgp">
13
+ <label>CardGate</label>
14
  <class>cardgate-section</class>
15
  <header_css>cardgate-header</header_css>
16
  <tab>sales</tab>
23
  <settings translate="comment">
24
  <label>Settings</label>
25
  <comment><![CDATA[<strong>Note:</strong> Don't forget to set-up in the <a href='https://my.cardgate.com/' target='_blank'>Merchant Backoffice</a> a Control URL to 'http://www.yourdomain.com/cgp/standard/control/'.]]></comment>
26
+ <sort_order>1</sort_order>
27
  <show_in_default>1</show_in_default>
28
  <show_in_website>1</show_in_website>
29
  <show_in_store>1</show_in_store>
259
  <show_in_website>1</show_in_website>
260
  <show_in_store>1</show_in_store>
261
  </sort_order>
262
+ <payment_fee translate="label">
263
+ <label>Payment fee</label>
264
+ <sort_order>110</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>1</show_in_store>
268
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
269
+ </payment_fee>
270
+ <payment_fee_tax translate="label">
271
+ <label>Payment fee tax class</label>
272
+ <frontend_type>select</frontend_type>
273
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
274
+ <sort_order>120</sort_order>
275
+ <show_in_default>1</show_in_default>
276
+ <show_in_store>1</show_in_store>
277
+ <show_in_website>1</show_in_website>
278
+ <comment>Choose the fee's tax class</comment>
279
+ </payment_fee_tax>
280
+ <payment_fee_inc_ex translate="label">
281
+ <label>Including/Excluding Tax</label>
282
+ <frontend_type>select</frontend_type>
283
+ <source_model>adminhtml/system_config_source_yesno</source_model>
284
+ <sort_order>130</sort_order>
285
+ <show_in_default>1</show_in_default>
286
+ <show_in_website>1</show_in_website>
287
+ <show_in_store>1</show_in_store>
288
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
289
+ </payment_fee_inc_ex>
290
+ <payment_fee_label translate="label,comment">
291
+ <label>Payment fee label</label>
292
+ <sort_order>140</sort_order>
293
+ <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>1</show_in_store>
296
+ <comment>Short description which is shown on orders/invoices</comment>
297
+ </payment_fee_label>
298
  </fields>
299
  </cgp_visa>
300
 
348
  <show_in_website>1</show_in_website>
349
  <show_in_store>1</show_in_store>
350
  </sort_order>
351
+ <payment_fee translate="label">
352
+ <label>Payment fee</label>
353
+ <sort_order>110</sort_order>
354
+ <show_in_default>1</show_in_default>
355
+ <show_in_website>1</show_in_website>
356
+ <show_in_store>1</show_in_store>
357
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
358
+ </payment_fee>
359
+ <payment_fee_tax translate="label">
360
+ <label>Payment fee tax class</label>
361
+ <frontend_type>select</frontend_type>
362
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
363
+ <sort_order>120</sort_order>
364
+ <show_in_default>1</show_in_default>
365
+ <show_in_store>1</show_in_store>
366
+ <show_in_website>1</show_in_website>
367
+ <comment>Choose the fee's tax class</comment>
368
+ </payment_fee_tax>
369
+ <payment_fee_inc_ex translate="label">
370
+ <label>Including/Excluding Tax</label>
371
+ <frontend_type>select</frontend_type>
372
+ <source_model>adminhtml/system_config_source_yesno</source_model>
373
+ <sort_order>130</sort_order>
374
+ <show_in_default>1</show_in_default>
375
+ <show_in_website>1</show_in_website>
376
+ <show_in_store>1</show_in_store>
377
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
378
+ </payment_fee_inc_ex>
379
+ <payment_fee_label translate="label,comment">
380
+ <label>Payment fee label</label>
381
+ <sort_order>140</sort_order>
382
+ <show_in_default>1</show_in_default>
383
+ <show_in_website>1</show_in_website>
384
+ <show_in_store>1</show_in_store>
385
+ <comment>Short description which is shown on orders/invoices</comment>
386
+ </payment_fee_label>
387
  </fields>
388
  </cgp_mastercard>
389
 
437
  <show_in_website>1</show_in_website>
438
  <show_in_store>1</show_in_store>
439
  </sort_order>
440
+ <payment_fee translate="label">
441
+ <label>Payment fee</label>
442
+ <sort_order>110</sort_order>
443
+ <show_in_default>1</show_in_default>
444
+ <show_in_website>1</show_in_website>
445
+ <show_in_store>1</show_in_store>
446
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
447
+ </payment_fee>
448
+ <payment_fee_tax translate="label">
449
+ <label>Payment fee tax class</label>
450
+ <frontend_type>select</frontend_type>
451
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
452
+ <sort_order>120</sort_order>
453
+ <show_in_default>1</show_in_default>
454
+ <show_in_store>1</show_in_store>
455
+ <show_in_website>1</show_in_website>
456
+ <comment>Choose the fee's tax class</comment>
457
+ </payment_fee_tax>
458
+ <payment_fee_inc_ex translate="label">
459
+ <label>Including/Excluding Tax</label>
460
+ <frontend_type>select</frontend_type>
461
+ <source_model>adminhtml/system_config_source_yesno</source_model>
462
+ <sort_order>130</sort_order>
463
+ <show_in_default>1</show_in_default>
464
+ <show_in_website>1</show_in_website>
465
+ <show_in_store>1</show_in_store>
466
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
467
+ </payment_fee_inc_ex>
468
+ <payment_fee_label translate="label,comment">
469
+ <label>Payment fee label</label>
470
+ <sort_order>140</sort_order>
471
+ <show_in_default>1</show_in_default>
472
+ <show_in_website>1</show_in_website>
473
+ <show_in_store>1</show_in_store>
474
+ <comment>Short description which is shown on orders/invoices</comment>
475
+ </payment_fee_label>
476
  </fields>
477
  </cgp_americanexpress>
478
 
526
  <show_in_website>1</show_in_website>
527
  <show_in_store>1</show_in_store>
528
  </sort_order>
529
+ <payment_fee translate="label">
530
+ <label>Payment fee</label>
531
+ <sort_order>110</sort_order>
532
+ <show_in_default>1</show_in_default>
533
+ <show_in_website>1</show_in_website>
534
+ <show_in_store>1</show_in_store>
535
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
536
+ </payment_fee>
537
+ <payment_fee_tax translate="label">
538
+ <label>Payment fee tax class</label>
539
+ <frontend_type>select</frontend_type>
540
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
541
+ <sort_order>120</sort_order>
542
+ <show_in_default>1</show_in_default>
543
+ <show_in_store>1</show_in_store>
544
+ <show_in_website>1</show_in_website>
545
+ <comment>Choose the fee's tax class</comment>
546
+ </payment_fee_tax>
547
+ <payment_fee_inc_ex translate="label">
548
+ <label>Including/Excluding Tax</label>
549
+ <frontend_type>select</frontend_type>
550
+ <source_model>adminhtml/system_config_source_yesno</source_model>
551
+ <sort_order>130</sort_order>
552
+ <show_in_default>1</show_in_default>
553
+ <show_in_website>1</show_in_website>
554
+ <show_in_store>1</show_in_store>
555
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
556
+ </payment_fee_inc_ex>
557
+ <payment_fee_label translate="label,comment">
558
+ <label>Payment fee label</label>
559
+ <sort_order>140</sort_order>
560
+ <show_in_default>1</show_in_default>
561
+ <show_in_website>1</show_in_website>
562
+ <show_in_store>1</show_in_store>
563
+ <comment>Short description which is shown on orders/invoices</comment>
564
+ </payment_fee_label>
565
  </fields>
566
  </cgp_maestro>
567
 
615
  <show_in_website>1</show_in_website>
616
  <show_in_store>1</show_in_store>
617
  </sort_order>
618
+ <payment_fee translate="label">
619
+ <label>Payment fee</label>
620
+ <sort_order>110</sort_order>
621
+ <show_in_default>1</show_in_default>
622
+ <show_in_website>1</show_in_website>
623
+ <show_in_store>1</show_in_store>
624
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
625
+ </payment_fee>
626
+ <payment_fee_tax translate="label">
627
+ <label>Payment fee tax class</label>
628
+ <frontend_type>select</frontend_type>
629
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
630
+ <sort_order>120</sort_order>
631
+ <show_in_default>1</show_in_default>
632
+ <show_in_store>1</show_in_store>
633
+ <show_in_website>1</show_in_website>
634
+ <comment>Choose the fee's tax class</comment>
635
+ </payment_fee_tax>
636
+ <payment_fee_inc_ex translate="label">
637
+ <label>Including/Excluding Tax</label>
638
+ <frontend_type>select</frontend_type>
639
+ <source_model>adminhtml/system_config_source_yesno</source_model>
640
+ <sort_order>130</sort_order>
641
+ <show_in_default>1</show_in_default>
642
+ <show_in_website>1</show_in_website>
643
+ <show_in_store>1</show_in_store>
644
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
645
+ </payment_fee_inc_ex>
646
+ <payment_fee_label translate="label,comment">
647
+ <label>Payment fee label</label>
648
+ <sort_order>140</sort_order>
649
+ <show_in_default>1</show_in_default>
650
+ <show_in_website>1</show_in_website>
651
+ <show_in_store>1</show_in_store>
652
+ <comment>Short description which is shown on orders/invoices</comment>
653
+ </payment_fee_label>
654
  </fields>
655
  </cgp_cartebleue>
656
 
704
  <show_in_website>1</show_in_website>
705
  <show_in_store>1</show_in_store>
706
  </sort_order>
707
+ <payment_fee translate="label">
708
+ <label>Payment fee</label>
709
+ <sort_order>110</sort_order>
710
+ <show_in_default>1</show_in_default>
711
+ <show_in_website>1</show_in_website>
712
+ <show_in_store>1</show_in_store>
713
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
714
+ </payment_fee>
715
+ <payment_fee_tax translate="label">
716
+ <label>Payment fee tax class</label>
717
+ <frontend_type>select</frontend_type>
718
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
719
+ <sort_order>120</sort_order>
720
+ <show_in_default>1</show_in_default>
721
+ <show_in_store>1</show_in_store>
722
+ <show_in_website>1</show_in_website>
723
+ <comment>Choose the fee's tax class</comment>
724
+ </payment_fee_tax>
725
+ <payment_fee_inc_ex translate="label">
726
+ <label>Including/Excluding Tax</label>
727
+ <frontend_type>select</frontend_type>
728
+ <source_model>adminhtml/system_config_source_yesno</source_model>
729
+ <sort_order>130</sort_order>
730
+ <show_in_default>1</show_in_default>
731
+ <show_in_website>1</show_in_website>
732
+ <show_in_store>1</show_in_store>
733
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
734
+ </payment_fee_inc_ex>
735
+ <payment_fee_label translate="label,comment">
736
+ <label>Payment fee label</label>
737
+ <sort_order>140</sort_order>
738
+ <show_in_default>1</show_in_default>
739
+ <show_in_website>1</show_in_website>
740
+ <show_in_store>1</show_in_store>
741
+ <comment>Short description which is shown on orders/invoices</comment>
742
+ </payment_fee_label>
743
  </fields>
744
  </cgp_cartebancaire>
745
 
793
  <show_in_website>1</show_in_website>
794
  <show_in_store>1</show_in_store>
795
  </sort_order>
796
+ <payment_fee translate="label">
797
+ <label>Payment fee</label>
798
+ <sort_order>110</sort_order>
799
+ <show_in_default>1</show_in_default>
800
+ <show_in_website>1</show_in_website>
801
+ <show_in_store>1</show_in_store>
802
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
803
+ </payment_fee>
804
+ <payment_fee_tax translate="label">
805
+ <label>Payment fee tax class</label>
806
+ <frontend_type>select</frontend_type>
807
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
808
+ <sort_order>120</sort_order>
809
+ <show_in_default>1</show_in_default>
810
+ <show_in_store>1</show_in_store>
811
+ <show_in_website>1</show_in_website>
812
+ <comment>Choose the fee's tax class</comment>
813
+ </payment_fee_tax>
814
+ <payment_fee_inc_ex translate="label">
815
+ <label>Including/Excluding Tax</label>
816
+ <frontend_type>select</frontend_type>
817
+ <source_model>adminhtml/system_config_source_yesno</source_model>
818
+ <sort_order>130</sort_order>
819
+ <show_in_default>1</show_in_default>
820
+ <show_in_website>1</show_in_website>
821
+ <show_in_store>1</show_in_store>
822
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
823
+ </payment_fee_inc_ex>
824
+ <payment_fee_label translate="label,comment">
825
+ <label>Payment fee label</label>
826
+ <sort_order>140</sort_order>
827
+ <show_in_default>1</show_in_default>
828
+ <show_in_website>1</show_in_website>
829
+ <show_in_store>1</show_in_store>
830
+ <comment>Short description which is shown on orders/invoices</comment>
831
+ </payment_fee_label>
832
  </fields>
833
  </cgp_vpay>
834
 
881
  <show_in_default>1</show_in_default>
882
  <show_in_website>1</show_in_website>
883
  <show_in_store>1</show_in_store>
884
+ </sort_order>
885
+ <payment_fee translate="label">
886
+ <label>Payment fee</label>
887
+ <sort_order>110</sort_order>
888
+ <show_in_default>1</show_in_default>
889
+ <show_in_website>1</show_in_website>
890
+ <show_in_store>1</show_in_store>
891
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
892
+ </payment_fee>
893
+ <payment_fee_tax translate="label">
894
+ <label>Payment fee tax class</label>
895
+ <frontend_type>select</frontend_type>
896
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
897
+ <sort_order>120</sort_order>
898
+ <show_in_default>1</show_in_default>
899
+ <show_in_store>1</show_in_store>
900
+ <show_in_website>1</show_in_website>
901
+ <comment>Choose the fee's tax class</comment>
902
+ </payment_fee_tax>
903
+ <payment_fee_inc_ex translate="label">
904
+ <label>Including/Excluding Tax</label>
905
+ <frontend_type>select</frontend_type>
906
+ <source_model>adminhtml/system_config_source_yesno</source_model>
907
+ <sort_order>130</sort_order>
908
+ <show_in_default>1</show_in_default>
909
+ <show_in_website>1</show_in_website>
910
+ <show_in_store>1</show_in_store>
911
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
912
+ </payment_fee_inc_ex>
913
+ <payment_fee_label translate="label,comment">
914
+ <label>Payment fee label</label>
915
+ <sort_order>140</sort_order>
916
+ <show_in_default>1</show_in_default>
917
+ <show_in_website>1</show_in_website>
918
+ <show_in_store>1</show_in_store>
919
+ <comment>Short description which is shown on orders/invoices</comment>
920
+ </payment_fee_label>
921
  </fields>
922
  </cgp_sofortbanking>
923
 
971
  <show_in_website>1</show_in_website>
972
  <show_in_store>1</show_in_store>
973
  </sort_order>
974
+ <payment_fee translate="label">
975
+ <label>Payment fee</label>
976
+ <sort_order>110</sort_order>
977
+ <show_in_default>1</show_in_default>
978
+ <show_in_website>1</show_in_website>
979
+ <show_in_store>1</show_in_store>
980
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
981
+ </payment_fee>
982
+ <payment_fee_tax translate="label">
983
+ <label>Payment fee tax class</label>
984
+ <frontend_type>select</frontend_type>
985
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
986
+ <sort_order>120</sort_order>
987
+ <show_in_default>1</show_in_default>
988
+ <show_in_store>1</show_in_store>
989
+ <show_in_website>1</show_in_website>
990
+ <comment>Choose the fee's tax class</comment>
991
+ </payment_fee_tax>
992
+ <payment_fee_inc_ex translate="label">
993
+ <label>Including/Excluding Tax</label>
994
+ <frontend_type>select</frontend_type>
995
+ <source_model>adminhtml/system_config_source_yesno</source_model>
996
+ <sort_order>130</sort_order>
997
+ <show_in_default>1</show_in_default>
998
+ <show_in_website>1</show_in_website>
999
+ <show_in_store>1</show_in_store>
1000
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1001
+ </payment_fee_inc_ex>
1002
+ <payment_fee_label translate="label,comment">
1003
+ <label>Payment fee label</label>
1004
+ <sort_order>140</sort_order>
1005
+ <show_in_default>1</show_in_default>
1006
+ <show_in_website>1</show_in_website>
1007
+ <show_in_store>1</show_in_store>
1008
+ <comment>Short description which is shown on orders/invoices</comment>
1009
+ </payment_fee_label>
1010
  </fields>
1011
  </cgp_ideal>
1012
 
1059
  <show_in_default>1</show_in_default>
1060
  <show_in_website>1</show_in_website>
1061
  <show_in_store>1</show_in_store>
1062
+ </sort_order>
1063
+ <payment_fee translate="label">
1064
+ <label>Payment fee</label>
1065
+ <sort_order>110</sort_order>
1066
+ <show_in_default>1</show_in_default>
1067
+ <show_in_website>1</show_in_website>
1068
+ <show_in_store>1</show_in_store>
1069
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
1070
+ </payment_fee>
1071
+ <payment_fee_tax translate="label">
1072
+ <label>Payment fee tax class</label>
1073
+ <frontend_type>select</frontend_type>
1074
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
1075
+ <sort_order>120</sort_order>
1076
+ <show_in_default>1</show_in_default>
1077
+ <show_in_store>1</show_in_store>
1078
+ <show_in_website>1</show_in_website>
1079
+ <comment>Choose the fee's tax class</comment>
1080
+ </payment_fee_tax>
1081
+ <payment_fee_inc_ex translate="label">
1082
+ <label>Including/Excluding Tax</label>
1083
+ <frontend_type>select</frontend_type>
1084
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1085
+ <sort_order>130</sort_order>
1086
+ <show_in_default>1</show_in_default>
1087
+ <show_in_website>1</show_in_website>
1088
+ <show_in_store>1</show_in_store>
1089
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1090
+ </payment_fee_inc_ex>
1091
+ <payment_fee_label translate="label,comment">
1092
+ <label>Payment fee label</label>
1093
+ <sort_order>140</sort_order>
1094
+ <show_in_default>1</show_in_default>
1095
+ <show_in_website>1</show_in_website>
1096
+ <show_in_store>1</show_in_store>
1097
+ <comment>Short description which is shown on orders/invoices</comment>
1098
+ </payment_fee_label>
1099
  </fields>
1100
  </cgp_mistercash>
1101
 
1148
  <show_in_default>1</show_in_default>
1149
  <show_in_website>1</show_in_website>
1150
  <show_in_store>1</show_in_store>
1151
+ </sort_order>
1152
+ <payment_fee translate="label">
1153
+ <label>Payment fee</label>
1154
+ <sort_order>110</sort_order>
1155
+ <show_in_default>1</show_in_default>
1156
+ <show_in_website>1</show_in_website>
1157
+ <show_in_store>1</show_in_store>
1158
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
1159
+ </payment_fee>
1160
+ <payment_fee_tax translate="label">
1161
+ <label>Payment fee tax class</label>
1162
+ <frontend_type>select</frontend_type>
1163
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
1164
+ <sort_order>120</sort_order>
1165
+ <show_in_default>1</show_in_default>
1166
+ <show_in_store>1</show_in_store>
1167
+ <show_in_website>1</show_in_website>
1168
+ <comment>Choose the fee's tax class</comment>
1169
+ </payment_fee_tax>
1170
+ <payment_fee_inc_ex translate="label">
1171
+ <label>Including/Excluding Tax</label>
1172
+ <frontend_type>select</frontend_type>
1173
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1174
+ <sort_order>130</sort_order>
1175
+ <show_in_default>1</show_in_default>
1176
+ <show_in_website>1</show_in_website>
1177
+ <show_in_store>1</show_in_store>
1178
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1179
+ </payment_fee_inc_ex>
1180
+ <payment_fee_label translate="label,comment">
1181
+ <label>Payment fee label</label>
1182
+ <sort_order>140</sort_order>
1183
+ <show_in_default>1</show_in_default>
1184
+ <show_in_website>1</show_in_website>
1185
+ <show_in_store>1</show_in_store>
1186
+ <comment>Short description which is shown on orders/invoices</comment>
1187
+ </payment_fee_label>
1188
  </fields>
1189
  </cgp_paypal>
1190
 
1237
  <show_in_default>1</show_in_default>
1238
  <show_in_website>1</show_in_website>
1239
  <show_in_store>1</show_in_store>
1240
+ </sort_order>
1241
+ <payment_fee translate="label">
1242
+ <label>Payment fee</label>
1243
+ <sort_order>110</sort_order>
1244
+ <show_in_default>1</show_in_default>
1245
+ <show_in_website>1</show_in_website>
1246
+ <show_in_store>1</show_in_store>
1247
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
1248
+ </payment_fee>
1249
+ <payment_fee_tax translate="label">
1250
+ <label>Payment fee tax class</label>
1251
+ <frontend_type>select</frontend_type>
1252
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
1253
+ <sort_order>120</sort_order>
1254
+ <show_in_default>1</show_in_default>
1255
+ <show_in_store>1</show_in_store>
1256
+ <show_in_website>1</show_in_website>
1257
+ <comment>Choose the fee's tax class</comment>
1258
+ </payment_fee_tax>
1259
+ <payment_fee_inc_ex translate="label">
1260
+ <label>Including/Excluding Tax</label>
1261
+ <frontend_type>select</frontend_type>
1262
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1263
+ <sort_order>130</sort_order>
1264
+ <show_in_default>1</show_in_default>
1265
+ <show_in_website>1</show_in_website>
1266
+ <show_in_store>1</show_in_store>
1267
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1268
+ </payment_fee_inc_ex>
1269
+ <payment_fee_label translate="label,comment">
1270
+ <label>Payment fee label</label>
1271
+ <sort_order>140</sort_order>
1272
+ <show_in_default>1</show_in_default>
1273
+ <show_in_website>1</show_in_website>
1274
+ <show_in_store>1</show_in_store>
1275
+ <comment>Short description which is shown on orders/invoices</comment>
1276
+ </payment_fee_label>
1277
  </fields>
1278
  </cgp_webmoney>
1279
 
1309
  <show_in_website>1</show_in_website>
1310
  <show_in_store>1</show_in_store>
1311
  </klarna_eid>
1312
+
 
 
 
 
 
 
 
 
 
1313
  <allowspecific translate="label">
1314
  <label>Payment from applicable countries</label>
1315
  <frontend_type>allowspecific</frontend_type>
1335
  <show_in_default>1</show_in_default>
1336
  <show_in_website>1</show_in_website>
1337
  <show_in_store>1</show_in_store>
1338
+ </sort_order>
1339
+ <payment_fee translate="label">
1340
+ <label>Payment fee</label>
1341
+ <sort_order>110</sort_order>
1342
+ <show_in_default>1</show_in_default>
1343
+ <show_in_website>1</show_in_website>
1344
+ <show_in_store>1</show_in_store>
1345
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
1346
+ </payment_fee>
1347
+ <payment_fee_tax translate="label">
1348
+ <label>Payment fee tax class</label>
1349
+ <frontend_type>select</frontend_type>
1350
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
1351
+ <sort_order>120</sort_order>
1352
+ <show_in_default>1</show_in_default>
1353
+ <show_in_store>1</show_in_store>
1354
+ <show_in_website>1</show_in_website>
1355
+ <comment>Choose the fee's tax class</comment>
1356
+ </payment_fee_tax>
1357
+ <payment_fee_inc_ex translate="label">
1358
+ <label>Including/Excluding Tax</label>
1359
+ <frontend_type>select</frontend_type>
1360
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1361
+ <sort_order>130</sort_order>
1362
+ <show_in_default>1</show_in_default>
1363
+ <show_in_website>1</show_in_website>
1364
+ <show_in_store>1</show_in_store>
1365
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1366
+ </payment_fee_inc_ex>
1367
+ <payment_fee_label translate="label,comment">
1368
+ <label>Payment fee label</label>
1369
+ <sort_order>140</sort_order>
1370
+ <show_in_default>1</show_in_default>
1371
+ <show_in_website>1</show_in_website>
1372
+ <show_in_store>1</show_in_store>
1373
+ <comment>Short description which is shown on orders/invoices</comment>
1374
+ </payment_fee_label>
1375
  </fields>
1376
  </cgp_klarna>
1377
 
1432
  <show_in_default>1</show_in_default>
1433
  <show_in_website>1</show_in_website>
1434
  <show_in_store>1</show_in_store>
1435
+ </sort_order>
1436
+ <payment_fee translate="label">
1437
+ <label>Payment fee</label>
1438
+ <sort_order>110</sort_order>
1439
+ <show_in_default>1</show_in_default>
1440
+ <show_in_website>1</show_in_website>
1441
+ <show_in_store>1</show_in_store>
1442
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
1443
+ </payment_fee>
1444
+ <payment_fee_tax translate="label">
1445
+ <label>Payment fee tax class</label>
1446
+ <frontend_type>select</frontend_type>
1447
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
1448
+ <sort_order>120</sort_order>
1449
+ <show_in_default>1</show_in_default>
1450
+ <show_in_store>1</show_in_store>
1451
+ <show_in_website>1</show_in_website>
1452
+ <comment>Choose the fee's tax class</comment>
1453
+ </payment_fee_tax>
1454
+ <payment_fee_inc_ex translate="label">
1455
+ <label>Including/Excluding Tax</label>
1456
+ <frontend_type>select</frontend_type>
1457
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1458
+ <sort_order>130</sort_order>
1459
+ <show_in_default>1</show_in_default>
1460
+ <show_in_website>1</show_in_website>
1461
+ <show_in_store>1</show_in_store>
1462
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1463
+ </payment_fee_inc_ex>
1464
+ <payment_fee_label translate="label,comment">
1465
+ <label>Payment fee label</label>
1466
+ <sort_order>140</sort_order>
1467
+ <show_in_default>1</show_in_default>
1468
+ <show_in_website>1</show_in_website>
1469
+ <show_in_store>1</show_in_store>
1470
+ <comment>Short description which is shown on orders/invoices</comment>
1471
+ </payment_fee_label>
1472
  </fields>
1473
  </cgp_klarnaaccount>
1474
 
1521
  <show_in_default>1</show_in_default>
1522
  <show_in_website>1</show_in_website>
1523
  <show_in_store>1</show_in_store>
1524
+ </sort_order>
1525
+ <payment_fee translate="label">
1526
+ <label>Payment fee</label>
1527
+ <sort_order>110</sort_order>
1528
+ <show_in_default>1</show_in_default>
1529
+ <show_in_website>1</show_in_website>
1530
+ <show_in_store>1</show_in_store>
1531
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
1532
+ </payment_fee>
1533
+ <payment_fee_tax translate="label">
1534
+ <label>Payment fee tax class</label>
1535
+ <frontend_type>select</frontend_type>
1536
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
1537
+ <sort_order>120</sort_order>
1538
+ <show_in_default>1</show_in_default>
1539
+ <show_in_store>1</show_in_store>
1540
+ <show_in_website>1</show_in_website>
1541
+ <comment>Choose the fee's tax class</comment>
1542
+ </payment_fee_tax>
1543
+ <payment_fee_inc_ex translate="label">
1544
+ <label>Including/Excluding Tax</label>
1545
+ <frontend_type>select</frontend_type>
1546
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1547
+ <sort_order>130</sort_order>
1548
+ <show_in_default>1</show_in_default>
1549
+ <show_in_website>1</show_in_website>
1550
+ <show_in_store>1</show_in_store>
1551
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1552
+ </payment_fee_inc_ex>
1553
+ <payment_fee_label translate="label,comment">
1554
+ <label>Payment fee label</label>
1555
+ <sort_order>140</sort_order>
1556
+ <show_in_default>1</show_in_default>
1557
+ <show_in_website>1</show_in_website>
1558
+ <show_in_store>1</show_in_store>
1559
+ <comment>Short description which is shown on orders/invoices</comment>
1560
+ </payment_fee_label>
1561
  </fields>
1562
  </cgp_giropay>
1563
+
1564
  <cgp_banktransfer translate="label" module="cgp">
1565
  <label>Bank Transfer</label>
1566
  <sort_order>350</sort_order>
1618
  <show_in_default>1</show_in_default>
1619
  <show_in_website>1</show_in_website>
1620
  <show_in_store>1</show_in_store>
1621
+ </sort_order>
1622
+ <payment_fee translate="label">
1623
+ <label>Payment fee</label>
1624
+ <sort_order>110</sort_order>
1625
+ <show_in_default>1</show_in_default>
1626
+ <show_in_website>1</show_in_website>
1627
+ <show_in_store>1</show_in_store>
1628
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
1629
+ </payment_fee>
1630
+ <payment_fee_tax translate="label">
1631
+ <label>Payment fee tax class</label>
1632
+ <frontend_type>select</frontend_type>
1633
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
1634
+ <sort_order>120</sort_order>
1635
+ <show_in_default>1</show_in_default>
1636
+ <show_in_store>1</show_in_store>
1637
+ <show_in_website>1</show_in_website>
1638
+ <comment>Choose the fee's tax class</comment>
1639
+ </payment_fee_tax>
1640
+ <payment_fee_inc_ex translate="label">
1641
+ <label>Including/Excluding Tax</label>
1642
+ <frontend_type>select</frontend_type>
1643
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1644
+ <sort_order>130</sort_order>
1645
+ <show_in_default>1</show_in_default>
1646
+ <show_in_website>1</show_in_website>
1647
+ <show_in_store>1</show_in_store>
1648
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1649
+ </payment_fee_inc_ex>
1650
+ <payment_fee_label translate="label,comment">
1651
+ <label>Payment fee label</label>
1652
+ <sort_order>140</sort_order>
1653
+ <show_in_default>1</show_in_default>
1654
+ <show_in_website>1</show_in_website>
1655
+ <show_in_store>1</show_in_store>
1656
+ <comment>Short description which is shown on orders/invoices</comment>
1657
+ </payment_fee_label>
1658
  </fields>
1659
  </cgp_banktransfer>
1660
 
1707
  <show_in_default>1</show_in_default>
1708
  <show_in_website>1</show_in_website>
1709
  <show_in_store>1</show_in_store>
1710
+ </sort_order>
1711
+ <payment_fee translate="label">
1712
+ <label>Payment fee</label>
1713
+ <sort_order>110</sort_order>
1714
+ <show_in_default>1</show_in_default>
1715
+ <show_in_website>1</show_in_website>
1716
+ <show_in_store>1</show_in_store>
1717
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
1718
+ </payment_fee>
1719
+ <payment_fee_tax translate="label">
1720
+ <label>Payment fee tax class</label>
1721
+ <frontend_type>select</frontend_type>
1722
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
1723
+ <sort_order>120</sort_order>
1724
+ <show_in_default>1</show_in_default>
1725
+ <show_in_store>1</show_in_store>
1726
+ <show_in_website>1</show_in_website>
1727
+ <comment>Choose the fee's tax class</comment>
1728
+ </payment_fee_tax>
1729
+ <payment_fee_inc_ex translate="label">
1730
+ <label>Including/Excluding Tax</label>
1731
+ <frontend_type>select</frontend_type>
1732
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1733
+ <sort_order>130</sort_order>
1734
+ <show_in_default>1</show_in_default>
1735
+ <show_in_website>1</show_in_website>
1736
+ <show_in_store>1</show_in_store>
1737
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1738
+ </payment_fee_inc_ex>
1739
+ <payment_fee_label translate="label,comment">
1740
+ <label>Payment fee label</label>
1741
+ <sort_order>140</sort_order>
1742
+ <show_in_default>1</show_in_default>
1743
+ <show_in_website>1</show_in_website>
1744
+ <show_in_store>1</show_in_store>
1745
+ <comment>Short description which is shown on orders/invoices</comment>
1746
+ </payment_fee_label>
1747
  </fields>
1748
  </cgp_directdebit>
1749
+
1750
  <cgp_przelewy24 translate="label" module="cgp">
1751
  <label>Przelewy24</label>
1752
  <sort_order>370</sort_order>
1796
  <show_in_default>1</show_in_default>
1797
  <show_in_website>1</show_in_website>
1798
  <show_in_store>1</show_in_store>
1799
+ </sort_order>
1800
+ <payment_fee translate="label">
1801
+ <label>Payment fee</label>
1802
+ <sort_order>110</sort_order>
1803
+ <show_in_default>1</show_in_default>
1804
+ <show_in_website>1</show_in_website>
1805
+ <show_in_store>1</show_in_store>
1806
+ <comment>Payment fee amount (eg 0.35 or 1)</comment>
1807
+ </payment_fee>
1808
+ <payment_fee_tax translate="label">
1809
+ <label>Payment fee tax class</label>
1810
+ <frontend_type>select</frontend_type>
1811
+ <source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
1812
+ <sort_order>120</sort_order>
1813
+ <show_in_default>1</show_in_default>
1814
+ <show_in_store>1</show_in_store>
1815
+ <show_in_website>1</show_in_website>
1816
+ <comment>Choose the fee's tax class</comment>
1817
+ </payment_fee_tax>
1818
+ <payment_fee_inc_ex translate="label">
1819
+ <label>Including/Excluding Tax</label>
1820
+ <frontend_type>select</frontend_type>
1821
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1822
+ <sort_order>130</sort_order>
1823
+ <show_in_default>1</show_in_default>
1824
+ <show_in_website>1</show_in_website>
1825
+ <show_in_store>1</show_in_store>
1826
+ <comment>Yes = fee entered including tax / No = fee entered excluding tax</comment>
1827
+ </payment_fee_inc_ex>
1828
+ <payment_fee_label translate="label,comment">
1829
+ <label>Payment fee label</label>
1830
+ <sort_order>140</sort_order>
1831
+ <show_in_default>1</show_in_default>
1832
+ <show_in_website>1</show_in_website>
1833
+ <show_in_store>1</show_in_store>
1834
+ <comment>Short description which is shown on orders/invoices</comment>
1835
+ </payment_fee_label>
1836
  </fields>
1837
  </cgp_przelewy24>
1838
+
1839
  </groups>
1840
  </cgp>
1841
+
1842
  </sections>
1843
  </config>
app/design/frontend/base/default/template/cardgate/cgp/checkout/fee.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ($this->displayBoth()):?>
3
+ <tr>
4
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
5
+ <?php echo $this->getTotal()->getTitle() . " " . $this->getExcludeTaxLabel() ?>
6
+ </td>
7
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
8
+ <?php echo $this->helper('checkout')->formatPrice($this->getInvoiceFeeExcludeTax()) ?>
9
+ </td>
10
+ </tr>
11
+ <tr>
12
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
13
+ <?php echo $this->getTotal()->getTitle() . " " . $this->getIncludeTaxLabel() ?>
14
+ </td>
15
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
16
+ <?php echo $this->helper('checkout')->formatPrice($this->getInvoiceFeeIncludeTax()) ?>
17
+ </td>
18
+ </tr>
19
+ <?php elseif($this->displayIncludeTax()) : ?>
20
+ <tr>
21
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
22
+ <?php echo $this->getTotal()->getTitle() ?>
23
+ </td>
24
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
25
+ <?php echo $this->helper('checkout')->formatPrice($this->getInvoiceFeeIncludeTax()) ?>
26
+ </td>
27
+ </tr>
28
+ <?php else:?>
29
+ <tr>
30
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
31
+ <?php echo $this->getTotal()->getTitle() ?>
32
+ </td>
33
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
34
+ <?php echo $this->helper('checkout')->formatPrice($this->getInvoiceFeeExcludeTax()) ?>
35
+ </td>
36
+ </tr>
37
+ <?php endif;?>
38
+
39
+
app/design/frontend/base/default/template/cardgate/cgp/form/klarna.phtml CHANGED
@@ -86,7 +86,10 @@
86
  </div>
87
  <br>
88
  <?php echo $this->getGermanNotice(); ?>
89
- <?php echo $this->getInvoiceFeeNotice(); ?>
 
 
 
90
  </div>
91
  </div>
92
 
86
  </div>
87
  <br>
88
  <?php echo $this->getGermanNotice(); ?>
89
+ <?php
90
+ // TODO: Remove me
91
+ //echo $this->getInvoiceFeeNotice();
92
+ ?>
93
  </div>
94
  </div>
95
 
app/locale/nl_NL/Cardgate_Cgp.csv CHANGED
@@ -71,10 +71,16 @@
71
  "Direct debit: Waiting for confirmation.","Incasso: wacht op bevestiging."
72
  "Your payment is being evaluated by the bank. Please do not attempt to pay again, until your payment is either confirmed or denied by the bank.","Uw betaling wordt beoordeeld door de bank. Probeer niet nogmaals te betalen, totdat de betaling goed- of afgekeurd is door de bank."
73
  "Your payment has failed. If you wish, you can try using a different payment method.","Uw betaling is niet geslaagd. Indien gewenst, kunt u een andere betaalmethode proberen."
74
- "Invoice Fee (excl. VAT)","Factuurkosten (excl. BTW)"
75
- "Invoice Fee (incl. VAT)","Factuurkosten (incl. BTW)"
76
- "Invoice fee tax class","Factuurkosten BTW class"
77
- "The tax class to use to calculate the invoice fee tax","De BTW class die gebruikt wordt voor het berekenen van de factuurkosten BTW."
 
 
 
 
 
 
78
  "Send Order Email only at payment","Verstuur bestelling Email pas bij betaling"
79
  "Send Order Email only after payment completion.","Verstuur de bestelling Email pas als de betaling afgerond is."
80
  "Instructions","Instructies"
71
  "Direct debit: Waiting for confirmation.","Incasso: wacht op bevestiging."
72
  "Your payment is being evaluated by the bank. Please do not attempt to pay again, until your payment is either confirmed or denied by the bank.","Uw betaling wordt beoordeeld door de bank. Probeer niet nogmaals te betalen, totdat de betaling goed- of afgekeurd is door de bank."
73
  "Your payment has failed. If you wish, you can try using a different payment method.","Uw betaling is niet geslaagd. Indien gewenst, kunt u een andere betaalmethode proberen."
74
+ "Payment fee","Betaaltoeslag"
75
+ "Payment fee amount (eg 0.35 or 1)","Betaaltoeslag bedrag"
76
+ "Payment fee tax class","Betaaltoeslag BTW tarief"
77
+ "Choose the fee's tax class","Kies een BTW tarief voor de toeslag"
78
+ "Including/Excluding Tax","Inclusief/Exclusief BTW"
79
+ "Yes = fee entered including tax / No = fee entered excluding tax","Ja = opgegeven tarief is incl BTW / Nee = opgegeven tarief is excl BTW"
80
+ "Payment fee label","Betaaltoeslag beschrijving"
81
+ "Short description which is shown on orders/invoices","Korte omschrijving welke zichtbaar is op orders/facturen"
82
+
83
+
84
  "Send Order Email only at payment","Verstuur bestelling Email pas bij betaling"
85
  "Send Order Email only after payment completion.","Verstuur de bestelling Email pas als de betaling afgerond is."
86
  "Instructions","Instructies"
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cardgate_Cgp</name>
4
- <version>1.0.38</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Card Gate Plus Payment Module</summary>
10
- <description>Card Gate Plus is a Payment Service Provider from the Netherlands. We offer various payment methods against competitive rates.</description>
11
- <notes>- New payment methods: Carte Bleue and Carte Bancaire.</notes>
12
- <authors><author><name>Richard Schoots</name><user>auto-converted</user><email>support@cardgate.com</email></author></authors>
13
- <date>2015-08-06</date>
14
- <time>11:01:14</time>
15
- <contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="cardgate"><file name="cardgate_cgp.png" hash="b97b15baba0b27042733c8ea4b4fb6bc"/></dir></dir><file name="cardgate_cgp.css" hash="bebfc13fca1b36867c17864ae70fdabd"/></dir></dir></dir></target><target name="magelocale"><dir name="nl_NL"><file name="Cardgate_Cgp.csv" hash="634f39395ba9302afc2eab9da25be4a2"/></dir></target><target name="mageetc"><dir name="modules"><file name="Cardgate_Cgp.xml" hash="c7a72af045f4b737b50cc6c360d4300d"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="cardgate"><dir name="cgp"><dir name="form"><file name="banktransfer.phtml" hash="ff7a2a827a7b7a5ed9bcb5d484c30c68"/><file name="ideal.phtml" hash="42fdfee86ba3a098f5f73e9240332581"/><file name="klarna.phtml" hash="590c98ab018c474e8e4dc65e9199ba85"/><file name="klarnaaccount.phtml" hash="419f88941703c8562369844bb6a1d692"/></dir><file name="redirect.phtml" hash="ecb2b0a854cd6358adeba535f8889046"/></dir></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Cardgate"><dir name="Cgp"><dir name="Block"><dir name="Form"><file name="Banktransfer.php" hash="3fbc8e9778a79aa8802a1a2bd77681f9"/><file name="Ideal.php" hash="c0e11d3161bd93ca869a31d9b54e1b4b"/><file name="Klarna.php" hash="9bdbe1886bcdb283b86b6d208c3aa712"/><file name="Klarnaaccount.php" hash="0b4b84d9c472e815a30d5977ac53c932"/></dir><file name="Redirect.php" hash="668b52ec0c5fba7f42223d4e40a99987"/></dir><dir name="Helper"><file name="Data.php" hash="c94c725de2e14dc8019323c1ecf08962"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Languages.php" hash="4fe09e45e3d9f3866d4b7c8437832972"/><file name="Modes.php" hash="888158f9118ba5087357d5c1ad8514d4"/></dir></dir></dir></dir><dir name="Gateway"><file name="Abstract.php" hash="055acda433b7703c3fb7c0b1b85c80ab"/><file name="Americanexpress.php" hash="e92216206b3b623aab4bd7b6e19741db"/><file name="Banktransfer.php" hash="babaf0ea30aad8aa9540c0879a9e67ca"/><file name="Cartebancaire.php" hash="30f2e9023e8aff6932a39d0545b759ea"/><file name="Cartebleue.php" hash="3fa9e36a6d871c5d2bc8c783404c8fad"/><file name="Default.php" hash="956d1ff0c2cfe0698efc23277e602cec"/><file name="Directdebit.php" hash="aab6b38b231d5add0e3b0fdcb3d73e3c"/><file name="Giropay.php" hash="e4c2497eaf88ddda0ba5d745945ea3bd"/><file name="Ideal.php" hash="430de461f07352905984bfa15adf9eec"/><file name="Klarna.php" hash="330efb073aba572606b1f25b597bb106"/><file name="Klarnaaccount.php" hash="2012566e77136f823e965c8811321ea3"/><file name="Maestro.php" hash="5675bd4e11b38499b209d91ca5367a07"/><file name="Mastercard.php" hash="11a3aca8cc5f3e04e08244e600c67e3d"/><file name="Mistercash.php" hash="ca9bfde52ea045fe73c6287bbb12837c"/><file name="Paypal.php" hash="cc679581956c2ae857404bc84e798fcc"/><file name="Przelewy24.php" hash="577fa43cee76b9546fc8c500a73e341a"/><file name="Sofortbanking.php" hash="7e3a03aec546156f4a3d47cb6232be2f"/><file name="Visa.php" hash="610a7893d1c03515dc1046b789005817"/><file name="Vpay.php" hash="aaf3f019a7a21c5b91a64bf95da81ed8"/><file name="Webmoney.php" hash="fb504c06b78108ac50bf3933fd44ab0e"/></dir><file name="Base.php" hash="8fb25eee8835a524245273e05e07b39d"/><file name="Observer.php" hash="81f7a3c5149f52dcb2d4c7434d250003"/></dir><dir name="controllers"><file name="StandardController.php" hash="51f3acae0faeb38cb719e3f99779e6eb"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1caa98cae31103bb77143f821f68f451"/><file name="config.xml" hash="ff5a880b69ed2f658d2baeb72d134f01"/><file name="system.xml" hash="c29e9f4cd16f77cf08c1b1e7443a9ba4"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cardgate_Cgp</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Card Gate Payment Module</summary>
10
+ <description>Card Gate is a Payment Service Provider from the Netherlands. We offer various payment methods against competitive rates.</description>
11
+ <notes>- Added payment fee options</notes>
12
+ <authors><author><name>Cardgate BV</name><user>cardgateplus</user><email>support@cardgate.com</email></author></authors>
13
+ <date>2015-10-08</date>
14
+ <time>08:04:28</time>
15
+ <contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="cardgate_cgp.css" hash="bebfc13fca1b36867c17864ae70fdabd"/><dir name="images"><dir name="cardgate"><file name="cardgate_cgp.png" hash="b97b15baba0b27042733c8ea4b4fb6bc"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="nl_NL"><file name="Cardgate_Cgp.csv" hash="fd663613a760fa0f253c30aadca0b16b"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardgate_Cgp.xml" hash="c7a72af045f4b737b50cc6c360d4300d"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="cardgate"><dir name="cgp"><dir name="checkout"><file name="fee.phtml" hash="79362bab3963195ad6727d077fe87b11"/></dir><dir name="form"><file name="banktransfer.phtml" hash="ff7a2a827a7b7a5ed9bcb5d484c30c68"/><file name="ideal.phtml" hash="42fdfee86ba3a098f5f73e9240332581"/><file name="klarna.phtml" hash="e2876171abf8e94d7b77a47ce9279561"/><file name="klarnaaccount.phtml" hash="419f88941703c8562369844bb6a1d692"/></dir><file name="redirect.phtml" hash="ecb2b0a854cd6358adeba535f8889046"/></dir></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Cardgate"><dir name="Cgp"><dir name="Block"><dir name="Form"><file name="Banktransfer.php" hash="be49e1b58910ee33b329badaa9fc85ce"/><file name="Ideal.php" hash="1d199462951145674bf1d180fd9b5c69"/><file name="Klarna.php" hash="c66cbcc135151dcc4337d22fc0552a46"/><file name="Klarnaaccount.php" hash="77e35328922bfb232f93896b77367c1e"/></dir><dir name="Paymentfee"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Totals.php" hash="7f4fb8293923e064ecbd77451c52afd9"/></dir></dir></dir><dir name="Checkout"><file name="Fee.php" hash="07e72679dc8ddd5f7e2db9e24bb76aa6"/></dir><dir name="Creditmemo"><file name="Totals.php" hash="87021e3b682c1abf1ae95e173730023a"/></dir><dir name="Invoice"><dir name="Totals"><file name="Fee.php" hash="40c399761dccfd494d7cfb439447c5e3"/></dir></dir><dir name="Order"><dir name="Totals"><file name="Fee.php" hash="0cde857c2b7f33cdb5927143a98f0958"/></dir></dir></dir><file name="Redirect.php" hash="2f854d58133eebad7f128a08d799f7ef"/></dir><dir name="Helper"><file name="Data.php" hash="ed47b3c61a5e701e1683a7717c6b8ef1"/><file name="Paymentfee.php" hash="6ae85c5606efc68ecd188c3513826f3a"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Languages.php" hash="fb24871559fa1ce2613438ad5613a196"/><file name="Modes.php" hash="678a822a7f0c0665fc696c44937825be"/></dir></dir></dir></dir><file name="Base.php" hash="143117456b375ecc92a95b7dd1af6443"/><dir name="Gateway"><file name="Abstract.php" hash="dcba164a178dfc644b42ad30abfb0f97"/><file name="Americanexpress.php" hash="705926d7a69fb889f54185743f4cac9f"/><file name="Banktransfer.php" hash="d4d5712ab327c418ee2d949e49faee01"/><file name="Cartebancaire.php" hash="451bff78fa26e4bae883d0c18ca1f844"/><file name="Cartebleue.php" hash="b7974f8f8e655daaf50a899d15cc15fd"/><file name="Default.php" hash="dd934ee60d32000773f26be805d46925"/><file name="Directdebit.php" hash="7890209183bab5f47edcca60a19cd007"/><file name="Giropay.php" hash="ea35629ddfd08cd341128af6d95c8911"/><file name="Ideal.php" hash="1b5b6318c3e544659f465fdbc463fa51"/><file name="Klarna.php" hash="901891d606ea469296e75251fc7abe14"/><file name="Klarnaaccount.php" hash="4d85440b0df2df05ec001c6a5d7416dd"/><file name="Maestro.php" hash="c29f0bd00282c992017a2487d12d8bda"/><file name="Mastercard.php" hash="3febe4f0ee3cc630cd959e8ce086d2ee"/><file name="Mistercash.php" hash="d618b6ab14ffa5d9810cf65232b6d2a3"/><file name="Paypal.php" hash="ad4600fdc877a84a6a4f8647ae2587df"/><file name="Przelewy24.php" hash="f49bfa8354fa2bce2add3221a04843cf"/><file name="Sofortbanking.php" hash="544531b74c8fd34e7ccd48a32210d81f"/><file name="Visa.php" hash="50cbf582c2b5192923d290fcbec35870"/><file name="Vpay.php" hash="acf7d286f343b4e663a55a8540bf45d2"/><file name="Webmoney.php" hash="72a36f0854db4c02e0477208b47faccf"/></dir><file name="Observer.php" hash="0a8743e670890c04bb3ddcd195c2568d"/><dir name="Paymentfee"><dir name="Creditmemo"><file name="Total.php" hash="5191056c5dae3862c2a468acd3e5cbac"/></dir><dir name="Invoice"><dir name="Pdf"><file name="Total.php" hash="13a82b34e6cacd851572ea210bb7ad74"/></dir><file name="Tax.php" hash="dc485fa37d31e13e20f578cb58075486"/><file name="Total.php" hash="f26e4dc51d0e510eb1c2c65750dec92b"/></dir><dir name="Quote"><file name="Quote.php" hash="949da37dba84caae36b1d2780f4a9df8"/><file name="TaxTotal.php" hash="983bd35479a44d954316de51b5cd5fda"/><file name="Total.php" hash="398944b8a703fda9b670865a88894553"/></dir></dir></dir><dir name="controllers"><file name="StandardController.php" hash="784074fd16c959cc45f77e6f482b6d01"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f14dc99c26f44cc53b4a5974dd9cdd2d"/><file name="config.xml" hash="249b411cc0f1cfacea8d1906bbc0fde9"/><file name="system.xml" hash="ef3e29a64439383f4c2a009f6a46af65"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>