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