diff --git a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php index 1409e87e..9071f90f 100644 --- a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php @@ -89,15 +89,20 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode && $this->getStatusDetail($procReturnCode) === self::TX_APPROVED) { $status = self::TX_APPROVED; } - - /** @var array $oosResolveMerchantDataResponse */ + + /** @var array $oosResolveMerchantDataResponse */ $oosResolveMerchantDataResponse = $raw3DAuthResponseData['oosResolveMerchantDataResponse']; $mdStatus = $oosResolveMerchantDataResponse['mdStatus']; - + $transactionSecurity = null; + if (null === $mdStatus) { + $this->logger->error('mdStatus boş döndü. Sağlanan banka API bilgileri eksik/yanlış olabilir.'); + } else { + $transactionSecurity = $this->mapResponseTransactionSecurity($mdStatus); + } $threeDResponse = [ 'order_id' => $oosResolveMerchantDataResponse['xid'] ?? null, - 'transaction_security' => $this->mapResponseTransactionSecurity($mdStatus), + 'transaction_security' => $transactionSecurity, 'proc_return_code' => $procReturnCode, 'status' => $status, 'status_detail' => $this->getStatusDetail($procReturnCode), @@ -156,7 +161,7 @@ public function mapCancelResponse($rawResponseData): array if (null !== $state) { $transactionType = $this->mapTxType($state); } - + $results = [ 'auth_code' => null, 'trans_id' => null, @@ -222,7 +227,7 @@ public function mapStatusResponse(array $rawResponseData): array if (null !== $state) { $transactionType = $this->mapTxType($state); } - + $results = [ 'auth_code' => null, 'trans_id' => null, @@ -269,7 +274,7 @@ public function mapHistoryResponse(array $rawResponseData): array $state = $transactionDetails[0]['state']; $authCode = $transactionDetails[0]['authCode']; } - + if (count($transactionDetails) > 1) { foreach ($transactionDetails as $key => $_transaction) { if ($key > 0) { diff --git a/tests/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php index 0037e8c7..f2f0af63 100644 --- a/tests/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php @@ -236,6 +236,38 @@ public function threeDPaymentDataProvider(): array 'status_detail' => null, ], ], + 'fail2-md-empty' => [ + // 3D Auth fail case + 'threeDResponseData' => [ + 'oosResolveMerchantDataResponse' => [ + 'xid' => 'YKB_0000080603153823', + 'amount' => '5696', + 'currency' => 'TL', + 'installment' => '00', + 'point' => '0', + 'pointAmount' => '0', + 'txStatus' => 'N', + 'mdStatus' => '', + 'mdErrorMessage' => 'None 3D - Secure Transaction', + 'mac' => 'ED7254A3ABC264QOP67MN', + ], + ], + 'paymentData' => [], + 'expectedData' => [ + 'transaction_security' => null, + 'md_status' => null, + 'md_error_message' => 'None 3D - Secure Transaction', + 'trans_id' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'error_code' => null, + 'error_message' => null, + 'order_id' => 'YKB_0000080603153823', + 'proc_return_code' => null, + 'status' => 'declined', + 'status_detail' => null, + ], + ], ]; }