|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Omnipay\AcquiroPay\Message; |
|
4
|
|
|
|
|
5
|
|
|
use Omnipay\Common\Message\AbstractResponse; |
|
6
|
|
|
use Omnipay\Common\Message\RedirectResponseInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Response. |
|
10
|
|
|
*/ |
|
11
|
|
|
class Response extends AbstractResponse implements RedirectResponseInterface |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Get the response data. |
|
15
|
|
|
* |
|
16
|
|
|
* @return mixed |
|
17
|
|
|
*/ |
|
18
|
45 |
|
public function getData() |
|
19
|
|
|
{ |
|
20
|
45 |
|
$parent = parent::getData(); |
|
21
|
|
|
|
|
22
|
45 |
|
return json_decode(json_encode((array) $parent), true); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Response Message. |
|
27
|
|
|
* |
|
28
|
|
|
* @return null|string A response message from the payment gateway |
|
29
|
|
|
*/ |
|
30
|
6 |
|
public function getMessage() |
|
31
|
|
|
{ |
|
32
|
6 |
|
$data = $this->getData(); |
|
33
|
|
|
|
|
34
|
6 |
|
return isset($data['description']) ? $data['description'] : null; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Get status. |
|
39
|
|
|
* |
|
40
|
|
|
* @return string|null |
|
41
|
|
|
*/ |
|
42
|
36 |
|
public function getStatus() |
|
43
|
|
|
{ |
|
44
|
36 |
|
$data = $this->getData(); |
|
45
|
|
|
|
|
46
|
36 |
|
return isset($data['extended_status']) ? $data['extended_status'] : null; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Is the response successful? |
|
51
|
|
|
* |
|
52
|
|
|
* @return bool |
|
53
|
|
|
*/ |
|
54
|
45 |
|
public function isSuccessful() |
|
55
|
|
|
{ |
|
56
|
45 |
|
$data = $this->getData(); |
|
57
|
|
|
|
|
58
|
|
|
return |
|
59
|
45 |
|
(isset($data['status']) && $data['status'] !== 'KO') && |
|
60
|
45 |
|
(isset($data['duplicate']) && $data['duplicate'] !== 'true'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Does the response require a redirect? |
|
65
|
|
|
* |
|
66
|
|
|
* @return bool |
|
67
|
|
|
*/ |
|
68
|
12 |
|
public function isRedirect() |
|
69
|
|
|
{ |
|
70
|
12 |
|
$request = $this->request->getData(); |
|
71
|
12 |
|
$response = $this->getData(); |
|
72
|
|
|
|
|
73
|
|
|
return |
|
74
|
12 |
|
$request['opcode'] === 0 && |
|
75
|
12 |
|
$response['extended_status'] === '3DSECURE'; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Gateway Reference. |
|
80
|
|
|
* |
|
81
|
|
|
* @return null|string A reference provided by the gateway to represent this transaction |
|
82
|
|
|
*/ |
|
83
|
27 |
|
public function getTransactionReference() |
|
84
|
|
|
{ |
|
85
|
27 |
|
$data = $this->getData(); |
|
86
|
|
|
|
|
87
|
27 |
|
return isset($data['payment_id']) ? $data['payment_id'] : null; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Gets the redirect target url. |
|
92
|
|
|
* |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
6 |
|
public function getRedirectUrl() |
|
96
|
|
|
{ |
|
97
|
6 |
|
$data = $this->getData(); |
|
98
|
|
|
|
|
99
|
6 |
|
return $data['additional']['secure3d']['auth-form']; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Get the required redirect method (either GET or POST). |
|
104
|
|
|
* |
|
105
|
|
|
* @return string |
|
106
|
|
|
*/ |
|
107
|
6 |
|
public function getRedirectMethod() |
|
108
|
|
|
{ |
|
109
|
6 |
|
$data = $this->getData(); |
|
110
|
|
|
|
|
111
|
6 |
|
return $data['additional']['secure3d']['auth-form-method']; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Gets the redirect form data array, if the redirect method is POST. |
|
116
|
|
|
* |
|
117
|
|
|
* @return array |
|
118
|
|
|
*/ |
|
119
|
6 |
|
public function getRedirectData() |
|
120
|
|
|
{ |
|
121
|
6 |
|
$data = $this->getData(); |
|
122
|
6 |
|
$request = $this->getRequest()->getParameters(); |
|
123
|
|
|
|
|
124
|
|
|
return array( |
|
125
|
6 |
|
'PaReq' => $data['additional']['secure3d']['retransmit']['PaReq'], |
|
126
|
6 |
|
'MD' => $data['additional']['secure3d']['retransmit']['MD'], |
|
127
|
6 |
|
'TermUrl' => $request['returnUrl'], |
|
128
|
6 |
|
); |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|