Total Complexity | 9 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class RefundResponse extends AbstractResponse |
||
11 | { |
||
12 | /** |
||
13 | * Is the response pending success or failure? |
||
14 | * |
||
15 | * @return boolean |
||
16 | */ |
||
17 | public function isPending() |
||
18 | { |
||
19 | if (empty($this->data) || isset($this->data->errorId)) { |
||
20 | return false; |
||
21 | } |
||
22 | |||
23 | return $this->data->status == 'REFUND_REQUESTED'; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Is the response successful? |
||
28 | * |
||
29 | * @return boolean |
||
30 | */ |
||
31 | public function isSuccessful() |
||
32 | { |
||
33 | if (empty($this->data) || isset($this->data->errorId)) { |
||
34 | return false; |
||
35 | } |
||
36 | |||
37 | return $this->data->status == 'REFUNDED'; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Numeric status code (also in back office / report files) |
||
42 | * |
||
43 | * @return null|string |
||
44 | */ |
||
45 | public function getCode() |
||
46 | { |
||
47 | return $this->data->statusOutput->statusCode |
||
48 | ?? $this->data->refundResult->statusOutput->statusCode |
||
49 | ?? $this->data->errors[0]->errorCode |
||
50 | ?? null; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get the authorisation code if available. |
||
55 | * |
||
56 | * @return null|string |
||
57 | */ |
||
58 | public function getTransactionReference() |
||
59 | { |
||
60 | return $this->data->id ?? null; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Get the merchant response message if available. |
||
65 | * |
||
66 | * @return null|string |
||
67 | */ |
||
68 | public function getMessage() |
||
71 | } |
||
72 | } |
||
73 |