1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nexy\PayboxDirect; |
4
|
|
|
|
5
|
|
|
use Nexy\PayboxDirect\HttpClient\AbstractHttpClient; |
6
|
|
|
use Nexy\PayboxDirect\HttpClient\GuzzleHttpClient; |
7
|
|
|
use Nexy\PayboxDirect\OptionsResolver\OptionsResolver; |
8
|
|
|
use Nexy\PayboxDirect\Response\PayboxResponse; |
9
|
|
|
use Nexy\PayboxDirect\Variable\PayboxVariableActivity; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @author Sullivan Senechal <[email protected]> |
13
|
|
|
* |
14
|
|
|
* @see http://www1.paybox.com/espace-integrateur-documentation/les-solutions-paybox-direct-et-paybox-direct-plus/les-operations-de-caisse-direct-plus/ |
15
|
|
|
* @see http://www1.paybox.com/espace-integrateur-documentation/dictionnaire-des-donnees/paybox-direct-et-direct-plus/ |
16
|
|
|
*/ |
17
|
|
|
final class Paybox |
18
|
|
|
{ |
19
|
|
|
const VERSION_DIRECT = '00103'; |
20
|
|
|
const VERSION_DIRECT_PLUS = '00104'; |
21
|
|
|
|
22
|
|
|
const VERSIONS = [ |
23
|
|
|
'direct' => self::VERSION_DIRECT, |
24
|
|
|
'direct_plus' => self::VERSION_DIRECT_PLUS, |
25
|
|
|
]; |
26
|
|
|
|
27
|
|
|
const CURRENCY_EURO = 978; |
28
|
|
|
const CURRENCY_US_DOLLAR = 840; |
29
|
|
|
const CURRENCY_CFA = 952; |
30
|
|
|
|
31
|
|
|
const CURRENCIES = [ |
32
|
|
|
'euro' => self::CURRENCY_EURO, |
33
|
|
|
'us_dollar' => self::CURRENCY_US_DOLLAR, |
34
|
|
|
'cfa' => self::CURRENCY_CFA, |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
const API_URL_PRODUCTION = 'https://ppps.paybox.com/PPPS.php'; |
38
|
|
|
const API_URL_RESCUE = 'https://ppps1.paybox.com/PPPS.php'; |
39
|
|
|
const API_URL_TEST = 'https://preprod-ppps.paybox.com/PPPS.php'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var AbstractHttpClient |
43
|
|
|
*/ |
44
|
|
|
private $httpClient; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var array |
48
|
|
|
*/ |
49
|
|
|
private $options; |
50
|
|
|
|
51
|
|
|
public function __construct(array $options = [], AbstractHttpClient $httpClient = null) |
52
|
|
|
{ |
53
|
|
|
$resolver = new OptionsResolver(); |
54
|
|
|
$this->configureOptions($resolver); |
55
|
|
|
|
56
|
|
|
$this->options = $resolver->resolve($options); |
57
|
|
|
|
58
|
|
|
$this->httpClient = $httpClient ? $httpClient : new GuzzleHttpClient(); |
59
|
|
|
$this->httpClient->setOptions($this->options); |
60
|
|
|
$this->httpClient->init(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param string $DATEVAL |
65
|
|
|
* @param int $MONTANT |
66
|
|
|
* @param string $PORTEUR |
67
|
|
|
* @param string $REFERENCE |
68
|
|
|
* @param string|null $AUTORISATION |
69
|
|
|
* @param int|null $DEVISE |
70
|
|
|
* |
71
|
|
|
* @return PayboxResponse |
72
|
|
|
* |
73
|
|
|
* @throws Exception\PayboxException |
74
|
|
|
*/ |
75
|
|
View Code Duplication |
public function authorize($DATEVAL, $MONTANT, $PORTEUR, $REFERENCE, $AUTORISATION = null, $DEVISE = null) |
|
|
|
|
76
|
|
|
{ |
77
|
|
|
$parameters = [ |
78
|
|
|
'DATEVAL' => $DATEVAL, |
79
|
|
|
'MONTANT' => $MONTANT, |
80
|
|
|
'PORTEUR' => $PORTEUR, |
81
|
|
|
'REFERENCE' => $REFERENCE, |
82
|
|
|
]; |
83
|
|
|
|
84
|
|
|
if (null !== $AUTORISATION) { |
85
|
|
|
$parameters['AUTORISATION'] = $AUTORISATION; |
86
|
|
|
} |
87
|
|
|
if (null !== $DEVISE) { |
88
|
|
|
$parameters['DEVISE'] = $DEVISE; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $this->httpClient->call(1, $parameters); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param int $MONTANT |
96
|
|
|
* @param int $NUMAPPEL |
97
|
|
|
* @param int $NUMTRANS |
98
|
|
|
* @param string $REFERENCE |
99
|
|
|
* @param int|null $DEVISE |
100
|
|
|
* |
101
|
|
|
* @return PayboxResponse |
102
|
|
|
* |
103
|
|
|
* @throws Exception\PayboxException |
104
|
|
|
*/ |
105
|
|
View Code Duplication |
public function debit($MONTANT, $NUMAPPEL, $NUMTRANS, $REFERENCE, $DEVISE = null) |
|
|
|
|
106
|
|
|
{ |
107
|
|
|
$parameters = [ |
108
|
|
|
'MONTANT' => $MONTANT, |
109
|
|
|
'NUMAPPEL' => $NUMAPPEL, |
110
|
|
|
'NUMTRANS' => $NUMTRANS, |
111
|
|
|
'REFERENCE' => $REFERENCE, |
112
|
|
|
]; |
113
|
|
|
|
114
|
|
|
if (null !== $DEVISE) { |
115
|
|
|
$parameters['DEVISE'] = $DEVISE; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
return $this->httpClient->call(2, $parameters); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param string $DATEVAL |
123
|
|
|
* @param int $MONTANT |
124
|
|
|
* @param string $PORTEUR |
125
|
|
|
* @param string $REFERENCE |
126
|
|
|
* @param string|null $AUTORISATION |
127
|
|
|
* @param int|null $DEVISE |
128
|
|
|
* |
129
|
|
|
* @return PayboxResponse |
130
|
|
|
* |
131
|
|
|
* @throws Exception\PayboxException |
132
|
|
|
*/ |
133
|
|
View Code Duplication |
public function authorizeAndCapture($DATEVAL, $MONTANT, $PORTEUR, $REFERENCE, $AUTORISATION = null, $DEVISE = null) |
|
|
|
|
134
|
|
|
{ |
135
|
|
|
$parameters = [ |
136
|
|
|
'DATEVAL' => $DATEVAL, |
137
|
|
|
'MONTANT' => $MONTANT, |
138
|
|
|
'PORTEUR' => $PORTEUR, |
139
|
|
|
'REFERENCE' => $REFERENCE, |
140
|
|
|
]; |
141
|
|
|
|
142
|
|
|
if (null !== $AUTORISATION) { |
143
|
|
|
$parameters['AUTORISATION'] = $AUTORISATION; |
144
|
|
|
} |
145
|
|
|
if (null !== $DEVISE) { |
146
|
|
|
$parameters['DEVISE'] = $DEVISE; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
return $this->httpClient->call(3, $parameters); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param string $DATEVAL |
154
|
|
|
* @param int $MONTANT |
155
|
|
|
* @param string $PORTEUR |
156
|
|
|
* @param string $REFERENCE |
157
|
|
|
* @param int|null $DEVISE |
158
|
|
|
* |
159
|
|
|
* @return PayboxResponse |
160
|
|
|
* |
161
|
|
|
* @throws Exception\PayboxException |
162
|
|
|
*/ |
163
|
|
View Code Duplication |
public function credit($DATEVAL, $MONTANT, $PORTEUR, $REFERENCE, $DEVISE = null) |
|
|
|
|
164
|
|
|
{ |
165
|
|
|
$parameters = [ |
166
|
|
|
'DATEVAL' => $DATEVAL, |
167
|
|
|
'MONTANT' => $MONTANT, |
168
|
|
|
'PORTEUR' => $PORTEUR, |
169
|
|
|
'REFERENCE' => $REFERENCE, |
170
|
|
|
]; |
171
|
|
|
|
172
|
|
|
if (null !== $DEVISE) { |
173
|
|
|
$parameters['DEVISE'] = $DEVISE; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
return $this->httpClient->call(4, $parameters); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @param int $MONTANT |
181
|
|
|
* @param int $NUMAPPEL |
182
|
|
|
* @param int $NUMTRANSL |
183
|
|
|
* @param string $REFERENCE |
184
|
|
|
* @param int|null $DEVISE |
185
|
|
|
* |
186
|
|
|
* @return PayboxResponse |
187
|
|
|
* |
188
|
|
|
* @throws Exception\PayboxException |
189
|
|
|
*/ |
190
|
|
View Code Duplication |
public function cancel($MONTANT, $NUMAPPEL, $NUMTRANSL, $REFERENCE, $DEVISE = null) |
|
|
|
|
191
|
|
|
{ |
192
|
|
|
$parameters = [ |
193
|
|
|
'MONTANT' => $MONTANT, |
194
|
|
|
'NUMAPPEL' => $NUMAPPEL, |
195
|
|
|
'NUMTRANSL' => $NUMTRANSL, |
196
|
|
|
'REFERENCE' => $REFERENCE, |
197
|
|
|
]; |
198
|
|
|
|
199
|
|
|
if (null !== $DEVISE) { |
200
|
|
|
$parameters['DEVISE'] = $DEVISE; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
return $this->httpClient->call(5, $parameters); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @param int $MONTANT |
208
|
|
|
* @param string $REFERENCE |
209
|
|
|
* @param int|null $DEVISE |
210
|
|
|
* |
211
|
|
|
* @return PayboxResponse |
212
|
|
|
* |
213
|
|
|
* @throws Exception\PayboxException |
214
|
|
|
*/ |
215
|
|
|
public function check($MONTANT, $REFERENCE, $DEVISE = null) |
216
|
|
|
{ |
217
|
|
|
$parameters = [ |
218
|
|
|
'MONTANT' => $MONTANT, |
219
|
|
|
'REFERENCE' => $REFERENCE, |
220
|
|
|
]; |
221
|
|
|
|
222
|
|
|
if (null !== $DEVISE) { |
223
|
|
|
$parameters['DEVISE'] = $DEVISE; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
return $this->httpClient->call(11, $parameters); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* @param string $DATEVAL |
231
|
|
|
* @param int $MONTANT |
232
|
|
|
* @param string $PORTEUR |
233
|
|
|
* @param string $REFERENCE |
234
|
|
|
* @param int|null $DEVISE |
235
|
|
|
* |
236
|
|
|
* @return PayboxResponse |
237
|
|
|
* |
238
|
|
|
* @throws Exception\PayboxException |
239
|
|
|
*/ |
240
|
|
View Code Duplication |
public function transact($DATEVAL, $MONTANT, $PORTEUR, $REFERENCE, $DEVISE = null) |
|
|
|
|
241
|
|
|
{ |
242
|
|
|
$parameters = [ |
243
|
|
|
'DATEVAL' => $DATEVAL, |
244
|
|
|
'MONTANT' => $MONTANT, |
245
|
|
|
'PORTEUR' => $PORTEUR, |
246
|
|
|
'REFERENCE' => $REFERENCE, |
247
|
|
|
]; |
248
|
|
|
|
249
|
|
|
if (null !== $DEVISE) { |
250
|
|
|
$parameters['DEVISE'] = $DEVISE; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
return $this->httpClient->call(12, $parameters); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @param int $MONTANT |
258
|
|
|
* @param int $NUMAPPEL |
259
|
|
|
* @param int $NUMTRANS |
260
|
|
|
* @param string|null $AUTORISATION |
261
|
|
|
* @param int|null $DEVISE |
262
|
|
|
* |
263
|
|
|
* @return PayboxResponse |
264
|
|
|
* |
265
|
|
|
* @throws Exception\PayboxException |
266
|
|
|
*/ |
267
|
|
View Code Duplication |
public function updateAmount($MONTANT, $NUMAPPEL, $NUMTRANS, $AUTORISATION = null, $DEVISE = null) |
|
|
|
|
268
|
|
|
{ |
269
|
|
|
$parameters = [ |
270
|
|
|
'MONTANT' => $MONTANT, |
271
|
|
|
'NUMAPPEL' => $NUMAPPEL, |
272
|
|
|
'NUMTRANS' => $NUMTRANS, |
273
|
|
|
]; |
274
|
|
|
|
275
|
|
|
if (null !== $AUTORISATION) { |
276
|
|
|
$parameters['AUTORISATION'] = $AUTORISATION; |
277
|
|
|
} |
278
|
|
|
if (null !== $DEVISE) { |
279
|
|
|
$parameters['DEVISE'] = $DEVISE; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
return $this->httpClient->call(13, $parameters); |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* @param int $MONTANT |
287
|
|
|
* @param int $NUMAPPEL |
288
|
|
|
* @param int $NUMTRANS |
289
|
|
|
* @param int|null $DEVISE |
290
|
|
|
* |
291
|
|
|
* @return PayboxResponse |
292
|
|
|
* |
293
|
|
|
* @throws Exception\PayboxException |
294
|
|
|
*/ |
295
|
|
|
public function refund($MONTANT, $NUMAPPEL, $NUMTRANS, $DEVISE = null) |
296
|
|
|
{ |
297
|
|
|
$parameters = [ |
298
|
|
|
'MONTANT' => $MONTANT, |
299
|
|
|
'NUMAPPEL' => $NUMAPPEL, |
300
|
|
|
'NUMTRANS' => $NUMTRANS, |
301
|
|
|
]; |
302
|
|
|
|
303
|
|
|
if (null !== $DEVISE) { |
304
|
|
|
$parameters['DEVISE'] = $DEVISE; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
return $this->httpClient->call(14, $parameters); |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* @param int $NUMTRANS |
312
|
|
|
* |
313
|
|
|
* @return PayboxResponse |
314
|
|
|
* |
315
|
|
|
* @throws Exception\PayboxException |
316
|
|
|
*/ |
317
|
|
|
public function inquiry($NUMTRANS) |
318
|
|
|
{ |
319
|
|
|
$parameters = [ |
320
|
|
|
'NUMTRANS' => $NUMTRANS, |
321
|
|
|
]; |
322
|
|
|
|
323
|
|
|
return $this->httpClient->call(17, $parameters); |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* @param string $DATEVAL |
328
|
|
|
* @param string $PORTEUR |
329
|
|
|
* @param string $REFABONNE |
330
|
|
|
* @param string $REFERENCE |
331
|
|
|
* @param string|null $AUTORISATION |
332
|
|
|
* @param string|null $DEVISE |
333
|
|
|
* |
334
|
|
|
* @return PayboxResponse |
335
|
|
|
* |
336
|
|
|
* @throws Exception\PayboxException |
337
|
|
|
*/ |
338
|
|
View Code Duplication |
public function authorizeSubscriber($DATEVAL, $PORTEUR, $REFABONNE, $REFERENCE, $AUTORISATION = null, $DEVISE = null) |
|
|
|
|
339
|
|
|
{ |
340
|
|
|
$parameters = [ |
341
|
|
|
'DATEVAL' => $DATEVAL, |
342
|
|
|
'PORTEUR' => $PORTEUR, |
343
|
|
|
'REFABONNE' => $REFABONNE, |
344
|
|
|
'REFERENCE' => $REFERENCE, |
345
|
|
|
]; |
346
|
|
|
|
347
|
|
|
if (null !== $AUTORISATION) { |
348
|
|
|
$parameters['AUTORISATION'] = $AUTORISATION; |
349
|
|
|
} |
350
|
|
|
if (null !== $DEVISE) { |
351
|
|
|
$parameters['DEVISE'] = $DEVISE; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
return $this->httpClient->call(51, $parameters); |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* @param int $MONTANT |
359
|
|
|
* @param int $NUMAPPEL |
360
|
|
|
* @param int $NUMTRANS |
361
|
|
|
* @param string $REFERENCE |
362
|
|
|
* @param int|null $DEVISE |
363
|
|
|
* |
364
|
|
|
* @return PayboxResponse |
365
|
|
|
* |
366
|
|
|
* @throws Exception\PayboxException |
367
|
|
|
*/ |
368
|
|
View Code Duplication |
public function debitSubscriber($MONTANT, $NUMAPPEL, $NUMTRANS, $REFERENCE, $DEVISE = null) |
|
|
|
|
369
|
|
|
{ |
370
|
|
|
$parameters = [ |
371
|
|
|
'MONTANT' => $MONTANT, |
372
|
|
|
'NUMAPPEL' => $NUMAPPEL, |
373
|
|
|
'NUMTRANS' => $NUMTRANS, |
374
|
|
|
'REFERENCE' => $REFERENCE, |
375
|
|
|
]; |
376
|
|
|
|
377
|
|
|
if (null !== $DEVISE) { |
378
|
|
|
$parameters['DEVISE'] = $DEVISE; |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
return $this->httpClient->call(52, $parameters); |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* @param string $DATEVAL |
386
|
|
|
* @param int $MONTANT |
387
|
|
|
* @param string $PORTEUR |
388
|
|
|
* @param string $REFABONNE |
389
|
|
|
* @param string $REFERENCE |
390
|
|
|
* @param int|null $DEVISE |
391
|
|
|
* |
392
|
|
|
* @return PayboxResponse |
393
|
|
|
* |
394
|
|
|
* @throws Exception\PayboxException |
395
|
|
|
*/ |
396
|
|
View Code Duplication |
public function authorizeAndCaptureSubscriber($DATEVAL, $MONTANT, $PORTEUR, $REFABONNE, $REFERENCE, $DEVISE = null) |
|
|
|
|
397
|
|
|
{ |
398
|
|
|
$parameters = [ |
399
|
|
|
'DATEVAL' => $DATEVAL, |
400
|
|
|
'MONTANT' => $MONTANT, |
401
|
|
|
'PORTEUR' => $PORTEUR, |
402
|
|
|
'REFABONNE' => $REFABONNE, |
403
|
|
|
'REFERENCE' => $REFERENCE, |
404
|
|
|
]; |
405
|
|
|
|
406
|
|
|
if (null !== $DEVISE) { |
407
|
|
|
$parameters['DEVISE'] = $DEVISE; |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
return $this->httpClient->call(53, $parameters); |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* @param string $DATEVAL |
415
|
|
|
* @param int $MONTANT |
416
|
|
|
* @param string $PORTEUR |
417
|
|
|
* @param string $REFABONNE |
418
|
|
|
* @param string $REFERENCE |
419
|
|
|
* @param int|null $DEVISE |
420
|
|
|
* |
421
|
|
|
* @return PayboxResponse |
422
|
|
|
* |
423
|
|
|
* @throws Exception\PayboxException |
424
|
|
|
*/ |
425
|
|
View Code Duplication |
public function creditSubscriber($DATEVAL, $MONTANT, $PORTEUR, $REFABONNE, $REFERENCE, $DEVISE = null) |
|
|
|
|
426
|
|
|
{ |
427
|
|
|
$parameters = [ |
428
|
|
|
'DATEVAL' => $DATEVAL, |
429
|
|
|
'MONTANT' => $MONTANT, |
430
|
|
|
'PORTEUR' => $PORTEUR, |
431
|
|
|
'REFABONNE' => $REFABONNE, |
432
|
|
|
'REFERENCE' => $REFERENCE, |
433
|
|
|
]; |
434
|
|
|
|
435
|
|
|
if (null !== $DEVISE) { |
436
|
|
|
$parameters['DEVISE'] = $DEVISE; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
return $this->httpClient->call(54, $parameters); |
440
|
|
|
} |
441
|
|
|
|
442
|
|
|
/** |
443
|
|
|
* @param string $DATEVAL |
444
|
|
|
* @param int $MONTANT |
445
|
|
|
* @param int $NUMAPPEL |
446
|
|
|
* @param int $NUMTRANS |
447
|
|
|
* @param string $PORTEUR |
448
|
|
|
* @param string $REFABONNE |
449
|
|
|
* @param string $REFERENCE |
450
|
|
|
* @param int|null $DEVISE |
451
|
|
|
* |
452
|
|
|
* @return PayboxResponse |
453
|
|
|
* |
454
|
|
|
* @throws Exception\PayboxException |
455
|
|
|
*/ |
456
|
|
|
public function cancelSubscriberTransaction($DATEVAL, $MONTANT, $NUMAPPEL, $NUMTRANS, $PORTEUR, $REFABONNE, $REFERENCE, $DEVISE = null) |
457
|
|
|
{ |
458
|
|
|
$parameters = [ |
459
|
|
|
'DATEVAL' => $DATEVAL, |
460
|
|
|
'MONTANT' => $MONTANT, |
461
|
|
|
'NUMAPPEL' => $NUMAPPEL, |
462
|
|
|
'NUMTRANS' => $NUMTRANS, |
463
|
|
|
'PORTEUR' => $PORTEUR, |
464
|
|
|
'REFABONNE' => $REFABONNE, |
465
|
|
|
'REFERENCE' => $REFERENCE, |
466
|
|
|
]; |
467
|
|
|
|
468
|
|
|
if (null !== $DEVISE) { |
469
|
|
|
$parameters['DEVISE'] = $DEVISE; |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
return $this->httpClient->call(55, $parameters); |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* @param string $DATEVAL |
477
|
|
|
* @param int $MONTANT |
478
|
|
|
* @param string $PORTEUR |
479
|
|
|
* @param string $REFABONNE |
480
|
|
|
* @param string $REFERENCE |
481
|
|
|
* @param string|null $AUTORISATION |
482
|
|
|
* @param int|null $DEVISE |
483
|
|
|
* |
484
|
|
|
* @return PayboxResponse |
485
|
|
|
* |
486
|
|
|
* @throws Exception\PayboxException |
487
|
|
|
*/ |
488
|
|
View Code Duplication |
public function registerSubscriber($DATEVAL, $MONTANT, $PORTEUR, $REFABONNE, $REFERENCE, $AUTORISATION = null, $DEVISE = null) |
|
|
|
|
489
|
|
|
{ |
490
|
|
|
$parameters = [ |
491
|
|
|
'DATEVAL' => $DATEVAL, |
492
|
|
|
'MONTANT' => $MONTANT, |
493
|
|
|
'PORTEUR' => $PORTEUR, |
494
|
|
|
'REFABONNE' => $REFABONNE, |
495
|
|
|
'REFERENCE' => $REFERENCE, |
496
|
|
|
]; |
497
|
|
|
|
498
|
|
|
if (null !== $AUTORISATION) { |
499
|
|
|
$parameters['AUTORISATION'] = $AUTORISATION; |
500
|
|
|
} |
501
|
|
|
if (null !== $DEVISE) { |
502
|
|
|
$parameters['DEVISE'] = $DEVISE; |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
return $this->httpClient->call(56, $parameters); |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
/** |
509
|
|
|
* @param string $DATEVAL |
510
|
|
|
* @param int $MONTANT |
511
|
|
|
* @param string $PORTEUR |
512
|
|
|
* @param string $REFABONNE |
513
|
|
|
* @param string|null $AUTORISATION |
514
|
|
|
* @param int|null $DEVISE |
515
|
|
|
* |
516
|
|
|
* @return PayboxResponse |
517
|
|
|
* |
518
|
|
|
* @throws Exception\PayboxException |
519
|
|
|
*/ |
520
|
|
View Code Duplication |
public function updateSubscriber($DATEVAL, $MONTANT, $PORTEUR, $REFABONNE, $AUTORISATION = null, $DEVISE = null) |
|
|
|
|
521
|
|
|
{ |
522
|
|
|
$parameters = [ |
523
|
|
|
'DATEVAL' => $DATEVAL, |
524
|
|
|
'MONTANT' => $MONTANT, |
525
|
|
|
'PORTEUR' => $PORTEUR, |
526
|
|
|
'REFABONNE' => $REFABONNE, |
527
|
|
|
]; |
528
|
|
|
|
529
|
|
|
if (null !== $AUTORISATION) { |
530
|
|
|
$parameters['AUTORISATION'] = $AUTORISATION; |
531
|
|
|
} |
532
|
|
|
if (null !== $DEVISE) { |
533
|
|
|
$parameters['DEVISE'] = $DEVISE; |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
return $this->httpClient->call(57, $parameters); |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
/** |
540
|
|
|
* @param string $REFABONNE |
541
|
|
|
* |
542
|
|
|
* @return PayboxResponse |
543
|
|
|
* |
544
|
|
|
* @throws Exception\PayboxException |
545
|
|
|
*/ |
546
|
|
|
public function deleteSubscriber($REFABONNE) |
547
|
|
|
{ |
548
|
|
|
$parameters = [ |
549
|
|
|
'REFABONNE' => $REFABONNE, |
550
|
|
|
]; |
551
|
|
|
|
552
|
|
|
return $this->httpClient->call(58, $parameters); |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
/** |
556
|
|
|
* @param string $DATEVAL |
557
|
|
|
* @param int $MONTANT |
558
|
|
|
* @param string $PORTEUR |
559
|
|
|
* @param string $REFABONNE |
560
|
|
|
* @param string $REFERENCE |
561
|
|
|
* @param int|null $DEVISE |
562
|
|
|
* |
563
|
|
|
* @return PayboxResponse |
564
|
|
|
* |
565
|
|
|
* @throws Exception\PayboxException |
566
|
|
|
*/ |
567
|
|
View Code Duplication |
public function transactSubscriber($DATEVAL, $MONTANT, $PORTEUR, $REFABONNE, $REFERENCE, $DEVISE = null) |
|
|
|
|
568
|
|
|
{ |
569
|
|
|
$parameters = [ |
570
|
|
|
'DATEVAL' => $DATEVAL, |
571
|
|
|
'MONTANT' => $MONTANT, |
572
|
|
|
'PORTEUR' => $PORTEUR, |
573
|
|
|
'REFABONNE' => $REFABONNE, |
574
|
|
|
'REFERENCE' => $REFERENCE, |
575
|
|
|
]; |
576
|
|
|
|
577
|
|
|
if (null !== $DEVISE) { |
578
|
|
|
$parameters['DEVISE'] = $DEVISE; |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
return $this->httpClient->call(61, $parameters); |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
private function configureOptions(OptionsResolver $resolver) |
585
|
|
|
{ |
586
|
|
|
$resolver->setDefaults([ |
587
|
|
|
'timeout' => 10, |
588
|
|
|
'production' => false, |
589
|
|
|
'paybox_default_currency' => static::CURRENCY_EURO, |
590
|
|
|
]); |
591
|
|
|
$resolver->setRequired([ |
592
|
|
|
'paybox_version', // Paybox Direct Plus protocol |
593
|
|
|
'paybox_site', |
594
|
|
|
'paybox_rank', |
595
|
|
|
'paybox_identifier', |
596
|
|
|
'paybox_key', |
597
|
|
|
]); |
598
|
|
|
|
599
|
|
|
$resolver->setAllowedTypes('timeout', 'int'); |
600
|
|
|
$resolver->setAllowedTypes('production', 'bool'); |
601
|
|
|
$resolver->setAllowedTypes('paybox_version', 'string'); |
602
|
|
|
$resolver->setAllowedTypes('paybox_default_currency', 'int'); |
603
|
|
|
$resolver->setAllowedTypes('paybox_site', 'string'); |
604
|
|
|
$resolver->setAllowedTypes('paybox_rank', 'string'); |
605
|
|
|
$resolver->setAllowedTypes('paybox_identifier', 'string'); |
606
|
|
|
$resolver->setAllowedTypes('paybox_key', 'string'); |
607
|
|
|
|
608
|
|
|
$resolver->setAllowedValues('paybox_version', static::VERSIONS); |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
/** |
612
|
|
|
* @param string $operation |
613
|
|
|
* @param OptionsResolver $resolver |
614
|
|
|
*/ |
615
|
|
|
private function configurePayboxCallParameters($operation, OptionsResolver $resolver) |
|
|
|
|
616
|
|
|
{ |
617
|
|
|
$parametersDefinition = $operation['parameters']; |
618
|
|
|
|
619
|
|
|
// Available for each Paybox Action |
620
|
|
|
$defaults = [ |
621
|
|
|
'ACTIVITE' => PayboxVariableActivity::WEB_REQUEST, |
622
|
|
|
'DATEQ' => null, |
623
|
|
|
]; |
624
|
|
|
$defined = [ |
625
|
|
|
'CVV', |
626
|
|
|
'DATENAISS', |
627
|
|
|
'DIFFERE', |
628
|
|
|
'ERRORCODETEST', |
629
|
|
|
'ID3D', |
630
|
|
|
'PAYS', |
631
|
|
|
'PRIV_CODETRAITEMENT', |
632
|
|
|
'SHA-1', |
633
|
|
|
'TYPECARTE', |
634
|
|
|
]; |
635
|
|
|
|
636
|
|
|
if (isset($parametersDefinition['defaults'])) { |
637
|
|
|
$defaults = array_merge($defaults, $parametersDefinition['defaults']); |
638
|
|
|
} |
639
|
|
|
$resolver->setDefaults($defaults); |
640
|
|
|
if (isset($parametersDefinition['required'])) { |
641
|
|
|
$resolver->setRequired($parametersDefinition['required']); |
642
|
|
|
} |
643
|
|
|
if (isset($parametersDefinition['defined'])) { |
644
|
|
|
$defined = array_merge($defined, $parametersDefinition['defined']); |
645
|
|
|
} |
646
|
|
|
$resolver->setDefined($defined); |
647
|
|
|
|
648
|
|
|
$resolver |
|
|
|
|
649
|
|
|
->setAllowedTypesIfDefined('ACQUEREUR', 'string') |
650
|
|
|
->setAllowedTypesIfDefined('ACTIVITE', 'int') |
651
|
|
|
->setAllowedTypesIfDefined('ARCHIVAGE', 'string') |
652
|
|
|
->setAllowedTypesIfDefined('AUTORISATION', 'string') |
653
|
|
|
->setAllowedTypesIfDefined('CVV', 'string') |
654
|
|
|
->setAllowedTypesIfDefined('DATENAISS', 'string') |
655
|
|
|
->setAllowedTypesIfDefined('DATEQ', ['string', 'null']) |
656
|
|
|
->setAllowedTypesIfDefined('DATEVAL', 'string') |
657
|
|
|
->setAllowedTypesIfDefined('DEVISE', ['int', 'null']) |
658
|
|
|
->setAllowedTypesIfDefined('DIFFERE', 'int') |
659
|
|
|
->setAllowedTypesIfDefined('ERRORCODETEST', 'int') |
660
|
|
|
->setAllowedTypesIfDefined('ID3D', 'string') |
661
|
|
|
->setAllowedTypesIfDefined('MONTANT', 'int') |
662
|
|
|
->setAllowedTypesIfDefined('NUMAPPEL', 'int') |
663
|
|
|
->setAllowedTypesIfDefined('NUMTRANS', 'int') |
664
|
|
|
->setAllowedTypesIfDefined('PORTEUR', 'string') |
665
|
|
|
->setAllowedTypesIfDefined('PRIV_CODETRAITEMENT', 'string') |
666
|
|
|
->setAllowedTypesIfDefined('REFABONNE', 'string') |
667
|
|
|
->setAllowedTypesIfDefined('REFERENCE', 'string') // TODO: Auto-generated if not provided? |
668
|
|
|
; |
669
|
|
|
|
670
|
|
|
$resolver |
|
|
|
|
671
|
|
|
->setAllowedValuesIfDefined('ACQUEREUR', ['PAYPAL', 'EMS', 'ATOSBE', 'BCMC', 'PSC', 'FINAREF', 'BUYSTER', '34ONEY']) |
672
|
|
|
->setAllowedValuesIfDefined('ACTIVITE', [ |
673
|
|
|
PayboxVariableActivity::NOT_SPECIFIED, |
674
|
|
|
PayboxVariableActivity::PHONE_REQUEST, |
675
|
|
|
PayboxVariableActivity::MAIL_REQUEST, |
676
|
|
|
PayboxVariableActivity::MINITEL_REQUEST, |
677
|
|
|
PayboxVariableActivity::WEB_REQUEST, |
678
|
|
|
PayboxVariableActivity::RECURRING_PAYMENT, |
679
|
|
|
]) |
680
|
|
|
->setAllowedValuesIfDefined('DEVISE', [null, static::CURRENCY_EURO, static::CURRENCY_US_DOLLAR, static::CURRENCY_CFA]) |
681
|
|
|
->setAllowedValuesIfDefined('PAYS', '') |
682
|
|
|
->setAllowedValuesIfDefined('SHA-1', '') |
683
|
|
|
->setAllowedValuesIfDefined('TYPECARTE', '') |
684
|
|
|
; |
685
|
|
|
} |
686
|
|
|
} |
687
|
|
|
|
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.