From dbc19b5c31abd0cb463f0be6c9eb1c04b13d1409 Mon Sep 17 00:00:00 2001 From: Matias Vasquez Date: Tue, 3 Sep 2024 14:59:23 -0400 Subject: [PATCH 1/2] test: add test for status response when card number is null --- .../Webpay/WebpayPlus/WebpayPlusWithoutMocksTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Webpay/WebpayPlus/WebpayPlusWithoutMocksTest.php b/tests/Webpay/WebpayPlus/WebpayPlusWithoutMocksTest.php index 1b52a7e5..0d4ed400 100644 --- a/tests/Webpay/WebpayPlus/WebpayPlusWithoutMocksTest.php +++ b/tests/Webpay/WebpayPlus/WebpayPlusWithoutMocksTest.php @@ -153,4 +153,15 @@ public function it_can_not_capture_a_transaction_with_simultaneous_capture_comme $this->assertTrue(true); } + + /** @test */ + public function it_returns_a_card_number_in_null_when_it_not_exists() + { + $transaction = new Transaction($this->options); + $createResponse = $transaction->create($this->buyOrder, $this->sessionId, $this->amount, $this->returnUrl); + $statusResponse = $transaction->status($createResponse->getToken()); + + $this->assertEquals(TransactionStatusResponse::class, get_class($statusResponse)); + $this->assertEquals(null, $statusResponse->getCardNumber()); + } } From c0bbddb2f267fa3b96717b26d7fe2d691125c653 Mon Sep 17 00:00:00 2001 From: Matias Vasquez Date: Tue, 3 Sep 2024 15:00:00 -0400 Subject: [PATCH 2/2] feat: check if card detail is null to set value --- src/Utils/HasTransactionStatus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/HasTransactionStatus.php b/src/Utils/HasTransactionStatus.php index 626c6d43..e90d30fc 100644 --- a/src/Utils/HasTransactionStatus.php +++ b/src/Utils/HasTransactionStatus.php @@ -85,7 +85,7 @@ public function setTransactionStatusFields(array $json): void $this->buyOrder = Utils::returnValueIfExists($json, 'buy_order'); $this->sessionId = Utils::returnValueIfExists($json, 'session_id'); $this->cardDetail = Utils::returnValueIfExists($json, 'card_detail'); - $this->cardNumber = Utils::returnValueIfExists($this->cardDetail, 'card_number'); + $this->cardNumber = Utils::returnValueIfExists($this->cardDetail ?? [], 'card_number'); $this->accountingDate = Utils::returnValueIfExists($json, 'accounting_date'); $this->transactionDate = Utils::returnValueIfExists($json, 'transaction_date'); $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code');