Skip to content

Commit

Permalink
Merge pull request #10 from superbrave/fixed-transaction-status-response
Browse files Browse the repository at this point in the history
Fixed the transaction status response.
  • Loading branch information
kiettran authored Feb 26, 2020
2 parents 80c8794 + 732abb5 commit da7868d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Message/TransactionStatusResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/Message/TransactionStatusResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tests/Mocks/TransactionStatusSuccess.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"contractId": "NjRlYjM3MTctOGI1ZC00MDg4LTgxMDgtOTMyMjQ2NzVlNTM4",
"transactionId": "7c9cb2f4-83ce-4b10-8d5c-de230181224f",
"statusCode": "COMPLETED",
"status": "COMPLETED",
"transactionStatusDetails": "",
"acquirerTransactionId": ""
}

0 comments on commit da7868d

Please sign in to comment.