From 02a72ce33e4a93b5d8818f2163801bbd338b3f77 Mon Sep 17 00:00:00 2001 From: Kiet Tran Date: Wed, 26 Feb 2020 16:42:27 +0100 Subject: [PATCH 1/2] Fixed the transaction status response. Every fetchTransaction contains a status. This status can be completed or settled. when this happens, the transaction has been paid. --- src/Message/TransactionStatusResponse.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Message/TransactionStatusResponse.php b/src/Message/TransactionStatusResponse.php index 10946ab..f621d6f 100755 --- a/src/Message/TransactionStatusResponse.php +++ b/src/Message/TransactionStatusResponse.php @@ -12,7 +12,10 @@ class TransactionStatusResponse extends AbstractResponse */ public function isSuccessful(): bool { - return isset($this->data['statusCode']) && $this->data['statusCode'] === 200; + return (isset($this->data['status']) && in_array($this->data['status'], [ + self::RESPONSE_STATUS_COMPLETED, + self::RESPONSE_STATUS_SETTLED, + ])) && (isset($this->data['statusCode']) && $this->data['statusCode'] === 200); } /** From 732abb505bd71cd5957eda9d7b80aaa4d6bb9bdf Mon Sep 17 00:00:00 2001 From: Kiet Tran Date: Wed, 26 Feb 2020 16:47:45 +0100 Subject: [PATCH 2/2] Fixed the status 'COMPLETED' in the expected response body of the unit tests. --- tests/Message/TransactionStatusResponseTest.php | 3 ++- tests/Mocks/TransactionStatusSuccess.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Message/TransactionStatusResponseTest.php b/tests/Message/TransactionStatusResponseTest.php index 0925a19..8d44525 100644 --- a/tests/Message/TransactionStatusResponseTest.php +++ b/tests/Message/TransactionStatusResponseTest.php @@ -45,9 +45,10 @@ public function testResponseReturnsSuccessful(): void $expectedResponseBody = [ 'contractId' => 'NjRlYjM3MTctOGI1ZC00MDg4LTgxMDgtOTMyMjQ2NzVlNTM4', 'transactionId' => '7c9cb2f4-83ce-4b10-8d5c-de230181224f', - 'statusCode' => 200, + 'status' => 'COMPLETED', 'transactionStatusDetails' => '', 'acquirerTransactionId' => '', + 'statusCode' => 200, ]; $this->assertTrue($response->isSuccessful()); diff --git a/tests/Mocks/TransactionStatusSuccess.json b/tests/Mocks/TransactionStatusSuccess.json index 1b89b1b..c020c6f 100644 --- a/tests/Mocks/TransactionStatusSuccess.json +++ b/tests/Mocks/TransactionStatusSuccess.json @@ -1,7 +1,7 @@ { "contractId": "NjRlYjM3MTctOGI1ZC00MDg4LTgxMDgtOTMyMjQ2NzVlNTM4", "transactionId": "7c9cb2f4-83ce-4b10-8d5c-de230181224f", - "statusCode": "COMPLETED", + "status": "COMPLETED", "transactionStatusDetails": "", "acquirerTransactionId": "" }