Skip to content

Commit

Permalink
Merge pull request #126 from mewebstudio/125-posnetaccount-maprespons…
Browse files Browse the repository at this point in the history
…etransactionsecurity-hatası

fix #125 - PosNet mapResponseTransactionSecurity throws error when mdStatus=null
  • Loading branch information
nuryagdym authored May 18, 2023
2 parents 2c7bc87 + 1193a1b commit 574bcca
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> $oosResolveMerchantDataResponse */

/** @var array<string, string|null> $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),
Expand Down Expand Up @@ -156,7 +161,7 @@ public function mapCancelResponse($rawResponseData): array
if (null !== $state) {
$transactionType = $this->mapTxType($state);
}

$results = [
'auth_code' => null,
'trans_id' => null,
Expand Down Expand Up @@ -222,7 +227,7 @@ public function mapStatusResponse(array $rawResponseData): array
if (null !== $state) {
$transactionType = $this->mapTxType($state);
}

$results = [
'auth_code' => null,
'trans_id' => null,
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
],
];
}

Expand Down

0 comments on commit 574bcca

Please sign in to comment.