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