|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PagOnline\Init; |
|
4
|
|
|
|
|
5
|
|
|
use PagOnline\Exceptions\IgfsMissingParException; |
|
6
|
|
|
use PagOnline\IgfsUtils; |
|
7
|
|
|
use PagOnline\XmlEntities\Entry; |
|
8
|
|
|
use PagOnline\XmlEntities\Level3Info; |
|
9
|
|
|
|
|
10
|
|
|
class IgfsCgVerify extends BaseIgfsCgInit |
|
11
|
|
|
{ |
|
12
|
|
|
public $paymentID; |
|
13
|
|
|
public $refTranID; |
|
14
|
|
|
|
|
15
|
|
|
public $tranID; |
|
16
|
|
|
public $authCode; |
|
17
|
|
|
public $enrStatus; |
|
18
|
|
|
public $authStatus; |
|
19
|
|
|
public $brand; |
|
20
|
|
|
public $acquirerID; |
|
21
|
|
|
public $maskedPan; |
|
22
|
|
|
public $addInfo1; |
|
23
|
|
|
public $addInfo2; |
|
24
|
|
|
public $addInfo3; |
|
25
|
|
|
public $addInfo4; |
|
26
|
|
|
public $addInfo5; |
|
27
|
|
|
public $payInstrToken; |
|
28
|
|
|
public $expireMonth; |
|
29
|
|
|
public $expireYear; |
|
30
|
|
|
public $level3Info; |
|
31
|
|
|
public $additionalFee; |
|
32
|
|
|
public $status; |
|
33
|
|
|
public $accountName; |
|
34
|
|
|
public $nssResult; |
|
35
|
|
|
public $topUpID; |
|
36
|
|
|
public $receiptPdf; |
|
37
|
|
|
public $payAddData; |
|
38
|
|
|
public $payUserRef; |
|
39
|
|
|
public $shopUserMobilePhone; |
|
40
|
|
|
/** |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $requestNamespace = Requests\IgfsCgVerifyRequest::class; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritdoc} |
|
47
|
|
|
*/ |
|
48
|
2 |
|
public function resetFields() |
|
49
|
|
|
{ |
|
50
|
2 |
|
parent::resetFields(); |
|
51
|
2 |
|
$this->paymentID = null; |
|
52
|
2 |
|
$this->refTranID = null; |
|
53
|
|
|
|
|
54
|
2 |
|
$this->tranID = null; |
|
55
|
2 |
|
$this->authCode = null; |
|
56
|
2 |
|
$this->enrStatus = null; |
|
57
|
2 |
|
$this->authStatus = null; |
|
58
|
2 |
|
$this->brand = null; |
|
59
|
2 |
|
$this->acquirerID = null; |
|
60
|
2 |
|
$this->maskedPan = null; |
|
61
|
2 |
|
$this->addInfo1 = null; |
|
62
|
2 |
|
$this->addInfo2 = null; |
|
63
|
2 |
|
$this->addInfo3 = null; |
|
64
|
2 |
|
$this->addInfo4 = null; |
|
65
|
2 |
|
$this->addInfo5 = null; |
|
66
|
2 |
|
$this->payInstrToken = null; |
|
67
|
2 |
|
$this->expireMonth = null; |
|
68
|
2 |
|
$this->expireYear = null; |
|
69
|
2 |
|
$this->level3Info = null; |
|
70
|
2 |
|
$this->additionalFee = null; |
|
71
|
2 |
|
$this->status = null; |
|
72
|
2 |
|
$this->accountName = null; |
|
73
|
2 |
|
$this->nssResult = null; |
|
74
|
2 |
|
$this->topUpID = null; |
|
75
|
2 |
|
$this->receiptPdf = null; |
|
76
|
2 |
|
$this->payAddData = null; |
|
77
|
2 |
|
$this->payUserRef = null; |
|
78
|
2 |
|
$this->shopUserMobilePhone = null; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritdoc} |
|
83
|
|
|
*/ |
|
84
|
2 |
|
protected function getAdditionalRequestSignatureFields(): array |
|
85
|
|
|
{ |
|
86
|
2 |
|
return [ |
|
87
|
2 |
|
$this->paymentID, |
|
88
|
2 |
|
$this->refTranID, |
|
89
|
2 |
|
]; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
7 |
|
protected function checkFields() |
|
93
|
|
|
{ |
|
94
|
7 |
|
parent::checkFields(); |
|
95
|
3 |
|
if (empty($this->paymentID)) { |
|
96
|
1 |
|
throw new IgfsMissingParException('Missing paymentID'); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* {@inheritdoc} |
|
102
|
|
|
*/ |
|
103
|
2 |
|
protected function buildRequest() |
|
104
|
|
|
{ |
|
105
|
2 |
|
$request = parent::buildRequest(); |
|
106
|
2 |
|
$this->replaceRequestParameter($request, 'paymentID', $this->paymentID); |
|
107
|
2 |
|
$this->replaceRequestParameter($request, 'refTranID', $this->refTranID); |
|
108
|
|
|
|
|
109
|
2 |
|
return $request; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
1 |
|
protected function parseResponseMap($response) |
|
113
|
|
|
{ |
|
114
|
1 |
|
parent::parseResponseMap($response); |
|
115
|
|
|
// Opzionale |
|
116
|
1 |
|
$this->tranID = IgfsUtils::getValue($response, 'tranID'); |
|
117
|
|
|
// Opzionale |
|
118
|
1 |
|
$this->authCode = IgfsUtils::getValue($response, 'authCode'); |
|
119
|
|
|
// Opzionale |
|
120
|
1 |
|
$this->enrStatus = IgfsUtils::getValue($response, 'enrStatus'); |
|
121
|
|
|
// Opzionale |
|
122
|
1 |
|
$this->authStatus = IgfsUtils::getValue($response, 'authStatus'); |
|
123
|
|
|
// Opzionale |
|
124
|
1 |
|
$this->brand = IgfsUtils::getValue($response, 'brand'); |
|
125
|
|
|
// Opzionale |
|
126
|
1 |
|
$this->acquirerID = IgfsUtils::getValue($response, 'acquirerID'); |
|
127
|
|
|
// Opzionale |
|
128
|
1 |
|
$this->maskedPan = IgfsUtils::getValue($response, 'maskedPan'); |
|
129
|
|
|
// Opzionale |
|
130
|
1 |
|
$this->addInfo1 = IgfsUtils::getValue($response, 'addInfo1'); |
|
131
|
|
|
// Opzionale |
|
132
|
1 |
|
$this->addInfo2 = IgfsUtils::getValue($response, 'addInfo2'); |
|
133
|
|
|
// Opzionale |
|
134
|
1 |
|
$this->addInfo3 = IgfsUtils::getValue($response, 'addInfo3'); |
|
135
|
|
|
// Opzionale |
|
136
|
1 |
|
$this->addInfo4 = IgfsUtils::getValue($response, 'addInfo4'); |
|
137
|
|
|
// Opzionale |
|
138
|
1 |
|
$this->addInfo5 = IgfsUtils::getValue($response, 'addInfo5'); |
|
139
|
|
|
// Opzionale |
|
140
|
1 |
|
$this->payInstrToken = IgfsUtils::getValue($response, 'payInstrToken'); |
|
141
|
|
|
// Opzionale |
|
142
|
1 |
|
$this->expireMonth = IgfsUtils::getValue($response, 'expireMonth'); |
|
143
|
|
|
// Opzionale |
|
144
|
1 |
|
$this->expireYear = IgfsUtils::getValue($response, 'expireYear'); |
|
145
|
|
|
// Opzionale |
|
146
|
1 |
|
$this->level3Info = Level3Info::fromXml(IgfsUtils::getValue($response, 'level3Info')); |
|
147
|
|
|
// Opzionale |
|
148
|
1 |
|
$this->additionalFee = IgfsUtils::getValue($response, 'additionalFee'); |
|
149
|
|
|
// Opzionale |
|
150
|
1 |
|
$this->status = IgfsUtils::getValue($response, 'status'); |
|
151
|
|
|
// Opzionale |
|
152
|
1 |
|
$this->accountName = IgfsUtils::getValue($response, 'accountName'); |
|
153
|
|
|
// Opzionale |
|
154
|
1 |
|
$this->nssResult = IgfsUtils::getValue($response, 'nssResult'); |
|
155
|
|
|
// Opzionale |
|
156
|
1 |
|
$this->topUpID = IgfsUtils::getValue($response, 'topUpID'); |
|
157
|
|
|
// Opzionale |
|
158
|
1 |
|
$this->payUserRef = IgfsUtils::getValue($response, 'payUserRef'); |
|
159
|
|
|
// Opzionale |
|
160
|
1 |
|
$this->shopUserMobilePhone = IgfsUtils::getValue($response, 'shopUserMobilePhone'); |
|
161
|
|
|
// Opzionale |
|
162
|
1 |
|
$this->receiptPdf = (string) \base64_decode(IgfsUtils::getValue($response, 'receiptPdf'), true); |
|
|
|
|
|
|
163
|
1 |
|
if (empty($this->receiptPdf)) { |
|
164
|
1 |
|
$this->receiptPdf = null; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
1 |
|
$responseNode = $this->responseXmlToObject($response[static::$soapResponseTag]); |
|
168
|
1 |
|
if ($responseNode === null) { |
|
169
|
|
|
return; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
1 |
|
$xml_response = IgfsUtils::parseResponseFields($responseNode); |
|
173
|
1 |
|
if (isset($xml_response['payAddData'])) { |
|
174
|
1 |
|
$this->payAddData = []; |
|
175
|
1 |
|
foreach ($responseNode->xpath('//payAddData') as $item) { |
|
176
|
1 |
|
\array_push($this->payAddData, Entry::fromXml($item->asXML())); |
|
|
|
|
|
|
177
|
|
|
} |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* @param array $response |
|
183
|
|
|
* |
|
184
|
|
|
* @throws \PagOnline\Exceptions\IgfsException |
|
185
|
|
|
* |
|
186
|
|
|
* @return string |
|
187
|
|
|
*/ |
|
188
|
1 |
|
protected function getResponseSignature($response) |
|
189
|
|
|
{ |
|
190
|
1 |
|
$fields = [ |
|
191
|
1 |
|
IgfsUtils::getValue($response, 'tid'), // TID |
|
192
|
1 |
|
IgfsUtils::getValue($response, 'shopID'), // SHOPID |
|
193
|
1 |
|
IgfsUtils::getValue($response, 'rc'), // RC |
|
194
|
1 |
|
IgfsUtils::getValue($response, 'errorDesc'), // ERRORDESC |
|
195
|
1 |
|
IgfsUtils::getValue($response, 'paymentID'), // PAYMENTID |
|
196
|
1 |
|
IgfsUtils::getValue($response, 'tranID'), // ORDERID |
|
197
|
1 |
|
IgfsUtils::getValue($response, 'authCode'), // AUTHCODE |
|
198
|
1 |
|
IgfsUtils::getValue($response, 'enrStatus'), // ENRSTATUS |
|
199
|
1 |
|
IgfsUtils::getValue($response, 'authStatus'), // AUTHSTATUS |
|
200
|
1 |
|
]; |
|
201
|
|
|
// signature dove il buffer e' cosi composto TID|SHOPID|RC|ERRORDESC|PAYMENTID|REDIRECTURL |
|
202
|
1 |
|
return $this->getSignature($fields); |
|
203
|
|
|
} |
|
204
|
|
|
} |
|
205
|
|
|
|