1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PagOnline\Mpi; |
4
|
|
|
|
5
|
|
|
use PagOnline\Exceptions\IgfsMissingParException; |
6
|
|
|
use PagOnline\IgfsUtils; |
7
|
|
|
|
8
|
|
|
class IgfsCgMpiEnroll extends BaseIgfsCgMpi |
9
|
|
|
{ |
10
|
|
|
public $shopUserRef; |
11
|
|
|
public $amount; |
12
|
|
|
public $currencyCode; |
13
|
|
|
|
14
|
|
|
public $pan; |
15
|
|
|
public $payInstrToken; |
16
|
|
|
public $billingID; |
17
|
|
|
public $expireMonth; |
18
|
|
|
public $expireYear; |
19
|
|
|
public $termURL; |
20
|
|
|
public $description; |
21
|
|
|
|
22
|
|
|
public $addInfo1; |
23
|
|
|
public $addInfo2; |
24
|
|
|
public $addInfo3; |
25
|
|
|
public $addInfo4; |
26
|
|
|
public $addInfo5; |
27
|
|
|
|
28
|
|
|
public $enrStatus; |
29
|
|
|
public $paReq; |
30
|
|
|
public $md; |
31
|
|
|
public $acsURL; |
32
|
|
|
public $acsPage; |
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $requestNamespace = Requests\IgfsCgMpiEnrollRequest::class; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Reset request fields. |
40
|
|
|
*/ |
41
|
1 |
|
public function resetFields() |
42
|
|
|
{ |
43
|
1 |
|
parent::resetFields(); |
44
|
1 |
|
$this->shopUserRef = null; |
45
|
1 |
|
$this->amount = null; |
46
|
1 |
|
$this->currencyCode = null; |
47
|
|
|
|
48
|
1 |
|
$this->pan = null; |
49
|
1 |
|
$this->payInstrToken = null; |
50
|
1 |
|
$this->billingID = null; |
51
|
1 |
|
$this->expireMonth = null; |
52
|
1 |
|
$this->expireYear = null; |
53
|
1 |
|
$this->termURL = null; |
54
|
1 |
|
$this->description = null; |
55
|
|
|
|
56
|
1 |
|
$this->addInfo1 = null; |
57
|
1 |
|
$this->addInfo2 = null; |
58
|
1 |
|
$this->addInfo3 = null; |
59
|
1 |
|
$this->addInfo4 = null; |
60
|
1 |
|
$this->addInfo5 = null; |
61
|
|
|
|
62
|
1 |
|
$this->enrStatus = null; |
63
|
1 |
|
$this->paReq = null; |
64
|
1 |
|
$this->md = null; |
65
|
1 |
|
$this->acsURL = null; |
66
|
1 |
|
$this->acsPage = null; |
67
|
|
|
} |
68
|
|
|
|
69
|
1 |
|
protected function getAdditionalRequestSignatureFields(): array |
70
|
|
|
{ |
71
|
1 |
|
return [ |
72
|
1 |
|
$this->shopUserRef, // SHOPUSERREF |
73
|
1 |
|
$this->amount, // AMOUNT |
74
|
1 |
|
$this->currencyCode, // CURRENCYCODE |
75
|
1 |
|
$this->pan, // PAN |
76
|
1 |
|
$this->payInstrToken, // PAYINSTRTOKEN |
77
|
1 |
|
$this->expireMonth, // EXPIREMONTH |
78
|
1 |
|
$this->expireYear, // EXPIREYEAR |
79
|
1 |
|
$this->termURL, // TERMURL |
80
|
1 |
|
$this->description, // DESCRIPTION |
81
|
1 |
|
$this->addInfo1, // UDF1 |
82
|
1 |
|
$this->addInfo2, // UDF2 |
83
|
1 |
|
$this->addInfo3, // UDF3 |
84
|
1 |
|
$this->addInfo4, // UDF4 |
85
|
1 |
|
$this->addInfo5, // UDF5 |
86
|
1 |
|
]; |
87
|
|
|
} |
88
|
|
|
|
89
|
8 |
|
protected function checkFields() |
90
|
|
|
{ |
91
|
8 |
|
parent::checkFields(); |
92
|
5 |
|
if ($this->amount == null) { |
93
|
2 |
|
throw new IgfsMissingParException('Missing amount'); |
94
|
|
|
} |
95
|
3 |
|
if ($this->currencyCode == null) { |
96
|
1 |
|
throw new IgfsMissingParException('Missing currencyCode'); |
97
|
|
|
} |
98
|
2 |
|
if ($this->pan === null && $this->payInstrToken === null) { |
99
|
1 |
|
throw new IgfsMissingParException('Missing pan'); |
100
|
|
|
} |
101
|
1 |
|
if ($this->pan !== null && $this->pan === '') { |
102
|
|
|
throw new IgfsMissingParException('Missing pan'); |
103
|
|
|
} |
104
|
|
|
|
105
|
1 |
|
if ($this->payInstrToken !== null && (string) $this->payInstrToken === '') { |
106
|
|
|
// Se è stato impostato il payInstrToken verifico... |
107
|
|
|
throw new IgfsMissingParException('Missing payInstrToken'); |
108
|
|
|
} |
109
|
|
|
|
110
|
1 |
|
if ($this->termURL == null) { |
111
|
|
|
throw new IgfsMissingParException('Missing termURL'); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* {@inheritdoc} |
117
|
|
|
*/ |
118
|
1 |
|
protected function buildRequest() |
119
|
|
|
{ |
120
|
1 |
|
$request = parent::buildRequest(); |
121
|
1 |
|
$this->replaceRequestParameter($request, 'shopUserRef', $this->shopUserRef); |
122
|
1 |
|
$this->replaceRequestParameter($request, 'amount', $this->amount); |
123
|
1 |
|
$this->replaceRequestParameter($request, 'currencyCode', $this->currencyCode); |
124
|
1 |
|
$this->replaceRequestParameter($request, 'pan', $this->pan); |
125
|
1 |
|
$this->replaceRequestParameter($request, 'payInstrToken', $this->payInstrToken); |
126
|
1 |
|
$this->replaceRequestParameter($request, 'billingID', $this->billingID); |
127
|
1 |
|
$this->replaceRequestParameter($request, 'expireMonth', $this->expireMonth); |
128
|
1 |
|
$this->replaceRequestParameter($request, 'expireYear', $this->expireYear); |
129
|
1 |
|
$this->replaceRequestParameter($request, 'termURL', $this->termURL); |
130
|
1 |
|
$this->replaceRequestParameter($request, 'description', $this->description); |
131
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo1', $this->addInfo1); |
132
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo2', $this->addInfo2); |
133
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo3', $this->addInfo3); |
134
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo4', $this->addInfo4); |
135
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo5', $this->addInfo5); |
136
|
|
|
|
137
|
1 |
|
return $request; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
protected function parseResponseMap($response) |
141
|
|
|
{ |
142
|
|
|
parent::parseResponseMap($response); |
143
|
|
|
$this->enrStatus = IgfsUtils::getValue($response, 'enrStatus'); |
144
|
|
|
// Opzionale |
145
|
|
|
$this->paReq = IgfsUtils::getValue($response, 'paReq'); |
146
|
|
|
// Opzionale |
147
|
|
|
$this->md = IgfsUtils::getValue($response, 'md'); |
148
|
|
|
// Opzionale |
149
|
|
|
$this->acsURL = IgfsUtils::getValue($response, 'acsURL'); |
150
|
|
|
// Opzionale |
151
|
|
|
$this->acsPage = IgfsUtils::getValue($response, 'acsPage'); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param array $response |
156
|
|
|
* |
157
|
|
|
* @throws \PagOnline\Exceptions\IgfsException |
158
|
|
|
* |
159
|
|
|
* @return string |
160
|
|
|
*/ |
161
|
|
|
protected function getResponseSignature($response) |
162
|
|
|
{ |
163
|
|
|
$fields = [ |
164
|
|
|
IgfsUtils::getValue($response, 'tid'), // TID |
165
|
|
|
IgfsUtils::getValue($response, 'shopID'), // SHOPID |
166
|
|
|
IgfsUtils::getValue($response, 'rc'), // RC |
167
|
|
|
IgfsUtils::getValue($response, 'errorDesc'), // ERRORDESC |
168
|
|
|
IgfsUtils::getValue($response, 'enrStatus'), // ENRSTATUS |
169
|
|
|
IgfsUtils::getValue($response, 'paReq'), // PAREQ |
170
|
|
|
IgfsUtils::getValue($response, 'md'), // MD |
171
|
|
|
IgfsUtils::getValue($response, 'acsURL'), // ACSURL |
172
|
|
|
IgfsUtils::getValue($response, 'acsPage'), ]; // ACSPAGE |
173
|
|
|
// signature dove il buffer e' cosi composto TID|SHOPID|RC|ERRORCODE|ENRSTATUS|PAREQ|MD|ACSURL|ACSPAGE |
174
|
|
|
return $this->getSignature($fields); |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|