|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PagOnline\Tokenizer; |
|
4
|
|
|
|
|
5
|
|
|
use PagOnline\Exceptions\IgfsMissingParException; |
|
6
|
|
|
use PagOnline\IgfsUtils; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class IgfsCgTokenizerEnroll. |
|
10
|
|
|
*/ |
|
11
|
|
|
class IgfsCgTokenizerEnroll extends BaseIgfsCgTokenizer |
|
12
|
|
|
{ |
|
13
|
|
|
public $shopUserRef; |
|
14
|
|
|
public $pan; |
|
15
|
|
|
public $expireMonth; |
|
16
|
|
|
public $expireYear; |
|
17
|
|
|
public $accountName; |
|
18
|
|
|
public $payInstrToken; |
|
19
|
|
|
public $billingID; |
|
20
|
|
|
public $regenPayInstrToken; |
|
21
|
|
|
public $keepOnRegenPayInstrToken; |
|
22
|
|
|
public $payInstrTokenExpire; |
|
23
|
|
|
public $payInstrTokenUsageLimit; |
|
24
|
|
|
public $payInstrTokenAlg; |
|
25
|
|
|
public $addInfo1; |
|
26
|
|
|
public $addInfo2; |
|
27
|
|
|
public $addInfo3; |
|
28
|
|
|
public $addInfo4; |
|
29
|
|
|
public $addInfo5; |
|
30
|
|
|
/** |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $requestNamespace = Requests\IgfsCgTokenizerEnrollRequest::class; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
1 |
|
public function resetFields() |
|
39
|
|
|
{ |
|
40
|
1 |
|
parent::resetFields(); |
|
41
|
1 |
|
$this->shopUserRef = null; |
|
42
|
1 |
|
$this->pan = null; |
|
43
|
1 |
|
$this->expireMonth = null; |
|
44
|
1 |
|
$this->expireYear = null; |
|
45
|
1 |
|
$this->accountName = null; |
|
46
|
1 |
|
$this->payInstrToken = null; |
|
47
|
1 |
|
$this->billingID = null; |
|
48
|
1 |
|
$this->regenPayInstrToken = null; |
|
49
|
1 |
|
$this->keepOnRegenPayInstrToken = null; |
|
50
|
1 |
|
$this->payInstrTokenExpire = null; |
|
51
|
1 |
|
$this->payInstrTokenUsageLimit = null; |
|
52
|
1 |
|
$this->payInstrTokenAlg = null; |
|
53
|
1 |
|
$this->addInfo1 = null; |
|
54
|
1 |
|
$this->addInfo2 = null; |
|
55
|
1 |
|
$this->addInfo3 = null; |
|
56
|
1 |
|
$this->addInfo4 = null; |
|
57
|
1 |
|
$this->addInfo5 = null; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* {@inheritdoc} |
|
62
|
|
|
*/ |
|
63
|
1 |
|
protected function getAdditionalRequestSignatureFields(): array |
|
64
|
|
|
{ |
|
65
|
1 |
|
return [ |
|
66
|
1 |
|
$this->shopUserRef, // SHOPUSERREF |
|
67
|
1 |
|
$this->pan, // PAN |
|
68
|
1 |
|
$this->expireMonth, // EXPIREMONTH |
|
69
|
1 |
|
$this->expireYear, // EXPIREYEAR |
|
70
|
1 |
|
$this->payInstrToken, // PAYINSTRTOKEN |
|
71
|
1 |
|
$this->addInfo1, // UDF1 |
|
72
|
1 |
|
$this->addInfo2, // UDF2 |
|
73
|
1 |
|
$this->addInfo3, // UDF3 |
|
74
|
1 |
|
$this->addInfo4, // UDF4 |
|
75
|
1 |
|
$this->addInfo5, |
|
76
|
1 |
|
]; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @throws IgfsMissingParException |
|
81
|
|
|
*/ |
|
82
|
9 |
|
protected function checkFields() |
|
83
|
|
|
{ |
|
84
|
9 |
|
parent::checkFields(); |
|
85
|
5 |
|
if (empty($this->pan)) { |
|
86
|
1 |
|
throw new IgfsMissingParException('Missing pan'); |
|
87
|
|
|
} |
|
88
|
4 |
|
if (empty($this->expireMonth)) { |
|
89
|
1 |
|
throw new IgfsMissingParException('Missing expireMonth'); |
|
90
|
|
|
} |
|
91
|
3 |
|
if (empty($this->expireYear)) { |
|
92
|
1 |
|
throw new IgfsMissingParException('Missing expireYear'); |
|
93
|
|
|
} |
|
94
|
2 |
|
if (empty($this->payInstrToken)) { |
|
95
|
1 |
|
throw new IgfsMissingParException('Missing payInstrToken'); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
1 |
|
protected function buildRequest() |
|
100
|
|
|
{ |
|
101
|
1 |
|
$request = parent::buildRequest(); |
|
102
|
1 |
|
$this->replaceRequestParameter($request, 'shopUserRef', $this->shopUserRef); |
|
103
|
1 |
|
$this->replaceRequestParameter($request, 'pan', $this->pan); |
|
104
|
1 |
|
$this->replaceRequestParameter($request, 'expireMonth', $this->expireMonth); |
|
105
|
1 |
|
$this->replaceRequestParameter($request, 'expireYear', $this->expireYear); |
|
106
|
1 |
|
$this->replaceRequestParameter($request, 'accountName', $this->accountName); |
|
107
|
1 |
|
$this->replaceRequestParameter($request, 'payInstrToken', $this->payInstrToken); |
|
108
|
1 |
|
$this->replaceRequestParameter($request, 'billingID', $this->billingID); |
|
109
|
1 |
|
$this->replaceRequestParameter($request, 'regenPayInstrToken', $this->regenPayInstrToken); |
|
110
|
1 |
|
$this->replaceRequestParameter($request, 'keepOnRegenPayInstrToken', $this->keepOnRegenPayInstrToken); |
|
111
|
1 |
|
$this->replaceRequestParameter($request, 'payInstrTokenExpire', $this->payInstrTokenExpire); |
|
112
|
1 |
|
$this->replaceRequestParameter($request, 'payInstrTokenUsageLimit', $this->payInstrTokenUsageLimit); |
|
113
|
1 |
|
$this->replaceRequestParameter($request, 'payInstrTokenAlg', $this->payInstrTokenAlg); |
|
114
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo1', $this->addInfo1); |
|
115
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo2', $this->addInfo2); |
|
116
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo3', $this->addInfo3); |
|
117
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo4', $this->addInfo4); |
|
118
|
1 |
|
$this->replaceRequestParameter($request, 'addInfo5', $this->addInfo5); |
|
119
|
|
|
|
|
120
|
1 |
|
return $request; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
protected function parseResponseMap($response) |
|
124
|
|
|
{ |
|
125
|
|
|
parent::parseResponseMap($response); |
|
126
|
|
|
// Opzionale |
|
127
|
|
|
$this->payInstrToken = IgfsUtils::getValue($response, 'payInstrToken'); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param array $response |
|
132
|
|
|
* |
|
133
|
|
|
* @throws \PagOnline\Exceptions\IgfsException |
|
134
|
|
|
* |
|
135
|
|
|
* @return string |
|
136
|
|
|
*/ |
|
137
|
|
|
protected function getResponseSignature($response) |
|
138
|
|
|
{ |
|
139
|
|
|
$fields = [ |
|
140
|
|
|
IgfsUtils::getValue($response, 'tid'), // TID |
|
141
|
|
|
IgfsUtils::getValue($response, 'shopID'), // SHOPID |
|
142
|
|
|
IgfsUtils::getValue($response, 'rc'), // RC |
|
143
|
|
|
IgfsUtils::getValue($response, 'errorDesc'), // ERRORDESC |
|
144
|
|
|
IgfsUtils::getValue($response, 'payInstrToken'), ]; // PAYINSTRTOKEN |
|
145
|
|
|
// signature dove il buffer e' cosi composto TID|SHOPID|RC|ERRORDESC |
|
146
|
|
|
return $this->getSignature($fields); |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
|