Mage_Payone - Version 3.1.9

Version Notes

Mage_Payone-3.1.9

Download this release

Release Info

Developer noovias
Extension Mage_Payone
Version 3.1.9
Comparing to
See all releases


Code changes from version 3.1.8 to 3.1.9

Files changed (39) hide show
  1. app/code/community/Payone/Core/Block/Payment/Method/Info/CashOnDelivery.php +40 -40
  2. app/code/community/Payone/Core/Block/Payment/Method/Info/SafeInvoice.php +163 -163
  3. app/code/community/Payone/Core/Model/Config/General/Global.php +246 -246
  4. app/code/community/Payone/Core/Model/Config/Protect/AddressCheck.php +30 -0
  5. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Abstract.php +541 -541
  6. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php +3 -2
  7. app/code/community/Payone/Core/Model/Mapper/ApiRequest/Verification/AddressCheck.php +119 -113
  8. app/code/community/Payone/Core/Model/Observer/Checkout/Onepage/DebitPayment.php +35 -6
  9. app/code/community/Payone/Core/Model/Observer/Sales/Order.php +80 -78
  10. app/code/community/Payone/Core/Model/Observer/Sales/Order/Invoice.php +12 -0
  11. app/code/community/Payone/Core/Model/Observer/Sales/Quote/Address.php +38 -2
  12. app/code/community/Payone/Core/Model/Observer/TransactionStatus/InvoiceCreate.php +206 -206
  13. app/code/community/Payone/Core/Model/Payment/Method/Abstract.php +24 -17
  14. app/code/community/Payone/Core/Model/Payment/Method/SafeInvoice.php +136 -136
  15. app/code/community/Payone/Core/Model/Sales/Quote/Address.php +14 -0
  16. app/code/community/Payone/Core/Model/Service/Payment/Abstract.php +154 -154
  17. app/code/community/Payone/Core/Model/Service/TransactionStatus/Process.php +194 -194
  18. app/code/community/Payone/Core/Model/Service/TransactionStatus/StoreClearingParameters.php +83 -83
  19. app/code/community/Payone/Core/Model/System/Config/Abstract.php +3 -0
  20. app/code/community/Payone/Core/Model/System/Config/OrderStatus.php +21 -1
  21. app/code/community/Payone/Core/controllers/Checkout/Onepage/PaymentController.php +207 -207
  22. app/code/community/Payone/Core/controllers/Checkout/OnepageController.php +6 -60
  23. app/code/community/Payone/Core/etc/config.xml +12 -3
  24. app/code/community/Payone/Core/etc/system.xml +9 -0
  25. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.0.3-3.0.4.php +50 -50
  26. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.0.8-3.0.9.php +59 -59
  27. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.1.3-3.1.4.php +59 -59
  28. app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-3.1.4-3.1.5.php +58 -58
  29. app/code/community/Payone/Core/sql/payone_core_setup/upgrade-3.1.3-3.1.4.sql +10 -10
  30. app/code/community/Payone/Core/sql/payone_core_setup/upgrade-3.1.4-3.1.5.sql +6 -6
  31. app/design/adminhtml/default/default/template/payone/core/payment/method/form/debitpayment.phtml +1 -1
  32. app/design/adminhtml/default/default/template/payone/core/payment/method/info/cashondelivery.phtml +32 -32
  33. app/design/frontend/base/default/template/payone/core/checkout/onepage/review/sepamandate.phtml +1 -1
  34. app/design/frontend/base/default/template/payone/core/checkout/protect.phtml +7 -2
  35. app/design/frontend/base/default/template/payone/core/payment/method/form/onlinebanktransfer/bankgroup.phtml +74 -74
  36. app/design/frontend/base/default/template/payone/core/payment/method/info/safe_invoice.phtml +47 -47
  37. app/locale/de_DE/Payone_Core.csv +1 -0
  38. js/payone/core/debitpayment.js +18 -5
  39. package.xml +5 -5
app/code/community/Payone/Core/Block/Payment/Method/Info/CashOnDelivery.php CHANGED
@@ -1,41 +1,41 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
- * versions in the future. If you wish to customize Payone_Core for your
13
- * needs please refer to http://www.payone.de for more information.
14
- *
15
- * @category Payone
16
- * @package Payone_Core_Block
17
- * @subpackage Payment
18
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
- * @author Matthias Walter <info@noovias.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.noovias.com
22
- */
23
-
24
- /**
25
- *
26
- * @category Payone
27
- * @package Payone_Core_Block
28
- * @subpackage Payment
29
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
- * @link http://www.noovias.com
32
- */
33
- class Payone_Core_Block_Payment_Method_Info_CashOnDelivery
34
- extends Payone_Core_Block_Payment_Method_Info_Abstract
35
- {
36
- protected function _construct()
37
- {
38
- parent::_construct();
39
- $this->setTemplate('payone/core/payment/method/info/cashondelivery.phtml');
40
- }
41
}
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
+ * versions in the future. If you wish to customize Payone_Core for your
13
+ * needs please refer to http://www.payone.de for more information.
14
+ *
15
+ * @category Payone
16
+ * @package Payone_Core_Block
17
+ * @subpackage Payment
18
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
+ * @author Matthias Walter <info@noovias.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.noovias.com
22
+ */
23
+
24
+ /**
25
+ *
26
+ * @category Payone
27
+ * @package Payone_Core_Block
28
+ * @subpackage Payment
29
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
+ * @link http://www.noovias.com
32
+ */
33
+ class Payone_Core_Block_Payment_Method_Info_CashOnDelivery
34
+ extends Payone_Core_Block_Payment_Method_Info_Abstract
35
+ {
36
+ protected function _construct()
37
+ {
38
+ parent::_construct();
39
+ $this->setTemplate('payone/core/payment/method/info/cashondelivery.phtml');
40
+ }
41
}
app/code/community/Payone/Core/Block/Payment/Method/Info/SafeInvoice.php CHANGED
@@ -1,164 +1,164 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
- * versions in the future. If you wish to customize Payone_Core for your
13
- * needs please refer to http://www.payone.de for more information.
14
- *
15
- * @category Payone
16
- * @package Payone_Core_Block
17
- * @subpackage Payment
18
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
- * @author Matthias Walter <info@noovias.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.noovias.com
22
- */
23
-
24
- /**
25
- *
26
- * @category Payone
27
- * @package Payone_Core_Block
28
- * @subpackage Payment
29
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
- * @link http://www.noovias.com
32
- */
33
- class Payone_Core_Block_Payment_Method_Info_SafeInvoice
34
- extends Payone_Core_Block_Payment_Method_Info_Abstract
35
- {
36
- protected function _construct()
37
- {
38
- parent::_construct();
39
- $this->setTemplate('payone/core/payment/method/info/safe_invoice.phtml');
40
-
41
- }
42
-
43
- /**
44
- * @return string
45
- */
46
- public function getSafeInvoiceType()
47
- {
48
- $model = $this->getFactory()->getModelSystemConfigSafeInvoiceType();
49
- $array = $model->toSelectArray();
50
-
51
- $safeInvoiceType = $this->getInfo()->getPayoneSafeInvoiceType();
52
- if (array_key_exists($safeInvoiceType, $array)) {
53
- return $array[$safeInvoiceType];
54
- }
55
- return '';
56
- }
57
-
58
- public function toPdf()
59
- {
60
- $this->setTemplate('payone/core/payment/method/pdf/safe_invoice.phtml');
61
- return $this->toHtml();
62
- }
63
-
64
-
65
- /**
66
- * @return string
67
- */
68
- public function getPayoneClearingBankAccountholder()
69
- {
70
- return $this->getInfo()->getPayoneClearingBankAccountholder();
71
- }
72
-
73
- /**
74
- * @return string
75
- */
76
- public function getPayoneClearingBankCountry()
77
- {
78
- return $this->getInfo()->getPayoneClearingBankCountry();
79
- }
80
-
81
- /**
82
- * @return string
83
- */
84
- public function getPayoneClearingBankAccount()
85
- {
86
- return $this->getInfo()->getPayoneClearingBankAccount();
87
- }
88
-
89
- /**
90
- * @return string
91
- */
92
- public function getPayoneClearingBankCode()
93
- {
94
- return $this->getInfo()->getPayoneClearingBankCode();
95
- }
96
-
97
- /**
98
- * @return string
99
- */
100
- public function getPayoneClearingBankIban()
101
- {
102
- return $this->getInfo()->getPayoneClearingBankIban();
103
- }
104
-
105
- /**
106
- * @return string
107
- */
108
- public function getPayoneClearingBankBic()
109
- {
110
- return $this->getInfo()->getPayoneClearingBankBic();
111
- }
112
-
113
- /**
114
- * @return string
115
- */
116
- public function getPayoneClearingBankCity()
117
- {
118
- return $this->getInfo()->getPayoneClearingBankCity();
119
- }
120
-
121
- /**
122
- * @return string
123
- */
124
- public function getPayoneClearingBankName()
125
- {
126
- return $this->getInfo()->getPayoneClearingBankName();
127
- }
128
-
129
-
130
- /**
131
- * @return string
132
- */
133
- public function getPayoneClearingReference()
134
- {
135
- return $this->getInfo()->getPayoneClearingReference();
136
- }
137
-
138
-
139
- /**
140
- * @return string
141
- */
142
- public function getPayoneClearingInstructionnote()
143
- {
144
- return $this->getInfo()->getPayoneClearingInstructionnote();
145
- }
146
-
147
-
148
- /**
149
- * @return string
150
- */
151
- public function getPayoneClearingLegalnote()
152
- {
153
- return $this->getInfo()->getPayoneClearingLegalnote();
154
- }
155
-
156
-
157
- /**
158
- * @return string
159
- */
160
- public function getPayoneClearingDuedate()
161
- {
162
- return $this->getInfo()->getPayoneClearingDuedate();
163
- }
164
}
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
+ * versions in the future. If you wish to customize Payone_Core for your
13
+ * needs please refer to http://www.payone.de for more information.
14
+ *
15
+ * @category Payone
16
+ * @package Payone_Core_Block
17
+ * @subpackage Payment
18
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
+ * @author Matthias Walter <info@noovias.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.noovias.com
22
+ */
23
+
24
+ /**
25
+ *
26
+ * @category Payone
27
+ * @package Payone_Core_Block
28
+ * @subpackage Payment
29
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
+ * @link http://www.noovias.com
32
+ */
33
+ class Payone_Core_Block_Payment_Method_Info_SafeInvoice
34
+ extends Payone_Core_Block_Payment_Method_Info_Abstract
35
+ {
36
+ protected function _construct()
37
+ {
38
+ parent::_construct();
39
+ $this->setTemplate('payone/core/payment/method/info/safe_invoice.phtml');
40
+
41
+ }
42
+
43
+ /**
44
+ * @return string
45
+ */
46
+ public function getSafeInvoiceType()
47
+ {
48
+ $model = $this->getFactory()->getModelSystemConfigSafeInvoiceType();
49
+ $array = $model->toSelectArray();
50
+
51
+ $safeInvoiceType = $this->getInfo()->getPayoneSafeInvoiceType();
52
+ if (array_key_exists($safeInvoiceType, $array)) {
53
+ return $array[$safeInvoiceType];
54
+ }
55
+ return '';
56
+ }
57
+
58
+ public function toPdf()
59
+ {
60
+ $this->setTemplate('payone/core/payment/method/pdf/safe_invoice.phtml');
61
+ return $this->toHtml();
62
+ }
63
+
64
+
65
+ /**
66
+ * @return string
67
+ */
68
+ public function getPayoneClearingBankAccountholder()
69
+ {
70
+ return $this->getInfo()->getPayoneClearingBankAccountholder();
71
+ }
72
+
73
+ /**
74
+ * @return string
75
+ */
76
+ public function getPayoneClearingBankCountry()
77
+ {
78
+ return $this->getInfo()->getPayoneClearingBankCountry();
79
+ }
80
+
81
+ /**
82
+ * @return string
83
+ */
84
+ public function getPayoneClearingBankAccount()
85
+ {
86
+ return $this->getInfo()->getPayoneClearingBankAccount();
87
+ }
88
+
89
+ /**
90
+ * @return string
91
+ */
92
+ public function getPayoneClearingBankCode()
93
+ {
94
+ return $this->getInfo()->getPayoneClearingBankCode();
95
+ }
96
+
97
+ /**
98
+ * @return string
99
+ */
100
+ public function getPayoneClearingBankIban()
101
+ {
102
+ return $this->getInfo()->getPayoneClearingBankIban();
103
+ }
104
+
105
+ /**
106
+ * @return string
107
+ */
108
+ public function getPayoneClearingBankBic()
109
+ {
110
+ return $this->getInfo()->getPayoneClearingBankBic();
111
+ }
112
+
113
+ /**
114
+ * @return string
115
+ */
116
+ public function getPayoneClearingBankCity()
117
+ {
118
+ return $this->getInfo()->getPayoneClearingBankCity();
119
+ }
120
+
121
+ /**
122
+ * @return string
123
+ */
124
+ public function getPayoneClearingBankName()
125
+ {
126
+ return $this->getInfo()->getPayoneClearingBankName();
127
+ }
128
+
129
+
130
+ /**
131
+ * @return string
132
+ */
133
+ public function getPayoneClearingReference()
134
+ {
135
+ return $this->getInfo()->getPayoneClearingReference();
136
+ }
137
+
138
+
139
+ /**
140
+ * @return string
141
+ */
142
+ public function getPayoneClearingInstructionnote()
143
+ {
144
+ return $this->getInfo()->getPayoneClearingInstructionnote();
145
+ }
146
+
147
+
148
+ /**
149
+ * @return string
150
+ */
151
+ public function getPayoneClearingLegalnote()
152
+ {
153
+ return $this->getInfo()->getPayoneClearingLegalnote();
154
+ }
155
+
156
+
157
+ /**
158
+ * @return string
159
+ */
160
+ public function getPayoneClearingDuedate()
161
+ {
162
+ return $this->getInfo()->getPayoneClearingDuedate();
163
+ }
164
}
app/code/community/Payone/Core/Model/Config/General/Global.php CHANGED
@@ -1,246 +1,246 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
- * versions in the future. If you wish to customize Payone_Core for your
13
- * needs please refer to http://www.payone.de for more information.
14
- *
15
- * @category Payone
16
- * @package Payone_Core_Model
17
- * @subpackage Config
18
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
- * @author Matthias Walter <info@noovias.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.noovias.com
22
- */
23
-
24
- /**
25
- *
26
- * @category Payone
27
- * @package Payone_Core_Model
28
- * @subpackage Config
29
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
- * @link http://www.noovias.com
32
- */
33
- class Payone_Core_Model_Config_General_Global extends Payone_Core_Model_Config_AreaAbstract
34
- {
35
- /**
36
- * @var int
37
- */
38
- protected $mid = 0;
39
- /**
40
- * @var int
41
- */
42
- protected $portalid = 0;
43
- /**
44
- * @var int
45
- */
46
- protected $aid = 0;
47
- /**
48
- * @var string
49
- */
50
- protected $key = '';
51
- /**
52
- * @var int
53
- */
54
- protected $allowspecific = 0;
55
- /**
56
- * @var array
57
- */
58
- protected $specificcountry = array();
59
- /**
60
- * @var string
61
- */
62
- protected $request_type = '';
63
- /**
64
- * @var int
65
- */
66
- protected $transmit_ip = 1;
67
- /**
68
- * @var int
69
- */
70
- protected $proxy_mode = 0;
71
-
72
- /**
73
- * initialize config with specificcounty as array
74
- * @param array $data
75
- */
76
- public function init(array $data)
77
- {
78
- if(array_key_exists('specificcountry',$data) && is_string($data['specificcountry']))
79
- {
80
- $data['specificcountry_by_string'] = $data['specificcountry'];
81
- unset($data['specificcountry']);
82
- }
83
-
84
- parent::init($data);
85
- }
86
-
87
- /**
88
- * @param int $aid
89
- */
90
- public function setAid($aid)
91
- {
92
- $this->aid = $aid;
93
- }
94
-
95
- /**
96
- * @return int
97
- */
98
- public function getAid()
99
- {
100
- return $this->aid;
101
- }
102
-
103
- /**
104
- * @param int $allowspecific
105
- */
106
- public function setAllowspecific($allowspecific)
107
- {
108
- $this->allowspecific = $allowspecific;
109
- }
110
-
111
- /**
112
- * @return int
113
- */
114
- public function getAllowspecific()
115
- {
116
- return $this->allowspecific;
117
- }
118
-
119
- /**
120
- * @param string $key
121
- */
122
- public function setKey($key)
123
- {
124
- $this->key = $key;
125
- }
126
-
127
- /**
128
- * @return string
129
- */
130
- public function getKey()
131
- {
132
- return $this->key;
133
- }
134
-
135
- /**
136
- * @param int $mid
137
- */
138
- public function setMid($mid)
139
- {
140
- $this->mid = $mid;
141
- }
142
-
143
- /**
144
- * @return int
145
- */
146
- public function getMid()
147
- {
148
- return $this->mid;
149
- }
150
-
151
- /**
152
- * @param int $portalid
153
- */
154
- public function setPortalid($portalid)
155
- {
156
- $this->portalid = $portalid;
157
- }
158
-
159
- /**
160
- * @return int
161
- */
162
- public function getPortalid()
163
- {
164
- return $this->portalid;
165
- }
166
-
167
- /**
168
- * @param string $request_type
169
- */
170
- public function setRequestType($request_type)
171
- {
172
- $this->request_type = $request_type;
173
- }
174
-
175
- /**
176
- * @return string
177
- */
178
- public function getRequestType()
179
- {
180
- return $this->request_type;
181
- }
182
-
183
- /**
184
- * @param array $specificcountry
185
- */
186
- public function setSpecificcountry(array $specificcountry)
187
- {
188
- $this->specificcountry = $specificcountry;
189
- }
190
-
191
- /**
192
- * @return array
193
- */
194
- public function getSpecificcountry()
195
- {
196
- return $this->specificcountry;
197
- }
198
-
199
- /**
200
- * @param $specificcountry
201
- */
202
- public function setSpecificcountryByString($specificcountry)
203
- {
204
- $this->specificcountry = explode(',', $specificcountry);
205
- }
206
-
207
- /**
208
- * @return string
209
- */
210
- public function getSpecificcountryAsString()
211
- {
212
- return implode(',', $this->specificcountry);
213
- }
214
-
215
- /**
216
- * @param int $transmit_ip
217
- */
218
- public function setTransmitIp($transmit_ip)
219
- {
220
- $this->transmit_ip = $transmit_ip;
221
- }
222
-
223
- /**
224
- * @return int
225
- */
226
- public function getTransmitIp()
227
- {
228
- return $this->transmit_ip;
229
- }
230
-
231
- /**
232
- * @param int $proxy_mode
233
- */
234
- public function setProxyMode($proxy_mode)
235
- {
236
- $this->proxy_mode = $proxy_mode;
237
- }
238
-
239
- /**
240
- * @return int
241
- */
242
- public function getProxyMode()
243
- {
244
- return $this->proxy_mode;
245
- }
246
- }
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
+ * versions in the future. If you wish to customize Payone_Core for your
13
+ * needs please refer to http://www.payone.de for more information.
14
+ *
15
+ * @category Payone
16
+ * @package Payone_Core_Model
17
+ * @subpackage Config
18
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
+ * @author Matthias Walter <info@noovias.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.noovias.com
22
+ */
23
+
24
+ /**
25
+ *
26
+ * @category Payone
27
+ * @package Payone_Core_Model
28
+ * @subpackage Config
29
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
+ * @link http://www.noovias.com
32
+ */
33
+ class Payone_Core_Model_Config_General_Global extends Payone_Core_Model_Config_AreaAbstract
34
+ {
35
+ /**
36
+ * @var int
37
+ */
38
+ protected $mid = 0;
39
+ /**
40
+ * @var int
41
+ */
42
+ protected $portalid = 0;
43
+ /**
44
+ * @var int
45
+ */
46
+ protected $aid = 0;
47
+ /**
48
+ * @var string
49
+ */
50
+ protected $key = '';
51
+ /**
52
+ * @var int
53
+ */
54
+ protected $allowspecific = 0;
55
+ /**
56
+ * @var array
57
+ */
58
+ protected $specificcountry = array();
59
+ /**
60
+ * @var string
61
+ */
62
+ protected $request_type = '';
63
+ /**
64
+ * @var int
65
+ */
66
+ protected $transmit_ip = 1;
67
+ /**
68
+ * @var int
69
+ */
70
+ protected $proxy_mode = 0;
71
+
72
+ /**
73
+ * initialize config with specificcounty as array
74
+ * @param array $data
75
+ */
76
+ public function init(array $data)
77
+ {
78
+ if(array_key_exists('specificcountry',$data) && is_string($data['specificcountry']))
79
+ {
80
+ $data['specificcountry_by_string'] = $data['specificcountry'];
81
+ unset($data['specificcountry']);
82
+ }
83
+
84
+ parent::init($data);
85
+ }
86
+
87
+ /**
88
+ * @param int $aid
89
+ */
90
+ public function setAid($aid)
91
+ {
92
+ $this->aid = $aid;
93
+ }
94
+
95
+ /**
96
+ * @return int
97
+ */
98
+ public function getAid()
99
+ {
100
+ return $this->aid;
101
+ }
102
+
103
+ /**
104
+ * @param int $allowspecific
105
+ */
106
+ public function setAllowspecific($allowspecific)
107
+ {
108
+ $this->allowspecific = $allowspecific;
109
+ }
110
+
111
+ /**
112
+ * @return int
113
+ */
114
+ public function getAllowspecific()
115
+ {
116
+ return $this->allowspecific;
117
+ }
118
+
119
+ /**
120
+ * @param string $key
121
+ */
122
+ public function setKey($key)
123
+ {
124
+ $this->key = $key;
125
+ }
126
+
127
+ /**
128
+ * @return string
129
+ */
130
+ public function getKey()
131
+ {
132
+ return $this->key;
133
+ }
134
+
135
+ /**
136
+ * @param int $mid
137
+ */
138
+ public function setMid($mid)
139
+ {
140
+ $this->mid = $mid;
141
+ }
142
+
143
+ /**
144
+ * @return int
145
+ */
146
+ public function getMid()
147
+ {
148
+ return $this->mid;
149
+ }
150
+
151
+ /**
152
+ * @param int $portalid
153
+ */
154
+ public function setPortalid($portalid)
155
+ {
156
+ $this->portalid = $portalid;
157
+ }
158
+
159
+ /**
160
+ * @return int
161
+ */
162
+ public function getPortalid()
163
+ {
164
+ return $this->portalid;
165
+ }
166
+
167
+ /**
168
+ * @param string $request_type
169
+ */
170
+ public function setRequestType($request_type)
171
+ {
172
+ $this->request_type = $request_type;
173
+ }
174
+
175
+ /**
176
+ * @return string
177
+ */
178
+ public function getRequestType()
179
+ {
180
+ return $this->request_type;
181
+ }
182
+
183
+ /**
184
+ * @param array $specificcountry
185
+ */
186
+ public function setSpecificcountry(array $specificcountry)
187
+ {
188
+ $this->specificcountry = $specificcountry;
189
+ }
190
+
191
+ /**
192
+ * @return array
193
+ */
194
+ public function getSpecificcountry()
195
+ {
196
+ return $this->specificcountry;
197
+ }
198
+
199
+ /**
200
+ * @param $specificcountry
201
+ */
202
+ public function setSpecificcountryByString($specificcountry)
203
+ {
204
+ $this->specificcountry = explode(',', $specificcountry);
205
+ }
206
+
207
+ /**
208
+ * @return string
209
+ */
210
+ public function getSpecificcountryAsString()
211
+ {
212
+ return implode(',', $this->specificcountry);
213
+ }
214
+
215
+ /**
216
+ * @param int $transmit_ip
217
+ */
218
+ public function setTransmitIp($transmit_ip)
219
+ {
220
+ $this->transmit_ip = $transmit_ip;
221
+ }
222
+
223
+ /**
224
+ * @return int
225
+ */
226
+ public function getTransmitIp()
227
+ {
228
+ return $this->transmit_ip;
229
+ }
230
+
231
+ /**
232
+ * @param int $proxy_mode
233
+ */
234
+ public function setProxyMode($proxy_mode)
235
+ {
236
+ $this->proxy_mode = $proxy_mode;
237
+ }
238
+
239
+ /**
240
+ * @return int
241
+ */
242
+ public function getProxyMode()
243
+ {
244
+ return $this->proxy_mode;
245
+ }
246
+ }
app/code/community/Payone/Core/Model/Config/Protect/AddressCheck.php CHANGED
@@ -76,6 +76,9 @@ class Payone_Core_Model_Config_Protect_AddressCheck
76
*/
77
protected $mapping_personstatus = null;
78
79
public function init(array $data)
80
{
81
foreach ($data as $key => $value) {
@@ -153,6 +156,17 @@ class Payone_Core_Model_Config_Protect_AddressCheck
153
return true;
154
}
155
156
/**
157
* @param int $check_shipping
158
*/
@@ -169,6 +183,22 @@ class Payone_Core_Model_Config_Protect_AddressCheck
169
return $this->check_shipping;
170
}
171
172
/**
173
* @param int $enabled
174
*/
76
*/
77
protected $mapping_personstatus = null;
78
79
+ /** @var int */
80
+ protected $check_billing_for_virtual_order = 0;
81
+
82
public function init(array $data)
83
{
84
foreach ($data as $key => $value) {
156
return true;
157
}
158
159
+ /**
160
+ * @return bool
161
+ */
162
+ public function mustCheckBillingForVirtualOrder()
163
+ {
164
+ if ($this->getCheckBillingForVirtualOrder()) {
165
+ return true;
166
+ }
167
+ return false;
168
+ }
169
+
170
/**
171
* @param int $check_shipping
172
*/
183
return $this->check_shipping;
184
}
185
186
+ /**
187
+ * @param int $check_billing_for_virtual_order
188
+ */
189
+ public function setCheckBillingForVirtualOrder($check_billing_for_virtual_order)
190
+ {
191
+ $this->check_billing_for_virtual_order = $check_billing_for_virtual_order;
192
+ }
193
+
194
+ /**
195
+ * @return int
196
+ */
197
+ public function getCheckBillingForVirtualOrder()
198
+ {
199
+ return $this->check_billing_for_virtual_order;
200
+ }
201
+
202
/**
203
* @param int $enabled
204
*/
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Abstract.php CHANGED
@@ -1,542 +1,542 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
- * versions in the future. If you wish to customize Payone_Core for your
13
- * needs please refer to http://www.payone.de for more information.
14
- *
15
- * @category Payone
16
- * @package Payone_Core_Model
17
- * @subpackage Mapper
18
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
- * @author Matthias Walter <info@noovias.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.noovias.com
22
- */
23
-
24
- /**
25
- *
26
- * @category Payone
27
- * @package Payone_Core_Model
28
- * @subpackage Mapper
29
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
- * @link http://www.noovias.com
32
- */
33
- abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
34
- extends Payone_Core_Model_Mapper_ApiRequest_Abstract
35
- implements Payone_Core_Model_Mapper_ApiRequest_Payment_Interface
36
- {
37
- const DEFAULT_SHIPPING_SKU = 'Shipping';
38
- const DEFAULT_ADJUSTMENT_POSITIVE_SKU = 'Adjustment Refund';
39
- const DEFAULT_ADJUSTMENT_NEGATIVE_SKU = 'Adjustment Fee';
40
-
41
- const DEFAULT_DISCOUNT_SKU = 'Discount';
42
- const DEFAULT_TAX_SKU = 'Tax';
43
-
44
- const EVENT_PREFIX = 'payone_core_mapper_apirequest_payment';
45
-
46
- /** @var float */
47
- protected $amount = 0.00;
48
-
49
- /** @var Mage_Sales_Model_Order */
50
- protected $order = null;
51
-
52
- /** @var Payone_Core_Model_Payment_Method_Abstract */
53
- protected $paymentMethod = null;
54
-
55
- /** @var Payone_Core_Model_Config_Payment_Method_Interface */
56
- protected $configPayment = null;
57
-
58
- /** @var Payone_Core_Model_Config_Misc */
59
- protected $configMisc = null;
60
-
61
- /**
62
- * @return string
63
- */
64
- abstract public function getEventType();
65
-
66
- /**
67
- * @param Mage_Sales_Model_Order_Payment $payment
68
- */
69
- protected function init(Mage_Sales_Model_Order_Payment $payment)
70
- {
71
- $this->setOrder($payment->getOrder());
72
- $this->setPaymentMethod($payment->getMethodInstance());
73
- }
74
-
75
- /**
76
- * @param Payone_Api_Request_Interface $request
77
- */
78
- protected function mapDefaultParameters(Payone_Api_Request_Interface $request)
79
- {
80
- $helper = $this->helper();
81
-
82
- $solutionName = 'noovias';
83
- $solutionVersion = $helper->getPayoneVersion();
84
- $integratorName = 'magento';
85
- $integratorVersion = $helper->getMagentoVersion();
86
-
87
- $request->setEncoding('UTF-8');
88
- $request->setMid($this->getConfigPayment()->getMid());
89
- $request->setPortalid($this->getConfigPayment()->getPortalid());
90
- $request->setMode($this->getConfigPayment()->getMode());
91
- $request->setKey($this->getConfigPayment()->getKey());
92
- $request->setIntegratorName($integratorName);
93
- $request->setIntegratorVersion($integratorVersion);
94
- $request->setSolutionName($solutionName);
95
- $request->setSolutionVersion($solutionVersion);
96
- }
97
-
98
- /**
99
- * @return Payone_Api_Request_Parameter_Invoicing_Item
100
- */
101
- protected function mapShippingFeeAsItem()
102
- {
103
- $order = $this->getOrder();
104
-
105
- $configMiscShipping = $this->getConfigMisc()->getShippingCosts();
106
- $sku = $configMiscShipping->getSku();
107
- if (empty($sku)) {
108
- $sku = $this->helper()->__(self::DEFAULT_SHIPPING_SKU);
109
- }
110
- $params['id'] = $sku;
111
- $params['de'] = $order->getShippingDescription();
112
- $params['no'] = 1;
113
- $params['pr'] = $order->getShippingInclTax();
114
- $params['va'] = $this->getShippingTaxRate();
115
-
116
- if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
117
- $params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
118
- }
119
-
120
- $item = new Payone_Api_Request_Parameter_Invoicing_Item();
121
- $item->init($params);
122
-
123
- return $item;
124
- }
125
-
126
- /**
127
- * @param float $discountAmount
128
- * @return Payone_Api_Request_Parameter_Invoicing_Item
129
- */
130
- protected function mapDiscountAsItem($discountAmount)
131
- {
132
- $configMiscDiscount = $this->getConfigMisc()->getDiscount();
133
- $sku = $configMiscDiscount->getSku();
134
- $description = $configMiscDiscount->getDescription();
135
- if (empty($sku)) {
136
- $sku = $this->helper()->__(self::DEFAULT_DISCOUNT_SKU);
137
- }
138
- if (empty($description)) {
139
- $description = $this->helper()->__(self::DEFAULT_DISCOUNT_SKU);
140
- }
141
-
142
- $params['id'] = $sku;
143
- $params['de'] = $description;
144
- $params['no'] = 1;
145
- $params['pr'] = $discountAmount;
146
-
147
- if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
148
- $params['it'] = Payone_Api_Enum_InvoicingItemType::VOUCHER;
149
- }
150
- $item = new Payone_Api_Request_Parameter_Invoicing_Item();
151
- $item->init($params);
152
-
153
- return $item;
154
- }
155
-
156
- /**
157
- * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
158
- * @return Payone_Api_Request_Parameter_Invoicing_Item
159
- *
160
- * used by Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
161
- */
162
- protected function mapRefundShippingAsItemByCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
163
- {
164
- $order = $this->getOrder();
165
-
166
- $configMiscShipping = $this->getConfigMisc()->getShippingCosts();
167
- $sku = $configMiscShipping->getSku();
168
- if (empty($sku)) {
169
- $sku = $this->helper()->__(self::DEFAULT_SHIPPING_SKU);
170
- }
171
-
172
- $params['id'] = $sku;
173
- $params['de'] = $order->getShippingDescription();
174
- $params['no'] = 1;
175
- $params['pr'] = $creditmemo->getShippingInclTax();
176
- if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
177
- $params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
178
- }
179
-
180
- $item = new Payone_Api_Request_Parameter_Invoicing_Item();
181
- $item->init($params);
182
-
183
- return $item;
184
- }
185
-
186
- /**
187
- * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
188
- * @return Payone_Api_Request_Parameter_Invoicing_Item
189
- *
190
- * used by Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
191
- */
192
- protected function mapAdjustmentPositiveAsItemByCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
193
- {
194
- $configMiscCreditmemo = $this->getConfigMisc()->getCreditmemo();
195
- $sku = $configMiscCreditmemo->getAdjustmentRefundSku();
196
- $name = $configMiscCreditmemo->getAdjustmentRefundName();
197
- if (empty($sku)) {
198
- $sku = $this->helper()->__(self::DEFAULT_ADJUSTMENT_POSITIVE_SKU);
199
- }
200
- if (empty($name)) {
201
- $name = $this->helper()->__(self::DEFAULT_ADJUSTMENT_POSITIVE_SKU);
202
- }
203
-
204
- $params['id'] = $sku;
205
- $params['de'] = $name;
206
- $params['no'] = 1;
207
- $params['pr'] = $creditmemo->getAdjustmentPositive();
208
- if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
209
- $params['it'] = Payone_Api_Enum_InvoicingItemType::VOUCHER;
210
- }
211
-
212
- $item = new Payone_Api_Request_Parameter_Invoicing_Item();
213
- $item->init($params);
214
-
215
- return $item;
216
- }
217
-
218
- /**
219
- * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
220
- * @return Payone_Api_Request_Parameter_Invoicing_Item
221
- *
222
- * used by Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
223
- */
224
-
225
- protected function mapAdjustmentNegativeAsItemByCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
226
- {
227
- $configMiscCreditmemo = $this->getConfigMisc()->getCreditmemo();
228
- $sku = $configMiscCreditmemo->getAdjustmentFeeSku();
229
- $name = $configMiscCreditmemo->getAdjustmentFeeName();
230
- if (empty($sku)) {
231
- $sku = $this->helper()->__(self::DEFAULT_ADJUSTMENT_NEGATIVE_SKU);
232
- }
233
- if (empty($name)) {
234
- $name = $this->helper()->__(self::DEFAULT_ADJUSTMENT_NEGATIVE_SKU);
235
- }
236
-
237
- $params['id'] = $sku;
238
- $params['de'] = $name;
239
- $params['no'] = 1;
240
- $params['pr'] = $creditmemo->getAdjustmentNegative() * (-1);
241
- if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
242
- $params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS;
243
- }
244
-
245
- $item = new Payone_Api_Request_Parameter_Invoicing_Item();
246
- $item->init($params);
247
-
248
- return $item;
249
- }
250
-
251
-
252
- protected function getShippingTaxRate()
253
- {
254
- $order = $this->getOrder();
255
- $storeId = $this->getStoreId();
256
- $factory = $this->getFactory();
257
- $store = $factory->getModelCoreStore()->load($storeId);
258
-
259
- /** @var $taxCalculationModel Mage_Tax_Model_Calculation */
260
- $taxCalculationModel = $factory->getSingletonTaxCalculation();
261
-
262
- $shippingAddress = $order->getShippingAddress();
263
- $billingAddress = $order->getBillingAddress();
264
- $quoteId = $order->getQuoteId();
265
- $quote = $factory->getModelSalesQuote();
266
- $quote->load($quoteId);
267
-
268
- $customerTaxClassId = $quote->getCustomerTaxClassId();
269
- $request = $taxCalculationModel->getRateRequest($shippingAddress, $billingAddress, $customerTaxClassId, $store);
270
-
271
- $shippingTaxClass = $this->helperConfig()->getShippingTaxClassId($storeId);
272
- if ($shippingTaxClass) {
273
- $request->setProductClassId($shippingTaxClass);
274
- return $taxCalculationModel->getRate($request);
275
- }
276
- else {
277
- return 0.0;
278
- }
279
- }
280
-
281
-
282
- /**
283
- * Returns the invoice appendix and substitutes the placeholders, as far as possible
284
- *
285
- * @param Mage_Sales_Model_Order_Invoice|null $invoice
286
- * @return mixed|string
287
- */
288
- public function getInvoiceAppendix(Mage_Sales_Model_Order_Invoice $invoice = null)
289
- {
290
- $order = $this->getOrder();
291
-
292
- /** @var $customer Mage_Customer_Model_Customer */
293
- $customer = $this->getFactory()->getModelCustomer();
294
- $customer->load($order->getCustomerId());
295
-
296
- $invoiceIncrementId = '';
297
- if (!is_null($invoice)) {
298
- $invoiceIncrementId = $invoice->getIncrementId();
299
- }
300
-
301
- $substitutionArray = array(
302
- '{{order_increment_id}}' => $order->getIncrementId(),
303
- '{{order_id}}' => $order->getId(),
304
- '{{invoice_increment_id}}' => $invoiceIncrementId,
305
- '{{customer_increment_id}}' => $customer->getIncrementId(),
306
- '{{customer_id}}' => $order->getCustomerId(),
307
- );
308
-
309
- $appendix = $this->getConfigParameterInvoice()->getInvoiceAppendix();
310
- $appendix = str_replace(array_keys($substitutionArray), array_values($substitutionArray), $appendix);
311
-
312
- return $appendix;
313
- }
314
-
315
- /**
316
- * Returns the refund appendix and substitutes the placeholders, as far as possible
317
- *
318
- * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
319
- * @return string
320
- */
321
- public function getInvoiceAppendixRefund(Mage_Sales_Model_Order_Creditmemo $creditmemo)
322
- {
323
- $order = $this->getOrder();
324
-
325
- /** @var $customer Mage_Customer_Model_Customer */
326
- $customer = $this->getFactory()->getModelCustomer();
327
- $customer->load($order->getCustomerId());
328
-
329
- /** @var $invoice Mage_Sales_Model_Order_Invoice */
330
- $invoice = $creditmemo->getInvoice();
331
-
332
- $substitutionArray = array(
333
- '{{order_increment_id}}' => $order->getIncrementId(),
334
- '{{order_id}}' => $order->getId(),
335
- '{{creditmemo_increment_id}}' => $creditmemo->getIncrementId(),
336
- '{{invoice_increment_id}}' => $invoice->getIncrementId(),
337
- '{{invoice_id}}' => $invoice->getId(),
338
- '{{customer_increment_id}}' => $customer->getIncrementId(),
339
- '{{customer_id}}' => $order->getCustomerId(),
340
- );
341
-
342
- $appendix = $this->getConfigParameterInvoice()->getInvoiceAppendixRefund();
343
- $appendix = str_replace(array_keys($substitutionArray), array_values($substitutionArray), $appendix);
344
-
345
- return $appendix;
346
- }
347
-
348
-
349
- /**
350
- * @return bool
351
- */
352
- protected function mustTransmitInvoiceData()
353
- {
354
- if ($this->getConfigPayment()->isInvoiceTransmitEnabled()) {
355
- return true;
356
- }
357
-
358
- $paymentMethod = $this->getPaymentMethod();
359
- if ($paymentMethod->mustTransmitInvoicingData()) { // Certain payment methods require invoicing data to be transmitted ALWAYS.
360
- return true;
361
- }
362
-
363
- return false;
364
- }
365
-
366
- /**
367
- * @param Mage_Sales_Model_Abstract $object
368
- * @return string
369
- */
370
- protected function fetchNewIncrementId(Mage_Sales_Model_Abstract $object)
371
- {
372
- $entityTypeModel = $this->getFactory()->getModelEavEntityType();
373
-
374
- $code = '';
375
- if ($object instanceof Mage_Sales_Model_Order_Invoice) {
376
- $code = 'invoice';
377
- }
378
- elseif ($object instanceof Mage_Sales_Model_Order_Creditmemo) {
379
- $code = 'creditmemo';
380
- }
381
- $entityType = $entityTypeModel->loadByCode($code);
382
- $newIncrementId = $entityType->fetchNewIncrementId($this->getStoreId());
383
- if ($newIncrementId !== false) {
384
- $object->setIncrementId($newIncrementId);
385
- }
386
- return $newIncrementId;
387
- }
388
-
389
- /**
390
- * @param Payone_Core_Model_Config_Payment_Method_Interface $configPayment
391
- */
392
- public function setConfigPayment(Payone_Core_Model_Config_Payment_Method_Interface $configPayment)
393
- {
394
- $this->configPayment = $configPayment;
395
- }
396
-
397
- /**
398
- * @return Payone_Core_Model_Config_Payment_Method_Interface
399
- */
400
- public function getConfigPayment()
401
- {
402
- return $this->configPayment;
403
- }
404
-
405
- /**
406
- * @return Payone_Core_Model_Config_Misc
407
- */
408
- protected function getConfigMisc()
409
- {
410
- if ($this->configMisc === null) {
411
- $this->configMisc = $this->helperConfig()->getConfigMisc($this->getStoreId());
412
- }
413
- return $this->configMisc;
414
- }
415
-
416
-
417
- /**
418
- * @param Payone_Core_Model_Config_Misc $configMisc
419
- */
420
- public function setConfigMisc(Payone_Core_Model_Config_Misc $configMisc)
421
- {
422
- $this->configMisc = $configMisc;
423
- }
424
-
425
- /**
426
- * @return Payone_Core_Model_Config_General_ParameterInvoice
427
- */
428
- protected function getConfigParameterInvoice()
429
- {
430
- return $this->helperConfig()->getConfigGeneral($this->getStoreId())->getParameterInvoice();
431
- }
432
-
433
- /**
434
- * @return int
435
- */
436
- protected function getStoreId()
437
- {
438
- return $this->getPaymentMethod()->getStore();
439
- }
440
-
441
- /**
442
- * @param $storeId
443
- * @return Payone_Core_Model_Config_General
444
- */
445
- protected function getConfigGeneral($storeId = null)
446
- {
447
- if (is_null($storeId)) {
448
- $storeId = $this->getStoreId();
449
- }
450
- return $this->helperConfig()->getConfigGeneral($storeId);
451
- }
452
-
453
- /**
454
- * @param Mage_Sales_Model_Order $order
455
- */
456
- public function setOrder(Mage_Sales_Model_Order $order)
457
- {
458
- $this->order = $order;
459
- }
460
-
461
- /**
462
- * @return Mage_Sales_Model_Order
463
- */
464
- public function getOrder()
465
- {
466
- return $this->order;
467
- }
468
-
469
- /**
470
- * @param float $amount
471
- */
472
- public function setAmount($amount)
473
- {
474
- $this->amount = $amount;
475
- }
476
-
477
- /**
478
- * @return float
479
- */
480
- public function getAmount()
481
- {
482
- return $this->amount;
483
- }
484
-
485
- /**
486
- * @param Payone_Core_Model_Payment_Method_Abstract $paymentMethod
487
- */
488
- public function setPaymentMethod(Payone_Core_Model_Payment_Method_Abstract $paymentMethod)
489
- {
490
- $this->paymentMethod = $paymentMethod;
491
- }
492
-
493
- /**
494
- * @return Payone_Core_Model_Payment_Method_Abstract
495
- */
496
- public function getPaymentMethod()
497
- {
498
- return $this->paymentMethod;
499
- }
500
-
501
- /**
502
- * @return Payone_Core_Helper_Config
503
- */
504
- protected function helperConfig()
505
- {
506
- return $this->getFactory()->helperConfig();
507
- }
508
-
509
- /**
510
- * @return Payone_Core_Helper_Registry
511
- */
512
- protected function helperRegistry()
513
- {
514
- return $this->getFactory()->helperRegistry();
515
- }
516
-
517
- protected function getEventPrefix()
518
- {
519
- return self::EVENT_PREFIX;
520
- }
521
-
522
- /**
523
- * @return string
524
- */
525
- protected function getEventName()
526
- {
527
- return $this->getEventPrefix() . '_' . $this->getEventType();
528
- }
529
-
530
- /**
531
- * Wrapper for Mage::dispatchEvent()
532
- *
533
- * @param $name
534
- * @param array $data
535
- *
536
- * @return Mage_Core_Model_App
537
- */
538
- protected function dispatchEvent($name, array $data = array())
539
- {
540
- return Mage::dispatchEvent($name, $data);
541
- }
542
}
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
+ * versions in the future. If you wish to customize Payone_Core for your
13
+ * needs please refer to http://www.payone.de for more information.
14
+ *
15
+ * @category Payone
16
+ * @package Payone_Core_Model
17
+ * @subpackage Mapper
18
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
+ * @author Matthias Walter <info@noovias.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.noovias.com
22
+ */
23
+
24
+ /**
25
+ *
26
+ * @category Payone
27
+ * @package Payone_Core_Model
28
+ * @subpackage Mapper
29
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
+ * @link http://www.noovias.com
32
+ */
33
+ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Abstract
34
+ extends Payone_Core_Model_Mapper_ApiRequest_Abstract
35
+ implements Payone_Core_Model_Mapper_ApiRequest_Payment_Interface
36
+ {
37
+ const DEFAULT_SHIPPING_SKU = 'Shipping';
38
+ const DEFAULT_ADJUSTMENT_POSITIVE_SKU = 'Adjustment Refund';
39
+ const DEFAULT_ADJUSTMENT_NEGATIVE_SKU = 'Adjustment Fee';
40
+
41
+ const DEFAULT_DISCOUNT_SKU = 'Discount';
42
+ const DEFAULT_TAX_SKU = 'Tax';
43
+
44
+ const EVENT_PREFIX = 'payone_core_mapper_apirequest_payment';
45
+
46
+ /** @var float */
47
+ protected $amount = 0.00;
48
+
49
+ /** @var Mage_Sales_Model_Order */
50
+ protected $order = null;
51
+
52
+ /** @var Payone_Core_Model_Payment_Method_Abstract */
53
+ protected $paymentMethod = null;
54
+
55
+ /** @var Payone_Core_Model_Config_Payment_Method_Interface */
56
+ protected $configPayment = null;
57
+
58
+ /** @var Payone_Core_Model_Config_Misc */
59
+ protected $configMisc = null;
60
+
61
+ /**
62
+ * @return string
63
+ */
64
+ abstract public function getEventType();
65
+
66
+ /**
67
+ * @param Mage_Sales_Model_Order_Payment $payment
68
+ */
69
+ protected function init(Mage_Sales_Model_Order_Payment $payment)
70
+ {
71
+ $this->setOrder($payment->getOrder());
72
+ $this->setPaymentMethod($payment->getMethodInstance());
73
+ }
74
+
75
+ /**
76
+ * @param Payone_Api_Request_Interface $request
77
+ */
78
+ protected function mapDefaultParameters(Payone_Api_Request_Interface $request)
79
+ {
80
+ $helper = $this->helper();
81
+
82
+ $solutionName = 'noovias';
83
+ $solutionVersion = $helper->getPayoneVersion();
84
+ $integratorName = 'magento';
85
+ $integratorVersion = $helper->getMagentoVersion();
86
+
87
+ $request->setEncoding('UTF-8');
88
+ $request->setMid($this->getConfigPayment()->getMid());
89
+ $request->setPortalid($this->getConfigPayment()->getPortalid());
90
+ $request->setMode($this->getConfigPayment()->getMode());
91
+ $request->setKey($this->getConfigPayment()->getKey());
92
+ $request->setIntegratorName($integratorName);
93
+ $request->setIntegratorVersion($integratorVersion);
94
+ $request->setSolutionName($solutionName);
95
+ $request->setSolutionVersion($solutionVersion);
96
+ }
97
+
98
+ /**
99
+ * @return Payone_Api_Request_Parameter_Invoicing_Item
100
+ */
101
+ protected function mapShippingFeeAsItem()
102
+ {
103
+ $order = $this->getOrder();
104
+
105
+ $configMiscShipping = $this->getConfigMisc()->getShippingCosts();
106
+ $sku = $configMiscShipping->getSku();
107
+ if (empty($sku)) {
108
+ $sku = $this->helper()->__(self::DEFAULT_SHIPPING_SKU);
109
+ }
110
+ $params['id'] = $sku;
111
+ $params['de'] = $order->getShippingDescription();
112
+ $params['no'] = 1;
113
+ $params['pr'] = $order->getShippingInclTax();
114
+ $params['va'] = $this->getShippingTaxRate();
115
+
116
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
117
+ $params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
118
+ }
119
+
120
+ $item = new Payone_Api_Request_Parameter_Invoicing_Item();
121
+ $item->init($params);
122
+
123
+ return $item;
124
+ }
125
+
126
+ /**
127
+ * @param float $discountAmount
128
+ * @return Payone_Api_Request_Parameter_Invoicing_Item
129
+ */
130
+ protected function mapDiscountAsItem($discountAmount)
131
+ {
132
+ $configMiscDiscount = $this->getConfigMisc()->getDiscount();
133
+ $sku = $configMiscDiscount->getSku();
134
+ $description = $configMiscDiscount->getDescription();
135
+ if (empty($sku)) {
136
+ $sku = $this->helper()->__(self::DEFAULT_DISCOUNT_SKU);
137
+ }
138
+ if (empty($description)) {
139
+ $description = $this->helper()->__(self::DEFAULT_DISCOUNT_SKU);
140
+ }
141
+
142
+ $params['id'] = $sku;
143
+ $params['de'] = $description;
144
+ $params['no'] = 1;
145
+ $params['pr'] = $discountAmount;
146
+
147
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
148
+ $params['it'] = Payone_Api_Enum_InvoicingItemType::VOUCHER;
149
+ }
150
+ $item = new Payone_Api_Request_Parameter_Invoicing_Item();
151
+ $item->init($params);
152
+
153
+ return $item;
154
+ }
155
+
156
+ /**
157
+ * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
158
+ * @return Payone_Api_Request_Parameter_Invoicing_Item
159
+ *
160
+ * used by Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
161
+ */
162
+ protected function mapRefundShippingAsItemByCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
163
+ {
164
+ $order = $this->getOrder();
165
+
166
+ $configMiscShipping = $this->getConfigMisc()->getShippingCosts();
167
+ $sku = $configMiscShipping->getSku();
168
+ if (empty($sku)) {
169
+ $sku = $this->helper()->__(self::DEFAULT_SHIPPING_SKU);
170
+ }
171
+
172
+ $params['id'] = $sku;
173
+ $params['de'] = $order->getShippingDescription();
174
+ $params['no'] = 1;
175
+ $params['pr'] = $creditmemo->getShippingInclTax();
176
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
177
+ $params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT;
178
+ }
179
+
180
+ $item = new Payone_Api_Request_Parameter_Invoicing_Item();
181
+ $item->init($params);
182
+
183
+ return $item;
184
+ }
185
+
186
+ /**
187
+ * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
188
+ * @return Payone_Api_Request_Parameter_Invoicing_Item
189
+ *
190
+ * used by Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
191
+ */
192
+ protected function mapAdjustmentPositiveAsItemByCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
193
+ {
194
+ $configMiscCreditmemo = $this->getConfigMisc()->getCreditmemo();
195
+ $sku = $configMiscCreditmemo->getAdjustmentRefundSku();
196
+ $name = $configMiscCreditmemo->getAdjustmentRefundName();
197
+ if (empty($sku)) {
198
+ $sku = $this->helper()->__(self::DEFAULT_ADJUSTMENT_POSITIVE_SKU);
199
+ }
200
+ if (empty($name)) {
201
+ $name = $this->helper()->__(self::DEFAULT_ADJUSTMENT_POSITIVE_SKU);
202
+ }
203
+
204
+ $params['id'] = $sku;
205
+ $params['de'] = $name;
206
+ $params['no'] = 1;
207
+ $params['pr'] = $creditmemo->getAdjustmentPositive();
208
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
209
+ $params['it'] = Payone_Api_Enum_InvoicingItemType::VOUCHER;
210
+ }
211
+
212
+ $item = new Payone_Api_Request_Parameter_Invoicing_Item();
213
+ $item->init($params);
214
+
215
+ return $item;
216
+ }
217
+
218
+ /**
219
+ * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
220
+ * @return Payone_Api_Request_Parameter_Invoicing_Item
221
+ *
222
+ * used by Payone_Core_Model_Mapper_ApiRequest_Payment_Debit
223
+ */
224
+
225
+ protected function mapAdjustmentNegativeAsItemByCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
226
+ {
227
+ $configMiscCreditmemo = $this->getConfigMisc()->getCreditmemo();
228
+ $sku = $configMiscCreditmemo->getAdjustmentFeeSku();
229
+ $name = $configMiscCreditmemo->getAdjustmentFeeName();
230
+ if (empty($sku)) {
231
+ $sku = $this->helper()->__(self::DEFAULT_ADJUSTMENT_NEGATIVE_SKU);
232
+ }
233
+ if (empty($name)) {
234
+ $name = $this->helper()->__(self::DEFAULT_ADJUSTMENT_NEGATIVE_SKU);
235
+ }
236
+
237
+ $params['id'] = $sku;
238
+ $params['de'] = $name;
239
+ $params['no'] = 1;
240
+ $params['pr'] = $creditmemo->getAdjustmentNegative() * (-1);
241
+ if ($this->getPaymentMethod()->mustTransmitInvoicingItemTypes()) {
242
+ $params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS;
243
+ }
244
+
245
+ $item = new Payone_Api_Request_Parameter_Invoicing_Item();
246
+ $item->init($params);
247
+
248
+ return $item;
249
+ }
250
+
251
+
252
+ protected function getShippingTaxRate()
253
+ {
254
+ $order = $this->getOrder();
255
+ $storeId = $this->getStoreId();
256
+ $factory = $this->getFactory();
257
+ $store = $factory->getModelCoreStore()->load($storeId);
258
+
259
+ /** @var $taxCalculationModel Mage_Tax_Model_Calculation */
260
+ $taxCalculationModel = $factory->getSingletonTaxCalculation();
261
+
262
+ $shippingAddress = $order->getShippingAddress();
263
+ $billingAddress = $order->getBillingAddress();
264
+ $quoteId = $order->getQuoteId();
265
+ $quote = $factory->getModelSalesQuote();
266
+ $quote->load($quoteId);
267
+
268
+ $customerTaxClassId = $quote->getCustomerTaxClassId();
269
+ $request = $taxCalculationModel->getRateRequest($shippingAddress, $billingAddress, $customerTaxClassId, $store);
270
+
271
+ $shippingTaxClass = $this->helperConfig()->getShippingTaxClassId($storeId);
272
+ if ($shippingTaxClass) {
273
+ $request->setProductClassId($shippingTaxClass);
274
+ return $taxCalculationModel->getRate($request);
275
+ }
276
+ else {
277
+ return 0.0;
278
+ }
279
+ }
280
+
281
+
282
+ /**
283
+ * Returns the invoice appendix and substitutes the placeholders, as far as possible
284
+ *
285
+ * @param Mage_Sales_Model_Order_Invoice|null $invoice
286
+ * @return mixed|string
287
+ */
288
+ public function getInvoiceAppendix(Mage_Sales_Model_Order_Invoice $invoice = null)
289
+ {
290
+ $order = $this->getOrder();
291
+
292
+ /** @var $customer Mage_Customer_Model_Customer */
293
+ $customer = $this->getFactory()->getModelCustomer();
294
+ $customer->load($order->getCustomerId());
295
+
296
+ $invoiceIncrementId = '';
297
+ if (!is_null($invoice)) {
298
+ $invoiceIncrementId = $invoice->getIncrementId();
299
+ }
300
+
301
+ $substitutionArray = array(
302
+ '{{order_increment_id}}' => $order->getIncrementId(),
303
+ '{{order_id}}' => $order->getId(),
304
+ '{{invoice_increment_id}}' => $invoiceIncrementId,
305
+ '{{customer_increment_id}}' => $customer->getIncrementId(),
306
+ '{{customer_id}}' => $order->getCustomerId(),
307
+ );
308
+
309
+ $appendix = $this->getConfigParameterInvoice()->getInvoiceAppendix();
310
+ $appendix = str_replace(array_keys($substitutionArray), array_values($substitutionArray), $appendix);
311
+
312
+ return $appendix;
313
+ }
314
+
315
+ /**
316
+ * Returns the refund appendix and substitutes the placeholders, as far as possible
317
+ *
318
+ * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
319
+ * @return string
320
+ */
321
+ public function getInvoiceAppendixRefund(Mage_Sales_Model_Order_Creditmemo $creditmemo)
322
+ {
323
+ $order = $this->getOrder();
324
+
325
+ /** @var $customer Mage_Customer_Model_Customer */
326
+ $customer = $this->getFactory()->getModelCustomer();
327
+ $customer->load($order->getCustomerId());
328
+
329
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
330
+ $invoice = $creditmemo->getInvoice();
331
+
332
+ $substitutionArray = array(
333
+ '{{order_increment_id}}' => $order->getIncrementId(),
334
+ '{{order_id}}' => $order->getId(),
335
+ '{{creditmemo_increment_id}}' => $creditmemo->getIncrementId(),
336
+ '{{invoice_increment_id}}' => $invoice->getIncrementId(),
337
+ '{{invoice_id}}' => $invoice->getId(),
338
+ '{{customer_increment_id}}' => $customer->getIncrementId(),
339
+ '{{customer_id}}' => $order->getCustomerId(),
340
+ );
341
+
342
+ $appendix = $this->getConfigParameterInvoice()->getInvoiceAppendixRefund();
343
+ $appendix = str_replace(array_keys($substitutionArray), array_values($substitutionArray), $appendix);
344
+
345
+ return $appendix;
346
+ }
347
+
348
+
349
+ /**
350
+ * @return bool
351
+ */
352
+ protected function mustTransmitInvoiceData()
353
+ {
354
+ if ($this->getConfigPayment()->isInvoiceTransmitEnabled()) {
355
+ return true;
356
+ }
357
+
358
+ $paymentMethod = $this->getPaymentMethod();
359
+ if ($paymentMethod->mustTransmitInvoicingData()) { // Certain payment methods require invoicing data to be transmitted ALWAYS.
360
+ return true;
361
+ }
362
+
363
+ return false;
364
+ }
365
+
366
+ /**
367
+ * @param Mage_Sales_Model_Abstract $object
368
+ * @return string
369
+ */
370
+ protected function fetchNewIncrementId(Mage_Sales_Model_Abstract $object)
371
+ {
372
+ $entityTypeModel = $this->getFactory()->getModelEavEntityType();
373
+
374
+ $code = '';
375
+ if ($object instanceof Mage_Sales_Model_Order_Invoice) {
376
+ $code = 'invoice';
377
+ }
378
+ elseif ($object instanceof Mage_Sales_Model_Order_Creditmemo) {
379
+ $code = 'creditmemo';
380
+ }
381
+ $entityType = $entityTypeModel->loadByCode($code);
382
+ $newIncrementId = $entityType->fetchNewIncrementId($this->getStoreId());
383
+ if ($newIncrementId !== false) {
384
+ $object->setIncrementId($newIncrementId);
385
+ }
386
+ return $newIncrementId;
387
+ }
388
+
389
+ /**
390
+ * @param Payone_Core_Model_Config_Payment_Method_Interface $configPayment
391
+ */
392
+ public function setConfigPayment(Payone_Core_Model_Config_Payment_Method_Interface $configPayment)
393
+ {
394
+ $this->configPayment = $configPayment;
395
+ }
396
+
397
+ /**
398
+ * @return Payone_Core_Model_Config_Payment_Method_Interface
399
+ */
400
+ public function getConfigPayment()
401
+ {
402
+ return $this->configPayment;
403
+ }
404
+
405
+ /**
406
+ * @return Payone_Core_Model_Config_Misc
407
+ */
408
+ protected function getConfigMisc()
409
+ {
410
+ if ($this->configMisc === null) {
411
+ $this->configMisc = $this->helperConfig()->getConfigMisc($this->getStoreId());
412
+ }
413
+ return $this->configMisc;
414
+ }
415
+
416
+
417
+ /**
418
+ * @param Payone_Core_Model_Config_Misc $configMisc
419
+ */
420
+ public function setConfigMisc(Payone_Core_Model_Config_Misc $configMisc)
421
+ {
422
+ $this->configMisc = $configMisc;
423
+ }
424
+
425
+ /**
426
+ * @return Payone_Core_Model_Config_General_ParameterInvoice
427
+ */
428
+ protected function getConfigParameterInvoice()
429
+ {
430
+ return $this->helperConfig()->getConfigGeneral($this->getStoreId())->getParameterInvoice();
431
+ }
432
+
433
+ /**
434
+ * @return int
435
+ */
436
+ protected function getStoreId()
437
+ {
438
+ return $this->getPaymentMethod()->getStore();
439
+ }
440
+
441
+ /**
442
+ * @param $storeId
443
+ * @return Payone_Core_Model_Config_General
444
+ */
445
+ protected function getConfigGeneral($storeId = null)
446
+ {
447
+ if (is_null($storeId)) {
448
+ $storeId = $this->getStoreId();
449
+ }
450
+ return $this->helperConfig()->getConfigGeneral($storeId);
451
+ }
452
+
453
+ /**
454
+ * @param Mage_Sales_Model_Order $order
455
+ */
456
+ public function setOrder(Mage_Sales_Model_Order $order)
457
+ {
458
+ $this->order = $order;
459
+ }
460
+
461
+ /**
462
+ * @return Mage_Sales_Model_Order
463
+ */
464
+ public function getOrder()
465
+ {
466
+ return $this->order;
467
+ }
468
+
469
+ /**
470
+ * @param float $amount
471
+ */
472
+ public function setAmount($amount)
473
+ {
474
+ $this->amount = $amount;
475
+ }
476
+
477
+ /**
478
+ * @return float
479
+ */
480
+ public function getAmount()
481
+ {
482
+ return $this->amount;
483
+ }
484
+
485
+ /**
486
+ * @param Payone_Core_Model_Payment_Method_Abstract $paymentMethod
487
+ */
488
+ public function setPaymentMethod(Payone_Core_Model_Payment_Method_Abstract $paymentMethod)
489
+ {
490
+ $this->paymentMethod = $paymentMethod;
491
+ }
492
+
493
+ /**
494
+ * @return Payone_Core_Model_Payment_Method_Abstract
495
+ */
496
+ public function getPaymentMethod()
497
+ {
498
+ return $this->paymentMethod;
499
+ }
500
+
501
+ /**
502
+ * @return Payone_Core_Helper_Config
503
+ */
504
+ protected function helperConfig()
505
+ {
506
+ return $this->getFactory()->helperConfig();
507
+ }
508
+
509
+ /**
510
+ * @return Payone_Core_Helper_Registry
511
+ */
512
+ protected function helperRegistry()
513
+ {
514
+ return $this->getFactory()->helperRegistry();
515
+ }
516
+
517
+ protected function getEventPrefix()
518
+ {
519
+ return self::EVENT_PREFIX;
520
+ }
521
+
522
+ /**
523
+ * @return string
524
+ */
525
+ protected function getEventName()
526
+ {
527
+ return $this->getEventPrefix() . '_' . $this->getEventType();
528
+ }
529
+
530
+ /**
531
+ * Wrapper for Mage::dispatchEvent()
532
+ *
533
+ * @param $name
534
+ * @param array $data
535
+ *
536
+ * @return Mage_Core_Model_App
537
+ */
538
+ protected function dispatchEvent($name, array $data = array())
539
+ {
540
+ return Mage::dispatchEvent($name, $data);
541
+ }
542
}
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php CHANGED
@@ -435,17 +435,18 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
435
$isRedirect = true;
436
}
437
elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_OnlineBankTransfer) {
438
$payoneOnlinebanktransferType = $info->getPayoneOnlinebanktransferType();
439
$iban = $info->getPayoneSepaIban();
440
$bic = $info->getPayoneSepaBic();
441
442
$payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_OnlineBankTransfer();
443
$payment->setOnlinebanktransfertype($payoneOnlinebanktransferType);
444
445
switch ($payoneOnlinebanktransferType) {
446
case Payone_Api_Enum_OnlinebanktransferType::INSTANT_MONEY_TRANSFER:
447
case Payone_Api_Enum_OnlinebanktransferType::GIROPAY:
448
- $payment->setBankcountry($info->getPayoneSepaBankCountry());
449
if (!empty($iban) and !empty($bic)) {
450
$payment->setIban(strtoupper($iban));
451
$payment->setBic(strtoupper($bic)); // ensure bic and iban are sent uppercase
@@ -494,7 +495,7 @@ abstract class Payone_Core_Model_Mapper_ApiRequest_Payment_Authorize_Abstract
494
}
495
elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_DebitPayment) {
496
$payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_DebitPayment();
497
- $payment->setBankcountry($info->getPayoneSepaBankCountry());
498
$iban = $info->getPayoneSepaIban();
499
$bic = $info->getPayoneSepaBic();
500
if (!empty($iban) and !empty($bic)) {
435
$isRedirect = true;
436
}
437
elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_OnlineBankTransfer) {
438
+ $country = $this->getOrder()->getBillingAddress()->getCountry();
439
$payoneOnlinebanktransferType = $info->getPayoneOnlinebanktransferType();
440
$iban = $info->getPayoneSepaIban();
441
$bic = $info->getPayoneSepaBic();
442
443
$payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_OnlineBankTransfer();
444
+ $payment->setBankcountry($country);
445
$payment->setOnlinebanktransfertype($payoneOnlinebanktransferType);
446
447
switch ($payoneOnlinebanktransferType) {
448
case Payone_Api_Enum_OnlinebanktransferType::INSTANT_MONEY_TRANSFER:
449
case Payone_Api_Enum_OnlinebanktransferType::GIROPAY:
450
if (!empty($iban) and !empty($bic)) {
451
$payment->setIban(strtoupper($iban));
452
$payment->setBic(strtoupper($bic)); // ensure bic and iban are sent uppercase
495
}
496
elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_DebitPayment) {
497
$payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_DebitPayment();
498
+ $payment->setBankcountry($info->getPayoneBankCountry());
499
$iban = $info->getPayoneSepaIban();
500
$bic = $info->getPayoneSepaBic();
501
if (!empty($iban) and !empty($bic)) {
app/code/community/Payone/Core/Model/Mapper/ApiRequest/Verification/AddressCheck.php CHANGED
@@ -1,114 +1,120 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
- * versions in the future. If you wish to customize Payone_Core for your
13
- * needs please refer to http://www.payone.de for more information.
14
- *
15
- * @category Payone
16
- * @package Payone_Core_Model
17
- * @subpackage Mapper
18
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
- * @author Matthias Walter <info@noovias.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.noovias.com
22
- */
23
-
24
- /**
25
- *
26
- * @category Payone
27
- * @package Payone_Core_Model
28
- * @subpackage Mapper
29
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
- * @link http://www.noovias.com
32
- */
33
- class Payone_Core_Model_Mapper_ApiRequest_Verification_AddressCheck
34
- extends Payone_Core_Model_Mapper_ApiRequest_Verification_Abstract
35
- {
36
- /** @var Payone_Core_Model_Config_Protect_AddressCheck */
37
- protected $config = null;
38
-
39
-
40
- /**
41
- * @param Mage_Customer_Model_Address_Abstract $address
42
- * @return Payone_Api_Request_AddressCheck
43
- */
44
- public function mapFromAddress(Mage_Customer_Model_Address_Abstract $address)
45
- {
46
- $request = $this->getFactory()->getRequestVerificationAddressCheck();
47
- $helper = $this->helper();
48
- $configGlobal = $this->getConfigGlobal();
49
- $config = $this->getConfig();
50
-
51
- // @todo move addressCheckType detection to method
52
- // @todo add option to configure used Adresschecktype externaly
53
- if ($address->getAddressType() === 'billing') {
54
- $request->setAddresschecktype($config->getCheckBilling());
55
- }
56
- elseif ($address->getAddressType() === 'shipping') {
57
- $request->setAddresschecktype($config->getCheckShipping());
58
- }
59
- else {
60
- throw new Exception('Invalid Address Check Type');
61
- }
62
-
63
- $request->setAid($configGlobal->getAid());
64
- $request->setMid($configGlobal->getMid());
65
- $request->setMode($config->getMode());
66
- $request->setPortalid($configGlobal->getPortalid());
67
- $request->setKey($configGlobal->getKey());
68
-
69
-
70
- $request->setCity($address->getCity());
71
- $request->setCompany($address->getCompany());
72
- $request->setCountry($address->getCountry());
73
- $request->setFirstname($address->getFirstname());
74
- $request->setLastname($address->getLastname());
75
-
76
- $request->setIntegratorName('Magento');
77
- $request->setIntegratorVersion($helper->getMagentoVersion());
78
- $request->setSolutionName('noovias');
79
- $request->setSolutionVersion($helper->getPayoneVersion());
80
-
81
-
82
- $request->setEncoding('UTF-8');
83
- $request->setLanguage($helper->getDefaultLanguage());
84
- $request->setStreet($address->getStreetFull());
85
- $request->setTelephonenumber($address->getTelephone());
86
-
87
- $countryId = $address->getCountryId();
88
-
89
- if ($countryId == "US" || $countryId == "CA") {
90
- $request->setState($address->getRegionCode());
91
- }
92
-
93
- $request->setZip($address->getPostcode());
94
-
95
-
96
- return $request;
97
- }
98
-
99
- /**
100
- * @param Payone_Core_Model_Config_Protect_AddressCheck $configProtect
101
- */
102
- public function setConfig(Payone_Core_Model_Config_Protect_AddressCheck $configProtect)
103
- {
104
- $this->config = $configProtect;
105
- }
106
-
107
- /**
108
- * @return Payone_Core_Model_Config_Protect_AddressCheck
109
- */
110
- public function getConfig()
111
- {
112
- return $this->config;
113
- }
114
}
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
+ * versions in the future. If you wish to customize Payone_Core for your
13
+ * needs please refer to http://www.payone.de for more information.
14
+ *
15
+ * @category Payone
16
+ * @package Payone_Core_Model
17
+ * @subpackage Mapper
18
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
+ * @author Matthias Walter <info@noovias.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.noovias.com
22
+ */
23
+
24
+ /**
25
+ *
26
+ * @category Payone
27
+ * @package Payone_Core_Model
28
+ * @subpackage Mapper
29
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
+ * @link http://www.noovias.com
32
+ */
33
+ class Payone_Core_Model_Mapper_ApiRequest_Verification_AddressCheck
34
+ extends Payone_Core_Model_Mapper_ApiRequest_Verification_Abstract
35
+ {
36
+ /** @var Payone_Core_Model_Config_Protect_AddressCheck */
37
+ protected $config = null;
38
+
39
+
40
+ /**
41
+ * @param Mage_Customer_Model_Address_Abstract $address
42
+ *
43
+ * @return Payone_Api_Request_AddressCheck
44
+ */
45
+ public function mapFromAddress(Mage_Customer_Model_Address_Abstract $address)
46
+ {
47
+ $request = $this->getFactory()->getRequestVerificationAddressCheck();
48
+ $helper = $this->helper();
49
+ $configGlobal = $this->getConfigGlobal();
50
+ $config = $this->getConfig();
51
+
52
+ // @todo move addressCheckType detection to method
53
+ // @todo add option to configure used Adresschecktype externaly
54
+ if ($address->getAddressType() === 'billing') {
55
+ $request->setAddresschecktype($config->getCheckBilling());
56
+
57
+ // check if billing is used for shipping and shipping-address has to be checked
58
+ if ($address->getUseForShipping() === true and $config->mustCheckShipping()) {
59
+ $request->setAddresschecktype($config->getCheckShipping());
60
+ }
61
+ }
62
+ elseif ($address->getAddressType() === 'shipping') {
63
+ $request->setAddresschecktype($config->getCheckShipping());
64
+ }
65
+ else {
66
+ throw new Exception('Invalid Address Check Type');
67
+ }
68
+
69
+ $request->setAid($configGlobal->getAid());
70
+ $request->setMid($configGlobal->getMid());
71
+ $request->setMode($config->getMode());
72
+ $request->setPortalid($configGlobal->getPortalid());
73
+ $request->setKey($configGlobal->getKey());
74
+
75
+
76
+ $request->setCity($address->getCity());
77
+ $request->setCompany($address->getCompany());
78
+ $request->setCountry($address->getCountry());
79
+ $request->setFirstname($address->getFirstname());
80
+ $request->setLastname($address->getLastname());
81
+
82
+ $request->setIntegratorName('Magento');
83
+ $request->setIntegratorVersion($helper->getMagentoVersion());
84
+ $request->setSolutionName('noovias');
85
+ $request->setSolutionVersion($helper->getPayoneVersion());
86
+
87
+
88
+ $request->setEncoding('UTF-8');
89
+ $request->setLanguage($helper->getDefaultLanguage());
90
+ $request->setStreet($address->getStreetFull());
91
+ $request->setTelephonenumber($address->getTelephone());
92
+
93
+ $countryId = $address->getCountryId();
94
+
95
+ if ($countryId == "US" || $countryId == "CA") {
96
+ $request->setState($address->getRegionCode());
97
+ }
98
+
99
+ $request->setZip($address->getPostcode());
100
+
101
+
102
+ return $request;
103
+ }
104
+
105
+ /**
106
+ * @param Payone_Core_Model_Config_Protect_AddressCheck $configProtect
107
+ */
108
+ public function setConfig(Payone_Core_Model_Config_Protect_AddressCheck $configProtect)
109
+ {
110
+ $this->config = $configProtect;
111
+ }
112
+
113
+ /**
114
+ * @return Payone_Core_Model_Config_Protect_AddressCheck
115
+ */
116
+ public function getConfig()
117
+ {
118
+ return $this->config;
119
+ }
120
}
app/code/community/Payone/Core/Model/Observer/Checkout/Onepage/DebitPayment.php CHANGED
@@ -47,6 +47,27 @@ class Payone_Core_Model_Observer_Checkout_Onepage_DebitPayment extends Payone_Co
47
*/
48
public function performChecks(Varien_Event_Observer $observer)
49
{
50
$this->init($observer);
51
52
$paymentConfig = $this->getPaymentConfig();
@@ -55,7 +76,8 @@ class Payone_Core_Model_Observer_Checkout_Onepage_DebitPayment extends Payone_Co
55
$bankaccountcheckType = $paymentConfig->getBankAccountCheckType();
56
57
if ((!$sepaMandateEnabled and $checkBankaccountEnabled)
58
- or ($sepaMandateEnabled and $checkBankaccountEnabled and $bankaccountcheckType == Payone_Api_Enum_BankaccountCheckType::POS_BLACKLIST)) {
59
$this->performBankaccountCheck();
60
}
61
@@ -88,7 +110,8 @@ class Payone_Core_Model_Observer_Checkout_Onepage_DebitPayment extends Payone_Co
88
89
// Perform check:
90
$serviceBankaccountCheck = $this->getFactory()
91
- ->getServiceVerificationBankAccountCheck($paymentMethodConfigId, $this->getQuote()->getStoreId());
92
$serviceBankaccountCheck->execute($bankAccountNumber, $bankCode, $bankCountry, $iban, $bic);
93
}
94
@@ -102,7 +125,9 @@ class Payone_Core_Model_Observer_Checkout_Onepage_DebitPayment extends Payone_Co
102
103
$paymentMethodConfigId = $paymentData['payone_config_payment_method_id'];
104
105
- $manageMandateService = $this->getFactory()->getServiceManagementManageMandate($paymentMethodConfigId, $this->getQuote()->getStoreId());
106
107
// Gather Data:
108
$bankAccountNumber = array_key_exists('payone_account_number', $paymentData) ? $paymentData['payone_account_number'] : '';
@@ -130,9 +155,12 @@ class Payone_Core_Model_Observer_Checkout_Onepage_DebitPayment extends Payone_Co
130
*/
131
protected function init(Varien_Event_Observer $observer)
132
{
133
- $paymentData = $observer->getEvent()->getPaymentData();
134
/** @var Mage_Sales_Model_Quote $quote */
135
- $quote = $observer->getEvent()->getQuote();
136
$this->setPaymentData($paymentData);
137
$this->setQuote($quote);
138
@@ -145,7 +173,8 @@ class Payone_Core_Model_Observer_Checkout_Onepage_DebitPayment extends Payone_Co
145
throw new Payone_Core_Exception_PaymentMethodConfigNotFound();
146
}
147
148
- $paymentConfig = $this->helperConfig()->getConfigPaymentMethodById($paymentMethodConfigId, $quote->getStoreId());
149
$this->setPaymentConfig($paymentConfig);
150
}
151
47
*/
48
public function performChecks(Varien_Event_Observer $observer)
49
{
50
+ /** @var Mage_Checkout_OnepageController|Payone_Core_Checkout_OnepageController $controllerAction */
51
+ $controllerAction = $observer->getEvent()->getControllerAction();
52
+ $paymentData = $controllerAction->getRequest()->getPost('payment', array());
53
+ $selectedMethod = $paymentData['method'];
54
+
55
+ if ($selectedMethod != Payone_Core_Model_System_Config_PaymentMethodCode::DEBITPAYMENT) {
56
+ return; // only active for payone_debit_payment
57
+ }
58
+
59
+ if (!$controllerAction instanceof Payone_Core_Checkout_OnepageController) {
60
+ // for Core controller action check if there was a forward from Payone Controller to
61
+ // avoid double execution
62
+ $request = $controllerAction->getRequest();
63
+ if ($request->getBeforeForwardInfo('module_name') == 'payone_core'
64
+ and $request->getBeforeForwardInfo('controller_name') == 'checkout_onepage'
65
+ and $request->getBeforeForwardInfo('action_name') == 'verifyPayment'
66
+ ) {
67
+ return;
68
+ }
69
+ }
70
+
71
$this->init($observer);
72
73
$paymentConfig = $this->getPaymentConfig();
76
$bankaccountcheckType = $paymentConfig->getBankAccountCheckType();
77
78
if ((!$sepaMandateEnabled and $checkBankaccountEnabled)
79
+ or ($sepaMandateEnabled and $checkBankaccountEnabled and $bankaccountcheckType == Payone_Api_Enum_BankaccountCheckType::POS_BLACKLIST)
80
+ ) {
81
$this->performBankaccountCheck();
82
}
83
110
111
// Perform check:
112
$serviceBankaccountCheck = $this->getFactory()
113
+ ->getServiceVerificationBankAccountCheck($paymentMethodConfigId, $this->getQuote()
114
+ ->getStoreId());
115
$serviceBankaccountCheck->execute($bankAccountNumber, $bankCode, $bankCountry, $iban, $bic);
116
}
117
125
126
$paymentMethodConfigId = $paymentData['payone_config_payment_method_id'];
127
128
+ $manageMandateService = $this->getFactory()
129
+ ->getServiceManagementManageMandate($paymentMethodConfigId, $this->getQuote()
130
+ ->getStoreId());
131
132
// Gather Data:
133
$bankAccountNumber = array_key_exists('payone_account_number', $paymentData) ? $paymentData['payone_account_number'] : '';
155
*/
156
protected function init(Varien_Event_Observer $observer)
157
{
158
+ /** @var Mage_Checkout_OnepageController|Payone_Core_Checkout_OnepageController $controllerAction */
159
+ $controllerAction = $observer->getEvent()->getControllerAction();
160
+
161
+ $paymentData = $controllerAction->getRequest()->getPost('payment', array());
162
/** @var Mage_Sales_Model_Quote $quote */
163
+ $quote = $controllerAction->getOnepage()->getQuote();
164
$this->setPaymentData($paymentData);
165
$this->setQuote($quote);
166
173
throw new Payone_Core_Exception_PaymentMethodConfigNotFound();
174
}
175
176
+ $paymentConfig = $this->helperConfig()
177
+ ->getConfigPaymentMethodById($paymentMethodConfigId, $quote->getStoreId());
178
$this->setPaymentConfig($paymentConfig);
179
}
180
app/code/community/Payone/Core/Model/Observer/Sales/Order.php CHANGED
@@ -1,79 +1,81 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
- * versions in the future. If you wish to customize Payone_Core for your
13
- * needs please refer to http://www.payone.de for more information.
14
- *
15
- * @category Payone
16
- * @package Payone_Core_Model
17
- * @subpackage Observer
18
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
- * @author Matthias Walter <info@noovias.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.noovias.com
22
- */
23
-
24
- /**
25
- *
26
- * @category Payone
27
- * @package Payone_Core_Model
28
- * @subpackage Observer
29
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
- * @link http://www.noovias.com
32
- */
33
- class Payone_Core_Model_Observer_Sales_Order
34
- extends Payone_Core_Model_Observer_Abstract
35
- {
36
- /**
37
- * @param Varien_Event_Observer $observer
38
- * @return void
39
- */
40
- public function updateOrderGrid(Varien_Event_Observer $observer)
41
- {
42
- /**
43
- * @var $resource Mage_Sales_Model_Mysql4_Order
44
- */
45
- $resource = $observer->getEvent()->getResource();
46
-
47
- $resource->addVirtualGridColumn(
48
- 'payone_payment_method',
49
- 'order_payment',
50
- array('entity_id' => 'parent_id'),
51
- 'method'
52
- );
53
- }
54
-
55
- /**
56
- * @param Varien_Event_Observer $observer
57
- * @return void
58
- */
59
- public function incrementSampleCounter(Varien_Event_Observer $observer)
60
- {
61
- $storeId = $observer->getEvent()->getOrder()->getStoreId();
62
-
63
- $this->helperConfig()->incrementCreditratingSampleCounter($storeId);
64
- }
65
-
66
- /**
67
- *
68
- * @param Varien_Event_Observer $observer (has data 'payment' with a payment info instance (Mage_Sales_Model_Order_Payment))
69
- */
70
- public function cancelPayment(Varien_Event_Observer $observer)
71
- {
72
- /** @var $payment Mage_Sales_Model_Order_Payment */
73
- $payment = $observer->getPayment();
74
-
75
- $methodInstance = $payment->getMethodInstance();
76
-
77
- $methodInstance->cancel($payment);
78
- }
79
}
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
+ * versions in the future. If you wish to customize Payone_Core for your
13
+ * needs please refer to http://www.payone.de for more information.
14
+ *
15
+ * @category Payone
16
+ * @package Payone_Core_Model
17
+ * @subpackage Observer
18
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
+ * @author Matthias Walter <info@noovias.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.noovias.com
22
+ */
23
+
24
+ /**
25
+ *
26
+ * @category Payone
27
+ * @package Payone_Core_Model
28
+ * @subpackage Observer
29
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
+ * @link http://www.noovias.com
32
+ */
33
+ class Payone_Core_Model_Observer_Sales_Order
34
+ extends Payone_Core_Model_Observer_Abstract
35
+ {
36
+ /**
37
+ * @param Varien_Event_Observer $observer
38
+ * @return void
39
+ */
40
+ public function updateOrderGrid(Varien_Event_Observer $observer)
41
+ {
42
+ /**
43
+ * @var $resource Mage_Sales_Model_Mysql4_Order
44
+ */
45
+ $resource = $observer->getEvent()->getResource();
46
+
47
+ $resource->addVirtualGridColumn(
48
+ 'payone_payment_method',
49
+ 'order_payment',
50
+ array('entity_id' => 'parent_id'),
51
+ 'method'
52
+ );
53
+ }
54
+
55
+ /**
56
+ * @param Varien_Event_Observer $observer
57
+ * @return void
58
+ */
59
+ public function incrementSampleCounter(Varien_Event_Observer $observer)
60
+ {
61
+ $storeId = $observer->getEvent()->getOrder()->getStoreId();
62
+
63
+ $this->helperConfig()->incrementCreditratingSampleCounter($storeId);
64
+ }
65
+
66
+ /**
67
+ *
68
+ * @param Varien_Event_Observer $observer (has data 'payment' with a payment info instance (Mage_Sales_Model_Order_Payment))
69
+ */
70
+ public function cancelPayment(Varien_Event_Observer $observer)
71
+ {
72
+ /** @var $payment Mage_Sales_Model_Order_Payment */
73
+ $payment = $observer->getPayment();
74
+
75
+ $methodInstance = $payment->getMethodInstance();
76
+
77
+ if ($methodInstance instanceof Payone_Core_Model_Payment_Method_Abstract) {
78
+ $methodInstance->cancel($payment);
79
+ }
80
+ }
81
}
app/code/community/Payone/Core/Model/Observer/Sales/Order/Invoice.php CHANGED
@@ -43,6 +43,10 @@ class Payone_Core_Model_Observer_Sales_Order_Invoice
43
{
44
$event = $observer->getEvent();
45
$this->invoice = $event->getInvoice();
46
}
47
48
/**
@@ -55,4 +59,12 @@ class Payone_Core_Model_Observer_Sales_Order_Invoice
55
$request = $event->getRequest();
56
$this->invoice->setPayoneSequencenumber($request->getSequencenumber());
57
}
58
}
43
{
44
$event = $observer->getEvent();
45
$this->invoice = $event->getInvoice();
46
+ if(!$this->getHelperRegistry()->registry('current_invoice') instanceof Mage_Sales_Model_Order_Invoice)
47
+ {
48
+ $this->getHelperRegistry()->register('current_invoice',$event->getInvoice());
49
+ }
50
}
51
52
/**
59
$request = $event->getRequest();
60
$this->invoice->setPayoneSequencenumber($request->getSequencenumber());
61
}
62
+
63
+ /**
64
+ * @return Payone_Core_Helper_Registry
65
+ */
66
+ protected function getHelperRegistry()
67
+ {
68
+ return $this->getFactory()->helperRegistry();
69
+ }
70
}
app/code/community/Payone/Core/Model/Observer/Sales/Quote/Address.php CHANGED
@@ -46,6 +46,7 @@ class Payone_Core_Model_Observer_Sales_Quote_Address
46
$quote = $event->getQuote();
47
$quoteAddress = $event->getQuoteAddress();
48
$errors = $event->getErrors();
49
50
$fullActionName = $event->getFullActionName();
51
@@ -57,9 +58,11 @@ class Payone_Core_Model_Observer_Sales_Quote_Address
57
58
59
$addressType = $quoteAddress->getAddressType();
60
- if (($addressType === 'billing' and $config->mustCheckBilling())
61
- or ($addressType === 'shipping' and $config->mustCheckShipping()))
62
{
63
// Config says we must perform an addresscheck:
64
$service = $this->getFactory()->getServiceVerificationAddressCheck($config);
65
@@ -88,4 +91,37 @@ class Payone_Core_Model_Observer_Sales_Quote_Address
88
);
89
return $actions;
90
}
91
}
46
$quote = $event->getQuote();
47
$quoteAddress = $event->getQuoteAddress();
48
$errors = $event->getErrors();
49
+ $useForShipping = (bool) $event->getUseForShipping();
50
51
$fullActionName = $event->getFullActionName();
52
58
59
60
$addressType = $quoteAddress->getAddressType();
61
+ if ($this->mustCheckAddress($addressType, $config, $quote, $useForShipping))
62
{
63
+ // Inject into QuoteAdress for later use in mapper
64
+ $quoteAddress->setUseForShipping($useForShipping);
65
+
66
// Config says we must perform an addresscheck:
67
$service = $this->getFactory()->getServiceVerificationAddressCheck($config);
68
91
);
92
return $actions;
93
}
94
+
95
+ /**
96
+ * checks if an addresscheck must be performed
97
+ *
98
+ * @param $addressType
99
+ * @param Payone_Core_Model_Config_Protect_AddressCheck $config
100
+ * @param Mage_Sales_Model_Quote $quote
101
+ * @param $useForShipping
102
+ * @return bool
103
+ */
104
+ protected function mustCheckAddress($addressType, Payone_Core_Model_Config_Protect_AddressCheck $config, Mage_Sales_Model_Quote $quote, $useForShipping)
105
+ {
106
+ // check if address is shipping-address an shipping-address has to be checked
107
+ if ($addressType === 'shipping' and $config->mustCheckShipping()) {
108
+ return true;
109
+ }
110
+ // check if address is billing-address
111
+ if ($addressType === 'billing') {
112
+ // check if billing-address has to be checked
113
+ if ($config->mustCheckBilling()) {
114
+ return true;
115
+ }
116
+ // check if billing-address is used for shipping address and shipping-address has to be checked
117
+ if ($useForShipping === true and $config->mustCheckShipping() and !$quote->isVirtual()) {
118
+ return true;
119
+ }
120
+ // check if billing-address has to be checked for virtual order
121
+ if ($quote->isVirtual() and $config->mustCheckBillingForVirtualOrder()) {
122
+ return true;
123
+ }
124
+ }
125
+ return false;
126
+ }
127
}
app/code/community/Payone/Core/Model/Observer/TransactionStatus/InvoiceCreate.php CHANGED
@@ -1,207 +1,207 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
- * versions in the future. If you wish to customize Payone_Core for your
13
- * needs please refer to http://www.payone.de for more information.
14
- *
15
- * @category Payone
16
- * @package Payone_Core_Model
17
- * @subpackage Observer
18
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
- * @author Matthias Walter <info@noovias.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.noovias.com
22
- */
23
-
24
- /**
25
- *
26
- * @category Payone
27
- * @package Payone_Core_Model
28
- * @subpackage Observer
29
- * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
- * @link http://www.noovias.com
32
- */
33
- class Payone_Core_Model_Observer_TransactionStatus_InvoiceCreate
34
- extends Payone_Core_Model_Observer_Abstract
35
- {
36
- /**
37
- * @var Payone_Core_Model_Service_Sales_InvoiceCreate
38
- */
39
- protected $serviceInvoiceCreate = null;
40
-
41
- /** @var $method Payone_Core_Model_Payment_Method_Abstract */
42
- private $method = null;
43
-
44
- /** @var $order Mage_Sales_Model_Order */
45
- private $order = null;
46
-
47
- /** @var $config Payone_Core_Model_Config */
48
- private $config = null;
49
-
50
- /** @var $payment Mage_Sales_Model_Order_Payment */
51
- private $payment = null;
52
-
53
- /** @var $transactionStatus Payone_Core_Model_Domain_Protocol_TransactionStatus */
54
- private $transactionStatus = null;
55
-
56
- /**
57
- * @param Varien_Event_Observer $observer
58
- */
59
- public function onAppointed(Varien_Event_Observer $observer)
60
- {
61
- $this->initData($observer);
62
-
63
- $configMethod = $this->getConfigPaymentMethodById();
64
- // All Other PaymentMethods create Invoice if request-type is authorization
65
- if ($configMethod->isRequestAuthorization()) {
66
- if (!$this->method instanceof Payone_Core_Model_Payment_Method_AdvancePayment) {
67
- // Create Invoice
68
- $invoice = $this->getServiceInvoiceCreate()->createByOrder($this->order);
69
-
70
- $this->sendInvoiceEmail($invoice);
71
- }
72
- // Advance Payment: invoice is created on Transaction Paid
73
- }
74
- }
75
-
76
- /**
77
- * @param Varien_Event_Observer $observer
78
- */
79
- public function onPaid(Varien_Event_Observer $observer)
80
- {
81
- $this->initData($observer);
82
-
83
- $configMethod = $this->getConfigPaymentMethodById();
84
- // Advance Payment create Invoice if request-type is authorization
85
- if ($configMethod->isRequestAuthorization()) {
86
- $isAdvancePayment = $this->method instanceof Payone_Core_Model_Payment_Method_AdvancePayment;
87
-
88
- if ($isAdvancePayment) {
89
- $invoice = $this->getServiceInvoiceCreate()->createByOrder($this->order);
90
- }
91
- else {
92
- // Load Invoice which has been created in 'onAppointed'
93
- $invoice = $this->getInvoiceForOrder();
94
- }
95
-
96
- if ($invoice) {
97
- $invoice->pay();
98
-
99
- if ($isAdvancePayment) {
100
- $this->sendInvoiceEmail($invoice);
101
- }
102
-
103
- // Save invoice and it´s order as a transaction:
104
- try {
105
- $transaction = $this->getFactory()->getModelResourceTransaction();
106
- $transaction->addObject($invoice);
107
- $transaction->addObject($invoice->getOrder());
108
- $transaction->save();
109
- }
110
- catch (Mage_Core_Exception $e) {
111
- throw new Payone_Core_Exception_InvoiceSave($e->getMessage());
112
- }
113
- }
114
- }
115
- // All Other PaymentMethods already have an invoice
116
- }
117
-
118
- /**
119
- * @param Varien_Event_Observer $observer
120
- */
121
- protected function initData(Varien_Event_Observer $observer)
122
- {
123
- $event = $observer->getEvent();
124
-
125
- /** @var $transactionStatus Payone_Core_Model_Domain_Protocol_TransactionStatus */
126
- $this->transactionStatus = $event->getTransactionStatus();
127
-
128
- $order = $this->getOrderByTransactionStatus($this->transactionStatus);
129
- $payment = $order->getPayment();
130
- $this->method = $payment->getMethodInstance();
131
- /** @var $method Payone_Core_Model_Payment_Method_Abstract */
132
- $this->method = $payment->getMethodInstance();
133
- $this->order = $order;
134
- $this->config = $event->getConfig();
135
- $this->payment = $payment;
136
- }
137
-
138
- /**
139
- * @param Mage_Sales_Model_Order_Invoice $invoice
140
- */
141
- protected function sendInvoiceEmail(Mage_Sales_Model_Order_Invoice $invoice)
142
- {
143
- $invoice->setEmailSent(true);
144
- $invoice->sendEmail();
145
- $invoice->save();
146
- }
147
-
148
- /**
149
- * @param Payone_Core_Model_Service_Sales_InvoiceCreate $service
150
- */
151
- public function setServiceInvoiceCreate(Payone_Core_Model_Service_Sales_InvoiceCreate $service)
152
- {
153
- $this->serviceInvoiceCreate = $service;
154
- }
155
-
156
- /**
157
- * @return Payone_Core_Model_Service_Sales_InvoiceCreate
158
- */
159
- public function getServiceInvoiceCreate()
160
- {
161
- if ($this->serviceInvoiceCreate === null) {
162
- $this->serviceInvoiceCreate = $this->getFactory()->getServiceSalesInvoiceCreate();
163
- }
164
- return $this->serviceInvoiceCreate;
165
- }
166
-
167
- /**
168
- * @param Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus
169
- * @return Mage_Sales_Model_Order
170
- */
171
- protected function getOrderByTransactionStatus(Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus)
172
- {
173
- $order = $this->getFactory()->getModelSalesOrder();
174
- $order->load($transactionStatus->getOrderId());
175
- return $order;
176
- }
177
-
178
- /**
179
- * @return bool|Payone_Core_Model_Config_Payment_Method_Interface
180
- * @throws Payone_Core_Exception_PaymentMethodConfigNotFound
181
- */
182
- protected function getConfigPaymentMethodById()
183
- {
184
- $id = $this->payment->getPayoneConfigPaymentMethodId();
185
- $configPaymentMethod = $this->config->getPayment()->getMethodById($id);
186
-
187
- if (empty($configPaymentMethod)) {
188
- $message = 'Payment method configuration with id "' . $id . '" not found.';
189
- throw new Payone_Core_Exception_PaymentMethodConfigNotFound($message);
190
- }
191
-
192
- return $configPaymentMethod;
193
- }
194
-
195
- /**
196
- * @return Mage_Sales_Model_Order_Invoice
197
- */
198
- protected function getInvoiceForOrder()
199
- {
200
- /** @var $invoiceCollection Mage_Sales_Model_Mysql4_Order_Invoice_Collection */
201
- $invoiceCollection = $this->order->getInvoiceCollection();
202
- $invoiceCollection->addFieldToFilter('payone_sequencenumber', $this->transactionStatus->getSequencenumber());
203
- $invoice = $invoiceCollection->getFirstItem();
204
- return $invoice;
205
- }
206
-
207
}
<
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
12
+ * versions in the future. If you wish to customize Payone_Core for your
13
+ * needs please refer to http://www.payone.de for more information.
14
+ *
15
+ * @category Payone
16
+ * @package Payone_Core_Model
17
+ * @subpackage Observer
18
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
19
+ * @author Matthias Walter <info@noovias.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.noovias.com
22
+ */
23
+
24
+ /**
25
+ *
26
+ * @category Payone
27
+ * @package Payone_Core_Model
28
+ * @subpackage Observer
29
+ * @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
30
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
+ * @link http://www.noovias.com
32
+ */
33
+ class Payone_Core_Model_Observer_TransactionStatus_InvoiceCreate
34
+ extends Payone_Core_Model_Observer_Abstract
35
+ {
36
+ /**
37
+ * @var Payone_Core_Model_Service_Sales_InvoiceCreate
38
+ */
39
+ protected $serviceInvoiceCreate = null;
40
+
41
+ /** @var $method Payone_Core_Model_Payment_Method_Abstract */
42
+ private $method = null;
43
+
44
+ /** @var $order Mage_Sales_Model_Order */
45
+ private $order = null;
46
+
47
+ /** @var $config Payone_Core_Model_Config */
48
+ private $config = null;
49
+
50
+ /** @var $payment Mage_Sales_Model_Order_Payment */
51
+ private $payment = null;
52
+
53
+ /** @var $transactionStatus Payone_Core_Model_Domain_Protocol_TransactionStatus */
54
+ private $transactionStatus = null;
55
+
56
+ /**
57
+ * @param Varien_Event_Observer $observer
58
+ */
59
+ public function onAppointed(Varien_Event_Observer $observer)
60
+ {
61
+ $this->initData($observer);
62
+
63
+ $configMethod = $this->getConfigPaymentMethodById();
64
+ // All Other PaymentMethods create Invoice if request-type is authorization
65
+ if ($configMethod->isRequestAuthorization()) {
66
+ if (!$this->method instanceof Payone_Core_Model_Payment_Method_AdvancePayment) {
67
+ // Create Invoice
68
+ $invoice = $this->getServiceInvoiceCreate()->createByOrder($this->order);
69
+
70
+ $this->sendInvoiceEmail($invoice);
71
+ }
72
+ // Advance Payment: invoice is created on Transaction Paid
73
+ }