|
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 to newer |
|
12
|
|
|
* versions in the future. If you wish to customize Payone for your |
|
13
|
|
|
* needs please refer to http://www.payone.de for more information. |
|
14
|
|
|
* |
|
15
|
|
|
* @category Payone |
|
16
|
|
|
* @package Payone_Api |
|
17
|
|
|
* @subpackage Request |
|
18
|
|
|
* @copyright Copyright (c) 2012 <[email protected]> - www.noovias.com |
|
19
|
|
|
* @author Matthias Walter <[email protected]> |
|
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_Api |
|
28
|
|
|
* @subpackage Request |
|
29
|
|
|
* @copyright Copyright (c) 2012 <[email protected]> - 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_Api_Request_Authorization_Abstract |
|
34
|
|
|
extends Payone_Api_Request_Abstract |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* Sub account ID |
|
38
|
|
|
* |
|
39
|
|
|
* @var int |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $aid = NULL; |
|
42
|
|
|
/** |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $clearingtype = NULL; |
|
46
|
|
|
/** |
|
47
|
|
|
* Merchant reference number for the payment process. (Permitted symbols: 0-9, a-z, A-Z, .,-,_,/) |
|
48
|
|
|
* |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $reference = NULL; |
|
52
|
|
|
/** |
|
53
|
|
|
* Total amount (in smallest currency unit! e.g. cent) |
|
54
|
|
|
* |
|
55
|
|
|
* @var int |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $amount = NULL; |
|
58
|
|
|
/** |
|
59
|
|
|
* Currency (ISO-4217) |
|
60
|
|
|
* |
|
61
|
|
|
* @var string |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $currency = NULL; |
|
64
|
|
|
/** |
|
65
|
|
|
* Individual parameter |
|
66
|
|
|
* |
|
67
|
|
|
* @var string |
|
68
|
|
|
*/ |
|
69
|
|
|
protected $param = NULL; |
|
70
|
|
|
/** |
|
71
|
|
|
* dynamic text for debit and creditcard payments |
|
72
|
|
|
* |
|
73
|
|
|
* @var string |
|
74
|
|
|
*/ |
|
75
|
|
|
protected $narrative_text = NULL; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @var Payone_Api_Request_Parameter_Authorization_PersonalData |
|
79
|
|
|
*/ |
|
80
|
|
|
protected $personalData = null; |
|
81
|
|
|
/** |
|
82
|
|
|
* @var Payone_Api_Request_Parameter_Authorization_DeliveryData |
|
83
|
|
|
*/ |
|
84
|
|
|
protected $deliveryData = null; |
|
85
|
|
|
/** |
|
86
|
|
|
* @var Payone_Api_Request_Parameter_Authorization_PaymentMethod_Abstract |
|
87
|
|
|
*/ |
|
88
|
|
|
protected $payment = null; |
|
89
|
|
|
/** |
|
90
|
|
|
* @var Payone_Api_Request_Parameter_Authorization_3dsecure |
|
91
|
|
|
*/ |
|
92
|
|
|
protected $_3dsecure = null; |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @var Payone_Api_Request_Parameter_Invoicing_Transaction |
|
96
|
|
|
*/ |
|
97
|
|
|
protected $invoicing = null; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Mandatory for PayPal Express Checkout |
|
101
|
|
|
* Alphanumeric max 16 chars |
|
102
|
|
|
* @var string |
|
103
|
|
|
*/ |
|
104
|
|
|
protected $workorderid = null; |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @param int $aid |
|
108
|
|
|
*/ |
|
109
|
|
|
public function setAid($aid) |
|
110
|
|
|
{ |
|
111
|
|
|
$this->aid = $aid; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @return int |
|
116
|
|
|
*/ |
|
117
|
|
|
public function getAid() |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->aid; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @param int $amount |
|
124
|
|
|
*/ |
|
125
|
|
|
public function setAmount($amount) |
|
126
|
|
|
{ |
|
127
|
|
|
$this->amount = $amount; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @return int |
|
132
|
|
|
*/ |
|
133
|
|
|
public function getAmount() |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->amount; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @param string $clearingtype |
|
140
|
|
|
*/ |
|
141
|
|
|
public function setClearingtype($clearingtype) |
|
142
|
|
|
{ |
|
143
|
|
|
$this->clearingtype = $clearingtype; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @return string |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getClearingtype() |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->clearingtype; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @param string $currency |
|
156
|
|
|
*/ |
|
157
|
|
|
public function setCurrency($currency) |
|
158
|
|
|
{ |
|
159
|
|
|
$this->currency = $currency; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @return string |
|
164
|
|
|
*/ |
|
165
|
|
|
public function getCurrency() |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->currency; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @param string $narrative_text |
|
172
|
|
|
*/ |
|
173
|
|
|
public function setNarrativeText($narrative_text) |
|
174
|
|
|
{ |
|
175
|
|
|
$this->narrative_text = $narrative_text; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @return string |
|
180
|
|
|
*/ |
|
181
|
|
|
public function getNarrativeText() |
|
182
|
|
|
{ |
|
183
|
|
|
return $this->narrative_text; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @param string $param |
|
188
|
|
|
*/ |
|
189
|
|
|
public function setParam($param) |
|
190
|
|
|
{ |
|
191
|
|
|
$this->param = $param; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @return string |
|
196
|
|
|
*/ |
|
197
|
|
|
public function getParam() |
|
198
|
|
|
{ |
|
199
|
|
|
return $this->param; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* @param string $reference |
|
204
|
|
|
*/ |
|
205
|
|
|
public function setReference($reference) |
|
206
|
|
|
{ |
|
207
|
|
|
$this->reference = $reference; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @return string |
|
212
|
|
|
*/ |
|
213
|
|
|
public function getReference() |
|
214
|
|
|
{ |
|
215
|
|
|
return $this->reference; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* @param Payone_Api_Request_Parameter_Authorization_PersonalData $personalData |
|
220
|
|
|
*/ |
|
221
|
|
|
public function setPersonalData(Payone_Api_Request_Parameter_Authorization_PersonalData $personalData) |
|
222
|
|
|
{ |
|
223
|
|
|
$this->personalData = $personalData; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @return Payone_Api_Request_Parameter_Authorization_PersonalData |
|
228
|
|
|
*/ |
|
229
|
|
|
public function getPersonalData() |
|
230
|
|
|
{ |
|
231
|
|
|
return $this->personalData; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* @param Payone_Api_Request_Parameter_Authorization_DeliveryData $deliveryData |
|
236
|
|
|
*/ |
|
237
|
|
|
public function setDeliveryData(Payone_Api_Request_Parameter_Authorization_DeliveryData $deliveryData) |
|
238
|
|
|
{ |
|
239
|
|
|
$this->deliveryData = $deliveryData; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* @return Payone_Api_Request_Parameter_Authorization_DeliveryData |
|
244
|
|
|
*/ |
|
245
|
|
|
public function getDeliveryData() |
|
246
|
|
|
{ |
|
247
|
|
|
return $this->deliveryData; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
/** |
|
251
|
|
|
* @param Payone_Api_Request_Parameter_Authorization_PaymentMethod_Abstract $payment |
|
252
|
|
|
*/ |
|
253
|
|
|
public function setPayment(Payone_Api_Request_Parameter_Authorization_PaymentMethod_Abstract $payment) |
|
254
|
|
|
{ |
|
255
|
|
|
$this->payment = $payment; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* @return Payone_Api_Request_Parameter_Authorization_PaymentMethod_Abstract |
|
260
|
|
|
*/ |
|
261
|
|
|
public function getPayment() |
|
262
|
|
|
{ |
|
263
|
|
|
return $this->payment; |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
/** |
|
267
|
|
|
* @param Payone_Api_Request_Parameter_Authorization_3dsecure $secure |
|
268
|
|
|
*/ |
|
269
|
|
|
public function set3dsecure(Payone_Api_Request_Parameter_Authorization_3dsecure $secure) |
|
270
|
|
|
{ |
|
271
|
|
|
$this->_3dsecure = $secure; |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
/** |
|
275
|
|
|
* @return Payone_Api_Request_Parameter_Authorization_3dsecure |
|
276
|
|
|
*/ |
|
277
|
|
|
public function get3dsecure() |
|
278
|
|
|
{ |
|
279
|
|
|
return $this->_3dsecure; |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
|
|
283
|
|
|
/** |
|
284
|
|
|
* @param Payone_Api_Request_Parameter_Invoicing_Transaction $invoicing |
|
285
|
|
|
*/ |
|
286
|
|
|
public function setInvoicing(Payone_Api_Request_Parameter_Invoicing_Transaction $invoicing) |
|
287
|
|
|
{ |
|
288
|
|
|
$this->invoicing = $invoicing; |
|
289
|
|
|
} |
|
290
|
|
|
|
|
291
|
|
|
/** |
|
292
|
|
|
* @return Payone_Api_Request_Parameter_Invoicing_Transaction |
|
293
|
|
|
*/ |
|
294
|
|
|
public function getInvoicing() |
|
295
|
|
|
{ |
|
296
|
|
|
return $this->invoicing; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
/** |
|
300
|
|
|
* @return string |
|
301
|
|
|
*/ |
|
302
|
|
|
function getWorkorderId() |
|
|
|
|
|
|
303
|
|
|
{ |
|
304
|
|
|
return $this->workorderid; |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* @param string $workorderid |
|
309
|
|
|
*/ |
|
310
|
|
|
function setWorkorderId($workorderid) |
|
|
|
|
|
|
311
|
|
|
{ |
|
312
|
|
|
$this->workorderid = $workorderid; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
public function convertToFrontendApiUrl() |
|
316
|
|
|
{ |
|
317
|
|
|
$sFrontendApiUrl = 'https://secure.pay1.de/frontend/'; |
|
318
|
|
|
$aFrontendUnsetParams = array( |
|
319
|
|
|
'mid', |
|
320
|
|
|
'integrator_name', |
|
321
|
|
|
'integrator_version', |
|
322
|
|
|
'solution_name', |
|
323
|
|
|
'solution_version', |
|
324
|
|
|
'ip', |
|
325
|
|
|
'errorurl', |
|
326
|
|
|
'salutation', |
|
327
|
|
|
'pseudocardpan', |
|
328
|
|
|
); |
|
329
|
|
|
$aFrontendHashParams = array( |
|
330
|
|
|
'aid', |
|
331
|
|
|
'amount', |
|
332
|
|
|
'backurl', |
|
333
|
|
|
'clearingtype', |
|
334
|
|
|
'currency', |
|
335
|
|
|
'customerid', |
|
336
|
|
|
'de', |
|
337
|
|
|
'encoding', |
|
338
|
|
|
'id', |
|
339
|
|
|
'mode', |
|
340
|
|
|
'no', |
|
341
|
|
|
'portalid', |
|
342
|
|
|
'pr', |
|
343
|
|
|
'reference', |
|
344
|
|
|
'request', |
|
345
|
|
|
'successurl', |
|
346
|
|
|
'targetwindow', |
|
347
|
|
|
'va', |
|
348
|
|
|
'key', |
|
349
|
|
|
'invoiceappendix', |
|
350
|
|
|
'invoice_deliverydate', |
|
351
|
|
|
'invoice_deliveryenddate', |
|
352
|
|
|
'param', |
|
353
|
|
|
'narrative_text', |
|
354
|
|
|
); |
|
355
|
|
|
|
|
356
|
|
|
$aParameters = $this->toArray(); |
|
357
|
|
|
$aParameters['targetwindow'] = 'parent'; |
|
358
|
|
|
|
|
359
|
|
|
$aHashParams = array(); |
|
360
|
|
|
foreach ($aParameters as $sKey => $sValue) { |
|
361
|
|
|
if(array_search($sKey, $aFrontendUnsetParams) !== false) { |
|
362
|
|
|
unset($aParameters[$sKey]); |
|
363
|
|
|
} elseif(array_search($sKey, $aFrontendHashParams) !== false || stripos($sKey, '[') !== false) { |
|
364
|
|
|
$aHashParams[$sKey] = $sValue; |
|
365
|
|
|
} |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
$aParameters['hash'] = $this->_getFrontendHash($aHashParams); |
|
369
|
|
|
|
|
370
|
|
|
$sUrlParams = '?'; |
|
371
|
|
|
foreach ($aParameters as $sKey => $sValue) { |
|
372
|
|
|
$sUrlParams .= $sKey.'='.urlencode($sValue).'&'; |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
$sUrlParams = rtrim($sUrlParams, '&'); |
|
376
|
|
|
$sFrontendApiUrl = $sFrontendApiUrl.$sUrlParams; |
|
377
|
|
|
|
|
378
|
|
|
return $sFrontendApiUrl; |
|
379
|
|
|
} |
|
380
|
|
|
|
|
381
|
|
|
public function getFrontendApiResponse() |
|
382
|
|
|
{ |
|
383
|
|
|
$aResponse = array( |
|
384
|
|
|
'redirecturl' => $this->convertToFrontendApiUrl(), |
|
385
|
|
|
'status' => 'REDIRECT', |
|
386
|
|
|
'txid' => '', |
|
387
|
|
|
); |
|
388
|
|
|
|
|
389
|
|
|
return $aResponse; |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
protected function _getConfigKey() |
|
393
|
|
|
{ |
|
394
|
|
|
$oOrder = Mage::getSingleton('checkout/session')->getQuote(); |
|
395
|
|
|
$oPayment = $oOrder->getPayment(); |
|
396
|
|
|
$oPaymentMethod = $oPayment->getMethodInstance(); |
|
397
|
|
|
$oPaymentConfig = $oPaymentMethod->getConfigByOrder($oOrder); |
|
398
|
|
|
return $oPaymentConfig->getKey(); |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
protected function _getFrontendHash($aHashParams) |
|
402
|
|
|
{ |
|
403
|
|
|
ksort($aHashParams, SORT_STRING); |
|
404
|
|
|
unset($aHashParams['key']); |
|
405
|
|
|
$aHashParams['key'] = $this->_getConfigKey(); |
|
406
|
|
|
|
|
407
|
|
|
$sHashString = ''; |
|
408
|
|
|
foreach ($aHashParams as $sKey => $sValue) { |
|
409
|
|
|
$sHashString .= $sValue; |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
return md5($sHashString); |
|
413
|
|
|
} |
|
414
|
|
|
|
|
415
|
|
|
} |
|
416
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.