Total Complexity | 7 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class FetchTransactionResponse extends AbstractResponse |
||
11 | { |
||
12 | /** |
||
13 | * The response status code. |
||
14 | * |
||
15 | * @var int |
||
16 | */ |
||
17 | private $statusCode; |
||
18 | |||
19 | 7 | public function __construct(RequestInterface $request, int $statusCode, $data) |
|
20 | { |
||
21 | 7 | parent::__construct($request, $data); |
|
22 | |||
23 | 7 | $this->statusCode = $statusCode; |
|
24 | 7 | } |
|
25 | |||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | 1 | public function isSuccessful(): bool |
|
30 | { |
||
31 | 1 | return $this->statusCode === Response::HTTP_OK; |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | 3 | public function isCancelled(): bool |
|
38 | { |
||
39 | 3 | return $this->getTransactionStatus() === self::TRANSACTION_STATUS_CANCELLED; |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | 4 | public function getCode(): int |
|
46 | { |
||
47 | 4 | return $this->statusCode; |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | 1 | public function getTransactionReference(): ?string |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | * |
||
61 | * Fallback on the postback data that was given by ICEPAY. |
||
62 | * Do note: this is not (always) a reliable transaction status. |
||
63 | * |
||
64 | * @see https://documentation.icepay.com/payments/payment-process/payment-feedback/postback/ |
||
65 | */ |
||
66 | 3 | protected function getTransactionStatus(): ?string |
|
73 | } |
||
74 | } |
||
75 |