diff --git a/composer.json b/composer.json index 006fe0c6..ee42d1ca 100644 --- a/composer.json +++ b/composer.json @@ -39,10 +39,10 @@ "escapestudios/symfony2-coding-standard": "^3.11", "monolog/monolog": "^2.8", "php-http/curl-client": "^2.2", - "phpstan/phpstan": "^1.11", - "phpstan/phpstan-strict-rules": "^1.4", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^9", - "rector/rector": "^1.1", + "rector/rector": "^2.0", "slim/psr7": "^1.4", "squizlabs/php_codesniffer": "^3.5", "symfony/event-dispatcher": "^5.4", @@ -57,5 +57,11 @@ "allow-plugins": { "php-http/discovery": true } + }, + "scripts": { + "test": "./vendor/bin/phpunit --testsuite=unit", + "phpstan": "./vendor/bin/phpstan", + "baseline": "./vendor/bin/phpstan --generate-baseline", + "rector": "./vendor/bin/rector" } } 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/phpstan-baseline.neon b/phpstan-baseline.neon index dc95d65a..2097f0ca 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,191 +1,235 @@ parameters: ignoreErrors: - - message: "#^Parameter \\#1 \\$body of method Psr\\\\Http\\\\Message\\\\MessageInterface\\:\\:withBody\\(\\) expects Psr\\\\Http\\\\Message\\\\StreamInterface, Psr\\\\Http\\\\Message\\\\StreamInterface\\|null given\\.$#" + message: '#^Parameter \#1 \$body of method Psr\\Http\\Message\\MessageInterface\:\:withBody\(\) expects Psr\\Http\\Message\\StreamInterface, Psr\\Http\\Message\\StreamInterface\|null given\.$#' + identifier: argument.type count: 1 path: src/Client/HttpClient.php - - message: "#^Parameter \\#1 \\$content of method Psr\\\\Http\\\\Message\\\\StreamFactoryInterface\\:\\:createStream\\(\\) expects string, array\\\\|string given\\.$#" + message: '#^Parameter \#1 \$content of method Psr\\Http\\Message\\StreamFactoryInterface\:\:createStream\(\) expects string, array\\|string given\.$#' + identifier: argument.type count: 1 path: src/Client/HttpClient.php - - message: "#^Default value of the parameter \\#3 \\$order \\(array\\{\\}\\) of method Mews\\\\Pos\\\\Crypt\\\\PosNetCrypt\\:\\:createHash\\(\\) is incompatible with type array\\{amount\\: int, currency\\: string, id\\: string\\}\\.$#" + message: '#^Default value of the parameter \#3 \$order \(array\{\}\) of method Mews\\Pos\\Crypt\\PosNetCrypt\:\:createHash\(\) is incompatible with type array\{amount\: int, currency\: string, id\: string\}\.$#' + identifier: parameter.defaultValue count: 1 path: src/Crypt/PosNetCrypt.php - - message: "#^Parameter \\#1 \\$currency of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\AkbankPosRequestDataMapper\\:\\:mapCurrency\\(\\) expects 'EUR'\\|'GBP'\\|'JPY'\\|'RUB'\\|'TRY'\\|'USD', string given\\.$#" + message: '#^PHPDoc tag @var with type array\ is not subtype of native type array\{mixed, mixed, mixed, mixed, mixed, mixed, string\}\.$#' + identifier: varTag.nativeType + count: 1 + path: src/Crypt/PosNetV1PosCrypt.php + + - + message: '#^Parameter \#1 \$currency of method Mews\\Pos\\DataMapper\\RequestDataMapper\\AkbankPosRequestDataMapper\:\:mapCurrency\(\) expects ''EUR''\|''GBP''\|''JPY''\|''RUB''\|''TRY''\|''USD'', string given\.$#' + identifier: argument.type count: 5 path: src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php - - message: "#^Parameter \\#1 \\$currency of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\EstPosRequestDataMapper\\:\\:mapCurrency\\(\\) expects 'EUR'\\|'GBP'\\|'JPY'\\|'RUB'\\|'TRY'\\|'USD', string given\\.$#" + message: '#^Parameter \#1 \$currency of method Mews\\Pos\\DataMapper\\RequestDataMapper\\EstPosRequestDataMapper\:\:mapCurrency\(\) expects ''EUR''\|''GBP''\|''JPY''\|''RUB''\|''TRY''\|''USD'', string given\.$#' + identifier: argument.type count: 1 path: src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php - - message: "#^Default value of the parameter \\#7 \\$extraData \\(array\\{\\}\\) of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayFlexCPV4PosRequestDataMapper\\:\\:create3DFormData\\(\\) is incompatible with type array\\{CommonPaymentUrl\\: string, PaymentToken\\: string\\}\\.$#" + message: '#^Default value of the parameter \#7 \$extraData \(array\{\}\) of method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayFlexCPV4PosRequestDataMapper\:\:create3DFormData\(\) is incompatible with type array\{CommonPaymentUrl\: string, PaymentToken\: string\}\.$#' + identifier: parameter.defaultValue count: 1 path: src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php - - message: "#^Default value of the parameter \\#7 \\$extraData \\(array\\{\\}\\) of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayFlexV4PosRequestDataMapper\\:\\:create3DFormData\\(\\) is incompatible with type array\\{PaReq\\: string, TermUrl\\: string, MD\\: string, ACSUrl\\: string\\}\\.$#" + message: '#^Default value of the parameter \#7 \$extraData \(array\{\}\) of method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayFlexV4PosRequestDataMapper\:\:create3DFormData\(\) is incompatible with type array\{PaReq\: string, TermUrl\: string, MD\: string, ACSUrl\: string\}\.$#' + identifier: parameter.defaultValue count: 1 path: src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayFlexV4PosRequestDataMapper\\:\\:create3DEnrollmentCheckRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayFlexV4PosRequestDataMapper\:\:create3DEnrollmentCheckRequestData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php - - message: "#^Default value of the parameter \\#2 \\$data \\(array\\{\\}\\) of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayForPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) is incompatible with type array\\{transaction_date\\: DateTimeInterface\\}\\.$#" + message: '#^Default value of the parameter \#2 \$data \(array\{\}\) of method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayForPosRequestDataMapper\:\:createHistoryRequestData\(\) is incompatible with type array\{transaction_date\: DateTimeInterface\}\.$#' + identifier: parameter.defaultValue count: 1 path: src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php - - message: "#^Cannot assign offset 'authCode' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''authCode'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Cannot assign offset 'hostLogKey' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''hostLogKey'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Cannot assign offset 'hostLogKey' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''hostLogKey'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Cannot assign offset 'orderID' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''orderID'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Cannot assign offset 'orderID' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''orderID'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PosNetRequestDataMapper\\:\\:create3DEnrollmentCheckRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\RequestDataMapper\\PosNetRequestDataMapper\:\:create3DEnrollmentCheckRequestData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PosNetV1PosRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$extraData with no type specified\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\RequestDataMapper\\PosNetV1PosRequestDataMapper\:\:create3DFormData\(\) has parameter \$extraData with no type specified\.$#' + identifier: missingType.parameter count: 1 path: src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php - - message: "#^Argument of an invalid type array\\|object supplied for foreach, only iterables are supported\\.$#" + message: '#^Argument of an invalid type array\\|object supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable count: 1 path: src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\GarantiPosResponseDataMapper\\:\\:mapCancelResponse\\(\\) should return array\\ but returns array\\\\|string\\>\\|string\\|null\\>\\|string\\|null\\>\\.$#" - count: 1 - path: src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php - - - - message: "#^Offset 'ErrorMsg' does not exist on array\\\\|string\\.$#" + message: '#^Offset ''ErrorMsg'' might not exist on array\\|string\.$#' + identifier: offsetAccess.notFound count: 2 path: src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php - - message: "#^Offset 'ReasonCode' does not exist on array\\\\|string\\.$#" + message: '#^Offset ''ReasonCode'' might not exist on array\\|string\.$#' + identifier: offsetAccess.notFound count: 2 path: src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\KuveytPosResponseDataMapper\\:\\:mapStatusResponse\\(\\) has parameter \\$rawResponseData with no value type specified in iterable type array\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\ResponseDataMapper\\KuveytPosResponseDataMapper\:\:mapStatusResponse\(\) has parameter \$rawResponseData with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\PayFlexV4PosResponseDataMapper\\:\\:getCommonPaymentResponse\\(\\) should return array\\ but returns array\\\\|string\\|null\\>\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\ResponseDataMapper\\PayFlexV4PosResponseDataMapper\:\:getCommonPaymentResponse\(\) should return array\ but returns array\\|string\|null\>\.$#' + identifier: return.type count: 1 path: src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php - - message: "#^Property Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\AbstractResponseDataMapper\\:\\:\\$secureTypeMappings \\(array\\\\) does not accept non\\-empty\\-array\\<1\\|2\\|3\\|string, '3d'\\|'3d_host'\\|'3d_pay'\\|'3d_pay_hosting'\\|'regular'\\>\\.$#" + message: '#^Property Mews\\Pos\\DataMapper\\ResponseDataMapper\\AbstractResponseDataMapper\:\:\$secureTypeMappings \(array\\) does not accept non\-empty\-array\<1\|2\|3\|string, ''3d''\|''3d_host''\|''3d_pay''\|''3d_pay_hosting''\|''regular''\>\.$#' + identifier: assign.propertyType count: 1 path: src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php - - message: "#^Property Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\AbstractResponseDataMapper\\:\\:\\$currencyMappings \\(array\\\\) does not accept non\\-empty\\-array\\<392\\|643\\|826\\|840\\|949\\|978\\|string, 'EUR'\\|'GBP'\\|'JPY'\\|'RUB'\\|'TRY'\\|'USD'\\>\\.$#" + message: '#^Property Mews\\Pos\\DataMapper\\ResponseDataMapper\\AbstractResponseDataMapper\:\:\$currencyMappings \(array\\) does not accept non\-empty\-array\<392\|643\|826\|840\|949\|978\|string, ''EUR''\|''GBP''\|''JPY''\|''RUB''\|''TRY''\|''USD''\>\.$#' + identifier: assign.propertyType count: 1 path: src/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\Factory\\\\PosFactory\\:\\:createPosGateway\\(\\) should return Mews\\\\Pos\\\\PosInterface but returns object\\.$#" + message: '#^Method Mews\\Pos\\Factory\\PosFactory\:\:createPosGateway\(\) should return Mews\\Pos\\PosInterface but returns object\.$#' + identifier: return.type count: 1 path: src/Factory/PosFactory.php - - message: "#^Parameter \\#2 \\$rawPaymentResponseData of method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\GarantiPosResponseDataMapper\\:\\:map3DPaymentData\\(\\) expects array\\{Order\\: array\\\\|string\\>, Response\\: array\\, Transaction\\: array\\\\|string\\>\\}\\|null, array\\ given\\.$#" + message: '#^Strict comparison using \=\=\= between ''3d_host'' and ''3d_host'' will always evaluate to true\.$#' + identifier: identical.alwaysTrue + count: 1 + path: src/Gateways/AbstractGateway.php + + - + message: '#^Parameter \#2 \$rawPaymentResponseData of method Mews\\Pos\\DataMapper\\ResponseDataMapper\\GarantiPosResponseDataMapper\:\:map3DPaymentData\(\) expects array\{Order\: array\\|string\>, Response\: array\, Transaction\: array\\|string\>\}\|null, array\ given\.$#' + identifier: argument.type count: 1 path: src/Gateways/GarantiPos.php - - message: "#^Parameter \\#1 \\$raw3DAuthResponseData of method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\PayFlexCPV4PosResponseDataMapper\\:\\:map3DPayResponseData\\(\\) expects array\\{ErrorCode\\: string\\}\\|array\\{Rc\\: string, AuthCode\\: string, TransactionId\\: string, PaymentToken\\: string, MaskedPan\\: string\\}\\|array\\{Rc\\: string, Message\\: string, TransactionId\\: string, PaymentToken\\: string\\}, array given\\.$#" + message: '#^Parameter \#1 \$raw3DAuthResponseData of method Mews\\Pos\\DataMapper\\ResponseDataMapper\\PayFlexCPV4PosResponseDataMapper\:\:map3DPayResponseData\(\) expects array\{ErrorCode\: string\}\|array\{Rc\: string, AuthCode\: string, TransactionId\: string, PaymentToken\: string, MaskedPan\: string\}\|array\{Rc\: string, Message\: string, TransactionId\: string, PaymentToken\: string\}, array given\.$#' + identifier: argument.type count: 1 path: src/Gateways/PayFlexCPV4Pos.php - - message: "#^Parameter \\#7 \\$extraData of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayFlexCPV4PosRequestDataMapper\\:\\:create3DFormData\\(\\) expects array\\{CommonPaymentUrl\\: string, PaymentToken\\: string\\}, array\\{CommonPaymentUrl\\: string\\|null, PaymentToken\\: string\\|null, ErrorCode\\: null, ResponseMessage\\: string\\|null\\} given\\.$#" + message: '#^Parameter \#7 \$extraData of method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayFlexCPV4PosRequestDataMapper\:\:create3DFormData\(\) expects array\{CommonPaymentUrl\: string, PaymentToken\: string\}, array\{CommonPaymentUrl\: string\|null, PaymentToken\: string\|null, ErrorCode\: null, ResponseMessage\: string\|null\} given\.$#' + identifier: argument.type count: 1 path: src/Gateways/PayFlexCPV4Pos.php - - message: "#^Parameter \\#2 \\$creditCard of method Mews\\\\Pos\\\\Gateways\\\\PayFlexV4Pos\\:\\:sendEnrollmentRequest\\(\\) expects Mews\\\\Pos\\\\Entity\\\\Card\\\\CreditCardInterface, Mews\\\\Pos\\\\Entity\\\\Card\\\\CreditCardInterface\\|null given\\.$#" + message: '#^Parameter \#2 \$creditCard of method Mews\\Pos\\Gateways\\PayFlexV4Pos\:\:sendEnrollmentRequest\(\) expects Mews\\Pos\\Entity\\Card\\CreditCardInterface, Mews\\Pos\\Entity\\Card\\CreditCardInterface\|null given\.$#' + identifier: argument.type count: 1 path: src/Gateways/PayFlexV4Pos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\PosNet\\:\\:getOosTransactionData\\(\\) should return array\\{approved\\: string, respCode\\: string, respText\\: string, oosRequestDataResponse\\?\\: array\\{data1\\: string, data2\\: string, sign\\: string\\}\\} but returns array\\\\.$#" + message: '#^Method Mews\\Pos\\Gateways\\PosNet\:\:getOosTransactionData\(\) should return array\{approved\: string, respCode\: string, respText\: string, oosRequestDataResponse\?\: array\{data1\: string, data2\: string, sign\: string\}\} but returns array\\.$#' + identifier: return.type count: 1 path: src/Gateways/PosNet.php - - message: "#^Offset 'oosRequestDataRespo…' does not exist on array\\{approved\\: string, respCode\\: string, respText\\: string, oosRequestDataResponse\\?\\: array\\{data1\\: string, data2\\: string, sign\\: string\\}\\}\\.$#" + message: '#^Offset ''oosRequestDataResponse'' might not exist on array\{approved\: string, respCode\: string, respText\: string, oosRequestDataResponse\?\: array\{data1\: string, data2\: string, sign\: string\}\}\.$#' + identifier: offsetAccess.notFound count: 1 path: src/Gateways/PosNet.php - - message: "#^Parameter \\#4 \\$creditCard of method Mews\\\\Pos\\\\Gateways\\\\PosNet\\:\\:getOosTransactionData\\(\\) expects Mews\\\\Pos\\\\Entity\\\\Card\\\\CreditCardInterface, Mews\\\\Pos\\\\Entity\\\\Card\\\\CreditCardInterface\\|null given\\.$#" + message: '#^Parameter \#4 \$creditCard of method Mews\\Pos\\Gateways\\PosNet\:\:getOosTransactionData\(\) expects Mews\\Pos\\Entity\\Card\\CreditCardInterface, Mews\\Pos\\Entity\\Card\\CreditCardInterface\|null given\.$#' + identifier: argument.type count: 1 path: src/Gateways/PosNet.php diff --git a/src/Crypt/EstV3PosCrypt.php b/src/Crypt/EstV3PosCrypt.php index 0250c6d4..0ac9b1c7 100644 --- a/src/Crypt/EstV3PosCrypt.php +++ b/src/Crypt/EstV3PosCrypt.php @@ -35,7 +35,7 @@ public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): } } - $formInputs[] = $posAccount->getStoreKey(); + $formInputs[] = $posAccount->getStoreKey() ?? ''; // escape | and \ characters $data = \str_replace("\\", "\\\\", \array_values($formInputs)); $data = \str_replace(self::HASH_SEPARATOR, "\\".self::HASH_SEPARATOR, $data); diff --git a/src/Crypt/PosNetV1PosCrypt.php b/src/Crypt/PosNetV1PosCrypt.php index 00fc85f6..bf9fc1f1 100644 --- a/src/Crypt/PosNetV1PosCrypt.php +++ b/src/Crypt/PosNetV1PosCrypt.php @@ -80,7 +80,7 @@ public function createHash(AbstractPosAccount $posAccount, array $requestData): $threeDSecureData['CavvData'], $threeDSecureData['Eci'], $threeDSecureData['MdStatus'], - $posAccount->getStoreKey(), + $posAccount->getStoreKey() ?? '', ]; $hashStr = \implode(static::HASH_SEPARATOR, $hashData); diff --git a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php index 5cff29a2..c82211d0 100644 --- a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php @@ -114,7 +114,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array * @param string $txType * @param CreditCardInterface|null $creditCard * - * @return array + * @return array|int|string> * * @throws UnsupportedTransactionTypeException */ @@ -131,16 +131,16 @@ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAc //DisplayAmount: Amount değeri ile aynı olacak şekilde gönderilmelidir. 'DisplayAmount' => $this->formatAmount($order['amount']), 'CurrencyCode' => $this->mapCurrency($order['currency']), - 'MerchantOrderId' => $order['id'], - 'OkUrl' => $order['success_url'], - 'FailUrl' => $order['fail_url'], + 'MerchantOrderId' => (string) $order['id'], + 'OkUrl' => (string) $order['success_url'], + 'FailUrl' => (string) $order['fail_url'], 'DeviceData' => [ - 'ClientIP' => $order['ip'], + 'ClientIP' => (string) $order['ip'], ], ]; if ($creditCard instanceof CreditCardInterface) { - $requestData['CardHolderName'] = $creditCard->getHolderName(); + $requestData['CardHolderName'] = (string) $creditCard->getHolderName(); $requestData['CardType'] = $this->cardTypeMapping[$creditCard->getType()]; $requestData['CardNumber'] = $creditCard->getNumber(); $requestData['CardExpireDateYear'] = $creditCard->getExpireYear(self::CREDIT_CARD_EXP_YEAR_FORMAT); diff --git a/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php index 30685c95..5f94929a 100644 --- a/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php @@ -95,7 +95,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array * @param string $txType * @param CreditCardInterface|null $creditCard * - * @return array + * @return array */ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAccount, array $order, string $paymentModel, string $txType, ?CreditCardInterface $creditCard = null): array { @@ -109,13 +109,13 @@ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAc 'Amount' => $this->formatAmount($order['amount']), 'DisplayAmount' => $this->formatAmount($order['amount']), 'FECCurrencyCode' => $this->mapCurrency($order['currency']), - 'MerchantOrderId' => $order['id'], - 'OkUrl' => $order['success_url'], - 'FailUrl' => $order['fail_url'], + 'MerchantOrderId' => (string) $order['id'], + 'OkUrl' => (string) $order['success_url'], + 'FailUrl' => (string) $order['fail_url'], ]; if ($creditCard instanceof CreditCardInterface) { - $requestData['CardHolderName'] = $creditCard->getHolderName(); + $requestData['CardHolderName'] = (string) $creditCard->getHolderName(); $requestData['CardNumber'] = $creditCard->getNumber(); $requestData['CardExpireDateYear'] = $creditCard->getExpireYear(self::CREDIT_CARD_EXP_YEAR_FORMAT); $requestData['CardExpireDateMonth'] = $creditCard->getExpireMonth(self::CREDIT_CARD_EXP_MONTH_FORMAT); diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php index e5f4910f..a7f609da 100644 --- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php @@ -413,7 +413,7 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string * * @param array $raw3DAuthResponseData * - * @return array + * @return array */ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array { diff --git a/src/DataMapper/ResponseDataMapper/NonPaymentResponseMapperInterface.php b/src/DataMapper/ResponseDataMapper/NonPaymentResponseMapperInterface.php index 91bdca76..9789bac0 100644 --- a/src/DataMapper/ResponseDataMapper/NonPaymentResponseMapperInterface.php +++ b/src/DataMapper/ResponseDataMapper/NonPaymentResponseMapperInterface.php @@ -10,14 +10,14 @@ interface NonPaymentResponseMapperInterface /** * @param array $rawResponseData * - * @return array + * @return array */ public function mapRefundResponse(array $rawResponseData): array; /** * @param array $rawResponseData * - * @return array + * @return array */ public function mapCancelResponse(array $rawResponseData): array; @@ -31,14 +31,14 @@ public function mapStatusResponse(array $rawResponseData): array; /** * @param array|string> $rawResponseData * - * @return array> + * @return array */ public function mapHistoryResponse(array $rawResponseData): array; /** * @param array|string> $rawResponseData * - * @return array> + * @return array */ public function mapOrderHistoryResponse(array $rawResponseData): array; } diff --git a/src/DataMapper/ResponseDataMapper/PaymentResponseMapperInterface.php b/src/DataMapper/ResponseDataMapper/PaymentResponseMapperInterface.php index dad10bd4..fac21d67 100644 --- a/src/DataMapper/ResponseDataMapper/PaymentResponseMapperInterface.php +++ b/src/DataMapper/ResponseDataMapper/PaymentResponseMapperInterface.php @@ -16,7 +16,7 @@ interface PaymentResponseMapperInterface * @param string $txType * @param array $order * - * @return array + * @return array */ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType, array $order): array; @@ -39,7 +39,7 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen * @param string $txType * @param array $order * - * @return array + * @return array */ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txType, array $order): array; @@ -50,7 +50,7 @@ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txTyp * @param string $txType * @param array $order * - * @return array + * @return array */ public function map3DHostResponseData(array $raw3DAuthResponseData, string $txType, array $order): array; diff --git a/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php index cb532986..da6c5ee9 100644 --- a/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php @@ -426,7 +426,7 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string * * @param array $raw3DAuthResponseData * - * @return array + * @return array */ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array { @@ -527,7 +527,7 @@ private function mapSingleOrderHistoryTransaction(array $rawTx): array * @param string $txType * @param array $order * - * @return array + * @return array */ private function map3DPaymentPaymentResponse(array $rawPaymentResponseData, string $txType, array $order): array { diff --git a/src/Factory/SerializerFactory.php b/src/Factory/SerializerFactory.php index 008ed86d..a8000fe5 100644 --- a/src/Factory/SerializerFactory.php +++ b/src/Factory/SerializerFactory.php @@ -32,7 +32,6 @@ class SerializerFactory */ public static function createGatewaySerializer(string $gatewayClass): SerializerInterface { - /** @var SerializerInterface[] $serializers */ $serializers = [ AkbankPosSerializer::class, EstPosSerializer::class, @@ -48,6 +47,7 @@ public static function createGatewaySerializer(string $gatewayClass): Serializer VakifKatilimPosSerializer::class, ]; + /** @var class-string $serializer */ foreach ($serializers as $serializer) { if ($serializer::supports($gatewayClass)) { return new $serializer(); 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..476a31d2 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); @@ -177,6 +177,9 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); + /** @var array{data1: string, data2: string, sign: string} $responseData */ + $responseData = $data['oosRequestDataResponse']; + return $this->requestDataMapper->create3DFormData( $this->account, $order, @@ -184,7 +187,7 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $txType, $this->get3DGatewayURL($paymentModel), null, - $data['oosRequestDataResponse'] + $responseData ); } 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/src/Serializer/KuveytPosSerializer.php b/src/Serializer/KuveytPosSerializer.php index 34ad7c32..c5c6f8a2 100644 --- a/src/Serializer/KuveytPosSerializer.php +++ b/src/Serializer/KuveytPosSerializer.php @@ -20,6 +20,8 @@ class KuveytPosSerializer implements SerializerInterface { + use SerializerUtilTrait; + /** @var string[] */ private array $nonPaymentTransactions = [ PosInterface::TX_TYPE_REFUND, @@ -88,16 +90,6 @@ public function decode(string $data, string $txType): array } } - /** - * @param string $str - * - * @return bool returns true if string is a HTML document. - */ - private function isHTML(string $str): bool - { - return $str !== \strip_tags($str); - } - /** * Diger Gateway'lerden farkli olarak bu gateway HTML form olan bir response doner. * Kutupahenin islem akisina uymasi icin bu HTML form verilerini array'e donusturup, kendimiz post ediyoruz. diff --git a/src/Serializer/PayFlexCPV4PosSerializer.php b/src/Serializer/PayFlexCPV4PosSerializer.php index 1551f85f..2e561fe3 100644 --- a/src/Serializer/PayFlexCPV4PosSerializer.php +++ b/src/Serializer/PayFlexCPV4PosSerializer.php @@ -14,6 +14,8 @@ class PayFlexCPV4PosSerializer implements SerializerInterface { + use SerializerUtilTrait; + private Serializer $serializer; public function __construct() @@ -78,17 +80,4 @@ public function decode(string $data, ?string $txType = null): array throw $notEncodableValueException; } - - /** - * must be called after making sure that $str does not contain XML string. - * Because for XML strings it will also return true. - * - * @param string $str - * - * @return bool - */ - private function isHTML(string $str): bool - { - return $str !== \strip_tags($str); - } } diff --git a/src/Serializer/PayFlexV4PosSerializer.php b/src/Serializer/PayFlexV4PosSerializer.php index 16b2f647..7966d57d 100644 --- a/src/Serializer/PayFlexV4PosSerializer.php +++ b/src/Serializer/PayFlexV4PosSerializer.php @@ -14,6 +14,8 @@ class PayFlexV4PosSerializer implements SerializerInterface { + use SerializerUtilTrait; + private Serializer $serializer; public function __construct() @@ -75,9 +77,4 @@ public function decode(string $data, ?string $txType = null): array throw $notEncodableValueException; } } - - private function isHTML(string $str): bool - { - return $str !== \strip_tags($str); - } } diff --git a/src/Serializer/SerializerUtilTrait.php b/src/Serializer/SerializerUtilTrait.php new file mode 100644 index 00000000..9e7e4587 --- /dev/null +++ b/src/Serializer/SerializerUtilTrait.php @@ -0,0 +1,42 @@ +loadHTML($string, LIBXML_NOERROR | LIBXML_NOWARNING); + + // Clear any libxml errors + \libxml_clear_errors(); + + // Restore the previous libxml error handling state + \libxml_use_internal_errors($previousLibxmlState); + + // Check if the string has recognizable HTML elements + return $isValidHTML && $dom->getElementsByTagName('html')->length > 0; + } +} diff --git a/src/Serializer/VakifKatilimPosSerializer.php b/src/Serializer/VakifKatilimPosSerializer.php index 6cbe0279..096a4cc2 100644 --- a/src/Serializer/VakifKatilimPosSerializer.php +++ b/src/Serializer/VakifKatilimPosSerializer.php @@ -18,6 +18,8 @@ class VakifKatilimPosSerializer implements SerializerInterface { + use SerializerUtilTrait; + private Serializer $serializer; public function __construct() @@ -66,16 +68,6 @@ public function decode(string $data, string $txType): array } } - /** - * @param string $str - * - * @return bool returns true if string is a HTML document. - */ - private function isHTML(string $str): bool - { - return $str !== \strip_tags($str); - } - /** * Diger Gateway'lerden farkli olarak bu gateway HTML form olan bir response doner. * Kutupahenin islem akisina uymasi icin bu HTML form verilerini array'e donusturup, kendimiz post ediyoruz. 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..e3883b63 100644 --- a/tests/Unit/Gateways/GarantiPosTest.php +++ b/tests/Unit/Gateways/GarantiPosTest.php @@ -29,7 +29,7 @@ /** * @covers \Mews\Pos\Gateways\GarantiPos - * @covers \Mews\Pos\Gateways\AbstractGateway + * @covers \Mews\Pos\Gateways\AbstractGateway */ class GarantiPosTest extends TestCase { @@ -70,11 +70,11 @@ protected function setUp(): void parent::setUp(); $this->config = [ - 'name' => 'Garanti', - 'class' => GarantiPos::class, - 'gateway_endpoints' => [ - 'payment_api' => 'https://sanalposprovtest.garantibbva.com.tr/VPServlet', - 'gateway_3d' => 'https://sanalposprovtest.garantibbva.com.tr/servlet/gt3dengine', + 'name' => 'Garanti', + 'class' => GarantiPos::class, + 'gateway_endpoints' => [ + 'payment_api' => 'https://sanalposprovtest.garantibbva.com.tr/VPServlet', + 'gateway_3d' => 'https://sanalposprovtest.garantibbva.com.tr/servlet/gt3dengine', ], ]; @@ -144,7 +144,8 @@ public function testInit(): void */ public function testGet3DFormData( bool $isWithCard - ): void { + ): void + { $card = $isWithCard ? $this->card : null; $paymentModel = $isWithCard ? PosInterface::MODEL_3D_SECURE : PosInterface::MODEL_3D_HOST; $order = ['id' => '124']; @@ -175,6 +176,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -182,7 +184,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -264,7 +266,7 @@ public function testMake3DPayment( public function testMake3DPaymentHashMismatchException(): void { - $data = GarantiPosResponseDataMapperTest::threeDPaymentDataProvider()['paymentFail1']['threeDResponseData']; + $data = GarantiPosResponseDataMapperTest::threeDPaymentDataProvider()['paymentFail1']['threeDResponseData']; $request = Request::create('', 'POST', $data); $this->cryptMock->expects(self::once()) @@ -308,9 +310,9 @@ public function testMake3DPayPayment(): void ->method('check3DHash'); $responseData = ['$responseData']; - $request = Request::create('', 'POST', $responseData); - $order = ['id' => '123']; - $txType = PosInterface::TX_TYPE_PAY_AUTH; + $request = Request::create('', 'POST', $responseData); + $order = ['id' => '123']; + $txType = PosInterface::TX_TYPE_PAY_AUTH; $this->responseMapperMock->expects(self::once()) ->method('map3DPayResponseData') @@ -568,8 +570,8 @@ public function testOrderHistoryRequest(array $order, string $apiUrl): void */ public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void { - $account = $this->pos->getAccount(); - $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; $updatedRequestData = $requestData + [ 'abc' => 'def', @@ -616,7 +618,7 @@ public static function customQueryRequestDataProvider(): array public static function make3DPaymentDataProvider(): array { return [ - '3d_auth_fail_1' => [ + '3d_auth_fail_1' => [ 'order' => GarantiPosResponseDataMapperTest::threeDPaymentDataProvider()['3d_auth_fail_1']['order'], 'txType' => GarantiPosResponseDataMapperTest::threeDPaymentDataProvider()['3d_auth_fail_1']['txType'], 'request' => Request::create( @@ -741,18 +743,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 +764,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, ], ]; @@ -812,7 +817,7 @@ private function configureClientResponse( } ))) ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { - $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); + $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/InterPosTest.php b/tests/Unit/Gateways/InterPosTest.php index 161aa826..c4440494 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; @@ -71,9 +72,9 @@ protected function setUp(): void parent::setUp(); $this->config = [ - 'name' => 'DenizBank-InterPos', - 'class' => InterPos::class, - 'gateway_endpoints' => [ + 'name' => 'DenizBank-InterPos', + 'class' => InterPos::class, + 'gateway_endpoints' => [ 'payment_api' => 'https://test.inter-vpos.com.tr/mpi/Default.aspx', 'gateway_3d' => 'https://test.inter-vpos.com.tr/mpi/Default.aspx', 'gateway_3d_host' => 'https://test.inter-vpos.com.tr/mpi/3DHost.aspx', @@ -152,7 +153,8 @@ public function testInit(): void */ public function testGet3DFormData( bool $isWithCard - ): void { + ): void + { $card = $isWithCard ? $this->card : null; $paymentModel = $isWithCard ? PosInterface::MODEL_3D_SECURE : PosInterface::MODEL_3D_HOST; $gatewayUrl = $isWithCard ? 'https://test.inter-vpos.com.tr/mpi/Default.aspx' : 'https://test.inter-vpos.com.tr/mpi/3DHost.aspx'; @@ -184,6 +186,7 @@ public function testGet3DFormDataWithBadInputs( string $paymentModel, string $txType, bool $isWithCard, + bool $createWithoutCard, string $expectedExceptionClass ): void { @@ -191,7 +194,7 @@ public function testGet3DFormDataWithBadInputs( $this->expectException($expectedExceptionClass); - $this->pos->get3DFormData($order, $paymentModel, $txType, $card); + $this->pos->get3DFormData($order, $paymentModel, $txType, $card, $createWithoutCard); } /** @@ -206,7 +209,8 @@ public function testMake3DPayment( bool $checkHash, bool $is3DSuccess, bool $isSuccess - ): void { + ): void + { if ($checkHash) { $this->cryptMock->expects(self::once()) ->method('check3DHash') @@ -306,9 +310,9 @@ public function testMake3DPayPayment(): void ->method('check3DHash'); $responseData = ['$responseData']; - $request = Request::create('', 'POST', $responseData); - $order = ['id' => '123']; - $txType = PosInterface::TX_TYPE_PAY_AUTH; + $request = Request::create('', 'POST', $responseData); + $order = ['id' => '123']; + $txType = PosInterface::TX_TYPE_PAY_AUTH; $this->responseMapperMock->expects(self::once()) ->method('map3DPayResponseData') @@ -333,9 +337,9 @@ public function testMake3DHostPayment(): void ->method('check3DHash'); $responseData = ['$responseData']; - $request = Request::create('', 'POST', $responseData); - $order = ['id' => '123']; - $txType = PosInterface::TX_TYPE_PAY_AUTH; + $request = Request::create('', 'POST', $responseData); + $order = ['id' => '123']; + $txType = PosInterface::TX_TYPE_PAY_AUTH; $this->responseMapperMock->expects(self::once()) ->method('map3DHostResponseData') @@ -539,8 +543,8 @@ public function testRefundRequest(array $order, string $apiUrl): void */ public function testCustomQueryRequest(array $requestData, ?string $apiUrl, string $expectedApiUrl): void { - $account = $this->pos->getAccount(); - $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; + $account = $this->pos->getAccount(); + $txType = PosInterface::TX_TYPE_CUSTOM_QUERY; $updatedRequestData = $requestData + [ 'abc' => 'def', @@ -682,18 +686,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 +707,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, ], ]; @@ -753,7 +760,7 @@ private function configureClientResponse( } ))) ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { - $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); + $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/KuveytPosTest.php b/tests/Unit/Gateways/KuveytPosTest.php index 81650cfb..ce0358ab 100644 --- a/tests/Unit/Gateways/KuveytPosTest.php +++ b/tests/Unit/Gateways/KuveytPosTest.php @@ -29,7 +29,7 @@ use Symfony\Component\HttpFoundation\Request; /** - * @covers \Mews\Pos\Gateways\KuveytPos + * @covers \Mews\Pos\Gateways\KuveytPos * @covers \Mews\Pos\Gateways\AbstractGateway */ class KuveytPosTest extends TestCase @@ -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); } /** @@ -283,7 +284,7 @@ public function testMake3DPayment( $create3DPaymentRequestData = [ 'create3DPaymentRequestData', ]; - $encodedRequestData = 'request-body'; + $encodedRequestData = 'request-body'; if ($is3DSuccess) { @@ -317,8 +318,8 @@ public function testMake3DPayment( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { - $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { + $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); @@ -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, ], ]; @@ -675,7 +679,7 @@ private function configureClientResponse( } ))) ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { - $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); + $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); 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..190dcf38 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, ], ]; @@ -989,7 +994,7 @@ private function configureClientResponse( } ))) ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { - $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); + $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);