Skip to content

Commit

Permalink
fix issue #230 payflexv4pos payment hostdate format error
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Aug 12, 2024
1 parent 2cd6f90 commit bd10da2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down

0 comments on commit bd10da2

Please sign in to comment.