|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PagOnline\Tokenizer; |
|
4
|
|
|
|
|
5
|
|
|
use PagOnline\Exceptions\IgfsMissingParException; |
|
6
|
|
|
use PagOnline\IgfsUtils; |
|
7
|
|
|
|
|
8
|
|
|
class IgfsCgTokenizerCheck extends BaseIgfsCgTokenizer |
|
9
|
|
|
{ |
|
10
|
|
|
public $payInstrToken; |
|
11
|
|
|
public $billingID; |
|
12
|
|
|
|
|
13
|
|
|
public $maskedPan; |
|
14
|
|
|
public $expireMonth; |
|
15
|
|
|
public $expireYear; |
|
16
|
|
|
public $accountName; |
|
17
|
|
|
/** |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $requestNamespace = Requests\IgfsCgTokenizerCheckRequest::class; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* {@inheritdoc} |
|
24
|
|
|
*/ |
|
25
|
1 |
|
public function resetFields() |
|
26
|
|
|
{ |
|
27
|
1 |
|
parent::resetFields(); |
|
28
|
1 |
|
$this->payInstrToken = null; |
|
29
|
1 |
|
$this->billingID = null; |
|
30
|
|
|
|
|
31
|
1 |
|
$this->maskedPan = null; |
|
32
|
1 |
|
$this->expireMonth = null; |
|
33
|
1 |
|
$this->expireYear = null; |
|
34
|
1 |
|
$this->accountName = null; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* {@inheritdoc} |
|
39
|
|
|
*/ |
|
40
|
1 |
|
protected function getAdditionalRequestSignatureFields(): array |
|
41
|
|
|
{ |
|
42
|
1 |
|
return [ |
|
43
|
1 |
|
$this->payInstrToken, |
|
44
|
1 |
|
]; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @throws IgfsMissingParException |
|
49
|
|
|
*/ |
|
50
|
6 |
|
protected function checkFields() |
|
51
|
|
|
{ |
|
52
|
6 |
|
parent::checkFields(); |
|
53
|
2 |
|
if ($this->payInstrToken == null) { |
|
54
|
1 |
|
throw new IgfsMissingParException('Missing payInstrToken'); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @return mixed|string |
|
60
|
|
|
*/ |
|
61
|
1 |
|
protected function buildRequest() |
|
62
|
|
|
{ |
|
63
|
1 |
|
$request = parent::buildRequest(); |
|
64
|
1 |
|
$this->replaceRequestParameter($request, 'payInstrToken', $this->payInstrToken); |
|
65
|
1 |
|
$this->replaceRequestParameter($request, 'billingID', $this->billingID); |
|
66
|
|
|
|
|
67
|
1 |
|
return $request; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
protected function parseResponseMap($response) |
|
71
|
|
|
{ |
|
72
|
|
|
parent::parseResponseMap($response); |
|
73
|
|
|
// Opzionale |
|
74
|
|
|
$this->maskedPan = IgfsUtils::getValue($response, 'maskedPan'); |
|
75
|
|
|
// Opzionale |
|
76
|
|
|
$this->expireMonth = IgfsUtils::getValue($response, 'expireMonth'); |
|
77
|
|
|
// Opzionale |
|
78
|
|
|
$this->expireYear = IgfsUtils::getValue($response, 'expireYear'); |
|
79
|
|
|
// Opzionale |
|
80
|
|
|
$this->accountName = IgfsUtils::getValue($response, 'accountName'); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param array $response |
|
85
|
|
|
* |
|
86
|
|
|
* @throws \PagOnline\Exceptions\IgfsException |
|
87
|
|
|
* |
|
88
|
|
|
* @return string |
|
89
|
|
|
*/ |
|
90
|
|
|
protected function getResponseSignature($response) |
|
91
|
|
|
{ |
|
92
|
|
|
$fields = [ |
|
93
|
|
|
IgfsUtils::getValue($response, 'tid'), // TID |
|
94
|
|
|
IgfsUtils::getValue($response, 'shopID'), // SHOPID |
|
95
|
|
|
IgfsUtils::getValue($response, 'rc'), // RC |
|
96
|
|
|
IgfsUtils::getValue($response, 'errorDesc'), // ERRORDESC |
|
97
|
|
|
]; |
|
98
|
|
|
// signature dove il buffer e' cosi composto TID|SHOPID|RC|ERRORDESC |
|
99
|
|
|
return $this->getSignature($fields); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|