Skip to content

Commit

Permalink
Merge pull request #266 from mewebstudio/249-akbank-pos-amount-alani-…
Browse files Browse the repository at this point in the history
…patterne-uymuyor-hatasi

fix issue #249 - AkbankPos invalid amount pattern
  • Loading branch information
nuryagdym authored Feb 18, 2025
2 parents 732484f + f7ee2bd commit 65844b0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 26 deletions.
4 changes: 2 additions & 2 deletions examples/_common-codes/regular/history.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ function createHistoryOrder(string $gatewayClass, array $extraData, string $ip):
'end_date' => $txTime,
];
// ya da batch number ile (batch number odeme isleminden alinan response'da bulunur):
// $order = [
// 'batch_num' => 24,
// return [
// 'batch_num' => 396,
// ];
}

Expand Down
4 changes: 2 additions & 2 deletions examples/akbankpos/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
$testCards = [
'visa1' => [
// OTP 123456
'number' => '5218076007402834',
'number' => '4355093000315232',
'year' => '40',
'month' => '11',
'cvv' => '820',
'cvv' => '471',
'name' => 'John Doe',
],
];
12 changes: 11 additions & 1 deletion src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s
'terminalSafeId' => $posAccount->getTerminalId(),
'orderId' => (string) $order['id'],
'lang' => $this->getLang($posAccount, $order),
'amount' => (string) $order['amount'],
'amount' => $this->formatAmount($order['amount']),
'currencyCode' => (string) $this->mapCurrency((string) $order['currency']),
'installCount' => (string) $this->mapInstallment((int) $order['installment']),
'okUrl' => (string) $order['success_url'],
Expand Down Expand Up @@ -515,6 +515,16 @@ protected function prepareCancelOrder(array $order): array
]);
}

/**
* @param float $amount
*
* @return string
*/
protected function formatAmount(float $amount): string
{
return \number_format($amount, 2, '.', '');
}

/**
* @inheritDoc
*
Expand Down
7 changes: 4 additions & 3 deletions tests/Functional/AkbankPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ protected function setUp(): void

$this->card = CreditCardFactory::createForGateway(
$this->pos,
'5218076007402834',
'4355093000315232',
'40',
'11',
'820',
'471',
);
}

Expand Down Expand Up @@ -323,8 +323,9 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro

$this->recurringPos->cancel($statusOrder);

$this->assertTrue($this->recurringPos->isSuccess());
$response = $this->recurringPos->getResponse();
$this->assertTrue($this->recurringPos->isSuccess(), $response['error_message'] ?? null);

$this->assertIsArray($response);
$this->assertNotEmpty($response);
$this->assertTrue($eventIsThrown);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function testGet3DFormDataSubMerchant(): void
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
'orderId' => '2020110828BC',
'lang' => 'TR',
'amount' => '1.1',
'amount' => '1.10',
'currencyCode' => '949',
'installCount' => '1',
'okUrl' => 'http:://localhost/success',
Expand Down Expand Up @@ -270,7 +270,7 @@ public function testCreate3DPaymentSubMerchantRequestData(): void
'orderId' => '2020110828BC',
],
'transaction' => [
'amount' => 1.1,
'amount' => '1.10',
'currencyCode' => 949,
'motoInd' => 0,
'installCount' => 1,
Expand Down Expand Up @@ -679,7 +679,7 @@ public static function refundRequestDataProvider(): array
'orderId' => '2020110828BC',
],
'transaction' => [
'amount' => 1.02,
'amount' => '1.02',
'currencyCode' => 949,
],
],
Expand All @@ -702,7 +702,7 @@ public static function refundRequestDataProvider(): array
'orderTrackId' => '2020110828BC',
],
'transaction' => [
'amount' => 1.02,
'amount' => '1.02',
'currencyCode' => 949,
],
'version' => '1.00',
Expand Down Expand Up @@ -744,7 +744,7 @@ public static function nonSecurePaymentRequestDataProvider(): array
'orderId' => '2020110828BC',
],
'transaction' => [
'amount' => 1.1,
'amount' => '1.10',
'currencyCode' => 949,
'motoInd' => 0,
'installCount' => 1,
Expand Down Expand Up @@ -780,7 +780,7 @@ public static function nonSecurePaymentRequestDataProvider(): array
'orderId' => '2020110828BC',
],
'transaction' => [
'amount' => 1.1,
'amount' => '1.10',
'currencyCode' => 949,
'motoInd' => 0,
'installCount' => 2,
Expand Down Expand Up @@ -816,7 +816,7 @@ public static function nonSecurePaymentRequestDataProvider(): array
'orderId' => '2020110828BC',
],
'transaction' => [
'amount' => 1.1,
'amount' => '1.10',
'currencyCode' => 949,
'motoInd' => 0,
'installCount' => 1,
Expand Down Expand Up @@ -856,7 +856,7 @@ public static function nonSecurePaymentRequestDataProvider(): array
'orderTrackId' => '2020110828BC',
],
'transaction' => [
'amount' => 1.1,
'amount' => '1.10',
'currencyCode' => 949,
'motoInd' => 1,
'installCount' => 1,
Expand Down Expand Up @@ -896,7 +896,7 @@ public static function nonSecurePaymentPostRequestDataProvider(): array
'orderId' => '2020110828BC',
],
'transaction' => [
'amount' => 1.1,
'amount' => '1.10',
'currencyCode' => 949,
],
'customer' => [
Expand Down Expand Up @@ -953,7 +953,7 @@ public static function threeDFormDataProvider(): array
'3d_host_form_data' => [
'order' => [
'id' => '2020110828BC',
'amount' => 1.10,
'amount' => 10,
'ip' => '127.0.0.1',
'installment' => 0,
'currency' => PosInterface::CURRENCY_TRY,
Expand All @@ -974,7 +974,7 @@ public static function threeDFormDataProvider(): array
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
'orderId' => '2020110828BC',
'lang' => 'TR',
'amount' => '1.1',
'amount' => '10.00',
'currencyCode' => '949',
'installCount' => '1',
'okUrl' => 'http:://localhost/success',
Expand All @@ -987,7 +987,7 @@ public static function threeDFormDataProvider(): array
'3d_pay_form_data' => [
'order' => [
'id' => '2020110828BC',
'amount' => 1.10,
'amount' => 1.1,
'ip' => '127.0.0.1',
'installment' => 0,
'currency' => PosInterface::CURRENCY_TRY,
Expand All @@ -1008,7 +1008,7 @@ public static function threeDFormDataProvider(): array
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
'orderId' => '2020110828BC',
'lang' => 'TR',
'amount' => '1.1',
'amount' => '1.10',
'currencyCode' => '949',
'installCount' => '1',
'okUrl' => 'http:://localhost/success',
Expand All @@ -1024,7 +1024,7 @@ public static function threeDFormDataProvider(): array
'3d_form_data' => [
'order' => [
'id' => '2020110828BC',
'amount' => 1.10,
'amount' => 1.1,
'ip' => '127.0.0.1',
'installment' => 0,
'currency' => PosInterface::CURRENCY_TRY,
Expand All @@ -1045,7 +1045,7 @@ public static function threeDFormDataProvider(): array
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
'orderId' => '2020110828BC',
'lang' => 'TR',
'amount' => '1.1',
'amount' => '1.10',
'currencyCode' => '949',
'installCount' => '1',
'okUrl' => 'http:://localhost/success',
Expand All @@ -1061,7 +1061,7 @@ public static function threeDFormDataProvider(): array
'3d_pre_pay_form_data' => [
'order' => [
'id' => '2020110828BC',
'amount' => 1.10,
'amount' => 1000,
'ip' => '127.0.0.1',
'installment' => 0,
'currency' => PosInterface::CURRENCY_TRY,
Expand All @@ -1082,7 +1082,7 @@ public static function threeDFormDataProvider(): array
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
'orderId' => '2020110828BC',
'lang' => 'TR',
'amount' => '1.1',
'amount' => '1000.00',
'currencyCode' => '949',
'installCount' => '1',
'okUrl' => 'http:://localhost/success',
Expand Down Expand Up @@ -1121,7 +1121,7 @@ public static function create3DPaymentRequestDataDataProvider(): \Generator
'orderId' => '2020110828BC',
],
'transaction' => [
'amount' => 100.25,
'amount' => '100.25',
'currencyCode' => 949,
'motoInd' => 0,
'installCount' => 1,
Expand Down

0 comments on commit 65844b0

Please sign in to comment.