From 34474587d0da5d94b483f1260ab94f2081a1da1d Mon Sep 17 00:00:00 2001 From: mustapayev Date: Sat, 12 Oct 2024 13:06:29 +0200 Subject: [PATCH] estpos - fix issue #239 undefined index mdErrorMsg --- .../EstPosResponseDataMapper.php | 11 +++- .../EstPosResponseDataMapperTest.php | 58 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php index 5f9c3e47..535183aa 100644 --- a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php @@ -135,10 +135,19 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen 'eci' => null, 'tx_status' => null, 'cavv' => null, - 'md_error_message' => $this->is3dAuthSuccess($mdStatus) ? null : $raw3DAuthResponseData['mdErrorMsg'], + 'md_error_message' => null, '3d_all' => $raw3DAuthResponseData, ]; + if (null !== $mdStatus) { + if (!$this->is3dAuthSuccess($mdStatus)) { + $threeDResponse['md_error_message'] = $raw3DAuthResponseData['mdErrorMsg']; + } + } else { + $threeDResponse['error_code'] = $raw3DAuthResponseData['ErrorCode']; + $threeDResponse['error_message'] = $raw3DAuthResponseData['ErrMsg']; + } + if ($this->is3dAuthSuccess($mdStatus)) { $threeDResponse['eci'] = $raw3DAuthResponseData['eci']; $threeDResponse['cavv'] = $raw3DAuthResponseData['cavv']; diff --git a/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php index 5be978b7..ede214f3 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php @@ -505,6 +505,64 @@ public static function threeDPaymentDataProvider(): array 'installment_count' => 0, ], ], + '3d_auth_fail_wrong_card_number_format' => [ + 'order' => [ + 'currency' => PosInterface::CURRENCY_TRY, + 'amount' => 1.01, + ], + 'txType' => PosInterface::TX_TYPE_PAY_AUTH, + 'threeDResponseData' => [ + 'amount' => 0.01, + 'clientid' => '*', + 'currency' => '*', + 'Ecom_Payment_Card_ExpDate_Month' => 0, + 'Ecom_Payment_Card_ExpDate_Year' => 0, + 'ErrMsg' => 'Girilen kart numarası doğru formatta değildir. Kart numarasını kontrol ederek tekrar işlem deneyiniz.', + 'ErrorCode' => 'HPP-1001', + 'failUrl' => 'https://*.com/odeme/f05e81c8-4ea0-44a9-8fe8-d45b854c62d9', + 'HASH' => '**/fxNKZvC4E2EbQOgiqNi9FeXBMj636Q==', + 'hashAlgorithm' => 'ver3', + 'lang' => 'tr', + 'maskedCreditCard' => '***', + 'MaskedPan' => '**', + 'oid' => 'f05e81c8', + 'okUrl' => 'https://*.com/odeme/d45b854c62d9', + 'Response' => 'Error', + 'rnd' => 'MZrcwoSd1+-*', + 'storetype' => '3d', + 'taksit' => '', + 'traceId' => '****', + 'TranType' => 'Auth', + ], + 'paymentData' => [], + 'expectedData' => [ + 'amount' => 0.01, + 'auth_code' => null, + 'batch_num' => null, + 'cavv' => null, + 'currency' => '*', + 'eci' => null, + 'error_code' => 'HPP-1001', + 'error_message' => 'Girilen kart numarası doğru formatta değildir. Kart numarasını kontrol ederek tekrar işlem deneyiniz.', + 'installment_count' => 0, + 'masked_number' => '***', + 'md_error_message' => null, + 'md_status' => null, + 'month' => 0, + 'order_id' => 'f05e81c8', + 'payment_model' => '3d', + 'proc_return_code' => null, + 'ref_ret_num' => null, + 'status' => 'declined', + 'status_detail' => null, + 'transaction_id' => null, + 'transaction_security' => null, + 'transaction_type' => 'pay', + 'transaction_time' => null, + 'tx_status' => null, + 'year' => 0, + ], + ], '3d_auth_success_payment_fail' => [ 'order' => [ 'currency' => PosInterface::CURRENCY_TRY,