1 | <?php |
||
11 | class Response extends AbstractResponse implements RedirectResponseInterface |
||
12 | { |
||
13 | /** |
||
14 | * Get the response data. |
||
15 | * |
||
16 | * @return array |
||
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() |
|
36 | |||
37 | /** |
||
38 | * Get status. |
||
39 | * |
||
40 | * @return string|null |
||
41 | */ |
||
42 | 36 | public function getStatus() |
|
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() |
|
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() |
|
101 | |||
102 | /** |
||
103 | * Get the required redirect method (either GET or POST). |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | 6 | public function getRedirectMethod() |
|
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() |
|
130 | } |
||
131 |