| Total Complexity | 7 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| 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 | public function __construct(RequestInterface $request, int $statusCode, $data) |
||
| 20 | { |
||
| 21 | parent::__construct($request, $data); |
||
| 22 | |||
| 23 | $this->statusCode = $statusCode; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * {@inheritdoc} |
||
| 28 | */ |
||
| 29 | public function isSuccessful(): bool |
||
| 30 | { |
||
| 31 | return $this->statusCode === Response::HTTP_OK; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * {@inheritdoc} |
||
| 36 | */ |
||
| 37 | public function isCancelled(): bool |
||
| 38 | { |
||
| 39 | return $this->getTransactionStatus() === self::TRANSACTION_STATUS_CANCELLED; |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * {@inheritdoc} |
||
| 44 | */ |
||
| 45 | public function getCode(): int |
||
| 46 | { |
||
| 47 | return $this->statusCode; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritdoc} |
||
| 52 | */ |
||
| 53 | 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 | protected function getTransactionStatus(): ?string |
||
| 73 | } |
||
| 74 | } |
||
| 75 |