1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PagOnline\Tran; |
4
|
|
|
|
5
|
|
|
use PagOnline\Exceptions\IgfsMissingParException; |
6
|
|
|
use PagOnline\IgfsUtils; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class IgfsCgVoidAuth. |
10
|
|
|
*/ |
11
|
|
|
class IgfsCgVoidAuth extends BaseIgfsCgTran |
12
|
|
|
{ |
13
|
|
|
public $amount; |
14
|
|
|
public $refTranID; |
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected $requestNamespace = Requests\IgfsCgVoidAuthRequest::class; |
19
|
|
|
|
20
|
1 |
|
public function resetFields(): void |
21
|
|
|
{ |
22
|
1 |
|
parent::resetFields(); |
23
|
1 |
|
$this->amount = null; |
24
|
1 |
|
$this->refTranID = null; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
*/ |
30
|
1 |
|
protected function getAdditionalRequestSignatureFields(): array |
31
|
|
|
{ |
32
|
1 |
|
return [ |
33
|
1 |
|
$this->amount, // AMOUNT |
34
|
1 |
|
$this->refTranID, // REFORDERID |
35
|
1 |
|
$this->addInfo1, // UDF1 |
36
|
1 |
|
$this->addInfo2, // UDF2 |
37
|
1 |
|
$this->addInfo3, // UDF3 |
38
|
1 |
|
$this->addInfo4, // UDF4 |
39
|
1 |
|
$this->addInfo5, // UDF5 |
40
|
1 |
|
]; |
41
|
|
|
} |
42
|
|
|
|
43
|
6 |
|
protected function checkFields(): void |
44
|
|
|
{ |
45
|
6 |
|
parent::checkFields(); |
46
|
1 |
|
if ($this->amount == null) { |
47
|
|
|
throw new IgfsMissingParException('Missing amount'); |
48
|
|
|
} |
49
|
1 |
|
if ($this->refTranID == null) { |
50
|
|
|
throw new IgfsMissingParException('Missing refTranID'); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
1 |
|
protected function buildRequest() |
55
|
|
|
{ |
56
|
1 |
|
$request = parent::buildRequest(); |
57
|
1 |
|
$this->replaceRequestParameter($request, 'amount', $this->amount); |
58
|
1 |
|
$this->replaceRequestParameter($request, 'refTranID', $this->refTranID); |
59
|
|
|
|
60
|
1 |
|
return $request; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param array $response |
65
|
|
|
* |
66
|
|
|
* @throws \PagOnline\Exceptions\IgfsException |
67
|
|
|
* |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
protected function getResponseSignature($response): string |
71
|
|
|
{ |
72
|
|
|
$fields = [ |
73
|
|
|
IgfsUtils::getValue($response, 'tid'), // TID |
74
|
|
|
IgfsUtils::getValue($response, 'shopID'), // SHOPID |
75
|
|
|
IgfsUtils::getValue($response, 'rc'), // RC |
76
|
|
|
IgfsUtils::getValue($response, 'errorDesc'), // ERRORDESC |
77
|
|
|
IgfsUtils::getValue($response, 'tranID'), // ORDERID |
78
|
|
|
IgfsUtils::getValue($response, 'date'), // TRANDATE |
79
|
|
|
IgfsUtils::getValue($response, 'addInfo1'), // UDF1 |
80
|
|
|
IgfsUtils::getValue($response, 'addInfo2'), // UDF2 |
81
|
|
|
IgfsUtils::getValue($response, 'addInfo3'), // UDF3 |
82
|
|
|
IgfsUtils::getValue($response, 'addInfo4'), // UDF4 |
83
|
|
|
IgfsUtils::getValue($response, 'addInfo5'), ]; // UDF5 |
84
|
|
|
// signature dove il buffer e' cosi composto TID|SHOPID|RC|ERRORDESC|ORDERID|DATE|UDF1|UDF2|UDF3|UDF4|UDF5 |
85
|
|
|
return $this->getSignature($fields); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|