Skip to content

Commit 65844b0

Browse files
authored
Merge pull request #266 from mewebstudio/249-akbank-pos-amount-alani-patterne-uymuyor-hatasi
fix issue #249 - AkbankPos invalid amount pattern
2 parents 732484f + f7ee2bd commit 65844b0

File tree

5 files changed

+37
-26
lines changed

5 files changed

+37
-26
lines changed

examples/_common-codes/regular/history.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function createHistoryOrder(string $gatewayClass, array $extraData, string $ip):
4949
'end_date' => $txTime,
5050
];
5151
// ya da batch number ile (batch number odeme isleminden alinan response'da bulunur):
52-
// $order = [
53-
// 'batch_num' => 24,
52+
// return [
53+
// 'batch_num' => 396,
5454
// ];
5555
}
5656

examples/akbankpos/_payment_config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
$testCards = [
99
'visa1' => [
1010
// OTP 123456
11-
'number' => '5218076007402834',
11+
'number' => '4355093000315232',
1212
'year' => '40',
1313
'month' => '11',
14-
'cvv' => '820',
14+
'cvv' => '471',
1515
'name' => 'John Doe',
1616
],
1717
];

src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s
373373
'terminalSafeId' => $posAccount->getTerminalId(),
374374
'orderId' => (string) $order['id'],
375375
'lang' => $this->getLang($posAccount, $order),
376-
'amount' => (string) $order['amount'],
376+
'amount' => $this->formatAmount($order['amount']),
377377
'currencyCode' => (string) $this->mapCurrency((string) $order['currency']),
378378
'installCount' => (string) $this->mapInstallment((int) $order['installment']),
379379
'okUrl' => (string) $order['success_url'],
@@ -515,6 +515,16 @@ protected function prepareCancelOrder(array $order): array
515515
]);
516516
}
517517

518+
/**
519+
* @param float $amount
520+
*
521+
* @return string
522+
*/
523+
protected function formatAmount(float $amount): string
524+
{
525+
return \number_format($amount, 2, '.', '');
526+
}
527+
518528
/**
519529
* @inheritDoc
520530
*

tests/Functional/AkbankPosTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ protected function setUp(): void
5555

5656
$this->card = CreditCardFactory::createForGateway(
5757
$this->pos,
58-
'5218076007402834',
58+
'4355093000315232',
5959
'40',
6060
'11',
61-
'820',
61+
'471',
6262
);
6363
}
6464

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

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

326-
$this->assertTrue($this->recurringPos->isSuccess());
327326
$response = $this->recurringPos->getResponse();
327+
$this->assertTrue($this->recurringPos->isSuccess(), $response['error_message'] ?? null);
328+
328329
$this->assertIsArray($response);
329330
$this->assertNotEmpty($response);
330331
$this->assertTrue($eventIsThrown);

tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function testGet3DFormDataSubMerchant(): void
182182
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
183183
'orderId' => '2020110828BC',
184184
'lang' => 'TR',
185-
'amount' => '1.1',
185+
'amount' => '1.10',
186186
'currencyCode' => '949',
187187
'installCount' => '1',
188188
'okUrl' => 'http:://localhost/success',
@@ -270,7 +270,7 @@ public function testCreate3DPaymentSubMerchantRequestData(): void
270270
'orderId' => '2020110828BC',
271271
],
272272
'transaction' => [
273-
'amount' => 1.1,
273+
'amount' => '1.10',
274274
'currencyCode' => 949,
275275
'motoInd' => 0,
276276
'installCount' => 1,
@@ -679,7 +679,7 @@ public static function refundRequestDataProvider(): array
679679
'orderId' => '2020110828BC',
680680
],
681681
'transaction' => [
682-
'amount' => 1.02,
682+
'amount' => '1.02',
683683
'currencyCode' => 949,
684684
],
685685
],
@@ -702,7 +702,7 @@ public static function refundRequestDataProvider(): array
702702
'orderTrackId' => '2020110828BC',
703703
],
704704
'transaction' => [
705-
'amount' => 1.02,
705+
'amount' => '1.02',
706706
'currencyCode' => 949,
707707
],
708708
'version' => '1.00',
@@ -744,7 +744,7 @@ public static function nonSecurePaymentRequestDataProvider(): array
744744
'orderId' => '2020110828BC',
745745
],
746746
'transaction' => [
747-
'amount' => 1.1,
747+
'amount' => '1.10',
748748
'currencyCode' => 949,
749749
'motoInd' => 0,
750750
'installCount' => 1,
@@ -780,7 +780,7 @@ public static function nonSecurePaymentRequestDataProvider(): array
780780
'orderId' => '2020110828BC',
781781
],
782782
'transaction' => [
783-
'amount' => 1.1,
783+
'amount' => '1.10',
784784
'currencyCode' => 949,
785785
'motoInd' => 0,
786786
'installCount' => 2,
@@ -816,7 +816,7 @@ public static function nonSecurePaymentRequestDataProvider(): array
816816
'orderId' => '2020110828BC',
817817
],
818818
'transaction' => [
819-
'amount' => 1.1,
819+
'amount' => '1.10',
820820
'currencyCode' => 949,
821821
'motoInd' => 0,
822822
'installCount' => 1,
@@ -856,7 +856,7 @@ public static function nonSecurePaymentRequestDataProvider(): array
856856
'orderTrackId' => '2020110828BC',
857857
],
858858
'transaction' => [
859-
'amount' => 1.1,
859+
'amount' => '1.10',
860860
'currencyCode' => 949,
861861
'motoInd' => 1,
862862
'installCount' => 1,
@@ -896,7 +896,7 @@ public static function nonSecurePaymentPostRequestDataProvider(): array
896896
'orderId' => '2020110828BC',
897897
],
898898
'transaction' => [
899-
'amount' => 1.1,
899+
'amount' => '1.10',
900900
'currencyCode' => 949,
901901
],
902902
'customer' => [
@@ -953,7 +953,7 @@ public static function threeDFormDataProvider(): array
953953
'3d_host_form_data' => [
954954
'order' => [
955955
'id' => '2020110828BC',
956-
'amount' => 1.10,
956+
'amount' => 10,
957957
'ip' => '127.0.0.1',
958958
'installment' => 0,
959959
'currency' => PosInterface::CURRENCY_TRY,
@@ -974,7 +974,7 @@ public static function threeDFormDataProvider(): array
974974
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
975975
'orderId' => '2020110828BC',
976976
'lang' => 'TR',
977-
'amount' => '1.1',
977+
'amount' => '10.00',
978978
'currencyCode' => '949',
979979
'installCount' => '1',
980980
'okUrl' => 'http:://localhost/success',
@@ -987,7 +987,7 @@ public static function threeDFormDataProvider(): array
987987
'3d_pay_form_data' => [
988988
'order' => [
989989
'id' => '2020110828BC',
990-
'amount' => 1.10,
990+
'amount' => 1.1,
991991
'ip' => '127.0.0.1',
992992
'installment' => 0,
993993
'currency' => PosInterface::CURRENCY_TRY,
@@ -1008,7 +1008,7 @@ public static function threeDFormDataProvider(): array
10081008
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
10091009
'orderId' => '2020110828BC',
10101010
'lang' => 'TR',
1011-
'amount' => '1.1',
1011+
'amount' => '1.10',
10121012
'currencyCode' => '949',
10131013
'installCount' => '1',
10141014
'okUrl' => 'http:://localhost/success',
@@ -1024,7 +1024,7 @@ public static function threeDFormDataProvider(): array
10241024
'3d_form_data' => [
10251025
'order' => [
10261026
'id' => '2020110828BC',
1027-
'amount' => 1.10,
1027+
'amount' => 1.1,
10281028
'ip' => '127.0.0.1',
10291029
'installment' => 0,
10301030
'currency' => PosInterface::CURRENCY_TRY,
@@ -1045,7 +1045,7 @@ public static function threeDFormDataProvider(): array
10451045
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
10461046
'orderId' => '2020110828BC',
10471047
'lang' => 'TR',
1048-
'amount' => '1.1',
1048+
'amount' => '1.10',
10491049
'currencyCode' => '949',
10501050
'installCount' => '1',
10511051
'okUrl' => 'http:://localhost/success',
@@ -1061,7 +1061,7 @@ public static function threeDFormDataProvider(): array
10611061
'3d_pre_pay_form_data' => [
10621062
'order' => [
10631063
'id' => '2020110828BC',
1064-
'amount' => 1.10,
1064+
'amount' => 1000,
10651065
'ip' => '127.0.0.1',
10661066
'installment' => 0,
10671067
'currency' => PosInterface::CURRENCY_TRY,
@@ -1082,7 +1082,7 @@ public static function threeDFormDataProvider(): array
10821082
'terminalSafeId' => '2023090417500284633D137A249DBBEB',
10831083
'orderId' => '2020110828BC',
10841084
'lang' => 'TR',
1085-
'amount' => '1.1',
1085+
'amount' => '1000.00',
10861086
'currencyCode' => '949',
10871087
'installCount' => '1',
10881088
'okUrl' => 'http:://localhost/success',
@@ -1121,7 +1121,7 @@ public static function create3DPaymentRequestDataDataProvider(): \Generator
11211121
'orderId' => '2020110828BC',
11221122
],
11231123
'transaction' => [
1124-
'amount' => 100.25,
1124+
'amount' => '100.25',
11251125
'currencyCode' => 949,
11261126
'motoInd' => 0,
11271127
'installCount' => 1,

0 commit comments

Comments
 (0)