|
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_ClientApi |
|
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_ClientApi |
|
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_ClientApi_Request_Abstract implements Payone_ClientApi_Request_Interface |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @var int |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $mid = 0; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var int |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $portalid = 0; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $key = ''; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var string |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $mode = ''; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @var string |
|
57
|
|
|
*/ |
|
58
|
|
|
protected $request = ''; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @var string |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $responsetype; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @var string |
|
67
|
|
|
*/ |
|
68
|
|
|
protected $encoding = ''; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* name of the solution-partner (company) |
|
72
|
|
|
* |
|
73
|
|
|
* @var string |
|
74
|
|
|
*/ |
|
75
|
|
|
protected $solution_name = ''; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* version of the solution-partner's app / extension / plugin / etc.. |
|
79
|
|
|
* |
|
80
|
|
|
* @var string |
|
81
|
|
|
*/ |
|
82
|
|
|
protected $solution_version = ''; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* system-name |
|
86
|
|
|
* |
|
87
|
|
|
* @var string |
|
88
|
|
|
*/ |
|
89
|
|
|
protected $integrator_name = ''; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* system-version |
|
93
|
|
|
* |
|
94
|
|
|
* @var string |
|
95
|
|
|
*/ |
|
96
|
|
|
protected $integrator_version = ''; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* ISO 639 |
|
100
|
|
|
* @var string |
|
101
|
|
|
*/ |
|
102
|
|
|
protected $language = ''; |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @var string |
|
106
|
|
|
*/ |
|
107
|
|
|
protected $hash = ''; |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @param array $data |
|
111
|
|
|
*/ |
|
112
|
|
|
public function __construct(array $data = array()) |
|
113
|
|
|
{ |
|
114
|
|
|
if (count($data) > 0) { |
|
115
|
|
|
$this->init($data); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param array $data |
|
121
|
|
|
*/ |
|
122
|
|
View Code Duplication |
public function init(array $data = array()) |
|
|
|
|
|
|
123
|
|
|
{ |
|
124
|
|
|
foreach ($data as $key => $value) { |
|
125
|
|
|
$key = ucwords(str_replace('_', ' ', $key)); |
|
126
|
|
|
$method = 'set' . str_replace(' ', '', $key); |
|
127
|
|
|
|
|
128
|
|
|
if (method_exists($this, $method)) { |
|
129
|
|
|
$this->{$method}($value); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @return array |
|
136
|
|
|
*/ |
|
137
|
|
|
public function toArray() |
|
138
|
|
|
{ |
|
139
|
|
|
$result = array(); |
|
140
|
|
|
foreach ($this as $key => $data) { |
|
|
|
|
|
|
141
|
|
|
if ($data === null) { |
|
142
|
|
|
continue; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
$result[$key] = $data; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
ksort($result); |
|
149
|
|
|
|
|
150
|
|
|
return $result; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @return string |
|
155
|
|
|
*/ |
|
156
|
|
|
public function __toString() |
|
157
|
|
|
{ |
|
158
|
|
|
$stringArray = array(); |
|
159
|
|
|
foreach ($this->toArray() as $key => $value) { |
|
160
|
|
|
$stringArray[] = $key . '=' . $value; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
$result = implode('|', $stringArray); |
|
164
|
|
|
return $result; |
|
|
|
|
|
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @param $name |
|
169
|
|
|
* @return null|mixed |
|
170
|
|
|
*/ |
|
171
|
|
View Code Duplication |
public function get($name) |
|
|
|
|
|
|
172
|
|
|
{ |
|
173
|
|
|
if (strpos($name, '/') !== false) { |
|
174
|
|
|
$explodedName = explode('/', $name); |
|
175
|
|
|
if (count($explodedName) != 2) { |
|
176
|
|
|
return null; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
$property = $explodedName[0]; |
|
180
|
|
|
$propertyName = $explodedName[1]; |
|
181
|
|
|
if (property_exists($this, $property)) { |
|
182
|
|
|
$object = $this->$property; |
|
183
|
|
|
/** |
|
184
|
|
|
* @var $object Payone_Api_Request_Parameter_Interface |
|
185
|
|
|
*/ |
|
186
|
|
|
if (!($object instanceof Payone_Api_Request_Parameter_Interface)) { |
|
187
|
|
|
return null; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
return $object->get($propertyName); |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
elseif (property_exists($this, $name)) { |
|
194
|
|
|
return $this->$name; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
return null; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* @param string $name |
|
202
|
|
|
* @param mixed $value |
|
203
|
|
|
* @return boolean|null |
|
204
|
|
|
*/ |
|
205
|
|
|
public function set($name, $value) |
|
206
|
|
|
{ |
|
207
|
|
|
if (property_exists($this, $name)) { |
|
208
|
|
|
$this->$name = $value; |
|
209
|
|
|
return true; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
return null; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* @param string $encoding |
|
217
|
|
|
*/ |
|
218
|
|
|
public function setEncoding($encoding) |
|
219
|
|
|
{ |
|
220
|
|
|
$this->encoding = $encoding; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* @return string |
|
225
|
|
|
*/ |
|
226
|
|
|
public function getEncoding() |
|
227
|
|
|
{ |
|
228
|
|
|
return $this->encoding; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* @param string $key |
|
233
|
|
|
*/ |
|
234
|
|
|
public function setKey($key) |
|
235
|
|
|
{ |
|
236
|
|
|
$this->key = md5($key); |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
/** |
|
240
|
|
|
* @return string |
|
241
|
|
|
*/ |
|
242
|
|
|
public function getKey() |
|
243
|
|
|
{ |
|
244
|
|
|
return $this->key; |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @param int $mid |
|
249
|
|
|
*/ |
|
250
|
|
|
public function setMid($mid) |
|
251
|
|
|
{ |
|
252
|
|
|
$this->mid = $mid; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* @return int |
|
257
|
|
|
*/ |
|
258
|
|
|
public function getMid() |
|
259
|
|
|
{ |
|
260
|
|
|
return $this->mid; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* @param string $mode |
|
265
|
|
|
*/ |
|
266
|
|
|
public function setMode($mode) |
|
267
|
|
|
{ |
|
268
|
|
|
$this->mode = $mode; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
/** |
|
272
|
|
|
* @return string |
|
273
|
|
|
*/ |
|
274
|
|
|
public function getMode() |
|
275
|
|
|
{ |
|
276
|
|
|
return $this->mode; |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
/** |
|
280
|
|
|
* @param int $portalid |
|
281
|
|
|
*/ |
|
282
|
|
|
public function setPortalid($portalid) |
|
283
|
|
|
{ |
|
284
|
|
|
$this->portalid = $portalid; |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
/** |
|
288
|
|
|
* @return int |
|
289
|
|
|
*/ |
|
290
|
|
|
public function getPortalid() |
|
291
|
|
|
{ |
|
292
|
|
|
return $this->portalid; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* @param string $request |
|
297
|
|
|
*/ |
|
298
|
|
|
public function setRequest($request) |
|
299
|
|
|
{ |
|
300
|
|
|
$this->request = $request; |
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
/** |
|
304
|
|
|
* @return string |
|
305
|
|
|
*/ |
|
306
|
|
|
public function getRequest() |
|
307
|
|
|
{ |
|
308
|
|
|
return $this->request; |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
/** |
|
312
|
|
|
* @param string $responseType |
|
313
|
|
|
*/ |
|
314
|
|
|
public function setResponsetype($responseType) |
|
315
|
|
|
{ |
|
316
|
|
|
$this->responsetype = $responseType; |
|
317
|
|
|
} |
|
318
|
|
|
|
|
319
|
|
|
/** |
|
320
|
|
|
* @return string |
|
321
|
|
|
*/ |
|
322
|
|
|
public function getResponseType() |
|
323
|
|
|
{ |
|
324
|
|
|
return $this->responsetype; |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
/** |
|
328
|
|
|
* set the system-Name |
|
329
|
|
|
* |
|
330
|
|
|
* @param string $integrator_name |
|
331
|
|
|
*/ |
|
332
|
|
|
public function setIntegratorName($integrator_name) |
|
333
|
|
|
{ |
|
334
|
|
|
$this->integrator_name = $integrator_name; |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
/** |
|
338
|
|
|
* @return string |
|
339
|
|
|
*/ |
|
340
|
|
|
public function getIntegratorName() |
|
341
|
|
|
{ |
|
342
|
|
|
return $this->integrator_name; |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* set the system-version |
|
347
|
|
|
* |
|
348
|
|
|
* @param string $integrator_version |
|
349
|
|
|
*/ |
|
350
|
|
|
public function setIntegratorVersion($integrator_version) |
|
351
|
|
|
{ |
|
352
|
|
|
$this->integrator_version = $integrator_version; |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* @return string |
|
357
|
|
|
*/ |
|
358
|
|
|
public function getIntegratorVersion() |
|
359
|
|
|
{ |
|
360
|
|
|
return $this->integrator_version; |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* set the name of the solution-partner (company) |
|
365
|
|
|
* |
|
366
|
|
|
* @param string $solution_name |
|
367
|
|
|
*/ |
|
368
|
|
|
public function setSolutionName($solution_name) |
|
369
|
|
|
{ |
|
370
|
|
|
$this->solution_name = $solution_name; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
/** |
|
374
|
|
|
* @return string |
|
375
|
|
|
*/ |
|
376
|
|
|
public function getSolutionName() |
|
377
|
|
|
{ |
|
378
|
|
|
return $this->solution_name; |
|
379
|
|
|
} |
|
380
|
|
|
|
|
381
|
|
|
/** |
|
382
|
|
|
* set the version of the solution-partner's app / extension / plugin / etc.. |
|
383
|
|
|
* |
|
384
|
|
|
* @param string $solution_version |
|
385
|
|
|
*/ |
|
386
|
|
|
public function setSolutionVersion($solution_version) |
|
387
|
|
|
{ |
|
388
|
|
|
$this->solution_version = $solution_version; |
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
|
|
/** |
|
392
|
|
|
* @return string |
|
393
|
|
|
*/ |
|
394
|
|
|
public function getSolutionVersion() |
|
395
|
|
|
{ |
|
396
|
|
|
return $this->solution_version; |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
|
|
/** |
|
400
|
|
|
* @param string $hash |
|
401
|
|
|
*/ |
|
402
|
|
|
public function setHash($hash) |
|
403
|
|
|
{ |
|
404
|
|
|
$this->hash = $hash; |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* @return string |
|
409
|
|
|
*/ |
|
410
|
|
|
public function getHash() |
|
411
|
|
|
{ |
|
412
|
|
|
return $this->hash; |
|
413
|
|
|
} |
|
414
|
|
|
|
|
415
|
|
|
/** |
|
416
|
|
|
* @param string $language |
|
417
|
|
|
*/ |
|
418
|
|
|
public function setLanguage($language) |
|
419
|
|
|
{ |
|
420
|
|
|
$this->language = $language; |
|
421
|
|
|
} |
|
422
|
|
|
|
|
423
|
|
|
/** |
|
424
|
|
|
* @return string |
|
425
|
|
|
*/ |
|
426
|
|
|
public function getLanguage() |
|
427
|
|
|
{ |
|
428
|
|
|
return $this->language; |
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
} |
|
432
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.