diff --git a/src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php index 693e35dc..5a3503ca 100644 --- a/src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php @@ -209,7 +209,11 @@ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType if (self::TX_APPROVED === $commonResponse['status']) { $commonResponse['transaction_id'] = $rawPaymentResponseData['TransactionId']; - $commonResponse['transaction_time'] = new \DateTimeImmutable($rawPaymentResponseData['HostDate']); + $txTime = $rawPaymentResponseData['HostDate']; + if (\strlen($txTime) === 10) { // ziraat is sending host date without year + $txTime = date('Y').$txTime; + } + $commonResponse['transaction_time'] = new \DateTimeImmutable($txTime); $commonResponse['auth_code'] = $rawPaymentResponseData['AuthCode']; $commonResponse['ref_ret_num'] = $rawPaymentResponseData['TransactionId']; $commonResponse['batch_num'] = $rawPaymentResponseData['BatchNo']; diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php index 1b1f35c5..4e5e8f2b 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php @@ -401,6 +401,57 @@ public static function paymentDataProvider(): iterable ], ]; + yield 'success_with_short_host_date' => [ + 'txType' => PosInterface::TX_TYPE_PAY_PRE_AUTH, + 'responseData' => [ + 'MerchantId' => '000100000013506', + 'TransactionType' => 'Sale', + 'TransactionId' => '9972767117b3400eb2acafc0018643df', + 'ResultCode' => '0000', + 'ResultDetail' => 'İŞLEM BAŞARILI', + 'CustomItems' => [ + 'Item' => [ + '@name' => 'CardHolderName', + '@value' => 'AR* ÖZ*', + '#' => null, + ], + ], + 'InstallmentTable' => null, + 'CampaignResult' => null, + 'AuthCode' => '961451', + 'HostDate' => '0309234054', + 'Rrn' => '306823971358', + 'TerminalNo' => 'VP000579', + 'GainedPoint' => '10.00', + 'TotalPoint' => '103032.52', + 'CurrencyAmount' => '1.01', + 'CurrencyCode' => '949', + 'OrderId' => '202303095646', + 'ThreeDSecureType' => '1', + 'TransactionDeviceSource' => '0', + 'BatchNo' => '300', + 'TLAmount' => '1.01', + ], + 'expectedData' => [ + 'transaction_id' => '9972767117b3400eb2acafc0018643df', + 'transaction_type' => 'pay', + 'transaction_time' => new \DateTimeImmutable('2024-03-09 23:40:54'), + 'auth_code' => '961451', + 'ref_ret_num' => '9972767117b3400eb2acafc0018643df', + 'batch_num' => '300', + 'order_id' => '202303095646', + 'proc_return_code' => '0000', + 'status' => 'approved', + 'status_detail' => 'approved', + 'error_code' => null, + 'error_message' => null, + 'currency' => 'TRY', + 'amount' => 1.01, + 'payment_model' => 'regular', + 'installment_count' => null, + ], + ]; + yield 'fail_1' => [ 'txType' => PosInterface::TX_TYPE_PAY_PRE_AUTH, 'responseData' => [