From 1270f47bdfce226a002ebe5987935444349fb43a Mon Sep 17 00:00:00 2001 From: mustapayev Date: Tue, 24 Dec 2024 18:30:40 +0100 Subject: [PATCH] fix: issue #254 kuveytpos, vakif katilim undefined index MerchantOrderId --- .../KuveytPosResponseDataMapper.php | 3 +- .../VakifKatilimPosResponseDataMapper.php | 2 +- .../KuveytPosResponseDataMapperTest.php | 45 +++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php index c3fcf983..e5f4910f 100644 --- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php @@ -431,7 +431,7 @@ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array $vPosMessage = $raw3DAuthResponseData['VPosMessage']; $orderId = $vPosMessage['MerchantOrderId']; } else { - $orderId = $raw3DAuthResponseData['MerchantOrderId']; + $orderId = $raw3DAuthResponseData['MerchantOrderId'] ?? null; } $default = [ @@ -445,6 +445,7 @@ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array 'status_detail' => $this->getStatusDetail($procReturnCode), 'amount' => null, 'currency' => null, + 'masked_number' => null, 'tx_status' => null, 'error_code' => self::TX_APPROVED !== $status ? $procReturnCode : null, 'md_error_message' => self::TX_APPROVED !== $status ? $raw3DAuthResponseData['ResponseMessage'] : null, diff --git a/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php index 347a57b7..cb532986 100644 --- a/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php @@ -437,7 +437,7 @@ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array $status = self::TX_APPROVED; } - $orderId = $raw3DAuthResponseData['MerchantOrderId']; + $orderId = $raw3DAuthResponseData['MerchantOrderId'] ?? null; return [ 'order_id' => $orderId, diff --git a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php index 0aeadac6..cbc8e2b2 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php @@ -342,6 +342,50 @@ public static function paymentTestDataProvider(): iterable public static function threeDPaymentDataProvider(): array { return [ + 'invalid_configuration' => [ + 'order' => [], + 'txType' => PosInterface::TX_TYPE_PAY_AUTH, + 'threeDResponseData' => [ + 'IsEnrolled' => false, + 'IsVirtual' => false, + 'ResponseCode' => 'InvalidTransactionSecurity', + 'ResponseMessage' => 'İşlem türü geçersizdir.', + 'OrderId' => 0, + 'TransactionTime' => '0001-01-01T00:00:00', + 'ReferenceId' => '2860e2d55e92435fa232a5dde55f68a9', + 'MerchantId' => [ + '@xsi:nil' => true, + '#' => '', + ], + 'BusinessKey' => 0, + '@xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + '@xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', + ], + 'paymentData' => [], + 'expectedData' => [ + 'transaction_id' => null, + 'transaction_type' => 'pay', + 'transaction_time' => null, + 'transaction_security' => 'MPI fallback', + 'md_status' => null, + 'amount' => null, + 'currency' => null, + 'tx_status' => null, + 'md_error_message' => 'İşlem türü geçersizdir.', + 'masked_number' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'batch_num' => null, + 'error_message' => null, + 'order_id' => null, + 'proc_return_code' => 'InvalidTransactionSecurity', + 'status' => 'declined', + 'status_detail' => 'InvalidTransactionSecurity', + 'error_code' => 'InvalidTransactionSecurity', + 'payment_model' => null, + 'installment_count' => null, + ], + ], '3d_auth_success_payment_fail_1' => [ 'order' => [], 'txType' => PosInterface::TX_TYPE_PAY_AUTH, @@ -548,6 +592,7 @@ public static function threeDPaymentDataProvider(): array 'amount' => null, 'currency' => null, 'tx_status' => null, + 'masked_number' => null, 'md_error_message' => 'Şifrelenen veriler (Hashdata) uyuşmamaktadır.', 'payment_model' => null, 'installment_count' => null,