1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nexy\PayboxDirect\Request; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @author Sullivan Senechal <[email protected]> |
7
|
|
|
*/ |
8
|
|
|
final class AuthorizeRequest extends AbstractRequest |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var string |
12
|
|
|
*/ |
13
|
|
|
private $reference; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var int |
17
|
|
|
*/ |
18
|
|
|
private $amount; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var int |
22
|
|
|
*/ |
23
|
|
|
private $currency = null; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
private $cardSerial; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $cardValidity; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
private $cardVerificationValue = null; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $reference |
42
|
|
|
* @param int $amount |
43
|
|
|
* @param string $cardSerial |
44
|
|
|
* @param string $cardValidity |
45
|
|
|
*/ |
46
|
|
|
public function __construct($reference, $amount, $cardSerial, $cardValidity) |
47
|
|
|
{ |
48
|
|
|
$this->reference = $reference; |
49
|
|
|
$this->amount = $amount; |
50
|
|
|
$this->cardSerial = $cardSerial; |
51
|
|
|
$this->cardValidity = $cardValidity; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param int $currency |
56
|
|
|
*/ |
57
|
|
|
public function setCurrency($currency = null) |
58
|
|
|
{ |
59
|
|
|
$this->currency = $currency; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string|null $cardVerificationValue |
64
|
|
|
*/ |
65
|
|
|
public function setCardVerificationValue($cardVerificationValue = null) |
66
|
|
|
{ |
67
|
|
|
$this->cardVerificationValue = $cardVerificationValue; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
public function getRequestId() |
74
|
|
|
{ |
75
|
|
|
return RequestInterface::AUTHORIZE; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
*/ |
81
|
|
|
public function getParameters() |
82
|
|
|
{ |
83
|
|
|
$parameters = [ |
84
|
|
|
'REFERENCE' => $this->reference, |
85
|
|
|
'MONTANT' => $this->amount, |
86
|
|
|
'DEVISE' => $this->currency, |
87
|
|
|
'PORTEUR' => $this->cardSerial, |
88
|
|
|
'DATEVAL' => $this->cardValidity, |
89
|
|
|
]; |
90
|
|
|
|
91
|
|
|
if (null !== $this->cardVerificationValue) { |
92
|
|
|
$parameters['CVV'] = $this->cardVerificationValue; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
return array_merge(parent::getParameters(), $parameters); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|