1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Nexylan packages. |
5
|
|
|
* |
6
|
|
|
* (c) Nexylan SAS <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Nexy\PayboxDirect\Response; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @author Sullivan Senechal <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
abstract class AbstractResponse implements ResponseInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var int |
21
|
|
|
*/ |
22
|
|
|
private $code; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $comment; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private $site; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
private $rank; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var int |
41
|
|
|
*/ |
42
|
|
|
private $callNumber; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var int |
46
|
|
|
*/ |
47
|
|
|
private $questionNumber; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var int |
51
|
|
|
*/ |
52
|
|
|
private $transactionNumber; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var string|null|false |
56
|
|
|
*/ |
57
|
|
|
private $authorization = null; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var string|null|false |
61
|
|
|
*/ |
62
|
|
|
private $country = null; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var string|null|false |
66
|
|
|
*/ |
67
|
|
|
private $sha1 = null; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var string|null|false |
71
|
|
|
*/ |
72
|
|
|
private $cardType = null; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var mixed[] |
76
|
|
|
*/ |
77
|
|
|
protected $filteredParameters; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param string[] $parameters |
81
|
|
|
*/ |
82
|
|
|
public function __construct(array $parameters) |
83
|
|
|
{ |
84
|
|
|
// Cleanup array to set false for empty/invalid values. |
85
|
|
|
$this->filteredParameters = array_map(function ($value) { |
86
|
|
|
if (in_array($value, ['', '???'], true)) { |
87
|
|
|
return false; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
return $value; |
91
|
|
|
}, $parameters); |
92
|
|
|
|
93
|
|
|
$this->code = intval($this->filteredParameters['CODEREPONSE']); |
94
|
|
|
$this->comment = $this->filteredParameters['COMMENTAIRE']; |
95
|
|
|
$this->site = $this->filteredParameters['SITE']; |
96
|
|
|
$this->rank = $this->filteredParameters['RANG']; |
97
|
|
|
$this->callNumber = intval($this->filteredParameters['NUMAPPEL']); |
98
|
|
|
$this->questionNumber = intval($this->filteredParameters['NUMQUESTION']); |
99
|
|
|
$this->transactionNumber = intval($this->filteredParameters['NUMTRANS']); |
100
|
|
|
|
101
|
|
|
if (array_key_exists('AUTORISATION', $this->filteredParameters)) { |
102
|
|
|
$this->authorization = $this->filteredParameters['AUTORISATION']; |
103
|
|
|
} |
104
|
|
|
if (array_key_exists('PAYS', $this->filteredParameters)) { |
105
|
|
|
$this->country = $this->filteredParameters['PAYS']; |
106
|
|
|
} |
107
|
|
|
if (array_key_exists('SHA-1', $this->filteredParameters)) { |
108
|
|
|
$this->sha1 = $this->filteredParameters['SHA-1']; |
109
|
|
|
} |
110
|
|
|
if (array_key_exists('TYPECARTE', $this->filteredParameters)) { |
111
|
|
|
$this->cardType = $this->filteredParameters['TYPECARTE']; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* {@inheritdoc} |
117
|
|
|
*/ |
118
|
|
|
final public function isSuccessful() |
119
|
|
|
{ |
120
|
|
|
return 0 === $this->code; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* {@inheritdoc} |
125
|
|
|
*/ |
126
|
|
|
final public function getCode() |
127
|
|
|
{ |
128
|
|
|
return $this->code; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* {@inheritdoc} |
133
|
|
|
*/ |
134
|
|
|
final public function getComment() |
135
|
|
|
{ |
136
|
|
|
return $this->comment; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* {@inheritdoc} |
141
|
|
|
*/ |
142
|
|
|
final public function getSite() |
143
|
|
|
{ |
144
|
|
|
return $this->site; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* {@inheritdoc} |
149
|
|
|
*/ |
150
|
|
|
final public function getRank() |
151
|
|
|
{ |
152
|
|
|
return $this->rank; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* {@inheritdoc} |
157
|
|
|
*/ |
158
|
|
|
final public function getCallNumber() |
159
|
|
|
{ |
160
|
|
|
return $this->callNumber; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* {@inheritdoc} |
165
|
|
|
*/ |
166
|
|
|
final public function getQuestionNumber() |
167
|
|
|
{ |
168
|
|
|
return $this->questionNumber; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* {@inheritdoc} |
173
|
|
|
*/ |
174
|
|
|
final public function getTransactionNumber() |
175
|
|
|
{ |
176
|
|
|
return $this->transactionNumber; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* {@inheritdoc} |
181
|
|
|
*/ |
182
|
|
|
public function getAuthorization() |
183
|
|
|
{ |
184
|
|
|
return $this->authorization; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* {@inheritdoc} |
189
|
|
|
*/ |
190
|
|
|
public function getCountry() |
191
|
|
|
{ |
192
|
|
|
return $this->country; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* {@inheritdoc} |
197
|
|
|
*/ |
198
|
|
|
final public function getSha1() |
199
|
|
|
{ |
200
|
|
|
return $this->sha1; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* {@inheritdoc} |
205
|
|
|
*/ |
206
|
|
|
public function getCardType() |
207
|
|
|
{ |
208
|
|
|
return $this->cardType; |
209
|
|
|
} |
210
|
|
|
} |
211
|
|
|
|