diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php index 82f983af..fe48cd7f 100644 --- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php @@ -29,7 +29,8 @@ class KuveytPosResponseDataMapper extends AbstractResponseDataMapper */ protected array $orderStatusMappings = [ 1 => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, - 5 => PosInterface::PAYMENT_STATUS_FULLY_REFUNDED, + 4 => PosInterface::PAYMENT_STATUS_FULLY_REFUNDED, + 5 => PosInterface::PAYMENT_STATUS_PARTIALLY_REFUNDED, 6 => PosInterface::PAYMENT_STATUS_CANCELED, ]; @@ -187,6 +188,8 @@ public function mapStatusResponse(array $rawResponseData): array } } elseif (PosInterface::PAYMENT_STATUS_CANCELED === $defaultResponse['order_status']) { $defaultResponse['cancel_time'] = new \DateTimeImmutable($orderContract['UpdateSystemDate']); + } elseif (PosInterface::PAYMENT_STATUS_FULLY_REFUNDED === $defaultResponse['order_status']) { + $defaultResponse['refund_time'] = new \DateTimeImmutable($orderContract['UpdateSystemDate']); } } diff --git a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php index 426eec8b..4883abb9 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php @@ -1175,6 +1175,97 @@ public static function statusTestDataProvider(): iterable 'cancel_time' => new \DateTimeImmutable('2024-04-24T16:09:27.067'), ], ]; + yield 'tdv2_success_tx_pay_then_refund' => [ + 'responseData' => [ + 'GetMerchantOrderDetailResult' => [ + 'Results' => [], + 'Success' => true, + 'Value' => [ + 'OrderContract' => [ + 'IsSelected' => false, + 'IsSelectable' => true, + 'OrderId' => 155768298, + 'MerchantOrderId' => '202404240DEE', + 'MerchantId' => 496, + 'CardHolderName' => 'John Doe', + 'CardType' => 'MasterCard', + 'CardNumber' => '518896******2544', + 'OrderDate' => '2024-04-24T16:33:44.01', + 'OrderStatus' => 1, + 'LastOrderStatus' => 4, + 'OrderType' => 1, + 'TransactionStatus' => 1, + 'FirstAmount' => '10.01', + 'CancelAmount' => '0.00', + 'DrawbackAmount' => '10.01', + 'ClosedAmount' => '0.00', + 'FEC' => '0949', + 'VPSEntryMode' => 'ECOM', + 'InstallmentCount' => 0, + 'TransactionSecurity' => 1, + 'ResponseCode' => '00', + 'ResponseExplain' => 'İşlem gerçekleştirildi.', + 'EndOfDayStatus' => 2, + 'TransactionSide' => 'Auto', + 'CardHolderIPAddress' => '', + 'MerchantIPAddress' => '45.130.202.55', + 'MerchantUserName' => 'apitest', + 'ProvNumber' => '051004', + 'BatchId' => 545, + 'CardExpireDate' => '2506', + 'PosTerminalId' => 'VP008759', + 'Explain' => '', + 'Explain2' => '', + 'Explain3' => '', + 'RRN' => '411516539788', + 'Stan' => '539788', + 'UserName' => 'vposuser', + 'HostName' => 'STD8BOATEST2', + 'SystemDate' => '2024-04-24T16:33:44.02', + 'UpdateUserName' => 'webgate', + 'UpdateHostName' => 'STD8BOATEST2', + 'UpdateSystemDate' => '2024-04-26T10:59:49.443', + 'EndOfDayDate' => '2024-04-24T17:08:46.15', + 'HostIP' => '172.20.8.85', + 'FECAmount' => '0', + 'IdentityTaxNumber' => '', + 'QueryId' => '0', + 'DebtId' => '0', + 'DebtorName' => '', + 'Period' => '', + 'SurchargeAmount' => '0', + 'SGKDebtAmount' => '0', + 'DeferringCount' => null, + ], + ], + ], + ], + 'expectedData' => [ + 'auth_code' => '051004', + 'capture' => null, + 'capture_amount' => null, + 'currency' => 'TRY', + 'error_code' => null, + 'error_message' => null, + 'first_amount' => 10.01, + 'installment_count' => 0, + 'masked_number' => '518896******2544', + 'order_id' => '202404240DEE', + 'order_status' => 'FULLY_REFUNDED', + 'proc_return_code' => '00', + 'ref_ret_num' => '411516539788', + 'refund_amount' => null, + 'remote_order_id' => '155768298', + 'status' => 'approved', + 'status_detail' => null, + 'transaction_id' => '539788', + 'transaction_type' => null, + 'transaction_time' => new \DateTimeImmutable('2024-04-24T16:33:44.01'), + 'capture_time' => null, + 'refund_time' => new \DateTimeImmutable('2024-04-26T10:59:49.443'), + 'cancel_time' => null, + ], + ]; } public static function cancelTestDataProvider(): iterable