diff --git a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php index 0fb849aa..fc37055e 100644 --- a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php @@ -42,7 +42,7 @@ class KuveytPosRequestDataMapper extends AbstractRequestDataMapper PosInterface::TX_TYPE_PAY_AUTH => 'Sale', PosInterface::TX_TYPE_CANCEL => 'SaleReversal', PosInterface::TX_TYPE_STATUS => 'GetMerchantOrderDetail', - PosInterface::TX_TYPE_REFUND => 'PartialDrawback', // Also there is a "Drawback" + PosInterface::TX_TYPE_REFUND => 'Drawback', // Also there is a "PartialDrawback" ]; /** diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php index 7a031690..8082c004 100644 --- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php @@ -204,8 +204,9 @@ public function mapRefundResponse(array $rawResponseData): array 'all' => $rawResponseData, ]; + $drawbackResult = $rawResponseData['PartialDrawbackResult'] ?? $rawResponseData['DrawBackResult']; + $value = $drawbackResult['Value']; - $value = $rawResponseData['PartialDrawbackResult']['Value']; $procReturnCode = $this->getProcReturnCode($value); if (null === $procReturnCode) { @@ -216,7 +217,7 @@ public function mapRefundResponse(array $rawResponseData): array $status = self::TX_APPROVED; } - $responseResults = $rawResponseData['PartialDrawbackResult']['Results']; + $responseResults = $drawbackResult['Results']; if (self::TX_APPROVED !== $status && isset($responseResults['Result']) && [] !== $responseResults['Result']) { if (isset($responseResults['Result'][0])) { $responseResult = $responseResults['Result'][0]; diff --git a/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php index 454447f4..55daafd8 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/KuveytPosRequestDataMapperTest.php @@ -268,7 +268,7 @@ public static function createRefundRequestDataProvider(): Generator 'UserName' => 'apiuser', 'CardType' => 'Visa', 'BatchID' => 0, - 'TransactionType' => 'PartialDrawback', + 'TransactionType' => 'Drawback', 'InstallmentCount' => 0, 'Amount' => 101, 'DisplayAmount' => 0, diff --git a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php index ebc67403..b63dda22 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php @@ -1218,6 +1218,43 @@ public static function refundTestDataProvider(): iterable 'remote_order_id' => '114293626', ], ]; + + yield 'tdv2_success_full_refund' => [ + 'responseData' => [ + 'DrawBackResult' => [ + 'Results' => [], + 'Success' => true, + 'Value' => [ + 'IsEnrolled' => false, + 'IsVirtual' => false, + 'ProvisionNumber' => '050823', + 'RRN' => '411415539590', + 'Stan' => '539590', + 'ResponseCode' => '00', + 'ResponseMessage' => 'OTORİZASYON VERİLDİ', + 'OrderId' => 155767855, + 'TransactionTime' => '2024-04-23T15:19:15.7471578', + 'MerchantOrderId' => '202404229EAC', + 'CurrencyCode' => '0949', + 'MerchantId' => null, + 'BusinessKey' => '202404239999000000013631520', + ], + ], + ], + 'expectedData' => [ + 'auth_code' => '050823', + 'currency' => 'TRY', + 'error_code' => null, + 'error_message' => null, + 'order_id' => '202404229EAC', + 'proc_return_code' => '00', + 'ref_ret_num' => '411415539590', + 'remote_order_id' => '155767855', + 'status' => 'approved', + 'status_detail' => null, + 'transaction_id' => '539590', + ], + ]; yield 'tdv2_success1' => [ 'responseData' => [ 'PartialDrawbackResult' => [