diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php index ef4c5723..7090184b 100644 --- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php @@ -25,7 +25,7 @@ class KuveytPosResponseDataMapper extends AbstractResponseDataMapper /** * Order Status Codes * - * @var array + * @var array */ protected array $orderStatusMappings = [ 1 => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, diff --git a/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php index 3eedcea9..cd114625 100644 --- a/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php @@ -21,6 +21,18 @@ class VakifKatilimPosResponseDataMapper extends AbstractResponseDataMapper '51' => 'reject', ]; + /** + * Order Status Codes + * + * @var array + */ + protected array $orderStatusMappings = [ + 1 => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, + 4 => PosInterface::PAYMENT_STATUS_FULLY_REFUNDED, + 5 => PosInterface::PAYMENT_STATUS_PARTIALLY_REFUNDED, + 6 => PosInterface::PAYMENT_STATUS_CANCELED, + ]; + /** * {@inheritDoc} */ @@ -491,20 +503,16 @@ private function mapSingleOrderHistoryTransaction(array $rawTx): array $defaultResponse['installment_count'] = $this->mapInstallment($rawTx['InstallmentCount']); $defaultResponse['masked_number'] = $rawTx['CardNumber']; $defaultResponse['first_amount'] = (float) $rawTx['FirstAmount']; - $defaultResponse['order_status'] = $rawTx['LastOrderStatusDescription']; - - /** - * OrderStatus - * 1 => Satis - * 6 => Iptal - */ - if ('1' === $rawTx['OrderStatus']) { + $defaultResponse['order_status'] = $this->orderStatusMappings[$rawTx['LastOrderStatus']] ?? $rawTx['LastOrderStatusDescription']; + $initialOrderStatus = $this->orderStatusMappings[$rawTx['OrderStatus']] ?? null; + + if (PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED === $initialOrderStatus) { $defaultResponse['capture_amount'] = isset($rawTx['TranAmount']) ? (float) $rawTx['TranAmount'] : 0; $defaultResponse['capture'] = $defaultResponse['first_amount'] === $defaultResponse['capture_amount']; if ($defaultResponse['capture']) { $defaultResponse['capture_time'] = $defaultResponse['transaction_time']; } - } elseif ('6' === $rawTx['OrderStatus']) { + } elseif (PosInterface::PAYMENT_STATUS_CANCELED === $initialOrderStatus) { $defaultResponse['cancel_time'] = $defaultResponse['transaction_time']; } } diff --git a/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php index 7b8f7e7e..2b3c15b0 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php @@ -722,7 +722,7 @@ public static function statusTestDataProvider(): iterable 'installment_count' => 0, 'masked_number' => '5353********7017', 'order_id' => '1995434716', - 'order_status' => null, + 'order_status' => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, 'payment_model' => null, 'proc_return_code' => '00', 'ref_ret_num' => '035909014127', @@ -797,7 +797,7 @@ public static function statusTestDataProvider(): iterable 'installment_count' => 0, 'masked_number' => '5188********2666', 'order_id' => '20240701CF44', - 'order_status' => 'Iptal', + 'order_status' => PosInterface::PAYMENT_STATUS_CANCELED, 'payment_model' => '3d', 'proc_return_code' => '00', 'ref_ret_num' => '418315149569', @@ -1283,7 +1283,7 @@ public static function historyTestDataProvider(): array 'capture_time' => null, 'error_message' => null, 'ref_ret_num' => '036008014143', - 'order_status' => 'Satis', + 'order_status' => PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED, 'transaction_type' => null, 'first_amount' => 2.7, 'capture_amount' => 0, @@ -1494,7 +1494,7 @@ public static function orderHistoryTestDataProvider(): array 'first_amount' => 10.01, 'installment_count' => 2, 'masked_number' => '5351********9885', - 'order_status' => 'Iptal', + 'order_status' => PosInterface::PAYMENT_STATUS_CANCELED, 'payment_model' => '3d', 'proc_return_code' => '00', 'ref_ret_num' => '418315158962', @@ -1515,7 +1515,7 @@ public static function orderHistoryTestDataProvider(): array 'first_amount' => 10.01, 'installment_count' => 2, 'masked_number' => '5351********9885', - 'order_status' => 'Iptal', + 'order_status' => PosInterface::PAYMENT_STATUS_CANCELED, 'payment_model' => '3d', 'proc_return_code' => '00', 'ref_ret_num' => '418315158962',