From 1f460d302738712d6fd1e69c26c765a4f0407b46 Mon Sep 17 00:00:00 2001 From: mustapayev Date: Tue, 24 Dec 2024 16:41:39 +0100 Subject: [PATCH] feat: get3DFormData support for form data generation without card. default value of $createWithoutCard is set to true for backward compatibility. In the next major version it will be false. These changes are fix to backward compatibility break on commit ec4e4617 --- docs/PRE-AUTH-POST-EXAMPLE.md | 3 ++- docs/THREED-PAYMENT-EXAMPLE.md | 3 ++- ...ED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md | 3 ++- examples/_common-codes/3d/form.php | 2 +- src/Gateways/AbstractGateway.php | 7 ++++++- src/Gateways/AkbankPos.php | 4 ++-- src/Gateways/EstPos.php | 4 ++-- src/Gateways/GarantiPos.php | 4 ++-- src/Gateways/InterPos.php | 4 ++-- src/Gateways/KuveytPos.php | 4 ++-- src/Gateways/PayFlexCPV4Pos.php | 4 ++-- src/Gateways/PayFlexV4Pos.php | 2 +- src/Gateways/PayForPos.php | 4 ++-- src/Gateways/PosNet.php | 2 +- src/Gateways/PosNetV1Pos.php | 4 ++-- src/Gateways/ToslaPos.php | 4 ++-- src/Gateways/VakifKatilimPos.php | 4 ++-- src/PosInterface.php | 3 ++- .../AkbankPosRequestDataMapperTest.php | 1 - tests/Unit/Gateways/AkbankPosTest.php | 6 +++++- tests/Unit/Gateways/EstPosTest.php | 5 ++++- tests/Unit/Gateways/GarantiPosTest.php | 10 +++++++--- tests/Unit/Gateways/InterPosTest.php | 11 ++++++++--- tests/Unit/Gateways/KuveytPosTest.php | 10 +++++++--- tests/Unit/Gateways/PayFlexCPV4PosTest.php | 5 ++++- tests/Unit/Gateways/PayForTest.php | 6 +++++- tests/Unit/Gateways/PosNetV1PosTest.php | 5 ++++- tests/Unit/Gateways/ToslaPosTest.php | 5 ++++- tests/Unit/Gateways/VakifKatilimTest.php | 13 +++++++++---- 29 files changed, 94 insertions(+), 48 deletions(-) diff --git a/docs/PRE-AUTH-POST-EXAMPLE.md b/docs/PRE-AUTH-POST-EXAMPLE.md index 460c6b19..08ee6238 100644 --- a/docs/PRE-AUTH-POST-EXAMPLE.md +++ b/docs/PRE-AUTH-POST-EXAMPLE.md @@ -115,7 +115,8 @@ try { $order, $paymentModel, $transactionType, - $card + $card, + false ); } catch (\Exception|\Error $e) { var_dump($e); diff --git a/docs/THREED-PAYMENT-EXAMPLE.md b/docs/THREED-PAYMENT-EXAMPLE.md index c7b721ce..456a1f53 100644 --- a/docs/THREED-PAYMENT-EXAMPLE.md +++ b/docs/THREED-PAYMENT-EXAMPLE.md @@ -225,7 +225,8 @@ try { $order, $paymentModel, $transactionType, - $card + $card, + false ); } catch (\InvalidArgumentException $e) { // örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız. diff --git a/docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md b/docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md index d962d73d..d95edb09 100644 --- a/docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md +++ b/docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md @@ -144,7 +144,8 @@ try { $order, $paymentModel, $transactionType, - $card + $card, + false ); } catch (\InvalidArgumentException $e) { // örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız. diff --git a/examples/_common-codes/3d/form.php b/examples/_common-codes/3d/form.php index ebe5b7b3..7df39b30 100644 --- a/examples/_common-codes/3d/form.php +++ b/examples/_common-codes/3d/form.php @@ -163,7 +163,7 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void { // ============================================================================================ try { - $formData = $pos->get3DFormData($order, $paymentModel, $transaction, $card); + $formData = $pos->get3DFormData($order, $paymentModel, $transaction, $card, false); //dd($formData); } catch (\InvalidArgumentException $e) { // örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız. diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 7a12f4e1..fcc429a2 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -655,15 +655,20 @@ protected function is3DAuthSuccess(array $responseData): bool * @param PosInterface::MODEL_3D_* $paymentModel * @param PosInterface::TX_TYPE_PAY_AUTH|PosInterface::TX_TYPE_PAY_PRE_AUTH $txType * @param CreditCardInterface|null $card + * @param bool $createWithoutCard * * @throws \InvalidArgumentException when inputs are not valid */ - protected function check3DFormInputs(string $paymentModel, string $txType, CreditCardInterface $card = null): void + protected function check3DFormInputs(string $paymentModel, string $txType, CreditCardInterface $card = null, bool $createWithoutCard = false): void { if (!self::isSupportedTransaction($txType, $paymentModel)) { throw new \LogicException('Bu banka altyapısı sağlanan ödeme modelini ya da işlem tipini desteklenmiyor.'); } + if ($createWithoutCard) { + return; + } + if ((PosInterface::MODEL_3D_SECURE === $paymentModel || PosInterface::MODEL_3D_PAY === $paymentModel) && !$card instanceof \Mews\Pos\Entity\Card\CreditCardInterface) { throw new \InvalidArgumentException('Bu ödeme modeli için kart bilgileri zorunlu!'); diff --git a/src/Gateways/AkbankPos.php b/src/Gateways/AkbankPos.php index 96e56eb2..aeb2d0f8 100644 --- a/src/Gateways/AkbankPos.php +++ b/src/Gateways/AkbankPos.php @@ -158,9 +158,9 @@ public function make3DHostPayment(Request $request, array $order, string $txType /** * @inheritDoc */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); $this->logger->debug('preparing 3D form data'); diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index 10460d6e..6d338952 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -155,9 +155,9 @@ public function make3DHostPayment(Request $request, array $order, string $txType /** * @inheritDoc */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); $this->logger->debug('preparing 3D form data'); diff --git a/src/Gateways/GarantiPos.php b/src/Gateways/GarantiPos.php index 2d12a957..da8c987d 100644 --- a/src/Gateways/GarantiPos.php +++ b/src/Gateways/GarantiPos.php @@ -125,9 +125,9 @@ public function make3DPayPayment(Request $request, array $order, string $txType) /** * @inheritDoc */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); $this->logger->debug('preparing 3D form data'); diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 306e20d1..40789d3c 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -159,9 +159,9 @@ public function orderHistory(array $order): PosInterface /** * @inheritDoc */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); $this->logger->debug('preparing 3D form data'); diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index d3f4c29a..34fd4952 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -132,9 +132,9 @@ public function orderHistory(array $order): PosInterface * * @throws SoapFault */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); $this->logger->debug('preparing 3D form data'); diff --git a/src/Gateways/PayFlexCPV4Pos.php b/src/Gateways/PayFlexCPV4Pos.php index c8f08dd0..0e37a9ec 100644 --- a/src/Gateways/PayFlexCPV4Pos.php +++ b/src/Gateways/PayFlexCPV4Pos.php @@ -174,9 +174,9 @@ public function orderHistory(array $order): PosInterface /** * {@inheritDoc} */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); /** @var array{CommonPaymentUrl: string|null, PaymentToken: string|null, ErrorCode: string|null, ResponseMessage: string|null} $data */ $data = $this->registerPayment($order, $txType, $paymentModel, $creditCard); diff --git a/src/Gateways/PayFlexV4Pos.php b/src/Gateways/PayFlexV4Pos.php index 837a5ef1..944a7705 100644 --- a/src/Gateways/PayFlexV4Pos.php +++ b/src/Gateways/PayFlexV4Pos.php @@ -156,7 +156,7 @@ public function orderHistory(array $order): PosInterface /** * {@inheritDoc} */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { $this->check3DFormInputs($paymentModel, $txType, $creditCard); diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index 2b6c6299..329a2e3f 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -166,9 +166,9 @@ public function orderHistory(array $order): PosInterface /** * {@inheritDoc} */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); $this->logger->debug('preparing 3D form data'); diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index da6fcd04..678e6654 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -164,7 +164,7 @@ public function make3DHostPayment(Request $request, array $order, string $txType /** * @inheritDoc */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { $this->check3DFormInputs($paymentModel, $txType, $creditCard); diff --git a/src/Gateways/PosNetV1Pos.php b/src/Gateways/PosNetV1Pos.php index 95b8ddb4..ab465d1f 100644 --- a/src/Gateways/PosNetV1Pos.php +++ b/src/Gateways/PosNetV1Pos.php @@ -146,9 +146,9 @@ public function make3DHostPayment(Request $request, array $order, string $txType /** * @inheritDoc */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); $this->logger->debug('preparing 3D form data'); diff --git a/src/Gateways/ToslaPos.php b/src/Gateways/ToslaPos.php index 60e81046..942fbb9c 100644 --- a/src/Gateways/ToslaPos.php +++ b/src/Gateways/ToslaPos.php @@ -143,9 +143,9 @@ public function make3DHostPayment(Request $request, array $order, string $txType /** * @inheritDoc */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); $data = $this->registerPayment($order, $paymentModel, $txType); diff --git a/src/Gateways/VakifKatilimPos.php b/src/Gateways/VakifKatilimPos.php index 5ef7f7a4..100fcc82 100644 --- a/src/Gateways/VakifKatilimPos.php +++ b/src/Gateways/VakifKatilimPos.php @@ -99,9 +99,9 @@ public function make3DHostPayment(Request $request, array $order, string $txType /** * @inheritDoc */ - public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array + public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array { - $this->check3DFormInputs($paymentModel, $txType, $creditCard); + $this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard); $this->logger->debug('preparing 3D form data'); diff --git a/src/PosInterface.php b/src/PosInterface.php index 11a67797..e00116eb 100644 --- a/src/PosInterface.php +++ b/src/PosInterface.php @@ -118,6 +118,7 @@ interface PosInterface * @param string $paymentModel * @param string $txType * @param CreditCardInterface|null $creditCard + * @param bool $createWithoutCard 3D ve 3D_PAY ödemelerde kart bilgisi olmadan 3D formu oluşturulmasına izin verir. * * @return array{gateway: string, method: 'POST'|'GET', inputs: array} * @@ -128,7 +129,7 @@ interface PosInterface * @throws UnsupportedTransactionTypeException * @throws ClientExceptionInterface */ - public function get3DFormData(array $order, string $paymentModel, string $txType, ?CreditCardInterface $creditCard = null): array; + public function get3DFormData(array $order, string $paymentModel, string $txType, ?CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array; /** * Regular Payment diff --git a/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php index 53cc1c99..d02686e8 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/AkbankPosRequestDataMapperTest.php @@ -39,7 +39,6 @@ class AkbankPosRequestDataMapperTest extends TestCase private array $order; - /** @var MockObject|EventDispatcherInterface */ private EventDispatcherInterface $dispatcher; protected function setUp(): void diff --git a/tests/Unit/Gateways/AkbankPosTest.php b/tests/Unit/Gateways/AkbankPosTest.php index 3381f5dd..a7d70194 100644 --- a/tests/Unit/Gateways/AkbankPosTest.php +++ b/tests/Unit/Gateways/AkbankPosTest.php @@ -404,6 +404,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -411,7 +412,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -875,6 +876,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], '3d_pay_without_card' => [ @@ -882,6 +884,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_PAY, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], 'unsupported_payment_model' => [ @@ -889,6 +892,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_PAY_HOSTING, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => true, 'expectedExceptionClass' => \LogicException::class, ], ]; diff --git a/tests/Unit/Gateways/EstPosTest.php b/tests/Unit/Gateways/EstPosTest.php index c8a68826..7f90e978 100644 --- a/tests/Unit/Gateways/EstPosTest.php +++ b/tests/Unit/Gateways/EstPosTest.php @@ -186,6 +186,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -193,7 +194,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -831,6 +832,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], '3d_pay_without_card' => [ @@ -838,6 +840,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_PAY, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], ]; diff --git a/tests/Unit/Gateways/GarantiPosTest.php b/tests/Unit/Gateways/GarantiPosTest.php index 9a7fbb67..ec1df7d3 100644 --- a/tests/Unit/Gateways/GarantiPosTest.php +++ b/tests/Unit/Gateways/GarantiPosTest.php @@ -175,6 +175,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -182,7 +183,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -741,18 +742,20 @@ public static function orderHistoryRequestDataProvider(): array public static function threeDFormDataBadInputsProvider(): array { return [ - '3d_secure_without_card' => [ + '3d_secure_without_card' => [ 'order' => ['id' => '2020110828BC'], 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], - '3d_pay_without_card' => [ + '3d_pay_without_card' => [ 'order' => ['id' => '2020110828BC'], 'paymentModel' => PosInterface::MODEL_3D_PAY, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], 'unsupported_payment_model' => [ @@ -760,6 +763,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_HOST, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => true, 'expectedExceptionClass' => \LogicException::class, ], ]; diff --git a/tests/Unit/Gateways/InterPosTest.php b/tests/Unit/Gateways/InterPosTest.php index 161aa826..159bc58c 100644 --- a/tests/Unit/Gateways/InterPosTest.php +++ b/tests/Unit/Gateways/InterPosTest.php @@ -2,6 +2,7 @@ /** * @license MIT */ + namespace Mews\Pos\Tests\Unit\Gateways; use Mews\Pos\Client\HttpClient; @@ -184,6 +185,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -191,7 +193,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -682,18 +684,20 @@ public static function refundRequestDataProvider(): array public static function threeDFormDataBadInputsProvider(): array { return [ - '3d_secure_without_card' => [ + '3d_secure_without_card' => [ 'order' => ['id' => '2020110828BC'], 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], - '3d_pay_without_card' => [ + '3d_pay_without_card' => [ 'order' => ['id' => '2020110828BC'], 'paymentModel' => PosInterface::MODEL_3D_PAY, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], 'unsupported_payment_model' => [ @@ -701,6 +705,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_PAY_HOSTING, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \LogicException::class, ], ]; diff --git a/tests/Unit/Gateways/KuveytPosTest.php b/tests/Unit/Gateways/KuveytPosTest.php index 81650cfb..3e952462 100644 --- a/tests/Unit/Gateways/KuveytPosTest.php +++ b/tests/Unit/Gateways/KuveytPosTest.php @@ -243,6 +243,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -250,7 +251,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -599,11 +600,12 @@ public static function getApiUrlExceptionDataProvider(): array public static function threeDFormDataBadInputsProvider(): array { return [ - '3d_secure_without_card' => [ + '3d_secure_without_card' => [ 'order' => ['id' => '2020110828BC'], 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], 'unsupported_payment_model' => [ @@ -611,13 +613,15 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_HOST, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => true, 'expectedExceptionClass' => \LogicException::class, ], - 'unsupported_tx' => [ + 'unsupported_tx' => [ 'order' => ['id' => '2020110828BC'], 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_PRE_AUTH, 'isWithCard' => false, + 'create_without_card' => true, 'expectedExceptionClass' => \LogicException::class, ], ]; diff --git a/tests/Unit/Gateways/PayFlexCPV4PosTest.php b/tests/Unit/Gateways/PayFlexCPV4PosTest.php index f0ff9504..eafe3e7b 100644 --- a/tests/Unit/Gateways/PayFlexCPV4PosTest.php +++ b/tests/Unit/Gateways/PayFlexCPV4PosTest.php @@ -256,6 +256,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -263,7 +264,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } public function testMake3DPayment(): void @@ -647,6 +648,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_PAY, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], 'unsupported_payment_model' => [ @@ -654,6 +656,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => true, 'expectedExceptionClass' => \LogicException::class, ], ]; diff --git a/tests/Unit/Gateways/PayForTest.php b/tests/Unit/Gateways/PayForTest.php index 8d87ac8d..8fc2dcd8 100644 --- a/tests/Unit/Gateways/PayForTest.php +++ b/tests/Unit/Gateways/PayForTest.php @@ -188,6 +188,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -195,7 +196,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -792,6 +793,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], '3d_pay_without_card' => [ @@ -799,6 +801,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_PAY, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], 'unsupported_payment_model' => [ @@ -806,6 +809,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_PAY_HOSTING, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => true, 'expectedExceptionClass' => \LogicException::class, ], ]; diff --git a/tests/Unit/Gateways/PosNetV1PosTest.php b/tests/Unit/Gateways/PosNetV1PosTest.php index 4c0ad76e..781f8a19 100644 --- a/tests/Unit/Gateways/PosNetV1PosTest.php +++ b/tests/Unit/Gateways/PosNetV1PosTest.php @@ -188,6 +188,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -195,7 +196,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -719,6 +720,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], 'unsupported_payment_model' => [ @@ -726,6 +728,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_HOST, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => true, 'expectedExceptionClass' => \LogicException::class, ], ]; diff --git a/tests/Unit/Gateways/ToslaPosTest.php b/tests/Unit/Gateways/ToslaPosTest.php index fc64d546..4c84e5c7 100644 --- a/tests/Unit/Gateways/ToslaPosTest.php +++ b/tests/Unit/Gateways/ToslaPosTest.php @@ -352,6 +352,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -359,7 +360,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -1084,6 +1085,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_PAY, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], 'unsupported_payment_model' => [ @@ -1091,6 +1093,7 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_without_card' => true, 'expectedExceptionClass' => \LogicException::class, ], ]; diff --git a/tests/Unit/Gateways/VakifKatilimTest.php b/tests/Unit/Gateways/VakifKatilimTest.php index ff0ea997..b5271863 100644 --- a/tests/Unit/Gateways/VakifKatilimTest.php +++ b/tests/Unit/Gateways/VakifKatilimTest.php @@ -254,6 +254,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -261,7 +262,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -908,11 +909,12 @@ public static function orderHistoryRequestDataProvider(): array public static function threeDFormDataBadInputsProvider(): array { return [ - '3d_secure_without_card' => [ + '3d_secure_without_card' => [ 'order' => ['id' => '2020110828BC'], 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => false, 'expectedExceptionClass' => \InvalidArgumentException::class, ], 'unsupported_payment_model' => [ @@ -920,20 +922,23 @@ public static function threeDFormDataBadInputsProvider(): array 'paymentModel' => PosInterface::MODEL_3D_PAY, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'isWithCard' => false, + 'create_with_card' => true, 'expectedExceptionClass' => \LogicException::class, ], - 'unsupported_3d_secure_tx' => [ + 'unsupported_3d_secure_tx' => [ 'order' => ['id' => '2020110828BC'], 'paymentModel' => PosInterface::MODEL_3D_SECURE, 'txType' => PosInterface::TX_TYPE_PAY_PRE_AUTH, 'isWithCard' => false, + 'create_with_card' => true, 'expectedExceptionClass' => \LogicException::class, ], - 'unsupported_3d_host_tx' => [ + 'unsupported_3d_host_tx' => [ 'order' => ['id' => '2020110828BC'], 'paymentModel' => PosInterface::MODEL_3D_HOST, 'txType' => PosInterface::TX_TYPE_PAY_PRE_AUTH, 'isWithCard' => false, + 'create_with_card' => true, 'expectedExceptionClass' => \LogicException::class, ], ];