From b123ea0d30dccd9154f465711b7ab5003c640ea6 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Feb 2023 22:44:16 +0100 Subject: [PATCH 01/54] set up rector --- composer.json | 3 +- rector.php | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 rector.php diff --git a/composer.json b/composer.json index 39515ed5..ec07236c 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ "php-http/curl-client": "^2.2", "phpstan/phpstan": "^1.9", "phpstan/phpstan-strict-rules": "^1.4", - "phpunit/phpunit": "^8.3", + "phpunit/phpunit": "^8.5", + "rector/rector": "^0.15.12", "slim/psr7": "^1.4", "squizlabs/php_codesniffer": "^3.5", "symfony/var-dumper": "^5.1" diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..3188cc7e --- /dev/null +++ b/rector.php @@ -0,0 +1,121 @@ +paths([ + __DIR__.'/config', + __DIR__.'/examples', + __DIR__.'/src', + __DIR__.'/tests', + ]); + + $rectorConfig->rules([ + \Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector::class, + \Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class, + \Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector::class, + \Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class, + \Rector\CodeQuality\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector::class, + \Rector\CodeQuality\Rector\FuncCall\ArrayKeysAndInArrayToArrayKeyExistsRector::class, + \Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector::class, + \Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class, + \Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector::class, + \Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector::class, + \Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector::class, + \Rector\CodeQuality\Rector\FuncCall\StrvalToTypeCastRector::class, + \Rector\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector::class, + \Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessLastVariableAssignRector::class, + \Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessLastVariableAssignRector::class, + \Rector\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector::class, + \Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector::class, + \Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class, + \Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector::class, + \Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector::class, + \Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector::class, + \Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector::class, + \Rector\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector::class, + \Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector::class, + \Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector::class, + \Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class, + \Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector::class, + \Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector::class, + \Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class, + \Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector::class, + \Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector::class, + \Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector::class, + \Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class, + \Rector\CodeQuality\Rector\If_\CombineIfRector::class, + \Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, + \Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector::class, + \Rector\CodeQuality\Rector\If_\ShortenElseIfRector::class, + \Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector::class, + \Rector\CodeQuality\Rector\If_\SimplifyIfExactValueReturnValueRector::class, + \Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector::class, + \Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector::class, + \Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector::class, + \Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector::class, + \Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector::class, + \Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, + \Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector::class, + \Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector::class, + \Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector::class, + \Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector::class, + \Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector::class, + \Rector\CodeQuality\Rector\Assign\CombinedAssignRector::class, + + \Rector\CodingStyle\Rector\If_\NullableCompareToNullRector::class, + \Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::class, + \Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class, + \Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class, + \Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector::class, + \Rector\CodingStyle\Rector\ClassMethod\DataProviderArrayItemsNewlinedRector::class, + \Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector::class, + + \Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class, + \Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class, + \Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class, + \Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector::class, + \Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class, + \Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector::class, + \Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector::class, + \Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class, + \Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector::class, + \Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class, + \Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector::class, + \Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class, + \Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class, + \Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class, + \Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class, + \Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class, + \Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector::class, + + \Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class, + \Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector::class, + + \Rector\Php53\Rector\Ternary\TernaryToElvisRector::class, + \Rector\Php54\Rector\Array_\LongArrayToShortArrayRector::class, + \Rector\Php70\Rector\FuncCall\RandomFunctionRector::class, + \Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector::class, + \Rector\Php71\Rector\FuncCall\CountOnNullRector::class, + \Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector::class, + \Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector::class, + \Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class, + \Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector::class, + + \Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class, + ]); + + // define sets of rules + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_72, + ]); + + $rectorConfig->ruleWithConfiguration(\Rector\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector::class, [ + 'var', + 'phpstan-var', + 'property', + ]); +}; From a5173eceee3c4b31d0b3c09ee107824f0acdbb12 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Feb 2023 22:55:33 +0100 Subject: [PATCH 02/54] VakifBankPosRequestDataMapper fix order description --- src/DataMapper/VakifBankPosRequestDataMapper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index 89c8a140..c124c40c 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -69,7 +69,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, 'CAVV' => $responseData['Cavv'], 'MpiTransactionId' => $responseData['VerifyEnrollmentRequestId'], 'OrderId' => $order->id, - 'OrderDescription' => $this->order->description ?? null, + 'OrderDescription' => $order->description ?? null, 'ClientIp' => $order->ip, 'TransactionDeviceSource' => 0, // ECommerce ]; @@ -145,7 +145,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ 'TransactionDeviceSource' => 0, ]; - if ($card) { + if ($card !== null) { $requestData['Pan'] = $card->getNumber(); $requestData['Expiry'] = $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_LONG_FORMAT); $requestData['Cvv'] = $card->getCvv(); From 3e7a9d0dd0d45acbd41d8f2bb586aed30c9c734f Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Feb 2023 23:04:29 +0100 Subject: [PATCH 03/54] rector process src - first round --- src/Crypt/EstPosCrypt.php | 2 +- src/Crypt/EstV3PosCrypt.php | 2 +- src/Crypt/GarantiPosCrypt.php | 8 ++------ src/DataMapper/EstPosRequestDataMapper.php | 4 ++-- src/DataMapper/GarantiPosRequestDataMapper.php | 8 ++++---- src/DataMapper/InterPosRequestDataMapper.php | 4 ++-- src/DataMapper/KuveytPosRequestDataMapper.php | 4 ++-- src/DataMapper/PayForPosRequestDataMapper.php | 6 +++--- .../ResponseDataMapper/EstPosResponseDataMapper.php | 8 +++----- .../ResponseDataMapper/GarantiPosResponseDataMapper.php | 6 +----- .../ResponseDataMapper/InterPosResponseDataMapper.php | 2 +- .../ResponseDataMapper/PayForPosResponseDataMapper.php | 2 +- .../ResponseDataMapper/PosNetResponseDataMapper.php | 2 +- .../VakifBankPosResponseDataMapper.php | 2 +- src/Factory/AccountFactory.php | 8 ++++++-- src/Factory/CreditCardFactory.php | 6 +++--- src/Factory/PosFactory.php | 9 ++++----- src/Gateways/AbstractGateway.php | 6 +++--- src/Gateways/EstPos.php | 2 +- src/Gateways/GarantiPos.php | 2 +- src/Gateways/InterPos.php | 2 +- src/Gateways/KuveytPos.php | 2 +- src/Gateways/PayForPos.php | 2 +- src/Gateways/PosNet.php | 2 +- src/Gateways/VakifBankPos.php | 4 ++-- 25 files changed, 49 insertions(+), 56 deletions(-) diff --git a/src/Crypt/EstPosCrypt.php b/src/Crypt/EstPosCrypt.php index f2f92a9d..843041b3 100644 --- a/src/Crypt/EstPosCrypt.php +++ b/src/Crypt/EstPosCrypt.php @@ -42,7 +42,7 @@ public function check3DHash(AbstractPosAccount $account, array $data): bool $hashParamsArr = explode(':', $hashParams); foreach ($hashParamsArr as $value) { if (isset($data[$value])) { - $paramsVal = $paramsVal.$data[$value]; + $paramsVal .= $data[$value]; } } diff --git a/src/Crypt/EstV3PosCrypt.php b/src/Crypt/EstV3PosCrypt.php index 584cbf81..b7a575b8 100644 --- a/src/Crypt/EstV3PosCrypt.php +++ b/src/Crypt/EstV3PosCrypt.php @@ -18,7 +18,7 @@ class EstV3PosCrypt extends AbstractCrypt public function create3DHash(AbstractPosAccount $account, array $requestData, ?string $txType = null): string { ksort($requestData, SORT_NATURAL | SORT_FLAG_CASE); - foreach ($requestData as $key => $value) { + foreach (array_keys($requestData) as $key) { // this part is needed only to create hash from the bank response if (in_array(strtolower($key), ['hash', 'encoding'])) { unset($requestData[$key]); diff --git a/src/Crypt/GarantiPosCrypt.php b/src/Crypt/GarantiPosCrypt.php index 0af6e6e7..66984486 100644 --- a/src/Crypt/GarantiPosCrypt.php +++ b/src/Crypt/GarantiPosCrypt.php @@ -41,7 +41,7 @@ public function check3DHash(AbstractPosAccount $account, array $data): bool $hashParamsArr = explode(':', $hashParams); foreach ($hashParamsArr as $value) { if (isset($data[$value])) { - $paramsVal = $paramsVal.$data[$value]; + $paramsVal .= $data[$value]; } } @@ -91,11 +91,7 @@ public function createHash(AbstractPosAccount $account, array $requestData, ?str */ private function createSecurityData(AbstractPosAccount $account, ?string $txType = null): string { - if ('void' === $txType || 'refund' === $txType) { - $password = $account->getRefundPassword(); - } else { - $password = $account->getPassword(); - } + $password = 'void' === $txType || 'refund' === $txType ? $account->getRefundPassword() : $account->getPassword(); $map = [ $password, diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index 85d0e4cb..ca1416f7 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -147,7 +147,7 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar if (isset($order->id)) { $statusRequestData['OrderId'] = $order->id; - } else if (isset($order->recurringId)) { + } elseif (isset($order->recurringId)) { $statusRequestData['Extra']['RECURRINGID'] = $order->recurringId; } @@ -255,7 +255,7 @@ public function create3DFormDataCommon(AbstractPosAccount $account, $order, stri // todo add custom data dynamically instead of hard coding them ]; - if ($card) { + if ($card !== null) { $inputs['cardType'] = $this->cardTypeMapping[$card->getType()]; $inputs['pan'] = $card->getNumber(); $inputs['Ecom_Payment_Card_ExpDate_Month'] = $card->getExpireMonth(self::CREDIT_CARD_EXP_MONTH_FORMAT); diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index ca6d8d1e..9d6e1ed0 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -350,7 +350,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx $inputs['secure3dhash'] = $this->crypt->create3DHash($account, $mappedOrder, $this->mapTxType($txType)); - if ($card) { + if ($card !== null) { $inputs['cardnumber'] = $card->getNumber(); $inputs['cardexpiredatemonth'] = $card->getExpireMonth(self::CREDIT_CARD_EXP_MONTH_FORMAT); $inputs['cardexpiredateyear'] = $card->getExpireYear(self::CREDIT_CARD_EXP_YEAR_FORMAT); @@ -380,7 +380,7 @@ public function mapInstallment(?int $installment) */ public static function amountFormat($amount): int { - return intval(round($amount, 2) * 100); + return (int) (round($amount, 2) * 100); } /** @@ -388,7 +388,7 @@ public static function amountFormat($amount): int */ private function getMode(): string { - return !$this->isTestMode() ? 'PROD' : 'TEST'; + return $this->isTestMode() ? 'TEST' : 'PROD'; } /** @@ -416,7 +416,7 @@ private function getTerminalData(AbstractPosAccount $account, string $hash, bool */ private function getCardData(?AbstractCreditCard $card = null): array { - if ($card) { + if ($card !== null) { return [ 'Number' => $card->getNumber(), 'ExpireDate' => $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_FORMAT), diff --git a/src/DataMapper/InterPosRequestDataMapper.php b/src/DataMapper/InterPosRequestDataMapper.php index 4ab5b6a3..70953bd3 100644 --- a/src/DataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/InterPosRequestDataMapper.php @@ -91,7 +91,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ 'Lang' => $this->getLang($account, $order), ]; - if ($card) { + if ($card !== null) { $requestData['CardType'] = $this->cardTypeMapping[$card->getType()]; $requestData['Pan'] = $card->getNumber(); $requestData['Expiry'] = $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_FORMAT); @@ -195,7 +195,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx 'InstallmentCount' => $this->mapInstallment($order->installment), ]; - if ($card) { + if ($card !== null) { $inputs['CardType'] = $this->cardTypeMapping[$card->getType()]; $inputs['Pan'] = $card->getNumber(); $inputs['Expiry'] = $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_FORMAT); diff --git a/src/DataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/KuveytPosRequestDataMapper.php index 3f6d71ee..85afa5b5 100644 --- a/src/DataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/KuveytPosRequestDataMapper.php @@ -72,7 +72,7 @@ class KuveytPosRequestDataMapper extends AbstractRequestDataMapperCrypt */ public static function amountFormat(float $amount): int { - return intval(round($amount, 2) * 100); + return (int) (round($amount, 2) * 100); } /** @@ -131,7 +131,7 @@ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $account, $o 'FailUrl' => $order->fail_url, ]; - if ($card) { + if ($card !== null) { $inputs['CardHolderName'] = $card->getHolderName(); $inputs['CardType'] = $this->cardTypeMapping[$card->getType()]; $inputs['CardNumber'] = $card->getNumber(); diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index d9275bf6..9b3ef3b4 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -16,12 +16,12 @@ class PayForPosRequestDataMapper extends AbstractRequestDataMapper /** * Kurum kodudur. (Banka tarafından verilir) */ - const MBR_ID = '5'; + public const MBR_ID = '5'; /** * MOTO (Mail Order Telephone Order) 0 for false, 1 for true */ - const MOTO = '0'; + public const MOTO = '0'; public const CREDIT_CARD_EXP_DATE_FORMAT = 'my'; @@ -192,7 +192,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx 'Hash' => $hash, ]; - if ($card) { + if ($card !== null) { $inputs['CardHolderName'] = $card->getHolderName(); $inputs['Pan'] = $card->getNumber(); $inputs['Expiry'] = $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_FORMAT); diff --git a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php index f6696ab8..b7f8eaea 100644 --- a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php @@ -38,7 +38,7 @@ class EstPosResponseDataMapper extends AbstractResponseDataMapper implements Pay public function mapPaymentResponse(array $rawPaymentResponseData): array { $this->logger->log(LogLevel::DEBUG, 'mapping payment response', [$rawPaymentResponseData]); - if (empty($rawPaymentResponseData)) { + if ($rawPaymentResponseData === []) { return $this->getDefaultPaymentResponse(); } $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); @@ -119,10 +119,8 @@ public function map3DPayResponseData($raw3DAuthResponseData): array $raw3DAuthResponseData = $this->emptyStringsToNull($raw3DAuthResponseData); $procReturnCode = $this->getProcReturnCode($raw3DAuthResponseData); - if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode) { - if (in_array($raw3DAuthResponseData['mdStatus'], ['1', '2', '3', '4'])) { - $status = self::TX_APPROVED; - } + if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode && in_array($raw3DAuthResponseData['mdStatus'], ['1', '2', '3', '4'])) { + $status = self::TX_APPROVED; } $defaultResponse = $this->getDefaultPaymentResponse(); diff --git a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php index 2dad8918..e3f117df 100644 --- a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php @@ -136,11 +136,7 @@ public function map3DPayResponseData($raw3DAuthResponseData): array $commonResult = $this->map3DCommonResponseData($raw3DAuthResponseData); if (self::TX_APPROVED === $commonResult['status']) { $procReturnCode = $raw3DAuthResponseData['procreturncode']; - if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode) { - $commonResult['status'] = self::TX_APPROVED; - } else { - $commonResult['status'] = self::TX_DECLINED; - } + $commonResult['status'] = self::PROCEDURE_SUCCESS_CODE === $procReturnCode ? self::TX_APPROVED : self::TX_DECLINED; } if (in_array($raw3DAuthResponseData['mdstatus'], ['1', '2', '3', '4'])) { $commonResult['auth_code'] = $raw3DAuthResponseData['authcode']; diff --git a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php index 584be427..e2d7a6cd 100644 --- a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php @@ -24,7 +24,7 @@ class InterPosResponseDataMapper extends AbstractResponseDataMapper implements P public function mapPaymentResponse(array $rawPaymentResponseData): array { $this->logger->log(LogLevel::DEBUG, 'mapping payment response', [$rawPaymentResponseData]); - if (empty($rawPaymentResponseData)) { + if ($rawPaymentResponseData === []) { return $this->getDefaultPaymentResponse(); } $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); diff --git a/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php index e9ec6998..b43305be 100644 --- a/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php @@ -97,7 +97,7 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen 'error_message' => self::TX_APPROVED !== $threeDAuthStatus ? $raw3DAuthResponseData['ErrMsg'] : null, ]; - if (empty($paymentResponseData)) { + if ($paymentResponseData === []) { return array_merge($this->getDefaultPaymentResponse(), $threeDResponse, $this->map3DCommonResponseData($raw3DAuthResponseData)); } diff --git a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php index 331e218d..c41fe8c6 100644 --- a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php @@ -44,7 +44,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData): array { $status = self::TX_DECLINED; $this->logger->log(LogLevel::DEBUG, 'mapping payment response', [$rawPaymentResponseData]); - if (empty($rawPaymentResponseData)) { + if ($rawPaymentResponseData === []) { return $this->getDefaultPaymentResponse(); } diff --git a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php index c753311a..8e8b4575 100644 --- a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php @@ -46,7 +46,7 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen '3d_all' => $raw3DAuthResponseData, ]; - if (empty($paymentResponseData)) { + if ($paymentResponseData === []) { return array_merge($this->getDefaultPaymentResponse(), $threeDResponse); } diff --git a/src/Factory/AccountFactory.php b/src/Factory/AccountFactory.php index 244a228c..8ba8e777 100644 --- a/src/Factory/AccountFactory.php +++ b/src/Factory/AccountFactory.php @@ -172,9 +172,13 @@ public static function createInterPosAccount(string $bank, string $shopCode, str */ private static function checkParameters(string $model, ?string $storeKey) { - if (AbstractGateway::MODEL_NON_SECURE !== $model && null === $storeKey) { - throw new MissingAccountInfoException("$model requires storeKey!"); + if (AbstractGateway::MODEL_NON_SECURE === $model) { + return; } + if (null !== $storeKey) { + return; + } + throw new MissingAccountInfoException("$model requires storeKey!"); } /** diff --git a/src/Factory/CreditCardFactory.php b/src/Factory/CreditCardFactory.php index 6bb82a5e..c97bade2 100644 --- a/src/Factory/CreditCardFactory.php +++ b/src/Factory/CreditCardFactory.php @@ -46,14 +46,14 @@ public static function create( $expireMonth = str_pad($expireMonth, 2, '0', STR_PAD_LEFT); $expDate = DateTimeImmutable::createFromFormat('Ymd', $expireYear.$expireMonth.'01'); - if (!$expDate) { + if (! $expDate instanceof DateTimeImmutable) { throw new DomainException('INVALID DATE FORMAT'); } $supportedCardTypes = array_keys($pos->getCardTypeMapping()); - if (!empty($supportedCardTypes) && empty($cardType)) { + if ($supportedCardTypes !== [] && empty($cardType)) { throw new CardTypeRequiredException($pos::NAME); } - if (!empty($supportedCardTypes) && !in_array($cardType, $supportedCardTypes)) { + if ($supportedCardTypes !== [] && !in_array($cardType, $supportedCardTypes)) { throw new CardTypeNotSupportedException($cardType); } diff --git a/src/Factory/PosFactory.php b/src/Factory/PosFactory.php index e66e1ce6..ffaf04c5 100644 --- a/src/Factory/PosFactory.php +++ b/src/Factory/PosFactory.php @@ -69,10 +69,10 @@ public static function createPosGateway( ?LoggerInterface $logger = null ): PosInterface { - if (!$logger) { + if ($logger === null) { $logger = new NullLogger(); } - if (!$client) { + if ($client === null) { $client = HttpClientFactory::createDefaultHttpClient(); } if (is_string($config)) { @@ -141,9 +141,8 @@ public static function getGatewayRequestMapper(string $gatewayClass, array $curr return new PosNetRequestDataMapper($crypt, $currencies); } } - switch ($gatewayClass) { - case VakifBankPos::class: - return new VakifBankPosRequestDataMapper(null, $currencies); + if ($gatewayClass === VakifBankPos::class) { + return new VakifBankPosRequestDataMapper(null, $currencies); } throw new DomainException('unsupported gateway'); } diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 4177bec4..7eccf552 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -248,7 +248,7 @@ public function get3DGatewayURL(): string */ public function get3DHostGatewayURL(): ?string { - return isset($this->config['urls']['gateway_3d_host'][$this->getModeInWord()]) ? $this->config['urls']['gateway_3d_host'][$this->getModeInWord()] : null; + return $this->config['urls']['gateway_3d_host'][$this->getModeInWord()] ?? null; } /** @@ -284,7 +284,7 @@ public function payment($card = null) $model = $this->account->getModel(); $this->logger->log(LogLevel::DEBUG, 'payment called', [ - 'card_provided' => !!$this->card, + 'card_provided' => (bool) $this->card, 'model' => $model, ]); if (self::MODEL_NON_SECURE === $model) { @@ -552,6 +552,6 @@ protected function XMLStringToArray(string $data, array $context = []): array */ private function getModeInWord(): string { - return !$this->isTestMode() ? 'production' : 'test'; + return $this->isTestMode() ? 'test' : 'production'; } } diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index 0f419115..60714681 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -98,7 +98,7 @@ public function make3DHostPayment(Request $request) */ public function get3DFormData(): array { - if (!$this->order) { + if ($this->order === null) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order'); return []; } diff --git a/src/Gateways/GarantiPos.php b/src/Gateways/GarantiPos.php index 57e2274d..eb19af83 100644 --- a/src/Gateways/GarantiPos.php +++ b/src/Gateways/GarantiPos.php @@ -102,7 +102,7 @@ public function send($contents, ?string $url = null) */ public function get3DFormData(): array { - if (!$this->order) { + if ($this->order === null) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order'); return []; } diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 131d56c4..90aec9dd 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -126,7 +126,7 @@ public function history(array $meta) */ public function get3DFormData(): array { - if (!$this->order) { + if ($this->order === null) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order'); return []; } diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 883721ec..703b3ef4 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -69,7 +69,7 @@ public function send($contents, string $url = null) $this->data = $this->XMLStringToArray($responseBody); } catch (Exception $e) { if (!$this->isHTML($responseBody)) { - throw new Exception($responseBody); + throw new Exception($responseBody, $e->getCode(), $e); } //icinde form olan HTML response dondu $this->data = $responseBody; diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index f4582c5b..a5972136 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -122,7 +122,7 @@ public function history(array $meta) */ public function get3DFormData(): array { - if (!$this->order) { + if ($this->order === null) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order'); return []; } diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index cc93a37a..009a3245 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -121,7 +121,7 @@ public function get3DFormData(): array if (!$this->card || !$this->order) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order', [ 'order' => $this->order, - 'card_provided' => !!$this->card, + 'card_provided' => (bool) $this->card, ]); return []; } diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index 2adaafce..ea881e17 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -111,7 +111,7 @@ public function get3DFormData(): array if (!$this->card || !$this->order) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order', [ 'order' => $this->order, - 'card_provided' => !!$this->card, + 'card_provided' => (bool) $this->card, ]); return []; } @@ -188,7 +188,7 @@ public function send($contents, ?string $url = null) } catch (NotEncodableValueException $e) { if ($this->isHTML($responseBody)) { // if something wrong server responds with HTML content - throw new Exception($responseBody); + throw new Exception($responseBody, $e->getCode(), $e); } $this->data = json_decode($responseBody, true); } From c8595d5c0d45e918885ab72ec815e404fa18bae1 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Feb 2023 23:17:03 +0100 Subject: [PATCH 04/54] rector process examples - first round --- examples/akbank/regular/cancel.php | 2 +- examples/akbank/regular/post-auth.php | 2 +- examples/akbank/regular/refund.php | 2 +- examples/finansbank-payfor/regular/cancel.php | 2 +- examples/finansbank-payfor/regular/post-auth.php | 2 +- examples/finansbank-payfor/regular/refund.php | 2 +- examples/finansbank-payfor/regular/status.php | 2 +- examples/garanti/regular/cancel.php | 2 +- examples/garanti/regular/history.php | 2 +- examples/garanti/regular/post-auth.php | 2 +- examples/garanti/regular/refund.php | 2 +- examples/garanti/regular/status.php | 2 +- examples/interpos/regular/cancel.php | 2 +- examples/interpos/regular/post-auth.php | 2 +- examples/interpos/regular/refund.php | 2 +- examples/template/_footer.php | 2 +- examples/vakifbank/regular/cancel.php | 2 +- examples/vakifbank/regular/post-auth.php | 2 +- examples/vakifbank/regular/refund.php | 2 +- examples/ykb/regular/cancel.php | 2 +- examples/ykb/regular/post-auth.php | 2 +- examples/ykb/regular/refund.php | 2 +- examples/ykb/regular/status.php | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/akbank/regular/cancel.php b/examples/akbank/regular/cancel.php index b059a581..23690c48 100644 --- a/examples/akbank/regular/cancel.php +++ b/examples/akbank/regular/cancel.php @@ -6,7 +6,7 @@ require '_config.php'; require '../../template/_header.php'; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); if (isset($ord['recurringFrequency'])) { //tekrarlanan odemenin durumunu sorgulamak icin: diff --git a/examples/akbank/regular/post-auth.php b/examples/akbank/regular/post-auth.php index a2a57a0b..dd7c0f74 100644 --- a/examples/akbank/regular/post-auth.php +++ b/examples/akbank/regular/post-auth.php @@ -4,7 +4,7 @@ $templateTitle = 'Post Auth Order (ön provizyonu tamamlama)'; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], diff --git a/examples/akbank/regular/refund.php b/examples/akbank/regular/refund.php index 0a7a9977..066bfc5e 100644 --- a/examples/akbank/regular/refund.php +++ b/examples/akbank/regular/refund.php @@ -6,7 +6,7 @@ require '_config.php'; require '../../template/_header.php'; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); // Refund Order $order = [ diff --git a/examples/finansbank-payfor/regular/cancel.php b/examples/finansbank-payfor/regular/cancel.php index 47c22aa1..1b1c936e 100644 --- a/examples/finansbank-payfor/regular/cancel.php +++ b/examples/finansbank-payfor/regular/cancel.php @@ -6,7 +6,7 @@ use Mews\Pos\Gateways\AbstractGateway; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], diff --git a/examples/finansbank-payfor/regular/post-auth.php b/examples/finansbank-payfor/regular/post-auth.php index ea29e895..79392727 100644 --- a/examples/finansbank-payfor/regular/post-auth.php +++ b/examples/finansbank-payfor/regular/post-auth.php @@ -4,7 +4,7 @@ $templateTitle = 'Post Auth Order (ön provizyonu tamamlama)'; -$order = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $session->set('post_order', $order); $transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; diff --git a/examples/finansbank-payfor/regular/refund.php b/examples/finansbank-payfor/regular/refund.php index adf64c07..367e394b 100644 --- a/examples/finansbank-payfor/regular/refund.php +++ b/examples/finansbank-payfor/regular/refund.php @@ -6,7 +6,7 @@ use Mews\Pos\Gateways\AbstractGateway; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); // Refund Order $order = [ diff --git a/examples/finansbank-payfor/regular/status.php b/examples/finansbank-payfor/regular/status.php index f415cca7..13ed2a29 100644 --- a/examples/finansbank-payfor/regular/status.php +++ b/examples/finansbank-payfor/regular/status.php @@ -6,7 +6,7 @@ use Mews\Pos\Gateways\AbstractGateway; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], diff --git a/examples/garanti/regular/cancel.php b/examples/garanti/regular/cancel.php index 496b626c..d4b93a6c 100644 --- a/examples/garanti/regular/cancel.php +++ b/examples/garanti/regular/cancel.php @@ -6,7 +6,7 @@ use Mews\Pos\Gateways\AbstractGateway; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], diff --git a/examples/garanti/regular/history.php b/examples/garanti/regular/history.php index f671d2fa..e30005c2 100644 --- a/examples/garanti/regular/history.php +++ b/examples/garanti/regular/history.php @@ -4,7 +4,7 @@ $templateTitle = 'History Order'; require '../../template/_header.php'; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], diff --git a/examples/garanti/regular/post-auth.php b/examples/garanti/regular/post-auth.php index db142903..84b7ef77 100644 --- a/examples/garanti/regular/post-auth.php +++ b/examples/garanti/regular/post-auth.php @@ -4,7 +4,7 @@ $templateTitle = 'Post Auth Order (ön provizyonu tamamlama)'; -$order = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $order['id'], diff --git a/examples/garanti/regular/refund.php b/examples/garanti/regular/refund.php index 13989660..c7b71917 100644 --- a/examples/garanti/regular/refund.php +++ b/examples/garanti/regular/refund.php @@ -6,7 +6,7 @@ use Mews\Pos\Gateways\AbstractGateway; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], diff --git a/examples/garanti/regular/status.php b/examples/garanti/regular/status.php index 370524fa..31acb932 100644 --- a/examples/garanti/regular/status.php +++ b/examples/garanti/regular/status.php @@ -6,7 +6,7 @@ use Mews\Pos\Gateways\AbstractGateway; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], diff --git a/examples/interpos/regular/cancel.php b/examples/interpos/regular/cancel.php index dff7120f..480bb527 100644 --- a/examples/interpos/regular/cancel.php +++ b/examples/interpos/regular/cancel.php @@ -6,7 +6,7 @@ $templateTitle = 'Cancel Order'; require '../../template/_header.php'; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], diff --git a/examples/interpos/regular/post-auth.php b/examples/interpos/regular/post-auth.php index ea29e895..79392727 100644 --- a/examples/interpos/regular/post-auth.php +++ b/examples/interpos/regular/post-auth.php @@ -4,7 +4,7 @@ $templateTitle = 'Post Auth Order (ön provizyonu tamamlama)'; -$order = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $session->set('post_order', $order); $transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; diff --git a/examples/interpos/regular/refund.php b/examples/interpos/regular/refund.php index ad393176..0d4c01eb 100644 --- a/examples/interpos/regular/refund.php +++ b/examples/interpos/regular/refund.php @@ -6,7 +6,7 @@ $templateTitle = 'Refund Order'; require '../../template/_header.php'; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); // Refund Order $order = [ diff --git a/examples/template/_footer.php b/examples/template/_footer.php index 50325810..c99eadaa 100644 --- a/examples/template/_footer.php +++ b/examples/template/_footer.php @@ -1,4 +1,4 @@ - + diff --git a/examples/vakifbank/regular/cancel.php b/examples/vakifbank/regular/cancel.php index 5b8007a8..232628be 100644 --- a/examples/vakifbank/regular/cancel.php +++ b/examples/vakifbank/regular/cancel.php @@ -6,7 +6,7 @@ $templateTitle = 'Cancel Order'; require '../../template/_header.php'; -$order = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $order['id'], //ReferenceTransactionId diff --git a/examples/vakifbank/regular/post-auth.php b/examples/vakifbank/regular/post-auth.php index 1e6998cb..f370b71a 100644 --- a/examples/vakifbank/regular/post-auth.php +++ b/examples/vakifbank/regular/post-auth.php @@ -4,7 +4,7 @@ $templateTitle = 'Post Auth Order (ön provizyonu tamamlama)'; -$order = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $order['id'], diff --git a/examples/vakifbank/regular/refund.php b/examples/vakifbank/regular/refund.php index f84ecc96..9440d95c 100644 --- a/examples/vakifbank/regular/refund.php +++ b/examples/vakifbank/regular/refund.php @@ -6,7 +6,7 @@ $templateTitle = 'Refund Order'; require '../../template/_header.php'; -$order = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); // Refund Order $order = [ 'id' => $order['id'], //ReferenceTransactionId diff --git a/examples/ykb/regular/cancel.php b/examples/ykb/regular/cancel.php index 12bc798b..3fca573a 100644 --- a/examples/ykb/regular/cancel.php +++ b/examples/ykb/regular/cancel.php @@ -4,7 +4,7 @@ $templateTitle = 'Cancel Order'; require '../../template/_header.php'; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], diff --git a/examples/ykb/regular/post-auth.php b/examples/ykb/regular/post-auth.php index a343dacf..3c88ff08 100644 --- a/examples/ykb/regular/post-auth.php +++ b/examples/ykb/regular/post-auth.php @@ -4,7 +4,7 @@ $templateTitle = 'Post Auth Order (ön provizyonu tamamlama)'; -$order = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $order['id'], diff --git a/examples/ykb/regular/refund.php b/examples/ykb/regular/refund.php index 0057c14d..2019852a 100644 --- a/examples/ykb/regular/refund.php +++ b/examples/ykb/regular/refund.php @@ -6,7 +6,7 @@ $templateTitle = 'Refund Order'; require '../../template/_header.php'; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $transaction = AbstractGateway::TX_REFUND; $pos->prepare([ diff --git a/examples/ykb/regular/status.php b/examples/ykb/regular/status.php index 247bf8ed..65e1a210 100644 --- a/examples/ykb/regular/status.php +++ b/examples/ykb/regular/status.php @@ -6,7 +6,7 @@ $templateTitle = 'Order Status'; require '../../template/_header.php'; -$ord = $session->get('order') ? $session->get('order') : getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); $order = [ 'id' => $ord['id'], From 0e6876c0e45036b6ab31b9d21a79c5a1af2334f4 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Feb 2023 23:23:05 +0100 Subject: [PATCH 05/54] rector process test - first round --- tests/Crypt/KuveytPosCryptTest.php | 8 ++++++++ tests/Crypt/PayForPosCryptTest.php | 11 +++++++++++ tests/Crypt/PosNetCryptTest.php | 6 ++++++ tests/DataMapper/KuveytPosRequestDataMapperTest.php | 8 +++++++- tests/DataMapper/PosNetRequestDataMapperTest.php | 2 -- .../DataMapper/VakifBankPosRequestDataMapperTest.php | 12 +++++++----- tests/Gateways/KuveytPosTest.php | 3 --- 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/tests/Crypt/KuveytPosCryptTest.php b/tests/Crypt/KuveytPosCryptTest.php index 80c4694a..38755704 100644 --- a/tests/Crypt/KuveytPosCryptTest.php +++ b/tests/Crypt/KuveytPosCryptTest.php @@ -11,6 +11,14 @@ class KuveytPosCryptTest extends TestCase { + /** + * @var array|array + */ + public $order; + /** + * @var KuveytPosCrypt + */ + public $crypt; /** * @var KuveytPosAccount */ diff --git a/tests/Crypt/PayForPosCryptTest.php b/tests/Crypt/PayForPosCryptTest.php index 26aaf482..90fc852a 100644 --- a/tests/Crypt/PayForPosCryptTest.php +++ b/tests/Crypt/PayForPosCryptTest.php @@ -3,6 +3,7 @@ namespace Mews\Pos\Tests\Crypt; use Mews\Pos\Crypt\PayForPosCrypt; +use Mews\Pos\Entity\Account\PayForAccount; use Mews\Pos\Factory\AccountFactory; use Mews\Pos\Gateways\AbstractGateway; use PHPUnit\Framework\TestCase; @@ -10,9 +11,19 @@ class PayForPosCryptTest extends TestCase { + /** + * @var array|array + */ + public $order; + /** * @var PayForPosCrypt */ + public $crypt; + + /** + * @var PayForAccount + */ private $threeDAccount; protected function setUp(): void diff --git a/tests/Crypt/PosNetCryptTest.php b/tests/Crypt/PosNetCryptTest.php index 99090f1d..70855e3e 100644 --- a/tests/Crypt/PosNetCryptTest.php +++ b/tests/Crypt/PosNetCryptTest.php @@ -3,6 +3,7 @@ namespace Mews\Pos\Tests\Crypt; use Mews\Pos\Crypt\PosNetCrypt; +use Mews\Pos\Entity\Account\PosNetAccount; use Mews\Pos\Factory\AccountFactory; use Mews\Pos\Gateways\AbstractGateway; use PHPUnit\Framework\TestCase; @@ -13,6 +14,11 @@ class PosNetCryptTest extends TestCase /** * @var PosNetCrypt */ + public $crypt; + + /** + * @var PosNetAccount + */ private $threeDAccount; protected function setUp(): void diff --git a/tests/DataMapper/KuveytPosRequestDataMapperTest.php b/tests/DataMapper/KuveytPosRequestDataMapperTest.php index 9a2a2c3a..218bb161 100644 --- a/tests/DataMapper/KuveytPosRequestDataMapperTest.php +++ b/tests/DataMapper/KuveytPosRequestDataMapperTest.php @@ -5,6 +5,7 @@ namespace Mews\Pos\Tests\DataMapper; use Mews\Pos\DataMapper\KuveytPosRequestDataMapper; +use Mews\Pos\Entity\Account\KuveytPosAccount; use Mews\Pos\Entity\Card\AbstractCreditCard; use Mews\Pos\Exceptions\BankClassNullException; use Mews\Pos\Exceptions\BankNotFoundException; @@ -21,6 +22,11 @@ */ class KuveytPosRequestDataMapperTest extends TestCase { + /** + * @var KuveytPosAccount + */ + public $threeDAccount; + /** @var AbstractCreditCard */ private $card; @@ -133,7 +139,7 @@ public function testCompose3DFormData() 'FailUrl' => $order->fail_url, ]; - if ($card) { + if ($card !== null) { $inputs['CardHolderName'] = $card->getHolderName(); $inputs['CardType'] = 'Visa'; $inputs['CardNumber'] = $card->getNumber(); diff --git a/tests/DataMapper/PosNetRequestDataMapperTest.php b/tests/DataMapper/PosNetRequestDataMapperTest.php index 29dfacf1..e8f0b148 100644 --- a/tests/DataMapper/PosNetRequestDataMapperTest.php +++ b/tests/DataMapper/PosNetRequestDataMapperTest.php @@ -38,8 +38,6 @@ protected function setUp(): void { parent::setUp(); - $this->config = require __DIR__.'/../../config/pos.php'; - $threeDAccount = AccountFactory::createPosNetAccount( 'yapikredi', '6706598320', diff --git a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php index 4755b2c7..031dcee4 100644 --- a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php +++ b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php @@ -19,6 +19,10 @@ */ class VakifBankPosRequestDataMapperTest extends TestCase { + /** + * @var VakifBankAccount + */ + public $account; /** @var AbstractGateway */ private $pos; @@ -34,8 +38,6 @@ protected function setUp(): void { parent::setUp(); - $this->config = require __DIR__.'/../../config/pos.php'; - $this->account = AccountFactory::createVakifBankAccount( 'vakifbank', '000000000111111', @@ -119,9 +121,9 @@ public function testCreate3DPaymentRequestData() $pos->prepare($order, AbstractGateway::TX_PAY, $this->card); $txType = AbstractGateway::TX_PAY; $gatewayResponse = [ - 'Eci' => (string) rand(1, 100), - 'Cavv' => (string) rand(1, 100), - 'VerifyEnrollmentRequestId' => (string) rand(1, 100), + 'Eci' => (string) random_int(1, 100), + 'Cavv' => (string) random_int(1, 100), + 'VerifyEnrollmentRequestId' => (string) random_int(1, 100), ]; $expectedValue = $this->getSample3DPaymentRequestData($pos->getAccount(), $pos->getOrder(), $txType, $gatewayResponse, $pos->getCard()); diff --git a/tests/Gateways/KuveytPosTest.php b/tests/Gateways/KuveytPosTest.php index 07075d95..75b98933 100644 --- a/tests/Gateways/KuveytPosTest.php +++ b/tests/Gateways/KuveytPosTest.php @@ -18,7 +18,6 @@ use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Serializer\Encoder\XmlEncoder; /** * KuveytPosTest @@ -88,8 +87,6 @@ protected function setUp(): void 'John Doe', AbstractCreditCard::CARD_TYPE_VISA ); - - $this->xmlDecoder = new XmlEncoder(); } /** From 1a4a2395ad94de121aae3229d9873b26d917f372 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 21:41:03 +0100 Subject: [PATCH 06/54] normalize mapInstallment method --- src/DataMapper/EstPosRequestDataMapper.php | 7 ++----- src/DataMapper/GarantiPosRequestDataMapper.php | 7 ++----- src/DataMapper/InterPosRequestDataMapper.php | 7 ++----- src/DataMapper/KuveytPosRequestDataMapper.php | 7 ++----- src/DataMapper/PayForPosRequestDataMapper.php | 7 ++----- src/DataMapper/PosNetRequestDataMapper.php | 3 +-- src/DataMapper/VakifBankPosRequestDataMapper.php | 7 ++----- tests/DataMapper/EstPosRequestDataMapperTest.php | 4 ++-- tests/DataMapper/GarantiPosRequestDataMapperTest.php | 4 ++-- tests/DataMapper/InterPosRequestDataMapperTest.php | 4 ++-- tests/DataMapper/KuveytPosRequestDataMapperTest.php | 8 ++++---- tests/DataMapper/PayForPosRequestDataMapperTest.php | 8 ++++---- tests/DataMapper/VakifBankPosRequestDataMapperTest.php | 8 ++++---- 13 files changed, 31 insertions(+), 50 deletions(-) diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index ca1416f7..2b67a25a 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -269,12 +269,9 @@ public function create3DFormDataCommon(AbstractPosAccount $account, $order, stri ]; } - /** - * {@inheritDoc} - */ - public function mapInstallment(?int $installment) + public function mapInstallment(?int $installment): string { - return $installment > 1 ? $installment : ''; + return $installment > 1 ? (string) $installment : ''; } /** diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index 9d6e1ed0..dd4a8e2a 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -363,12 +363,9 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx ]; } - /** - * {@inheritDoc} - */ - public function mapInstallment(?int $installment) + public function mapInstallment(?int $installment): string { - return $installment > 1 ? $installment : ''; + return $installment > 1 ? (string) $installment : ''; } /** diff --git a/src/DataMapper/InterPosRequestDataMapper.php b/src/DataMapper/InterPosRequestDataMapper.php index 70953bd3..ef881b95 100644 --- a/src/DataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/InterPosRequestDataMapper.php @@ -208,12 +208,9 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx ]; } - /** - * {@inheritDoc} - */ - public function mapInstallment(?int $installment) + public function mapInstallment(?int $installment): string { - return $installment > 1 ? $installment : ''; + return $installment > 1 ? (string) $installment : ''; } /** diff --git a/src/DataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/KuveytPosRequestDataMapper.php index 85afa5b5..4ce404e3 100644 --- a/src/DataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/KuveytPosRequestDataMapper.php @@ -199,12 +199,9 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar throw new NotImplementedException(); } - /** - * {@inheritDoc} - */ - public function mapInstallment(?int $installment) + public function mapInstallment(?int $installment): string { - return $installment > 1 ? $installment : 0; + return $installment > 1 ? (string) $installment : '0'; } /** diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index 9b3ef3b4..01d46bc9 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -205,12 +205,9 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx ]; } - /** - * {@inheritDoc} - */ - public function mapInstallment(?int $installment) + public function mapInstallment(?int $installment): string { - return $installment > 1 ? $installment : 0; + return $installment > 1 ? (string) $installment : '0'; } /** diff --git a/src/DataMapper/PosNetRequestDataMapper.php b/src/DataMapper/PosNetRequestDataMapper.php index d9818097..6c9441b8 100644 --- a/src/DataMapper/PosNetRequestDataMapper.php +++ b/src/DataMapper/PosNetRequestDataMapper.php @@ -369,9 +369,8 @@ public static function formatOrderId(string $orderId, int $padLength = null): st /** * formats installment in 00, 02, 06 format - * {@inheritDoc} */ - public function mapInstallment(?int $installment) + public function mapInstallment(?int $installment): string { if ($installment > 1) { return str_pad((string) $installment, 2, '0', STR_PAD_LEFT); diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index c124c40c..c5f199d6 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -248,12 +248,9 @@ public static function amountFormat(float $amount): string return number_format($amount, 2, '.', ''); } - /** - * {@inheritDoc} - */ - public function mapInstallment(?int $installment) + public function mapInstallment(?int $installment): string { - return $installment > 1 ? $installment : 0; + return $installment > 1 ? (string) $installment : '0'; } /** diff --git a/tests/DataMapper/EstPosRequestDataMapperTest.php b/tests/DataMapper/EstPosRequestDataMapperTest.php index 21ccfe29..870da324 100644 --- a/tests/DataMapper/EstPosRequestDataMapperTest.php +++ b/tests/DataMapper/EstPosRequestDataMapperTest.php @@ -94,8 +94,8 @@ public function testMapCurrency() * * @testWith ["0", ""] * ["1", ""] - * ["2", 2] - * [2, 2] + * ["2", "2"] + * [2, "2"] * * @return void */ diff --git a/tests/DataMapper/GarantiPosRequestDataMapperTest.php b/tests/DataMapper/GarantiPosRequestDataMapperTest.php index 5bdc4a57..60e3a077 100644 --- a/tests/DataMapper/GarantiPosRequestDataMapperTest.php +++ b/tests/DataMapper/GarantiPosRequestDataMapperTest.php @@ -100,8 +100,8 @@ public function testMapCurrency() * * @testWith ["0", ""] * ["1", ""] - * ["2", 2] - * [2, 2] + * ["2", "2"] + * [2, "2"] * * @return void */ diff --git a/tests/DataMapper/InterPosRequestDataMapperTest.php b/tests/DataMapper/InterPosRequestDataMapperTest.php index 0dc69c48..d47b0123 100644 --- a/tests/DataMapper/InterPosRequestDataMapperTest.php +++ b/tests/DataMapper/InterPosRequestDataMapperTest.php @@ -92,8 +92,8 @@ public function testMapCurrency() * * @testWith ["0", ""] * ["1", ""] - * ["2", 2] - * [2, 2] + * ["2", "2"] + * [2, "2"] * * @return void */ diff --git a/tests/DataMapper/KuveytPosRequestDataMapperTest.php b/tests/DataMapper/KuveytPosRequestDataMapperTest.php index 218bb161..0713ae58 100644 --- a/tests/DataMapper/KuveytPosRequestDataMapperTest.php +++ b/tests/DataMapper/KuveytPosRequestDataMapperTest.php @@ -99,10 +99,10 @@ public function testMapCurrency() * @param string|int|null $installment * @param string|int $expected * - * @testWith ["0", 0] - * ["1", 0] - * ["2", 2] - * [2, 2] + * @testWith ["0", "0"] + * ["1", "0"] + * ["2", "2"] + * [2, "2"] * * @return void */ diff --git a/tests/DataMapper/PayForPosRequestDataMapperTest.php b/tests/DataMapper/PayForPosRequestDataMapperTest.php index 18da4d62..d967b963 100644 --- a/tests/DataMapper/PayForPosRequestDataMapperTest.php +++ b/tests/DataMapper/PayForPosRequestDataMapperTest.php @@ -83,10 +83,10 @@ public function testMapCurrency() * @param string|int|null $installment * @param string|int $expected * - * @testWith ["0", 0] - * ["1", 0] - * ["2", 2] - * [2, 2] + * @testWith ["0", "0"] + * ["1", "0"] + * ["2", "2"] + * [2, "2"] * * @return void */ diff --git a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php index 031dcee4..d53ecb1a 100644 --- a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php +++ b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php @@ -97,10 +97,10 @@ public function testMapCurrency() * @param string|int|null $installment * @param string|int $expected * - * @testWith ["0", 0] - * ["1", 0] - * ["2", 2] - * [2, 2] + * @testWith ["0", "0"] + * ["1", "0"] + * ["2", "2"] + * [2, "2"] * * @return void */ From 7163ea59325c48794ad5e054c9c8afff4aa0a51b Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 21:48:41 +0100 Subject: [PATCH 07/54] normalize mapInstallment method --- src/DataMapper/AbstractRequestDataMapper.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/DataMapper/AbstractRequestDataMapper.php b/src/DataMapper/AbstractRequestDataMapper.php index e9d3285e..615c6176 100644 --- a/src/DataMapper/AbstractRequestDataMapper.php +++ b/src/DataMapper/AbstractRequestDataMapper.php @@ -267,12 +267,7 @@ public function getRecurringOrderFrequencyMapping(): array return $this->recurringOrderFrequencyMapping; } - /** - * @param int|null $installment - * - * @return int|string - */ - abstract public function mapInstallment(?int $installment); + abstract public function mapInstallment(?int $installment): string; /** * bank returns error messages for specified language value From b80d593034a741a33ef2920f0b632b0d90120b19 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 22:17:30 +0100 Subject: [PATCH 08/54] rector round 2 --- src/Client/HttpClient.php | 5 - src/Crypt/CryptInterface.php | 14 +-- src/Crypt/GarantiPosCrypt.php | 8 -- src/Crypt/PosNetCrypt.php | 2 - src/DataMapper/AbstractRequestDataMapper.php | 110 ++++-------------- .../AbstractRequestDataMapperCrypt.php | 4 - src/DataMapper/EstPosRequestDataMapper.php | 12 +- src/DataMapper/EstV3PosRequestDataMapper.php | 3 + .../GarantiPosRequestDataMapper.php | 39 +++---- src/DataMapper/InterPosRequestDataMapper.php | 14 ++- src/DataMapper/KuveytPosRequestDataMapper.php | 9 +- src/DataMapper/PayForPosRequestDataMapper.php | 16 ++- src/DataMapper/PosNetRequestDataMapper.php | 4 +- .../VakifBankPosRequestDataMapper.php | 25 ++-- src/Entity/Account/AbstractPosAccount.php | 52 +++------ src/Entity/Account/GarantiPosAccount.php | 21 +--- src/Entity/Account/KuveytPosAccount.php | 10 -- src/Entity/Account/PosNetAccount.php | 6 - src/Entity/Account/VakifBankAccount.php | 23 +--- src/Entity/Card/AbstractCreditCard.php | 40 ++----- .../CardTypeNotSupportedException.php | 6 - src/Exceptions/CardTypeRequiredException.php | 10 +- src/Factory/AccountFactory.php | 98 ++++------------ src/Factory/CreditCardFactory.php | 17 ++- src/Factory/PosFactory.php | 25 +--- src/Gateways/AbstractGateway.php | 53 +-------- src/Gateways/EstPos.php | 4 +- src/Gateways/InterPos.php | 3 - src/Gateways/KuveytPos.php | 15 +-- src/Gateways/PayForPos.php | 8 +- src/Gateways/VakifBankPos.php | 10 +- src/PosInterface.php | 13 +-- tests/Crypt/KuveytPosCryptTest.php | 14 +-- tests/Crypt/PayForPosCryptTest.php | 12 +- tests/Crypt/PosNetCryptTest.php | 8 +- .../EstPosRequestDataMapperTest.php | 58 +-------- .../GarantiPosRequestDataMapperTest.php | 58 ++------- .../InterPosRequestDataMapperTest.php | 38 ------ .../KuveytPosRequestDataMapperTest.php | 6 +- .../PayForPosRequestDataMapperTest.php | 44 ------- .../PosNetRequestDataMapperTest.php | 77 ++---------- .../VakifBankPosRequestDataMapperTest.php | 61 +--------- tests/Gateways/KuveytPosTest.php | 14 +-- tests/Gateways/VakifBankPosTest.php | 12 +- 44 files changed, 201 insertions(+), 880 deletions(-) diff --git a/src/Client/HttpClient.php b/src/Client/HttpClient.php index 647e3d4a..7a3832b7 100644 --- a/src/Client/HttpClient.php +++ b/src/Client/HttpClient.php @@ -24,11 +24,6 @@ class HttpClient /** @var StreamFactoryInterface */ protected $streamFactory; - /** - * @param ClientInterface $client - * @param RequestFactoryInterface $requestFactory - * @param StreamFactoryInterface $streamFactory - */ public function __construct( ClientInterface $client, RequestFactoryInterface $requestFactory, diff --git a/src/Crypt/CryptInterface.php b/src/Crypt/CryptInterface.php index 1e6370d5..3cc95b54 100644 --- a/src/Crypt/CryptInterface.php +++ b/src/Crypt/CryptInterface.php @@ -10,33 +10,21 @@ interface CryptInterface /** * check hash of 3D secure response * - * @param AbstractPosAccount $account * @param array $data - * - * @return bool */ public function check3DHash(AbstractPosAccount $account, array $data): bool; /** * creates hash for 3D secure payments * - * @param AbstractPosAccount $account * @param array $requestData - * @param string|null $txType - * - * @return string */ public function create3DHash(AbstractPosAccount $account, array $requestData, ?string $txType = null): string; /** * create hash for non-3D actions * - * @param AbstractPosAccount $account - * @param array $requestData - * @param string|null $txType - * @param AbstractCreditCard|null $card - * - * @return string + * @param array $requestData */ public function createHash(AbstractPosAccount $account, array $requestData, ?string $txType = null, ?AbstractCreditCard $card = null): string; } diff --git a/src/Crypt/GarantiPosCrypt.php b/src/Crypt/GarantiPosCrypt.php index 66984486..f570aab4 100644 --- a/src/Crypt/GarantiPosCrypt.php +++ b/src/Crypt/GarantiPosCrypt.php @@ -85,9 +85,6 @@ public function createHash(AbstractPosAccount $account, array $requestData, ?str * Make Security Data * * @param GarantiPosAccount $account - * @param string|null $txType - * - * @return string */ private function createSecurityData(AbstractPosAccount $account, ?string $txType = null): string { @@ -101,11 +98,6 @@ private function createSecurityData(AbstractPosAccount $account, ?string $txType return $this->hashStringUpperCase(implode(static::HASH_SEPARATOR, $map)); } - /** - * @param string $str - * - * @return string - */ protected function hashStringUpperCase(string $str): string { return strtoupper(hash(static::HASH_ALGORITHM, $str)); diff --git a/src/Crypt/PosNetCrypt.php b/src/Crypt/PosNetCrypt.php index cf00289f..ee8b00fe 100644 --- a/src/Crypt/PosNetCrypt.php +++ b/src/Crypt/PosNetCrypt.php @@ -82,8 +82,6 @@ public function createHash(AbstractPosAccount $account, array $requestData, ?str * Make Security Data * * @param PosNetAccount $account - * - * @return string */ public function createSecurityData(AbstractPosAccount $account): string { diff --git a/src/DataMapper/AbstractRequestDataMapper.php b/src/DataMapper/AbstractRequestDataMapper.php index 615c6176..b4907fe4 100644 --- a/src/DataMapper/AbstractRequestDataMapper.php +++ b/src/DataMapper/AbstractRequestDataMapper.php @@ -15,9 +15,7 @@ */ abstract class AbstractRequestDataMapper { - /** - * @var array - */ + /** @var array */ protected $secureTypeMappings = []; /** @@ -40,15 +38,15 @@ abstract class AbstractRequestDataMapper * fakat bazi banklar ISO standarti kullanmiyorlar. * Currency mapping * - * @var array + * @var non-empty-array */ protected $currencyMappings = [ - 'TRY' => 949, - 'USD' => 840, - 'EUR' => 978, - 'GBP' => 826, - 'JPY' => 392, - 'RUB' => 643, + 'TRY' => '949', + 'USD' => '840', + 'EUR' => '978', + 'GBP' => '826', + 'JPY' => '392', + 'RUB' => '643', ]; /** @@ -64,8 +62,7 @@ abstract class AbstractRequestDataMapper protected $crypt; /** - * @param CryptInterface|null $crypt - * @param array $currencyMappings + * @param array $currencyMappings */ public function __construct(?CryptInterface $crypt = null, array $currencyMappings = []) { @@ -78,101 +75,52 @@ public function __construct(?CryptInterface $crypt = null, array $currencyMappin /** * @phpstan-param AbstractGateway::TX_* $txType * - * @param AbstractPosAccount $account - * @param $order - * @param array $responseData gateway'den gelen cevap - * - * @return array + * @param $order + * @param array $responseData gateway'den gelen cevap */ abstract public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array; /** - * @phpstan-param AbstractGateway::TX_* $txType - * - * @param AbstractPosAccount $account - * @param $order - * @param AbstractCreditCard|null $card - * - * @return array + * @param AbstractGateway::TX_* $txType + * @param $order */ abstract public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array; - /** - * @param AbstractPosAccount $account - * @param $order - * @param AbstractCreditCard|null $card - * - * @return array - */ abstract public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array; - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ abstract public function createStatusRequestData(AbstractPosAccount $account, $order): array; /** - * @param AbstractPosAccount $account - * @param object $order - * - * @return array + * @param object $order */ abstract public function createCancelRequestData(AbstractPosAccount $account, $order): array; - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ abstract public function createRefundRequestData(AbstractPosAccount $account, $order): array; /** - * @phpstan-param AbstractGateway::TX_* $txType - * - * @param AbstractPosAccount $account - * @param $order - * @param string $gatewayURL - * @param string $txType - * @param AbstractCreditCard|null $card + * @param AbstractGateway::TX_* $txType + * @param $order * - * @return array + * @return array{gateway: string, inputs: array} */ abstract public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array; /** - * @param AbstractPosAccount $account - * @param $order - * @param array $extraData bankaya gore degisen ozel degerler - * - * @return array + * @param $order + * @param array $extraData bankaya gore degisen ozel degerler */ abstract public function createHistoryRequestData(AbstractPosAccount $account, $order, array $extraData = []): array; - /** - * @return CryptInterface - */ public function getCrypt(): CryptInterface { return $this->crypt; } - /** - * @return bool - */ public function isTestMode(): bool { return $this->testMode; } - /** - * @param string $period - * - * @return string - */ public function mapRecurringFrequency(string $period): string { return $this->recurringOrderFrequencyMapping[$period] ?? $period; @@ -203,19 +151,13 @@ public function getTxTypeMappings(): array } /** - * @return array + * @return non-empty-array */ public function getCurrencyMappings(): array { return $this->currencyMappings; } - - /** - * @param bool $testMode - * - * @return AbstractRequestDataMapper - */ public function setTestMode(bool $testMode): self { $this->testMode = $testMode; @@ -236,8 +178,6 @@ public function mapCurrency(string $currency): string /** * @phpstan-param AbstractGateway::TX_* $txType * - * @return string - * * @throws UnsupportedTransactionTypeException */ public function mapTxType(string $txType): string @@ -249,11 +189,6 @@ public function mapTxType(string $txType): string return $this->txTypeMappings[$txType]; } - /** - * @param string $txType - * - * @return bool - */ public function isSupportedTxType(string $txType): bool { return isset($this->txTypeMappings[$txType]); @@ -272,11 +207,6 @@ abstract public function mapInstallment(?int $installment): string; /** * bank returns error messages for specified language value * usually accepted values are tr,en - * - * @param AbstractPosAccount $account - * @param $order - * - * @return string */ protected function getLang(AbstractPosAccount $account, $order): string { diff --git a/src/DataMapper/AbstractRequestDataMapperCrypt.php b/src/DataMapper/AbstractRequestDataMapperCrypt.php index 58be17ea..c59d628f 100644 --- a/src/DataMapper/AbstractRequestDataMapperCrypt.php +++ b/src/DataMapper/AbstractRequestDataMapperCrypt.php @@ -16,7 +16,6 @@ abstract class AbstractRequestDataMapperCrypt extends AbstractRequestDataMapper protected $crypt; /** - * @param CryptInterface $crypt * @param array $currencyMappings */ public function __construct(CryptInterface $crypt, array $currencyMappings = []) @@ -24,9 +23,6 @@ public function __construct(CryptInterface $crypt, array $currencyMappings = []) parent::__construct($crypt, $currencyMappings); } - /** - * @return CryptInterface - */ public function getCrypt(): CryptInterface { return $this->crypt; diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index 2b67a25a..7f5f2b71 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -6,6 +6,7 @@ use Mews\Pos\Entity\Account\AbstractPosAccount; use Mews\Pos\Entity\Card\AbstractCreditCard; +use Mews\Pos\Exceptions\UnsupportedTransactionTypeException; use Mews\Pos\Gateways\AbstractGateway; /** @@ -234,6 +235,10 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx /** * @param AbstractGateway::TX_* $txType + * + * @return array{gateway: string, inputs: array} + * + * @throws UnsupportedTransactionTypeException */ public function create3DFormDataCommon(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { @@ -275,9 +280,7 @@ public function mapInstallment(?int $installment): string } /** - * @param AbstractPosAccount $account - * - * @return array + * @return array{Name: string, Password: string, ClientId: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { @@ -288,6 +291,9 @@ private function getRequestAccountData(AbstractPosAccount $account): array ]; } + /** + * @return array{PbOrder: array{OrderType: int, OrderFrequencyInterval: mixed, OrderFrequencyCycle: string, TotalNumberPayments: mixed}} + */ private function getRecurringRequestOrderData($order): array { return [ diff --git a/src/DataMapper/EstV3PosRequestDataMapper.php b/src/DataMapper/EstV3PosRequestDataMapper.php index e36d3280..6de8399c 100644 --- a/src/DataMapper/EstV3PosRequestDataMapper.php +++ b/src/DataMapper/EstV3PosRequestDataMapper.php @@ -12,6 +12,9 @@ */ class EstV3PosRequestDataMapper extends EstPosRequestDataMapper { + /** + * @inheritDoc + */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { $data = $this->create3DFormDataCommon($account, $order, $txType, $gatewayURL, $card); diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index dd4a8e2a..33cd263b 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -58,6 +58,8 @@ class GarantiPosRequestDataMapper extends AbstractRequestDataMapperCrypt * @param GarantiPosAccount $account * * {@inheritDoc} + * + * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed, AddressList: mixed[]}, Transaction: array{Type: mixed, InstallmentCnt: int|string, Amount: mixed, CurrencyCode: mixed, CardholderPresentCode: string, MotoInd: string, Secure3D: array{AuthenticationCode: mixed, SecurityLevel: mixed, TxnID: mixed, Md: mixed}}, Recurring?: mixed[]} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { @@ -106,6 +108,8 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, * @param GarantiPosAccount $account * * {@inheritDoc} + * + * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Card: mixed[], Order: array{OrderID: mixed, AddressList: mixed[]}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string}, Recurring?: mixed[]} */ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array { @@ -148,7 +152,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ /** * @param GarantiPosAccount $account * - * {@inheritDoc} + * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, Amount: int, CurrencyCode: string, OriginalRetrefNum: mixed}} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { @@ -181,7 +185,7 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $ac /** * @param GarantiPosAccount $account * - * {@inheritDoc} + * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string}} */ public function createStatusRequestData(AbstractPosAccount $account, $order): array { @@ -217,6 +221,8 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar * @param GarantiPosAccount $account * * {@inheritDoc} + * + * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string, OriginalRetrefNum: mixed}} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -252,7 +258,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar /** * @param GarantiPosAccount $account * - * {@inheritDoc} + * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string, OriginalRetrefNum: mixed}} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -289,6 +295,8 @@ public function createRefundRequestData(AbstractPosAccount $account, $order): ar * @param GarantiPosAccount $account * * {@inheritDoc} + * + * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string}} */ public function createHistoryRequestData(AbstractPosAccount $account, $order, array $extraData = []): array { @@ -323,7 +331,10 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar /** * @param GarantiPosAccount $account + * * {@inheritDoc} + * + * @return array{gateway: string, inputs: array{secure3dsecuritylevel: string, mode: string, apiversion: string, terminalprovuserid: string, terminaluserid: string, terminalmerchantid: string, terminalid: string, txntype: string, txnamount: mixed, txncurrencycode: mixed, txninstallmentcount: mixed, orderid: mixed, successurl: mixed, errorurl: mixed, customeremailaddress: mixed, customeripaddress: mixed, secure3dhash: string}|array{secure3dsecuritylevel: string, mode: string, apiversion: string, terminalprovuserid: string, terminaluserid: string, terminalmerchantid: string, terminalid: string, txntype: string, txnamount: mixed, txncurrencycode: mixed, txninstallmentcount: mixed, orderid: mixed, successurl: mixed, errorurl: mixed, customeremailaddress: mixed, customeripaddress: mixed, secure3dhash: string, cardnumber: string, cardexpiredatemonth: string, cardexpiredateyear: string, cardcvv2: string}} */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { @@ -372,17 +383,12 @@ public function mapInstallment(?int $installment): string * Amount Formatter * converts 100 to 10000, or 10.01 to 1001 * @param float $amount - * - * @return int */ public static function amountFormat($amount): int { return (int) (round($amount, 2) * 100); } - /** - * @return string - */ private function getMode(): string { return $this->isTestMode() ? 'TEST' : 'PROD'; @@ -390,10 +396,8 @@ private function getMode(): string /** * @param GarantiPosAccount $account - * @param string $hash - * @param bool $isRefund * - * @return array + * @return array{ProvUserID: string, UserID: string, HashData: string, ID: string, MerchantID: string} */ private function getTerminalData(AbstractPosAccount $account, string $hash, bool $isRefund = false): array { @@ -406,11 +410,6 @@ private function getTerminalData(AbstractPosAccount $account, string $hash, bool ]; } - /** - * @param AbstractCreditCard|null $card - * - * @return array - */ private function getCardData(?AbstractCreditCard $card = null): array { if ($card !== null) { @@ -429,9 +428,9 @@ private function getCardData(?AbstractCreditCard $card = null): array } /** - * @param $order + * @param object $order * - * @return array + * @return array{Address: array{Type: string, Name: mixed, LastName: string, Company: string, Text: string, District: string, City: string, PostalCode: string, Country: string, PhoneNumber: string}} */ private function getOrderAddressData($order): array { @@ -467,9 +466,9 @@ private function getOrderAddressData($order): array * * * - * @param $order + * @param object $order * - * @return array + * @return array{TotalPaymentNum: mixed, FrequencyType: string, FrequencyInterval: mixed, Type: mixed, StartDate: mixed} */ private function createRecurringData($order): array { diff --git a/src/DataMapper/InterPosRequestDataMapper.php b/src/DataMapper/InterPosRequestDataMapper.php index ef881b95..19581701 100644 --- a/src/DataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/InterPosRequestDataMapper.php @@ -56,6 +56,8 @@ class InterPosRequestDataMapper extends AbstractRequestDataMapperCrypt ]; /** * {@inheritDoc} + * + * @return array{TxnType: string, SecureType: string, OrderId: mixed, PurchAmount: mixed, Currency: string, InstallmentCount: string, MD: mixed, PayerTxnId: mixed, Eci: mixed, PayerAuthenticationCode: mixed, MOTO: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { @@ -102,7 +104,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ } /** - * {@inheritDoc} + * @return array{TxnType: string, SecureType: string, OrderId: null, orgOrderId: mixed, PurchAmount: mixed, Currency: string, MOTO: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { @@ -118,7 +120,7 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $ac } /** - * {@inheritDoc} + * @return array{OrderId: null, orgOrderId: mixed, TxnType: string, SecureType: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createStatusRequestData(AbstractPosAccount $account, $order): array { @@ -133,6 +135,8 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * + * @return array{OrderId: null, orgOrderId: mixed, TxnType: string, SecureType: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -146,7 +150,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar } /** - * {@inheritDoc} + * @return array{OrderId: null, orgOrderId: mixed, PurchAmount: mixed, TxnType: string, SecureType: string, Lang: string, MOTO: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -214,9 +218,7 @@ public function mapInstallment(?int $installment): string } /** - * @param AbstractPosAccount $account - * - * @return array + * @return array{UserCode: string, UserPass: string, ShopCode: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/DataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/KuveytPosRequestDataMapper.php index 4ce404e3..48c0643d 100644 --- a/src/DataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/KuveytPosRequestDataMapper.php @@ -65,10 +65,6 @@ class KuveytPosRequestDataMapper extends AbstractRequestDataMapperCrypt /** * Amount Formatter * converts 100 to 10000, or 10.01 to 1001 - * - * @param float $amount - * - * @return int */ public static function amountFormat(float $amount): int { @@ -79,6 +75,8 @@ public static function amountFormat(float $amount): int * @param KuveytPosAccount $account * * {@inheritDoc} + * + * @return array{APIVersion: string, HashData: string, CustomerIPAddress: mixed, KuveytTurkVPosAdditionalData: array{AdditionalData: array{Key: string, Data: mixed}}, TransactionType: string, InstallmentCount: mixed, Amount: mixed, DisplayAmount: int, CurrencyCode: mixed, MerchantOrderId: mixed, TransactionSecurity: mixed, MerchantId: string, CustomerId: string, UserName: string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { @@ -107,7 +105,6 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, } /** - * @param KuveytPosAccount $account * @param AbstractGateway::TX_* $txType */ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array @@ -207,7 +204,7 @@ public function mapInstallment(?int $installment): string /** * @param KuveytPosAccount $account * - * @return array + * @return array{MerchantId: string, CustomerId: string, UserName: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index 01d46bc9..77a08a86 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -48,6 +48,8 @@ class PayForPosRequestDataMapper extends AbstractRequestDataMapper /** * {@inheritDoc} + * + * @return array{RequestGuid: mixed, UserCode: string, UserPass: string, OrderId: mixed, SecureType: string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { @@ -62,6 +64,8 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, /** * {@inheritDoc} + * + * @return array{MbrId: string, MOTO: string, OrderId: mixed, SecureType: string, TxnType: string, PurchAmount: mixed, Currency: string, InstallmentCount: string, Lang: string, CardHolderName: string|null, Pan: string, Expiry: string, Cvv2: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array { @@ -83,7 +87,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ } /** - * {@inheritDoc} + * @return array{MbrId: string, OrgOrderId: mixed, SecureType: string, TxnType: string, PurchAmount: mixed, Currency: string, Lang: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { @@ -99,7 +103,7 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $ac } /** - * {@inheritDoc} + * @return array{MbrId: string, OrgOrderId: mixed, SecureType: string, Lang: string, TxnType: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createStatusRequestData(AbstractPosAccount $account, $order): array { @@ -114,6 +118,8 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * + * @return array{MbrId: string, OrgOrderId: mixed, SecureType: string, TxnType: string, Currency: string, Lang: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -128,7 +134,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar } /** - * {@inheritDoc} + * @return array{MbrId: string, SecureType: string, Lang: string, OrgOrderId: mixed, TxnType: string, PurchAmount: mixed, Currency: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -211,9 +217,7 @@ public function mapInstallment(?int $installment): string } /** - * @param AbstractPosAccount $account - * - * @return array + * @return array{MerchantId: string, UserCode: string, UserPass: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/DataMapper/PosNetRequestDataMapper.php b/src/DataMapper/PosNetRequestDataMapper.php index 6c9441b8..2d3d2c3c 100644 --- a/src/DataMapper/PosNetRequestDataMapper.php +++ b/src/DataMapper/PosNetRequestDataMapper.php @@ -218,10 +218,10 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar /** - * @param PosNetAccount $account - * * {@inheritDoc} * + * @param PosNetAccount $account + * * @throws Exception */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null, $extraData = null): array diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index c5f199d6..fccd61ae 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -52,7 +52,10 @@ class VakifBankPosRequestDataMapper extends AbstractRequestDataMapper /** * @param VakifBankAccount $account + * * {@inheritDoc} + * + * @return array{TransactionType: string, TransactionId: mixed, CurrencyAmount: string, CurrencyCode: string, CardHoldersName: string|null, Cvv: string, Pan: string, Expiry: string, ECI: mixed, CAVV: mixed, MpiTransactionId: mixed, OrderId: mixed, OrderDescription: mixed, ClientIp: mixed, TransactionDeviceSource: int, MerchantId: string, Password: string, TerminalNo: string, NumberOfInstallments?: int|string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData, ?AbstractCreditCard $card = null): array { @@ -84,9 +87,6 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, /** * @param VakifBankAccount $account * @param object $order - * @param AbstractCreditCard $card - * - * @return array */ public function create3DEnrollmentCheckRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array { @@ -155,11 +155,10 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ } /** - * @param VakifBankAccount $account - * @param $order - * @param AbstractCreditCard|null $card + * @param VakifBankAccount $account + * @param object $order * - * @return array + * @return array{TransactionType: string, ReferenceTransactionId: mixed, CurrencyAmount: string, CurrencyCode: string, ClientIp: mixed, MerchantId: string, Password: string, TerminalNo: string} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { @@ -182,6 +181,8 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * + * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: mixed, ClientIp: mixed} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -195,7 +196,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar } /** - * {@inheritDoc} + * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: mixed, ClientIp: mixed, CurrencyAmount: string} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -218,9 +219,9 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar } /** - * @param array $extraData - * * {@inheritDoc} + * + * @return array{gateway: mixed, inputs: array{PaReq: mixed, TermUrl: mixed, MD: mixed}} */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null, array $extraData = []): array { @@ -239,8 +240,6 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx /** * Amount Formatter * - * @param float $amount - * * @return string ex: 10.1 => 10.10 */ public static function amountFormat(float $amount): string @@ -256,7 +255,7 @@ public function mapInstallment(?int $installment): string /** * @param VakifBankAccount $account * - * @return array + * @return array{MerchantId: string, Password: string, TerminalNo: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/Entity/Account/AbstractPosAccount.php b/src/Entity/Account/AbstractPosAccount.php index 70337eec..db66aadf 100644 --- a/src/Entity/Account/AbstractPosAccount.php +++ b/src/Entity/Account/AbstractPosAccount.php @@ -4,33 +4,30 @@ namespace Mews\Pos\Entity\Account; +use Mews\Pos\Gateways\AbstractGateway; + abstract class AbstractPosAccount { - /** - * @var string - */ + /** @var string */ protected $clientId; /** * account models: regular, 3d, 3d_pay, 3d_host - * @var string + * @var AbstractGateway::MODEL_* */ protected $model; - /** - * @var string - */ + + /** @var string */ protected $username; - /** - * @var string - */ + + /** @var string */ protected $password; /** * required for non regular account models * @var string|null */ protected $storeKey; - /** - * @var string - */ + + /** @var string */ protected $lang; /** * bank key name used in configuration file @@ -41,13 +38,8 @@ abstract class AbstractPosAccount /** * AbstractPosAccount constructor. - * @param string $bank - * @param string $model - * @param string $clientId - * @param string $username - * @param string $password - * @param string $lang - * @param string|null $storeKey + * + * @param AbstractGateway::MODEL_* $model */ public function __construct(string $bank, string $model, string $clientId, string $username, string $password, string $lang, ?string $storeKey = null) { @@ -60,57 +52,39 @@ public function __construct(string $bank, string $model, string $clientId, strin $this->bank = $bank; } - /** - * @return string - */ public function getClientId(): string { return $this->clientId; } /** - * @return string + * @return AbstractGateway::MODEL_* */ public function getModel(): string { return $this->model; } - /** - * @return string - */ public function getUsername(): string { return $this->username; } - /** - * @return string - */ public function getPassword(): string { return $this->password; } - /** - * @return string|null - */ public function getStoreKey(): ?string { return $this->storeKey; } - /** - * @return string - */ public function getLang(): string { return $this->lang; } - /** - * @return string - */ public function getBank(): string { return $this->bank; diff --git a/src/Entity/Account/GarantiPosAccount.php b/src/Entity/Account/GarantiPosAccount.php index b89ef364..4687ff7f 100644 --- a/src/Entity/Account/GarantiPosAccount.php +++ b/src/Entity/Account/GarantiPosAccount.php @@ -9,17 +9,11 @@ */ class GarantiPosAccount extends AbstractPosAccount { - /** - * @var string - */ + /** @var string */ private $terminalId; - /** - * @var string - */ + /** @var string */ private $refundUsername; - /** - * @var string - */ + /** @var string */ private $refundPassword; public function __construct( @@ -41,25 +35,16 @@ public function __construct( $this->refundPassword = $refundPassword; } - /** - * @return string - */ public function getRefundPassword(): string { return $this->refundPassword; } - /** - * @return string - */ public function getRefundUsername(): string { return $this->refundUsername; } - /** - * @return string - */ public function getTerminalId(): string { return $this->terminalId; diff --git a/src/Entity/Account/KuveytPosAccount.php b/src/Entity/Account/KuveytPosAccount.php index f3c69ecd..62758e8e 100644 --- a/src/Entity/Account/KuveytPosAccount.php +++ b/src/Entity/Account/KuveytPosAccount.php @@ -15,14 +15,10 @@ class KuveytPosAccount extends AbstractPosAccount protected $subMerchantId; /** - * @param string $bank * @param string $merchantId Mağaza Numarası * @param string $username POS panelinizden kullanıcı işlemleri sayfasında APİ rolünde kullanıcı oluşturulmalıdır * @param string $customerId CustomerNumber, Müşteri No * @param string $storeKey Oluşturulan APİ kullanıcısının şifre bilgisidir. - * @param string $model - * @param string $lang - * @param string|null $subMerchantId */ public function __construct( string $bank, @@ -38,17 +34,11 @@ public function __construct( $this->subMerchantId = $subMerchantId; } - /** - * @return string - */ public function getCustomerId(): string { return $this->password; } - /** - * @return string|null - */ public function getSubMerchantId(): ?string { return $this->subMerchantId; diff --git a/src/Entity/Account/PosNetAccount.php b/src/Entity/Account/PosNetAccount.php index 976b52df..006dcdea 100644 --- a/src/Entity/Account/PosNetAccount.php +++ b/src/Entity/Account/PosNetAccount.php @@ -32,17 +32,11 @@ public function __construct( $this->posNetId = $posNetId; } - /** - * @return string - */ public function getTerminalId(): string { return $this->terminalId; } - /** - * @return string - */ public function getPosNetId(): string { return $this->posNetId; diff --git a/src/Entity/Account/VakifBankAccount.php b/src/Entity/Account/VakifBankAccount.php index 0cf6cc6a..8972e4b4 100644 --- a/src/Entity/Account/VakifBankAccount.php +++ b/src/Entity/Account/VakifBankAccount.php @@ -8,18 +8,14 @@ class VakifBankAccount extends AbstractPosAccount public const MERCHANT_TYPE_MAIN_DEALER = 1; public const MERCHANT_TYPE_SUB_DEALER = 2; - /** - * @var int[] - */ + /** @var int[] */ private static $merchantTypes = [ self::MERCHANT_TYPE_STANDARD, self::MERCHANT_TYPE_MAIN_DEALER, self::MERCHANT_TYPE_SUB_DEALER, ]; - /** - * @var string - */ + /** @var string */ private $terminalId; /** @@ -43,12 +39,9 @@ class VakifBankAccount extends AbstractPosAccount /** * VakifBankAccount constructor. * - * @param string $bank - * @param string $model * @param string $merchantId Isyeri No * @param string $password Isyeri Sifre * @param string $terminalId Terminal No - * @param int $merchantType * @param string|null $subMerchantId */ public function __construct( @@ -67,33 +60,21 @@ public function __construct( $this->subMerchantId = $subMerchantId; } - /** - * @return string - */ public function getTerminalId(): string { return $this->terminalId; } - /** - * @return int - */ public function getMerchantType(): int { return $this->merchantType; } - /** - * @return string|null - */ public function getSubMerchantId(): ?string { return $this->subMerchantId; } - /** - * @return bool - */ public function isSubBranch(): bool { return self::MERCHANT_TYPE_SUB_DEALER === $this->merchantType; diff --git a/src/Entity/Card/AbstractCreditCard.php b/src/Entity/Card/AbstractCreditCard.php index c5601254..f089224a 100644 --- a/src/Entity/Card/AbstractCreditCard.php +++ b/src/Entity/Card/AbstractCreditCard.php @@ -31,19 +31,15 @@ abstract class AbstractCreditCard /** * visa, master, troy, amex, ... - * @var string|null + * @var self::CARD_TYPE_*|null */ protected $type; /** * AbstractCreditCard constructor. * - * @param string $number credit card number with or without spaces - * @param DateTimeImmutable $expDate - * @param string $cvv - * @param string|null $cardHolderName - * @param string|null $cardType examples values: 'visa', 'master', '1', '2' - * + * @param string $number credit card number with or without spaces + * @param self::CARD_TYPE_*|null $cardType */ public function __construct(string $number, DateTimeImmutable $expDate, string $cvv, ?string $cardHolderName = null, ?string $cardType = null) { @@ -56,7 +52,6 @@ public function __construct(string $number, DateTimeImmutable $expDate, string $ /** * returns card number without white spaces - * @return string */ public function getNumber(): string { @@ -64,11 +59,7 @@ public function getNumber(): string } /** - * returns exp year in 2 digit format - * - * @param string $format - * - * @return string + * @return string year by default in 2 digit format. */ public function getExpireYear(string $format = 'y'): string { @@ -76,11 +67,7 @@ public function getExpireYear(string $format = 'y'): string } /** - * returns exp year in 2 digit format. i.e '01' '02' '12' - * - * @param string $format - * - * @return string + * @return string month number, by default in 2 digit format. i.e '01' '02' '12' */ public function getExpireMonth(string $format = 'm'): string { @@ -88,43 +75,30 @@ public function getExpireMonth(string $format = 'm'): string } /** - * returns card exp date month and year combined. - * - * @param string $format - * - * @return string + * @return string card exp date month and year combined. */ public function getExpirationDate(string $format = 'ym'): string { return $this->expDate->format($format); } - /** - * @return string - */ public function getCvv(): string { return $this->cvv; } - /** - * @return string|null - */ public function getHolderName(): ?string { return $this->holderName; } - /** - * @param string|null $name - */ public function setHolderName(?string $name) { $this->holderName = $name; } /** - * @return string|null + * @return self::CARD_TYPE_*|null */ public function getType(): ?string { diff --git a/src/Exceptions/CardTypeNotSupportedException.php b/src/Exceptions/CardTypeNotSupportedException.php index 74d16e6c..10cb4d5d 100644 --- a/src/Exceptions/CardTypeNotSupportedException.php +++ b/src/Exceptions/CardTypeNotSupportedException.php @@ -16,9 +16,6 @@ class CardTypeNotSupportedException extends DomainException /** * BankNotFoundException constructor. * - * @param string $type - * @param string $message - * @param int $code * @param Throwable|null $previous */ public function __construct(string $type, string $message = 'Card type is not supported by this gateway!', int $code = 74, Throwable $previous = null) @@ -27,9 +24,6 @@ public function __construct(string $type, string $message = 'Card type is not su $this->type = $type; } - /** - * @return string - */ public function getType(): string { return $this->type; diff --git a/src/Exceptions/CardTypeRequiredException.php b/src/Exceptions/CardTypeRequiredException.php index 4785b128..c01c700e 100644 --- a/src/Exceptions/CardTypeRequiredException.php +++ b/src/Exceptions/CardTypeRequiredException.php @@ -10,17 +10,12 @@ */ class CardTypeRequiredException extends DomainException { - /** - * @var string - */ + /** @var string */ private $gatewayName; /** * BankNotFoundException constructor. * - * @param string $gatewayName - * @param string $message - * @param int $code * @param Throwable|null $previous */ public function __construct(string $gatewayName, string $message = 'Card type is required for this gateway!', int $code = 73, Throwable $previous = null) @@ -29,9 +24,6 @@ public function __construct(string $gatewayName, string $message = 'Card type is $this->gatewayName = $gatewayName; } - /** - * @return string - */ public function getGatewayName(): string { return $this->gatewayName; diff --git a/src/Factory/AccountFactory.php b/src/Factory/AccountFactory.php index 8ba8e777..04e4fab9 100644 --- a/src/Factory/AccountFactory.php +++ b/src/Factory/AccountFactory.php @@ -20,15 +20,8 @@ class AccountFactory { /** - * @param string $bank - * @param string $clientId Üye iş yeri numarası - * @param string $kullaniciAdi - * @param string $password - * @param string $model - * @param string|null $storeKey - * @param string $lang - * - * @return EstPosAccount + * @param string $clientId Üye iş yeri numarası + * @param AbstractGateway::MODEL_* $model * * @throws MissingAccountInfoException */ @@ -40,15 +33,7 @@ public static function createEstPosAccount(string $bank, string $clientId, strin } /** - * @param string $bank - * @param string $merchantId - * @param string $userCode - * @param string $userPassword - * @param string $model - * @param string|null $merchantPass - * @param string $lang - * - * @return PayForAccount + * @param AbstractGateway::MODEL_* $model * * @throws MissingAccountInfoException */ @@ -60,18 +45,9 @@ public static function createPayForAccount(string $bank, string $merchantId, str } /** - * @param string $bank - * @param string $merchantId Üye işyeri Numarası - * @param string $userId - * @param string $password Terminal UserID şifresi - * @param string $terminalId - * @param string $model - * @param string|null $storeKey - * @param string|null $refundUsername - * @param string|null $refundPassword - * @param string $lang - * - * @return GarantiPosAccount + * @param string $merchantId Üye işyeri Numarası + * @param string $password Terminal UserID şifresi + * @param AbstractGateway::MODEL_* $model * * @throws MissingAccountInfoException */ @@ -84,16 +60,12 @@ public static function createGarantiPosAccount(string $bank, string $merchantId, /** - * @param string $bank - * @param string $merchantId Mağaza Numarası - * @param string $username POS panelinizden kullanıcı işlemleri sayfasında APİ rolünde kullanıcı oluşturulmalıdır - * @param string $customerId CustomerNumber, Müşteri No - * @param string $storeKey Oluşturulan APİ kullanıcısının şifre bilgisidir. - * @param string $model - * @param string $lang - * @param string|null $subMerchantId - * - * @return KuveytPosAccount + * @param string $merchantId Mağaza Numarası + * @param string $username POS panelinizden kullanıcı işlemleri sayfasında APİ rolünde + * kullanıcı oluşturulmalıdır + * @param string $customerId CustomerNumber, Müşteri No + * @param string $storeKey Oluşturulan APİ kullanıcısının şifre bilgisidir. + * @param AbstractGateway::MODEL_* $model */ public static function createKuveytPosAccount(string $bank, string $merchantId, string $username, string $customerId, string $storeKey, string $model = AbstractGateway::MODEL_3D_SECURE, string $lang = AbstractGateway::LANG_TR, ?string $subMerchantId = null): KuveytPosAccount { @@ -101,17 +73,9 @@ public static function createKuveytPosAccount(string $bank, string $merchantId, } /** - * @param string $bank - * @param string $merchantId - * @param string $username kullanilmamakta, bos atayin - * @param string $password kullanilmamakta, bos atayin - * @param string $terminalId - * @param string $posNetId - * @param string $model - * @param string|null $storeKey - * @param string $lang - * - * @return PosNetAccount + * @param string $username kullanilmamakta, bos atayin + * @param string $password kullanilmamakta, bos atayin + * @param AbstractGateway::MODEL_* $model * * @throws MissingAccountInfoException */ @@ -123,19 +87,15 @@ public static function createPosNetAccount(string $bank, string $merchantId, str } /** - * @param string $bank - * @param string $merchantId Üye işyeri numarası - * @param string $password Üye işyeri şifres - * @param string $terminalNo İşlemin hangi terminal üzerinden gönderileceği bilgisi. VB007000... - * @param string $model - * @param int $merchantType - * @param null $subMerchantId - * - * @return VakifBankAccount + * @param string $merchantId Üye işyeri numarası + * @param string $password Üye işyeri şifres + * @param string $terminalNo İşlemin hangi terminal üzerinden gönderileceği bilgisi. VB007000... + * @param AbstractGateway::MODEL_* $model + * @param string|null $subMerchantId * * @throws MissingAccountInfoException */ - public static function createVakifBankAccount(string $bank, string $merchantId, string $password, string $terminalNo, string $model = AbstractGateway::MODEL_NON_SECURE, int $merchantType = VakifBankAccount::MERCHANT_TYPE_STANDARD, $subMerchantId = null): VakifBankAccount + public static function createVakifBankAccount(string $bank, string $merchantId, string $password, string $terminalNo, string $model = AbstractGateway::MODEL_NON_SECURE, int $merchantType = VakifBankAccount::MERCHANT_TYPE_STANDARD, string $subMerchantId = null): VakifBankAccount { self::checkVakifBankMerchantType($merchantType, $subMerchantId); @@ -143,15 +103,7 @@ public static function createVakifBankAccount(string $bank, string $merchantId, } /** - * @param string $bank - * @param string $shopCode - * @param string $userCode - * @param string $userPass - * @param string $model - * @param string|null $merchantPass - * @param string $lang - * - * @return InterPosAccount + * @param AbstractGateway::MODEL_* $model * * @throws MissingAccountInfoException */ @@ -163,8 +115,7 @@ public static function createInterPosAccount(string $bank, string $shopCode, str } /** - * @param string $model - * @param string|null $storeKey + * @param AbstractGateway::MODEL_* $model * * @return void * @@ -182,9 +133,6 @@ private static function checkParameters(string $model, ?string $storeKey) } /** - * @param int $merchantType - * @param string|null $subMerchantId - * * @return void * * @throws MissingAccountInfoException diff --git a/src/Factory/CreditCardFactory.php b/src/Factory/CreditCardFactory.php index c97bade2..c1735c42 100644 --- a/src/Factory/CreditCardFactory.php +++ b/src/Factory/CreditCardFactory.php @@ -19,16 +19,13 @@ class CreditCardFactory /** * AbstractCreditCard constructor. * - * @param PosInterface|AbstractGateway $pos - * @param string $number credit card number with or without spaces - * @param string $expireYear accepts year in 1, 2 and 4 digit format. accepted year formats '1' (2001), '02' - * (2002), '20' (2020), '2024' (2024) - * @param string $expireMonth single digit or double digit month values are accepted - * @param string $cvv - * @param string|null $cardHolderName - * @param string|null $cardType examples values: visa, master. bankaya gore zorunlu - * - * @return AbstractCreditCard + * @param PosInterface|AbstractGateway $pos + * @param string $number credit card number with or without spaces + * @param string $expireYear accepts year in 1, 2 and 4 digit format. accepted year + * formats '1' (2001), '02' + * (2002), '20' (2020), '2024' (2024) + * @param string $expireMonth single digit or double digit month values are accepted + * @param AbstractCreditCard::CARD_TYPE_*|null $cardType bankaya gore zorunlu */ public static function create( PosInterface $pos, diff --git a/src/Factory/PosFactory.php b/src/Factory/PosFactory.php index ffaf04c5..6dfd6828 100644 --- a/src/Factory/PosFactory.php +++ b/src/Factory/PosFactory.php @@ -52,12 +52,7 @@ class PosFactory { /** - * @param AbstractPosAccount $posAccount - * @param array|string|null $config config path or config array - * @param HttpClient|null $client - * @param LoggerInterface|null $logger - * - * @return PosInterface + * @param array|string|null $config config path or config array * * @throws BankClassNullException * @throws BankNotFoundException @@ -115,11 +110,8 @@ public static function createPosGateway( } /** - * @param class-string $gatewayClass - * @param array $currencies - * @param CryptInterface|null $crypt - * - * @return AbstractRequestDataMapper + * @param class-string $gatewayClass + * @param array $currencies */ public static function getGatewayRequestMapper(string $gatewayClass, array $currencies = [], ?CryptInterface $crypt = null): AbstractRequestDataMapper { @@ -148,11 +140,7 @@ public static function getGatewayRequestMapper(string $gatewayClass, array $curr } /** - * @param class-string $gatewayClass - * @param AbstractRequestDataMapper $requestDataMapper - * @param LoggerInterface $logger - * - * @return AbstractResponseDataMapper + * @param class-string $gatewayClass */ public static function getGatewayResponseMapper(string $gatewayClass, AbstractRequestDataMapper $requestDataMapper, LoggerInterface $logger): AbstractResponseDataMapper { @@ -179,10 +167,7 @@ public static function getGatewayResponseMapper(string $gatewayClass, AbstractRe } /** - * @param class-string $gatewayClass - * @param LoggerInterface $logger - * - * @return CryptInterface|null + * @param class-string $gatewayClass */ public static function getGatewayCrypt(string $gatewayClass, LoggerInterface $logger): ?CryptInterface { diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 7eccf552..88f4fdb9 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -59,9 +59,7 @@ abstract class AbstractGateway implements PosInterface */ protected $type; - /** - * @var object|null - */ + /** @var object|null */ protected $order; /** @@ -144,16 +142,13 @@ public function prepare(array $order, string $txType, $card = null) $this->card = $card; } - /** - * @return array|null - */ public function getResponse(): ?array { return $this->response; } /** - * @return array + * @return non-empty-array */ public function getCurrencies(): array { @@ -173,17 +168,11 @@ public function getConfig() */ abstract public function getAccount(); - /** - * @return AbstractCreditCard|null - */ public function getCard(): ?AbstractCreditCard { return $this->card; } - /** - * @param AbstractCreditCard|null $card - */ public function setCard(?AbstractCreditCard $card) { $this->card = $card; @@ -219,41 +208,27 @@ public function createXML(array $nodes, string $encoding = 'UTF-8', bool $ignore /** * Is success - * - * @return bool */ public function isSuccess(): bool { return isset($this->response['status']) && $this->responseDataMapper::TX_APPROVED === $this->response['status']; } - /** - * @return string - */ public function getApiURL(): string { return $this->config['urls'][$this->getModeInWord()]; } - /** - * @return string - */ public function get3DGatewayURL(): string { return $this->config['urls']['gateway'][$this->getModeInWord()]; } - /** - * @return string|null - */ public function get3DHostGatewayURL(): ?string { return $this->config['urls']['gateway_3d_host'][$this->getModeInWord()] ?? null; } - /** - * @return bool - */ public function isTestMode(): bool { return $this->testMode; @@ -381,8 +356,6 @@ public function history(array $meta) } /** - * @param bool $testMode - * * @return $this */ public function setTestMode(bool $testMode): self @@ -463,15 +436,13 @@ abstract public function create3DPaymentXML($responseData); /** * returns form data, key values, necessary for 3D payment * - * @return array + * @return array{gateway: string, inputs: array} */ abstract public function get3DFormData(): array; /** * prepares order for payment request * - * @param array $order - * * @return object */ abstract protected function preparePaymentOrder(array $order); @@ -479,8 +450,6 @@ abstract protected function preparePaymentOrder(array $order); /** * prepares order for TX_POST_PAY type request * - * @param array $order - * * @return object */ abstract protected function preparePostPaymentOrder(array $order); @@ -488,8 +457,6 @@ abstract protected function preparePostPaymentOrder(array $order); /** * prepares order for order status request * - * @param array $order - * * @return object */ abstract protected function prepareStatusOrder(array $order); @@ -497,8 +464,6 @@ abstract protected function prepareStatusOrder(array $order); /** * prepares order for history request * - * @param array $order - * * @return object */ abstract protected function prepareHistoryOrder(array $order); @@ -506,8 +471,6 @@ abstract protected function prepareHistoryOrder(array $order); /** * prepares order for cancel request * - * @param array $order - * * @return object */ abstract protected function prepareCancelOrder(array $order); @@ -515,16 +478,12 @@ abstract protected function prepareCancelOrder(array $order); /** * prepares order for refund request * - * @param array $order - * * @return object */ abstract protected function prepareRefundOrder(array $order); /** * @param string $str - * - * @return bool */ protected function isHTML($str): bool { @@ -533,11 +492,6 @@ protected function isHTML($str): bool /** * Converts XML string to array - * - * @param string $data - * @param array $context - * - * @return array */ protected function XMLStringToArray(string $data, array $context = []): array { @@ -548,7 +502,6 @@ protected function XMLStringToArray(string $data, array $context = []): array /** * return values are used as a key in config file - * @return string */ private function getModeInWord(): string { diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index 60714681..9ddabcbd 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -23,9 +23,7 @@ class EstPos extends AbstractGateway */ public const NAME = 'EstPos'; - /** - * @var EstPosAccount - */ + /** @var EstPosAccount */ protected $account; /** diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 90aec9dd..13854efc 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -32,9 +32,6 @@ class InterPos extends AbstractGateway /** @var InterPosResponseDataMapper */ protected $responseDataMapper; - /** - * @return InterPosAccount - */ public function getAccount(): InterPosAccount { return $this->account; diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 703b3ef4..17aded37 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -40,9 +40,6 @@ public function createXML(array $nodes, string $encoding = 'ISO-8859-1', bool $i return parent::createXML(['KuveytTurkVPosMessage' => $nodes], $encoding, $ignorePiNode); } - /** - * @return KuveytPosAccount - */ public function getAccount(): KuveytPosAccount { return $this->account; @@ -257,13 +254,9 @@ protected function prepareRefundOrder(array $order) } /** - * @param KuveytPosAccount $account - * @param $order - * @param self::TX_* $txType - * @param string $gatewayURL - * @param AbstractCreditCard|null $card + * @param self::TX_* $txType * - * @return array + * @return array{gateway: string, inputs: array} * * @throws Exception */ @@ -283,9 +276,8 @@ private function getCommon3DFormData(KuveytPosAccount $account, $order, string $ /** * 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. - * @param string $response * - * @return array + * @return array{gateway: string, inputs: array} */ private function transformReceived3DFormData(string $response): array { @@ -321,7 +313,6 @@ private function transformReceived3DFormData(string $response): array /** * html form'da gelen input degeleri array'e donusturur - * @param DOMNodeList $inputNodes * * @return array */ diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index a5972136..d401512e 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -22,9 +22,7 @@ class PayForPos extends AbstractGateway */ public const NAME = 'PayForPOS'; - /** - * @var PayForAccount - */ + /** @var PayForAccount */ protected $account; /** @var PayForPosRequestDataMapper */ @@ -116,9 +114,7 @@ public function history(array $meta) /** - * returns form data needed for 3d, 3d_pay and 3d_host models - * - * @return array + * @inheritDoc */ public function get3DFormData(): array { diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index ea881e17..269f4747 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -23,9 +23,7 @@ class VakifBankPos extends AbstractGateway */ public const NAME = 'VakifPOS'; - /** - * @var VakifBankAccount - */ + /** @var VakifBankAccount */ protected $account; /** @var VakifBankPosRequestDataMapper */ @@ -100,11 +98,7 @@ public function history(array $meta) } /** - * returns form data needed for 3d model - * - * @return array - * - * @throws Exception + * @inheritDoc */ public function get3DFormData(): array { diff --git a/src/PosInterface.php b/src/PosInterface.php index 39fe4b82..daab2883 100644 --- a/src/PosInterface.php +++ b/src/PosInterface.php @@ -17,9 +17,7 @@ interface PosInterface /** * Create XML DOM Document * - * @param array $nodes - * @param string $encoding - * @param bool $ignorePiNode when true it will not wrap it with this node + * @param bool $ignorePiNode when true it will not wrap it with this node * * @return string the XML, or false if an error occurred. */ @@ -34,7 +32,6 @@ public function makeRegularPayment(); /** * Make 3D Payment - * @param Request $request * * @return AbstractGateway */ @@ -42,7 +39,6 @@ public function make3DPayment(Request $request); /** * Make 3D Pay Payment - * @param Request $request * * @return AbstractGateway */ @@ -50,7 +46,6 @@ public function make3DPayPayment(Request $request); /** * Just returns formatted data of host payment response - * @param Request $request * * @return AbstractGateway */ @@ -60,7 +55,6 @@ public function make3DHostPayment(Request $request); * Send contents to WebService * * @param array|string $contents - * @param string|null $url * * @return string|array|null */ @@ -69,7 +63,6 @@ public function send($contents, ?string $url = null); /** * Prepare Order * - * @param array $order * @param AbstractGateway::TX_* $txType * @param AbstractCreditCard|null $card need when 3DFormData requested * @@ -112,8 +105,6 @@ public function status(); /** * Order History * - * @param array $meta - * * @return AbstractGateway */ public function history(array $meta); @@ -128,8 +119,6 @@ public function isSuccess(); /** * Enable/Disable test mode * - * @param bool $testMode - * * @return AbstractGateway */ public function setTestMode(bool $testMode); diff --git a/tests/Crypt/KuveytPosCryptTest.php b/tests/Crypt/KuveytPosCryptTest.php index 38755704..096bf8c6 100644 --- a/tests/Crypt/KuveytPosCryptTest.php +++ b/tests/Crypt/KuveytPosCryptTest.php @@ -11,17 +11,13 @@ class KuveytPosCryptTest extends TestCase { - /** - * @var array|array - */ + /** @var array|array */ public $order; - /** - * @var KuveytPosCrypt - */ + + /** @var KuveytPosCrypt */ public $crypt; - /** - * @var KuveytPosAccount - */ + + /** @var KuveytPosAccount */ private $threeDAccount; protected function setUp(): void diff --git a/tests/Crypt/PayForPosCryptTest.php b/tests/Crypt/PayForPosCryptTest.php index 90fc852a..c39d50d9 100644 --- a/tests/Crypt/PayForPosCryptTest.php +++ b/tests/Crypt/PayForPosCryptTest.php @@ -11,19 +11,13 @@ class PayForPosCryptTest extends TestCase { - /** - * @var array|array - */ + /** @var array|array */ public $order; - /** - * @var PayForPosCrypt - */ + /** @var PayForPosCrypt */ public $crypt; - /** - * @var PayForAccount - */ + /** @var PayForAccount */ private $threeDAccount; protected function setUp(): void diff --git a/tests/Crypt/PosNetCryptTest.php b/tests/Crypt/PosNetCryptTest.php index 70855e3e..a1fa3764 100644 --- a/tests/Crypt/PosNetCryptTest.php +++ b/tests/Crypt/PosNetCryptTest.php @@ -11,14 +11,10 @@ class PosNetCryptTest extends TestCase { - /** - * @var PosNetCrypt - */ + /** @var PosNetCrypt */ public $crypt; - /** - * @var PosNetAccount - */ + /** @var PosNetAccount */ private $threeDAccount; protected function setUp(): void diff --git a/tests/DataMapper/EstPosRequestDataMapperTest.php b/tests/DataMapper/EstPosRequestDataMapperTest.php index 870da324..02467915 100644 --- a/tests/DataMapper/EstPosRequestDataMapperTest.php +++ b/tests/DataMapper/EstPosRequestDataMapperTest.php @@ -424,13 +424,6 @@ public function testCreateRefundRequestData() $this->assertEquals($expectedData, $actual); } - /** - * @param AbstractPosAccount $account - * @param $order - * @param array $responseData - * - * @return array - */ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $order, array $responseData): array { $requestData = [ @@ -469,12 +462,6 @@ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $ord return $requestData; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): array { return [ @@ -486,12 +473,6 @@ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): ar ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleRecurringOrderCancelXMLData(AbstractPosAccount $account, $order): array { return [ @@ -506,13 +487,6 @@ private function getSampleRecurringOrderCancelXMLData(AbstractPosAccount $accoun ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * @param AbstractCreditCard $card - * - * @return array - */ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array { return [ @@ -537,12 +511,6 @@ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $accoun ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, $order): array { return [ @@ -554,12 +522,6 @@ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $ac ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleStatusRequestData(AbstractPosAccount $account, $order): array { return [ @@ -573,12 +535,6 @@ private function getSampleStatusRequestData(AbstractPosAccount $account, $order) ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleRecurringStatusRequestData(AbstractPosAccount $account, $order): array { return [ @@ -592,12 +548,6 @@ private function getSampleRecurringStatusRequestData(AbstractPosAccount $account ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): array { $data = [ @@ -616,13 +566,7 @@ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): ar return $data; } - /** - * @param AbstractPosAccount $account - * @param $customQueryData - * - * @return array - */ - private function getSampleHistoryRequestData(AbstractPosAccount $account, $customQueryData): array + private function getSampleHistoryRequestData(AbstractPosAccount $account, array $customQueryData): array { return [ 'Name' => $account->getUsername(), diff --git a/tests/DataMapper/GarantiPosRequestDataMapperTest.php b/tests/DataMapper/GarantiPosRequestDataMapperTest.php index 60e3a077..cad625e0 100644 --- a/tests/DataMapper/GarantiPosRequestDataMapperTest.php +++ b/tests/DataMapper/GarantiPosRequestDataMapperTest.php @@ -283,14 +283,7 @@ public function testCreateRefundRequestData() $this->assertEquals($expectedData, $actual); } - /** - * @param GarantiPosAccount $account - * @param $order - * @param array $responseData - * - * @return array - */ - private function getSample3DPaymentRequestData(AbstractPosAccount $account, $order, array $responseData): array + private function getSample3DPaymentRequestData(GarantiPosAccount $account, $order, array $responseData): array { return [ 'Mode' => 'TEST', @@ -340,13 +333,7 @@ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $ord ]; } - /** - * @param GarantiPosAccount $account - * @param $order - * - * @return array - */ - private function getSampleCancelXMLData(AbstractPosAccount $account, $order): array + private function getSampleCancelXMLData(GarantiPosAccount $account, $order): array { return [ 'Mode' => 'TEST', @@ -377,14 +364,7 @@ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): ar ]; } - /** - * @param GarantiPosAccount $account - * @param $order - * @param AbstractCreditCard $card - * - * @return array - */ - private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array + private function getSampleNonSecurePaymentRequestData(GarantiPosAccount $account, $order, AbstractCreditCard $card): array { return [ 'Mode' => 'TEST', @@ -433,13 +413,7 @@ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $accoun ]; } - /** - * @param GarantiPosAccount $account - * @param $order - * - * @return array - */ - private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, $order): array + private function getSampleNonSecurePaymentPostRequestData(GarantiPosAccount $account, $order): array { return [ 'Mode' => 'TEST', @@ -467,13 +441,7 @@ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $ac ]; } - /** - * @param GarantiPosAccount $account - * @param $order - * - * @return array - */ - private function getSampleStatusRequestData(AbstractPosAccount $account, $order): array + private function getSampleStatusRequestData(GarantiPosAccount $account, $order): array { return [ 'Mode' => 'TEST', @@ -503,13 +471,7 @@ private function getSampleStatusRequestData(AbstractPosAccount $account, $order) ]; } - /** - * @param GarantiPosAccount $account - * @param $order - * - * @return array - */ - private function getSampleRefundXMLData(AbstractPosAccount $account, $order): array + private function getSampleRefundXMLData(GarantiPosAccount $account, $order): array { return [ 'Mode' => 'TEST', @@ -540,13 +502,7 @@ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): ar ]; } - /** - * @param GarantiPosAccount $account - * @param $order - * - * @return array - */ - private function getSampleHistoryRequestData(AbstractPosAccount $account, $order): array + private function getSampleHistoryRequestData(GarantiPosAccount $account, $order): array { return [ 'Mode' => 'TEST', diff --git a/tests/DataMapper/InterPosRequestDataMapperTest.php b/tests/DataMapper/InterPosRequestDataMapperTest.php index d47b0123..c5cf25f8 100644 --- a/tests/DataMapper/InterPosRequestDataMapperTest.php +++ b/tests/DataMapper/InterPosRequestDataMapperTest.php @@ -327,13 +327,6 @@ public function testCreateRefundRequestData() $this->assertEquals($expectedData, $actual); } - /** - * @param $order - * @param InterPosAccount $account - * @param array $responseData - * - * @return array - */ private function getSample3DPaymentRequestData($order, InterPosAccount $account, array $responseData): array { return [ @@ -355,12 +348,6 @@ private function getSample3DPaymentRequestData($order, InterPosAccount $account, ]; } - /** - * @param $order - * @param InterPosAccount $account - * - * @return array - */ private function getSampleCancelXMLData($order, InterPosAccount $account): array { return [ @@ -375,13 +362,6 @@ private function getSampleCancelXMLData($order, InterPosAccount $account): array ]; } - /** - * @param $order - * @param AbstractCreditCard $card - * @param InterPosAccount $account - * - * @return array - */ private function getSampleNonSecurePaymentRequestData($order, AbstractCreditCard $card, InterPosAccount $account): array { $requestData = [ @@ -406,12 +386,6 @@ private function getSampleNonSecurePaymentRequestData($order, AbstractCreditCard return $requestData; } - /** - * @param $order - * @param InterPosAccount $account - * - * @return array - */ private function getSampleNonSecurePaymentPostRequestData($order, InterPosAccount $account): array { return [ @@ -428,12 +402,6 @@ private function getSampleNonSecurePaymentPostRequestData($order, InterPosAccoun ]; } - /** - * @param $order - * @param InterPosAccount $account - * - * @return array - */ private function getSampleStatusRequestData($order, InterPosAccount $account): array { return [ @@ -448,12 +416,6 @@ private function getSampleStatusRequestData($order, InterPosAccount $account): a ]; } - /** - * @param $order - * @param InterPosAccount $account - * - * @return array - */ private function getSampleRefundXMLData($order, InterPosAccount $account): array { return [ diff --git a/tests/DataMapper/KuveytPosRequestDataMapperTest.php b/tests/DataMapper/KuveytPosRequestDataMapperTest.php index 0713ae58..60b1d7f9 100644 --- a/tests/DataMapper/KuveytPosRequestDataMapperTest.php +++ b/tests/DataMapper/KuveytPosRequestDataMapperTest.php @@ -22,9 +22,7 @@ */ class KuveytPosRequestDataMapperTest extends TestCase { - /** - * @var KuveytPosAccount - */ + /** @var KuveytPosAccount */ public $threeDAccount; /** @var AbstractCreditCard */ @@ -39,8 +37,6 @@ class KuveytPosRequestDataMapperTest extends TestCase private $order; /** - * @return void - * * @throws BankClassNullException * @throws BankNotFoundException */ diff --git a/tests/DataMapper/PayForPosRequestDataMapperTest.php b/tests/DataMapper/PayForPosRequestDataMapperTest.php index d967b963..c0c58fee 100644 --- a/tests/DataMapper/PayForPosRequestDataMapperTest.php +++ b/tests/DataMapper/PayForPosRequestDataMapperTest.php @@ -328,13 +328,6 @@ public function testCreateRefundRequestData() $this->assertEquals($expectedData, $actual); } - /** - * @param AbstractPosAccount $account - * @param $order - * @param array $responseData - * - * @return array - */ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $order, array $responseData): array { return [ @@ -346,12 +339,6 @@ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $ord ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): array { return [ @@ -367,13 +354,6 @@ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): ar ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * @param AbstractCreditCard $card - * - * @return array - */ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array { return [ @@ -396,12 +376,6 @@ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $accoun ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, $order): array { return [ @@ -418,12 +392,6 @@ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $ac ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleStatusRequestData(AbstractPosAccount $account, $order): array { return [ @@ -438,12 +406,6 @@ private function getSampleStatusRequestData(AbstractPosAccount $account, $order) ]; } - /** - * @param AbstractPosAccount $account - * @param $order - * - * @return array - */ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): array { return [ @@ -460,12 +422,6 @@ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): ar ]; } - /** - * @param AbstractPosAccount $account - * @param $customQueryData - * - * @return array - */ private function getSampleHistoryRequestData(AbstractPosAccount $account, $customQueryData): array { $requestData = [ diff --git a/tests/DataMapper/PosNetRequestDataMapperTest.php b/tests/DataMapper/PosNetRequestDataMapperTest.php index e8f0b148..8db564d9 100644 --- a/tests/DataMapper/PosNetRequestDataMapperTest.php +++ b/tests/DataMapper/PosNetRequestDataMapperTest.php @@ -338,14 +338,11 @@ public function testCreateRefundRequestData() } /** - * @param PosNetAccount $account - * @param $order - * @param $oosTxResponseData - * @param string $gatewayURL - * - * @return array + * @param PosNetAccount $account + * @param $order + * @param array $oosTxResponseData */ - private function getSample3DFormData(AbstractPosAccount $account, $order, $oosTxResponseData, string $gatewayURL): array + private function getSample3DFormData(AbstractPosAccount $account, $order, array $oosTxResponseData, string $gatewayURL): array { $inputs = [ 'posnetData' => $oosTxResponseData['data1'], @@ -365,9 +362,6 @@ private function getSample3DFormData(AbstractPosAccount $account, $order, $oosTx ]; } - /** - * @return array - */ private function getSample3DEnrollmentCheckResponseData(): array { return [ @@ -382,13 +376,7 @@ private function getSample3DEnrollmentCheckResponseData(): array ]; } - /** - * @param PosNetAccount $account - * @param array $responseData - * - * @return array - */ - private function getSample3DPaymentRequestData(AbstractPosAccount $account, array $responseData): array + private function getSample3DPaymentRequestData(PosNetAccount $account, array $responseData): array { return [ 'mid' => $account->getClientId(), @@ -403,13 +391,7 @@ private function getSample3DPaymentRequestData(AbstractPosAccount $account, arra ]; } - /** - * @param PosNetAccount $account - * @param $order - * - * @return array - */ - private function getSampleCancelXMLData(AbstractPosAccount $account, $order): array + private function getSampleCancelXMLData(PosNetAccount $account, $order): array { $requestData = [ 'mid' => $account->getClientId(), @@ -430,14 +412,7 @@ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): ar return $requestData; } - /** - * @param PosNetAccount $account - * @param $order - * @param AbstractCreditCard $card - * - * @return array - */ - private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array + private function getSampleNonSecurePaymentRequestData(PosNetAccount $account, $order, AbstractCreditCard $card): array { return [ 'mid' => $account->getClientId(), @@ -455,13 +430,7 @@ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $accoun ]; } - /** - * @param PosNetAccount $account - * @param $order - * - * @return array - */ - private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, $order): array + private function getSampleNonSecurePaymentPostRequestData(PosNetAccount $account, $order): array { return [ 'mid' => $account->getClientId(), @@ -476,12 +445,7 @@ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $ac ]; } - /** - * @param PosNetAccount $account - * - * @return array - */ - private function getSampleStatusRequestData(AbstractPosAccount $account): array + private function getSampleStatusRequestData(PosNetAccount $account): array { return [ 'mid' => $account->getClientId(), @@ -492,13 +456,7 @@ private function getSampleStatusRequestData(AbstractPosAccount $account): array ]; } - /** - * @param PosNetAccount $account - * @param $order - * - * @return array - */ - private function getSampleRefundXMLData(AbstractPosAccount $account, $order): array + private function getSampleRefundXMLData(PosNetAccount $account, $order): array { $requestData = [ 'mid' => $account->getClientId(), @@ -519,13 +477,6 @@ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): ar return $requestData; } - /** - * @param PosNetAccount $account - * @param $order - * @param AbstractCreditCard $card - * - * @return array - */ private function getSample3DEnrollmentCheckRequestData(PosNetAccount $account, $order, AbstractCreditCard $card): array { return [ @@ -546,13 +497,7 @@ private function getSample3DEnrollmentCheckRequestData(PosNetAccount $account, $ ]; } - /** - * @param PosNetAccount $account - * @param array $responseData - * - * @return array - */ - private function getSampleResolveMerchantDataXMLData(AbstractPosAccount $account, array $responseData): array + private function getSampleResolveMerchantDataXMLData(PosNetAccount $account, array $responseData): array { return [ 'mid' => $account->getClientId(), diff --git a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php index d53ecb1a..5114ff1c 100644 --- a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php +++ b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php @@ -19,9 +19,7 @@ */ class VakifBankPosRequestDataMapperTest extends TestCase { - /** - * @var VakifBankAccount - */ + /** @var VakifBankAccount */ public $account; /** @var AbstractGateway */ private $pos; @@ -251,9 +249,6 @@ public function testCreate3DFormData() $this->assertEquals($expectedValue, $actualData); } - /** - * @return array - */ public function getSampleEnrollmentSuccessResponseData(): array { return [ @@ -285,12 +280,6 @@ public function getSampleEnrollmentFailResponseData(): array ]; } - /** - * @param AbstractPosAccount $account - * @param array $order - * - * @return array - */ private function getSampleCancelRequestData(AbstractPosAccount $account, array $order): array { return [ @@ -302,16 +291,7 @@ private function getSampleCancelRequestData(AbstractPosAccount $account, array $ ]; } - /** - * @param VakifBankAccount $account - * @param $order - * @param string $txType - * @param array $responseData - * @param AbstractCreditCard|null $card - * - * @return array - */ - private function getSample3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData, ?AbstractCreditCard $card): array + private function getSample3DPaymentRequestData(VakifBankAccount $account, $order, string $txType, array $responseData, ?AbstractCreditCard $card): array { $expectedValue = [ 'MerchantId' => $account->getClientId(), @@ -340,15 +320,7 @@ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $ord return $expectedValue; } - - /** - * @param VakifBankAccount $account - * @param $order - * @param AbstractCreditCard|null $card - * - * @return array - */ - private function getSample3DEnrollmentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card): array + private function getSample3DEnrollmentRequestData(VakifBankAccount $account, $order, ?AbstractCreditCard $card): array { $expectedValue = [ 'MerchantId' => $account->getClientId(), @@ -383,15 +355,7 @@ private function getSample3DEnrollmentRequestData(AbstractPosAccount $account, $ return $expectedValue; } - /** - * @param VakifBankAccount $account - * @param $order - * @param string $txType - * @param AbstractCreditCard $card - * - * @return array - */ - private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, AbstractCreditCard $card): array + private function getSampleNonSecurePaymentRequestData(VakifBankAccount $account, $order, string $txType, AbstractCreditCard $card): array { return [ 'MerchantId' => $account->getClientId(), @@ -409,13 +373,7 @@ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $accoun ]; } - /** - * @param VakifBankAccount $account - * @param array $order - * - * @return array - */ - private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, array $order): array + private function getSampleNonSecurePaymentPostRequestData(VakifBankAccount $account, array $order): array { return [ 'MerchantId' => $account->getClientId(), @@ -429,12 +387,6 @@ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $ac ]; } - /** - * @param AbstractPosAccount $account - * @param array $order - * - * @return array - */ private function getSampleRefundRequestData(AbstractPosAccount $account, array $order): array { return [ @@ -447,9 +399,6 @@ private function getSampleRefundRequestData(AbstractPosAccount $account, array $ ]; } - /** - * @return array - */ private function getSample3DFormDataFromEnrollmentResponse(): array { $inputs = [ diff --git a/tests/Gateways/KuveytPosTest.php b/tests/Gateways/KuveytPosTest.php index 75b98933..b6046807 100644 --- a/tests/Gateways/KuveytPosTest.php +++ b/tests/Gateways/KuveytPosTest.php @@ -24,27 +24,19 @@ */ class KuveytPosTest extends TestCase { - /** - * @var KuveytPosAccount - */ + /** @var KuveytPosAccount */ private $threeDAccount; private $config; - /** - * @var AbstractCreditCard - */ + /** @var AbstractCreditCard */ private $card; private $order; - /** - * @var KuveytPos - */ + /** @var KuveytPos */ private $pos; /** - * @return void - * * @throws BankClassNullException * @throws BankNotFoundException */ diff --git a/tests/Gateways/VakifBankPosTest.php b/tests/Gateways/VakifBankPosTest.php index 6fcae83f..2c7df5a1 100644 --- a/tests/Gateways/VakifBankPosTest.php +++ b/tests/Gateways/VakifBankPosTest.php @@ -22,19 +22,13 @@ */ class VakifBankPosTest extends TestCase { - /** - * @var VakifBankAccount - */ + /** @var VakifBankAccount */ private $account; - /** - * @var VakifBankPos - */ + /** @var VakifBankPos */ private $pos; private $config; - /** - * @var AbstractCreditCard - */ + /** @var AbstractCreditCard */ private $card; /** @var array */ From b26770089afeb6661c69f17da94759b581786219 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 22:26:59 +0100 Subject: [PATCH 09/54] get3DFormData() - throw exception if order or card data is not provided --- src/Gateways/EstPos.php | 4 +++- src/Gateways/GarantiPos.php | 4 +++- src/Gateways/InterPos.php | 7 ++++++- src/Gateways/KuveytPos.php | 3 ++- src/Gateways/PayForPos.php | 7 ++++++- src/Gateways/PosNet.php | 4 +++- src/Gateways/VakifBankPos.php | 8 +++++++- 7 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index 9ddabcbd..469ed3a6 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -4,6 +4,7 @@ */ namespace Mews\Pos\Gateways; +use LogicException; use Mews\Pos\Entity\Account\EstPosAccount; use Mews\Pos\Exceptions\HashMismatchException; use Psr\Log\LogLevel; @@ -98,7 +99,8 @@ public function get3DFormData(): array { if ($this->order === null) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order'); - return []; + + throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); diff --git a/src/Gateways/GarantiPos.php b/src/Gateways/GarantiPos.php index eb19af83..ee6f4752 100644 --- a/src/Gateways/GarantiPos.php +++ b/src/Gateways/GarantiPos.php @@ -4,6 +4,7 @@ */ namespace Mews\Pos\Gateways; +use LogicException; use Mews\Pos\DataMapper\GarantiPosRequestDataMapper; use Mews\Pos\DataMapper\ResponseDataMapper\GarantiPosResponseDataMapper; use Mews\Pos\Entity\Account\GarantiPosAccount; @@ -104,7 +105,8 @@ public function get3DFormData(): array { if ($this->order === null) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order'); - return []; + + throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 13854efc..0eca010c 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -4,6 +4,7 @@ */ namespace Mews\Pos\Gateways; +use LogicException; use Mews\Pos\DataMapper\InterPosRequestDataMapper; use Mews\Pos\DataMapper\ResponseDataMapper\InterPosResponseDataMapper; use Mews\Pos\Entity\Account\InterPosAccount; @@ -125,7 +126,8 @@ public function get3DFormData(): array { if ($this->order === null) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order'); - return []; + + throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } $gatewayUrl = $this->get3DHostGatewayURL(); if (self::MODEL_3D_SECURE === $this->account->getModel()) { @@ -133,6 +135,9 @@ public function get3DFormData(): array } elseif (self::MODEL_3D_PAY === $this->account->getModel()) { $gatewayUrl = $this->get3DGatewayURL(); } + if (null === $gatewayUrl) { + throw new LogicException('Gateway URL\' bulunamadı!'); + } $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); return $this->requestDataMapper->create3DFormData($this->account, $this->order, $this->type, $gatewayUrl, $this->card); diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 17aded37..442f9048 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -7,6 +7,7 @@ use DOMDocument; use DOMNodeList; use Exception; +use LogicException; use Mews\Pos\DataMapper\KuveytPosRequestDataMapper; use Mews\Pos\DataMapper\ResponseDataMapper\KuveytPosResponseDataMapper; use Mews\Pos\Entity\Account\KuveytPosAccount; @@ -263,7 +264,7 @@ protected function prepareRefundOrder(array $order) private function getCommon3DFormData(KuveytPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { if (!$order) { - return []; + throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } $formData = $this->requestDataMapper->create3DEnrollmentCheckRequestData($account, $order, $txType, $card); diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index d401512e..a62cb2fb 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -4,6 +4,7 @@ */ namespace Mews\Pos\Gateways; +use LogicException; use Mews\Pos\DataMapper\PayForPosRequestDataMapper; use Mews\Pos\DataMapper\ResponseDataMapper\PayForPosResponseDataMapper; use Mews\Pos\Entity\Account\PayForAccount; @@ -120,7 +121,8 @@ public function get3DFormData(): array { if ($this->order === null) { $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order'); - return []; + + throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); @@ -128,6 +130,9 @@ public function get3DFormData(): array if (self::MODEL_3D_HOST === $this->account->getModel()) { $gatewayURL = $this->get3DHostGatewayURL(); } + if (null === $gatewayURL) { + throw new LogicException('Gateway URL\' bulunamadı!'); + } return $this->requestDataMapper->create3DFormData($this->account, $this->order, $this->type, $gatewayURL, $this->card); } diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index 009a3245..864c5dc7 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -5,6 +5,7 @@ namespace Mews\Pos\Gateways; use Exception; +use LogicException; use Mews\Pos\DataMapper\PosNetRequestDataMapper; use Mews\Pos\DataMapper\ResponseDataMapper\PosNetResponseDataMapper; use Mews\Pos\Entity\Account\PosNetAccount; @@ -123,7 +124,8 @@ public function get3DFormData(): array 'order' => $this->order, 'card_provided' => (bool) $this->card, ]); - return []; + + throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } $data = $this->getOosTransactionData(); diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index 269f4747..417431df 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -5,6 +5,7 @@ namespace Mews\Pos\Gateways; use Exception; +use LogicException; use Mews\Pos\DataMapper\ResponseDataMapper\VakifBankPosResponseDataMapper; use Mews\Pos\DataMapper\VakifBankPosRequestDataMapper; use Mews\Pos\Entity\Account\VakifBankAccount; @@ -107,7 +108,8 @@ public function get3DFormData(): array 'order' => $this->order, 'card_provided' => (bool) $this->card, ]); - return []; + + throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } $data = $this->sendEnrollmentRequest(); @@ -205,6 +207,10 @@ public function createRegularPaymentXML() */ public function createRegularPostXML() { + if (null === $this->order) { + throw new LogicException('sipariş bilgileri eksik!'); + } + $requestData = $this->requestDataMapper->createNonSecurePostAuthPaymentRequestData($this->account, $this->order); return $this->createXML($requestData); From c89bd4e97e3a859259d13fdeffe291e13bb1eae8 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 22:36:42 +0100 Subject: [PATCH 10/54] rector round 3 - process response mappers --- .../AbstractResponseDataMapper.php | 16 +-------------- .../EstPosResponseDataMapper.php | 15 +------------- .../GarantiPosResponseDataMapper.php | 17 +++------------- .../InterPosResponseDataMapper.php | 20 ++++++------------- .../KuveytPosResponseDataMapper.php | 11 ---------- .../PayForPosResponseDataMapper.php | 11 ---------- .../PosNetResponseDataMapper.php | 11 ---------- .../VakifBankPosResponseDataMapper.php | 7 ------- .../KuveytPosResponseDataMapperTest.php | 2 +- .../VakifBankPosResponseDataMapperTest.php | 2 +- 10 files changed, 13 insertions(+), 99 deletions(-) diff --git a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php index 4b8a74fe..2a5a3b74 100644 --- a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php @@ -23,7 +23,6 @@ abstract class AbstractResponseDataMapper /** * @param array $currencyMappings * @param array $txTypeMappings - * @param LoggerInterface $logger */ public function __construct(array $currencyMappings, array $txTypeMappings, LoggerInterface $logger) { @@ -40,11 +39,6 @@ public function getTxTypeMappings(): array return $this->txTypeMappings; } - /** - * @param string $txType - * - * @return string - */ public function mapTxType(string $txType): string { return $this->txTypeMappings[$txType] ?? $txType; @@ -52,20 +46,12 @@ public function mapTxType(string $txType): string /** * "1000.01" => 1000.01 - * @param string $amount - * - * @return float */ public static function amountFormat(string $amount): float { return (float) $amount; } - /** - * @param string $mdStatus - * - * @return string - */ protected abstract function mapResponseTransactionSecurity(string $mdStatus): string; /** @@ -101,7 +87,7 @@ protected function mergeArraysPreferNonNullValues(array $arr1, array $arr2): arr /** * Returns default payment response data * - * @return array + * @return array{order_id: null, trans_id: null, auth_code: null, ref_ret_num: null, proc_return_code: null, status: string, status_detail: null, error_code: null, error_message: null, all: null} */ protected function getDefaultPaymentResponse(): array { diff --git a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php index b7f8eaea..689c0792 100644 --- a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php @@ -203,6 +203,7 @@ public function map3DHostResponseData(array $raw3DAuthResponseData): array /** * @param PaymentStatusModel $rawResponseData + * * {@inheritdoc} */ public function mapRefundResponse(array $rawResponseData): array @@ -378,9 +379,6 @@ public function mapRecurringStatusResponse(array $rawResponseData): array /** * "100001" => 1000.01 odeme durum sorgulandiginda gelen amount format * "1000.01" => 1000.01 odeme yapildiginda gelen amount format - * @param string $amount - * - * @return float */ public static function amountFormat(string $amount): float { @@ -415,11 +413,6 @@ public function mapHistoryResponse(array $rawResponseData): array ]; } - /** - * @param string $mdStatus - * - * @return string - */ protected function mapResponseTransactionSecurity(string $mdStatus): string { $transactionSecurity = 'MPI fallback'; @@ -434,10 +427,6 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text - * - * @param string|null $procReturnCode - * - * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -448,8 +437,6 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param array $response - * - * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php index e3f117df..6b5a265a 100644 --- a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php @@ -36,6 +36,7 @@ class GarantiPosResponseDataMapper extends AbstractResponseDataMapper implements /** * @param PaymentStatusModel|array $rawPaymentResponseData + * * {@inheritDoc} */ public function mapPaymentResponse(array $rawPaymentResponseData): array @@ -169,6 +170,7 @@ public function mapRefundResponse(array $rawResponseData): array /** * @param PaymentStatusModel|array $rawResponseData + * * {@inheritdoc} */ public function mapCancelResponse(array $rawResponseData): array @@ -200,6 +202,7 @@ public function mapCancelResponse(array $rawResponseData): array /** * @param PaymentStatusModel|array $rawResponseData + * * {@inheritdoc} */ public function mapStatusResponse(array $rawResponseData): array @@ -282,20 +285,12 @@ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array /** * 100001 => 1000.01 - * @param string $amount - * - * @return float */ public static function amountFormat(string $amount): float { return ((float) $amount) / 100; } - /** - * @param string $mdStatus - * - * @return string - */ protected function mapResponseTransactionSecurity(string $mdStatus): string { if (in_array($mdStatus, ['1', '2', '3', '4'])) { @@ -311,10 +306,6 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text - * - * @param string|null $procReturnCode - * - * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -325,8 +316,6 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param PaymentStatusModel $response - * - * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php index e2d7a6cd..ee352c73 100644 --- a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php @@ -111,6 +111,8 @@ public function map3DHostResponseData(array $raw3DAuthResponseData): array /** * {@inheritdoc} + * + * @return array{order_id: mixed, group_id: null, auth_code: null, ref_ret_num: mixed, proc_return_code: string|null, trans_id: mixed, error_code: mixed, error_message: mixed, status: string, status_detail: string|null, all: mixed} */ public function mapRefundResponse(array $rawResponseData): array { @@ -138,6 +140,8 @@ public function mapRefundResponse(array $rawResponseData): array /** * {@inheritdoc} + * + * @return array{order_id: mixed, group_id: null, auth_code: mixed, ref_ret_num: mixed, proc_return_code: string|null, trans_id: mixed, error_code: mixed, error_message: mixed, status: string, status_detail: string|null, all: mixed} */ public function mapCancelResponse($rawResponseData): array { @@ -165,6 +169,8 @@ public function mapCancelResponse($rawResponseData): array /** * {@inheritdoc} + * + * @return array{order_id: mixed, proc_return_code: string|null, trans_id: mixed, error_message: mixed, ref_ret_num: null, order_status: null, refund_amount: float, capture_amount: null, status: string, status_detail: string|null, capture: null, all: mixed} */ public function mapStatusResponse(array $rawResponseData): array { @@ -202,20 +208,12 @@ public function mapHistoryResponse(array $rawResponseData): array /** * 0 => 0.0 * 1.056,2 => 1056.2 - * @param string $amount - * - * @return float */ public static function amountFormat(string $amount): float { return (float) str_replace(',', '.', str_replace('.', '', $amount)); } - /** - * @param string $mdStatus - * - * @return string - */ protected function mapResponseTransactionSecurity(string $mdStatus): string { $transactionSecurity = 'MPI fallback'; @@ -230,10 +228,6 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text - * - * @param string|null $procReturnCode - * - * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -244,8 +238,6 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param array $response - * - * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php index c3242002..692c78fa 100644 --- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php @@ -104,8 +104,6 @@ public function map3DHostResponseData(array $raw3DAuthResponseData): array * Get ProcReturnCode * * @param array $response - * - * @return string|null */ protected function getProcReturnCode(array $response): ?string { @@ -113,11 +111,6 @@ protected function getProcReturnCode(array $response): ?string } - /** - * @param string $mdStatus - * - * @return string - */ protected function mapResponseTransactionSecurity(string $mdStatus): string { // todo implement @@ -126,10 +119,6 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text - * - * @param string|null $procReturnCode - * - * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { diff --git a/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php index b43305be..784c9254 100644 --- a/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php @@ -246,11 +246,6 @@ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array ]; } - /** - * @param string $mdStatus - * - * @return string - */ protected function mapResponseTransactionSecurity(string $mdStatus): string { $transactionSecurity = 'MPI fallback'; @@ -265,10 +260,6 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text - * - * @param string|null $procReturnCode - * - * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -279,8 +270,6 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param array $response - * - * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php index c41fe8c6..5c8a7883 100644 --- a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php @@ -312,11 +312,6 @@ public function mapHistoryResponse(array $rawResponseData): array return array_merge($results, $txResults); } - /** - * @param string $mdStatus - * - * @return string - */ protected function mapResponseTransactionSecurity(string $mdStatus): string { $transactionSecurity = 'MPI fallback'; @@ -331,10 +326,6 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text - * - * @param string|null $procReturnCode - * - * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -345,8 +336,6 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param array $response - * - * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php index 8e8b4575..130d13e6 100644 --- a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php @@ -169,11 +169,6 @@ public function mapHistoryResponse(array $rawResponseData): array return $this->emptyStringsToNull($rawResponseData); } - /** - * @param string $mdStatus - * - * @return string - */ protected function mapResponseTransactionSecurity(string $mdStatus): string { return 'MPI fallback'; @@ -183,8 +178,6 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string * Get ProcReturnCode * * @param array $response - * - * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php index 8f82b8a7..89431be1 100644 --- a/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php @@ -366,7 +366,7 @@ public function threeDPaymentDataProvider(): array 'error_code' => null, 'masked_number' => '4025502306586032', ] - ] + ], ]; } } diff --git a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php index 969850fb..afd5e549 100644 --- a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php @@ -131,7 +131,7 @@ public function threeDPaymentDataProvider(): array 'proc_return_code' => '0000', 'transaction_type' => 'pay', ] - ] + ], ]; } } From 9b6ecb3998ced0c24dcef927e9b9c1ba7f154418 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 22:38:55 +0100 Subject: [PATCH 11/54] EstPos remove redundant unset() --- src/DataMapper/EstPosRequestDataMapper.php | 1 - src/DataMapper/EstV3PosRequestDataMapper.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index 7f5f2b71..a5d9528d 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -223,7 +223,6 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { $data = $this->create3DFormDataCommon($account, $order, $txType, $gatewayURL, $card); - unset($data['inputs']['hash']); $orderMapped = clone $order; $orderMapped->installment = $this->mapInstallment($order->installment); diff --git a/src/DataMapper/EstV3PosRequestDataMapper.php b/src/DataMapper/EstV3PosRequestDataMapper.php index 6de8399c..3c40d329 100644 --- a/src/DataMapper/EstV3PosRequestDataMapper.php +++ b/src/DataMapper/EstV3PosRequestDataMapper.php @@ -20,7 +20,6 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx $data = $this->create3DFormDataCommon($account, $order, $txType, $gatewayURL, $card); $data['inputs']['hashAlgorithm'] = 'ver3'; - unset($data['inputs']['hash']); $data['inputs']['hash'] = $this->crypt->create3DHash($account, $data['inputs'], $txType); return $data; From c71c582949894302de069aee3b58705a9110827e Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 22:40:05 +0100 Subject: [PATCH 12/54] PosNetRequestDataMapper::create3DFormData() useJokerVadaa field => int to string --- src/DataMapper/PosNetRequestDataMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataMapper/PosNetRequestDataMapper.php b/src/DataMapper/PosNetRequestDataMapper.php index 2d3d2c3c..10aba83b 100644 --- a/src/DataMapper/PosNetRequestDataMapper.php +++ b/src/DataMapper/PosNetRequestDataMapper.php @@ -239,7 +239,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx ]; if (isset($order->koiCode) && $order->koiCode > 0) { - $inputs['useJokerVadaa'] = 1; + $inputs['useJokerVadaa'] = '1'; } return [ From 7996b85b1d7db24e3309b924888307d5e4aedcde Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 22:43:55 +0100 Subject: [PATCH 13/54] phpstan regenerate baseline --- phpstan-baseline.neon | 333 +++--------------------------------------- 1 file changed, 19 insertions(+), 314 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2f8c087c..dd95366d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15,21 +15,11 @@ parameters: count: 2 path: src/Crypt/KuveytPosCrypt.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\AbstractRequestDataMapper\\:\\:__construct\\(\\) has parameter \\$currencyMappings with no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/AbstractRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\AbstractRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/AbstractRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\AbstractRequestDataMapper\\:\\:create3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/AbstractRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\AbstractRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -110,21 +100,11 @@ parameters: count: 1 path: src/DataMapper/AbstractRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\AbstractRequestDataMapper\\:\\:getCurrencyMappings\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/AbstractRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\AbstractRequestDataMapper\\:\\:getLang\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/AbstractRequestDataMapper.php - - - message: "#^Property Mews\\\\Pos\\\\DataMapper\\\\AbstractRequestDataMapper\\:\\:\\$currencyMappings type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/AbstractRequestDataMapper.php - - message: "#^Property Mews\\\\Pos\\\\DataMapper\\\\AbstractRequestDataMapper\\:\\:\\$langMappings has no type specified\\.$#" count: 1 @@ -155,21 +135,11 @@ parameters: count: 1 path: src/DataMapper/EstPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:create3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/EstPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:create3DFormDataCommon\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/EstPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:create3DFormDataCommon\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/EstPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -250,26 +220,11 @@ parameters: count: 1 path: src/DataMapper/EstPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:getRecurringRequestOrderData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/EstPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:getRequestAccountData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/EstPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstV3PosRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/EstV3PosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstV3PosRequestDataMapper\\:\\:create3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/EstV3PosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$amount\\.$#" count: 2 @@ -291,72 +246,67 @@ parameters: path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$ref_ret_num\\.$#" + message: "#^Access to an undefined property object\\:\\:\\$name\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Cannot call method create3DHash\\(\\) on Mews\\\\Pos\\\\Crypt\\\\CryptInterface\\|null\\.$#" + message: "#^Access to an undefined property object\\:\\:\\$recurringFrequency\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Cannot call method createHash\\(\\) on Mews\\\\Pos\\\\Crypt\\\\CryptInterface\\|null\\.$#" - count: 7 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$order with no type specified\\.$#" + message: "#^Access to an undefined property object\\:\\:\\$recurringFrequencyType\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Access to an undefined property object\\:\\:\\$recurringInstallmentCount\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + message: "#^Access to an undefined property object\\:\\:\\$ref_ret_num\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" + message: "#^Cannot call method create3DHash\\(\\) on Mews\\\\Pos\\\\Crypt\\\\CryptInterface\\|null\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 + message: "#^Cannot call method createHash\\(\\) on Mews\\\\Pos\\\\Crypt\\\\CryptInterface\\|null\\.$#" + count: 7 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php @@ -365,61 +315,21 @@ parameters: count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createRecurringData\\(\\) has parameter \\$order with no type specified\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createRecurringData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getCardData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getOrderAddressData\\(\\) has parameter \\$order with no type specified\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getOrderAddressData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getTerminalData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:mapPaymentOrder\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -445,11 +355,6 @@ parameters: count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:create3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -460,16 +365,6 @@ parameters: count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" count: 1 @@ -500,36 +395,16 @@ parameters: count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:getRequestAccountData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:create3DEnrollmentCheckRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -545,11 +420,6 @@ parameters: count: 1 path: src/DataMapper/KuveytPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:create3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/KuveytPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -560,11 +430,6 @@ parameters: count: 1 path: src/DataMapper/KuveytPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/KuveytPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -625,16 +490,6 @@ parameters: count: 1 path: src/DataMapper/KuveytPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:getRequestAccountData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/KuveytPosRequestDataMapper.php - - - - message: "#^Property Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:\\$currencyMappings type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/KuveytPosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$currency\\.$#" count: 1 @@ -676,7 +531,7 @@ parameters: path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:create3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:create3DFormData\\(\\) should return array\\{gateway\\: string, inputs\\: array\\\\} but returns array\\{gateway\\: string, inputs\\: array\\{MbrId\\: '5', MerchantID\\: string, UserCode\\: string, OrderId\\: mixed, Lang\\: string, SecureType\\: string, TxnType\\: string, PurchAmount\\: mixed, \\.\\.\\.\\}\\|array\\{MbrId\\: '5', MerchantID\\: string, UserCode\\: string, OrderId\\: mixed, Lang\\: string, SecureType\\: string, TxnType\\: string, PurchAmount\\: mixed, \\.\\.\\.\\}\\}\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php @@ -690,16 +545,6 @@ parameters: count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" count: 1 @@ -720,46 +565,21 @@ parameters: count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:getRequestAccountData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$id\\.$#" count: 1 @@ -830,11 +650,6 @@ parameters: count: 1 path: src/DataMapper/PosNetRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PosNetRequestDataMapper\\:\\:create3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PosNetRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PosNetRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -925,11 +740,6 @@ parameters: count: 1 path: src/DataMapper/PosNetRequestDataMapper.php - - - message: "#^Property Mews\\\\Pos\\\\DataMapper\\\\PosNetRequestDataMapper\\:\\:\\$currencyMappings type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PosNetRequestDataMapper.php - - message: "#^Argument of an invalid type array\\|object supplied for foreach, only iterables are supported\\.$#" count: 1 @@ -982,12 +792,12 @@ parameters: - message: "#^Access to an undefined property object\\:\\:\\$amount\\.$#" - count: 1 + count: 2 path: src/DataMapper/VakifBankPosRequestDataMapper.php - message: "#^Access to an undefined property object\\:\\:\\$currency\\.$#" - count: 1 + count: 2 path: src/DataMapper/VakifBankPosRequestDataMapper.php - @@ -997,7 +807,7 @@ parameters: - message: "#^Access to an undefined property object\\:\\:\\$id\\.$#" - count: 1 + count: 2 path: src/DataMapper/VakifBankPosRequestDataMapper.php - @@ -1007,7 +817,7 @@ parameters: - message: "#^Access to an undefined property object\\:\\:\\$ip\\.$#" - count: 1 + count: 2 path: src/DataMapper/VakifBankPosRequestDataMapper.php - @@ -1065,11 +875,6 @@ parameters: count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/VakifBankPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -1080,16 +885,6 @@ parameters: count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/VakifBankPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/VakifBankPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" count: 1 @@ -1115,26 +910,11 @@ parameters: count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" - count: 1 - path: src/DataMapper/VakifBankPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/VakifBankPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/VakifBankPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -1145,11 +925,6 @@ parameters: count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:getRequestAccountData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/VakifBankPosRequestDataMapper.php - - message: "#^Property Mews\\\\Pos\\\\Entity\\\\Account\\\\GarantiPosAccount\\:\\:\\$refundPassword \\(string\\) does not accept string\\|null\\.$#" count: 1 @@ -1210,11 +985,6 @@ parameters: count: 1 path: src/Factory/PosFactory.php - - - message: "#^Method Mews\\\\Pos\\\\Factory\\\\PosFactory\\:\\:getGatewayRequestMapper\\(\\) has parameter \\$currencies with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Factory/PosFactory.php - - message: "#^Access to undefined constant Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\NonPaymentResponseMapperInterface&Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\PaymentResponseMapperInterface\\:\\:TX_APPROVED\\.$#" count: 1 @@ -1280,21 +1050,11 @@ parameters: count: 1 path: src/Gateways/AbstractGateway.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\AbstractGateway\\:\\:get3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/AbstractGateway.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\AbstractGateway\\:\\:getConfig\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/Gateways/AbstractGateway.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\AbstractGateway\\:\\:getCurrencies\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/AbstractGateway.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\AbstractGateway\\:\\:getOrder\\(\\) should return object but returns object\\|null\\.$#" count: 1 @@ -1440,11 +1200,6 @@ parameters: count: 1 path: src/Gateways/EstPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\EstPos\\:\\:get3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/EstPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\EstPos\\:\\:history\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#" count: 1 @@ -1560,11 +1315,6 @@ parameters: count: 1 path: src/Gateways/GarantiPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\GarantiPos\\:\\:get3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/GarantiPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\GarantiPos\\:\\:prepareCancelOrder\\(\\) has parameter \\$order with no value type specified in iterable type array\\.$#" count: 1 @@ -1660,11 +1410,6 @@ parameters: count: 1 path: src/Gateways/InterPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\InterPos\\:\\:get3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/InterPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\InterPos\\:\\:history\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#" count: 1 @@ -1725,11 +1470,6 @@ parameters: count: 1 path: src/Gateways/InterPos.php - - - message: "#^Parameter \\#4 \\$gatewayURL of method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:create3DFormData\\(\\) expects string, string\\|null given\\.$#" - count: 1 - path: src/Gateways/InterPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\KuveytPos\\:\\:builtInputsFromHTMLDoc\\(\\) has parameter \\$inputNodes with generic class DOMNodeList but does not specify its types\\: TNode$#" count: 1 @@ -1780,21 +1520,11 @@ parameters: count: 1 path: src/Gateways/KuveytPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\KuveytPos\\:\\:get3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/KuveytPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\KuveytPos\\:\\:getCommon3DFormData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/Gateways/KuveytPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\KuveytPos\\:\\:getCommon3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/KuveytPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\KuveytPos\\:\\:history\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#" count: 1 @@ -1840,11 +1570,6 @@ parameters: count: 1 path: src/Gateways/KuveytPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\KuveytPos\\:\\:transformReceived3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/KuveytPos.php - - message: "#^PHPDoc type Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\KuveytPosResponseDataMapper of property Mews\\\\Pos\\\\Gateways\\\\KuveytPos\\:\\:\\$responseDataMapper is not covariant with PHPDoc type Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\NonPaymentResponseMapperInterface&Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\PaymentResponseMapperInterface of overridden property Mews\\\\Pos\\\\Gateways\\\\AbstractGateway\\:\\:\\$responseDataMapper\\.$#" count: 1 @@ -1910,11 +1635,6 @@ parameters: count: 1 path: src/Gateways/PayForPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\PayForPos\\:\\:get3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/PayForPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\PayForPos\\:\\:history\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#" count: 1 @@ -1985,11 +1705,6 @@ parameters: count: 1 path: src/Gateways/PayForPos.php - - - message: "#^Parameter \\#4 \\$gatewayURL of method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:create3DFormData\\(\\) expects string, string\\|null given\\.$#" - count: 1 - path: src/Gateways/PayForPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\PosNet\\:\\:create3DPaymentXML\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -2035,11 +1750,6 @@ parameters: count: 1 path: src/Gateways/PosNet.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\PosNet\\:\\:get3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/PosNet.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\PosNet\\:\\:getOosTransactionData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -2170,11 +1880,6 @@ parameters: count: 1 path: src/Gateways/VakifBankPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankPos\\:\\:get3DFormData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/VakifBankPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankPos\\:\\:history\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#" count: 1 From 38282024be60f24d106eec7ef8309505968a7821 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 22:56:20 +0100 Subject: [PATCH 14/54] rector round 4 - apply NewlineAfterStatementRector --- src/Client/HttpClient.php | 2 ++ src/Crypt/AbstractCrypt.php | 1 + src/Crypt/EstV3PosCrypt.php | 2 ++ src/Crypt/GarantiPosCrypt.php | 1 + src/Crypt/PosNetCrypt.php | 1 + src/DataMapper/EstPosRequestDataMapper.php | 2 ++ src/DataMapper/GarantiPosRequestDataMapper.php | 2 ++ src/DataMapper/InterPosRequestDataMapper.php | 1 + src/DataMapper/KuveytPosRequestDataMapper.php | 2 ++ .../AbstractResponseDataMapper.php | 2 ++ .../ResponseDataMapper/EstPosResponseDataMapper.php | 3 +++ .../GarantiPosResponseDataMapper.php | 5 +++++ .../InterPosResponseDataMapper.php | 1 + .../KuveytPosResponseDataMapper.php | 2 ++ .../ResponseDataMapper/PosNetResponseDataMapper.php | 4 ++++ src/DataMapper/VakifBankPosRequestDataMapper.php | 4 ++++ src/Entity/Account/AbstractPosAccount.php | 3 +++ src/Entity/Account/GarantiPosAccount.php | 2 ++ src/Entity/Account/VakifBankAccount.php | 2 ++ src/Entity/Card/AbstractCreditCard.php | 3 +++ src/Factory/AccountFactory.php | 3 +++ src/Factory/CreditCardFactory.php | 2 ++ src/Factory/PosFactory.php | 6 ++++++ src/Gateways/AbstractGateway.php | 13 ++++++++++++- src/Gateways/EstPos.php | 3 +++ src/Gateways/GarantiPos.php | 2 ++ src/Gateways/InterPos.php | 3 +++ src/Gateways/KuveytPos.php | 5 +++++ src/Gateways/PayForPos.php | 3 +++ src/Gateways/PosNet.php | 2 ++ src/Gateways/VakifBankPos.php | 5 +++++ tests/DataMapper/EstPosRequestDataMapperTest.php | 1 + tests/DataMapper/EstV3PosRequestDataMapperTest.php | 2 ++ .../DataMapper/GarantiPosRequestDataMapperTest.php | 1 + tests/DataMapper/InterPosRequestDataMapperTest.php | 1 + tests/DataMapper/PayForPosRequestDataMapperTest.php | 1 + .../VakifBankPosRequestDataMapperTest.php | 1 + tests/Gateways/EstPosTest.php | 3 +++ tests/Gateways/GarantiPosTest.php | 2 ++ tests/Gateways/InterPosTest.php | 3 +++ tests/Gateways/KuveytPosTest.php | 1 + tests/Gateways/PayForTest.php | 1 + tests/Gateways/PosNetTest.php | 2 ++ tests/Gateways/VakifBankPosTest.php | 2 ++ 44 files changed, 112 insertions(+), 1 deletion(-) diff --git a/src/Client/HttpClient.php b/src/Client/HttpClient.php index 7a3832b7..460a2456 100644 --- a/src/Client/HttpClient.php +++ b/src/Client/HttpClient.php @@ -65,9 +65,11 @@ private function createRequest(string $method, string $url, ?array $payload = [] $request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded'); $payload['body'] = http_build_query($payload['form_params']); } + if (isset($payload['body'])) { $body = $this->streamFactory->createStream($payload['body']); } + $request = $request->withBody($body); } diff --git a/src/Crypt/AbstractCrypt.php b/src/Crypt/AbstractCrypt.php index df05a6c2..b48dd7c2 100644 --- a/src/Crypt/AbstractCrypt.php +++ b/src/Crypt/AbstractCrypt.php @@ -7,6 +7,7 @@ abstract class AbstractCrypt implements CryptInterface { protected const HASH_ALGORITHM = 'sha1'; + protected const HASH_SEPARATOR = ''; /** @var LoggerInterface */ diff --git a/src/Crypt/EstV3PosCrypt.php b/src/Crypt/EstV3PosCrypt.php index b7a575b8..e4305893 100644 --- a/src/Crypt/EstV3PosCrypt.php +++ b/src/Crypt/EstV3PosCrypt.php @@ -10,6 +10,7 @@ class EstV3PosCrypt extends AbstractCrypt { protected const HASH_ALGORITHM = 'sha512'; + protected const HASH_SEPARATOR = '|'; /** @@ -24,6 +25,7 @@ public function create3DHash(AbstractPosAccount $account, array $requestData, ?s unset($requestData[$key]); } } + $requestData[] = $account->getStoreKey(); // escape | and \ characters $data = str_replace("\\", "\\\\", array_values($requestData)); diff --git a/src/Crypt/GarantiPosCrypt.php b/src/Crypt/GarantiPosCrypt.php index f570aab4..5314ac01 100644 --- a/src/Crypt/GarantiPosCrypt.php +++ b/src/Crypt/GarantiPosCrypt.php @@ -53,6 +53,7 @@ public function check3DHash(AbstractPosAccount $account, array $data): bool return true; } + $this->logger->log(LogLevel::ERROR, 'hash check failed', [ 'data' => $data, 'generated_hash' => $actualHash, diff --git a/src/Crypt/PosNetCrypt.php b/src/Crypt/PosNetCrypt.php index ee8b00fe..99e1146a 100644 --- a/src/Crypt/PosNetCrypt.php +++ b/src/Crypt/PosNetCrypt.php @@ -12,6 +12,7 @@ class PosNetCrypt extends AbstractCrypt { protected const HASH_ALGORITHM = 'sha256'; + protected const HASH_SEPARATOR = ';'; /** diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index a5d9528d..a64f660b 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -15,7 +15,9 @@ class EstPosRequestDataMapper extends AbstractRequestDataMapperCrypt { public const CREDIT_CARD_EXP_DATE_FORMAT = 'm/y'; + public const CREDIT_CARD_EXP_MONTH_FORMAT = 'm'; + public const CREDIT_CARD_EXP_YEAR_FORMAT = 'y'; /** diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index 33cd263b..1a1f70b0 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -19,7 +19,9 @@ class GarantiPosRequestDataMapper extends AbstractRequestDataMapperCrypt public const API_VERSION = 'v0.01'; public const CREDIT_CARD_EXP_DATE_FORMAT = 'my'; + public const CREDIT_CARD_EXP_MONTH_FORMAT = 'm'; + public const CREDIT_CARD_EXP_YEAR_FORMAT = 'y'; /** diff --git a/src/DataMapper/InterPosRequestDataMapper.php b/src/DataMapper/InterPosRequestDataMapper.php index 19581701..d79f43cc 100644 --- a/src/DataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/InterPosRequestDataMapper.php @@ -54,6 +54,7 @@ class InterPosRequestDataMapper extends AbstractRequestDataMapperCrypt AbstractCreditCard::CARD_TYPE_AMEX => '2', AbstractCreditCard::CARD_TYPE_TROY => '3', ]; + /** * {@inheritDoc} * diff --git a/src/DataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/KuveytPosRequestDataMapper.php index 48c0643d..9ffb5bce 100644 --- a/src/DataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/KuveytPosRequestDataMapper.php @@ -18,7 +18,9 @@ class KuveytPosRequestDataMapper extends AbstractRequestDataMapperCrypt { public const API_VERSION = '1.0.0'; + public const CREDIT_CARD_EXP_YEAR_FORMAT = 'y'; + public const CREDIT_CARD_EXP_MONTH_FORMAT = 'm'; /** diff --git a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php index 2a5a3b74..7e8bea33 100644 --- a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php @@ -8,7 +8,9 @@ abstract class AbstractResponseDataMapper { public const TX_APPROVED = 'approved'; + public const TX_DECLINED = 'declined'; + public const PROCEDURE_SUCCESS_CODE = '00'; /** @var LoggerInterface */ diff --git a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php index 689c0792..e0d58284 100644 --- a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php @@ -41,6 +41,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData): array if ($rawPaymentResponseData === []) { return $this->getDefaultPaymentResponse(); } + $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); $procReturnCode = $this->getProcReturnCode($rawPaymentResponseData); @@ -341,6 +342,7 @@ public function mapRecurringStatusResponse(array $rawResponseData): array // when order not found for the given recurring order id then RECURRINGCOUNT = 0 $status = self::TX_APPROVED; } + $recurringOrderResponse = [ 'recurringId' => $extra['RECURRINGID'], 'recurringInstallmentCount' => $extra['RECURRINGCOUNT'], @@ -388,6 +390,7 @@ public static function amountFormat(string $amount): float /** * @param PaymentStatusModel $rawResponseData + * * {@inheritDoc} */ public function mapHistoryResponse(array $rawResponseData): array diff --git a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php index 6b5a265a..56d34b02 100644 --- a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php @@ -49,6 +49,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData): array if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode) { $status = self::TX_APPROVED; } + $transaction = $rawPaymentResponseData['Transaction']; $mappedResponse = [ @@ -139,6 +140,7 @@ public function map3DPayResponseData($raw3DAuthResponseData): array $procReturnCode = $raw3DAuthResponseData['procreturncode']; $commonResult['status'] = self::PROCEDURE_SUCCESS_CODE === $procReturnCode ? self::TX_APPROVED : self::TX_DECLINED; } + if (in_array($raw3DAuthResponseData['mdstatus'], ['1', '2', '3', '4'])) { $commonResult['auth_code'] = $raw3DAuthResponseData['authcode']; $commonResult['trans_id'] = $raw3DAuthResponseData['transid']; @@ -182,6 +184,7 @@ public function mapCancelResponse(array $rawResponseData): array if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode) { $status = self::TX_APPROVED; } + $transaction = $rawResponseData['Transaction']; @@ -214,6 +217,7 @@ public function mapStatusResponse(array $rawResponseData): array if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode) { $status = self::TX_APPROVED; } + $transaction = $rawResponseData['Transaction']; return [ @@ -301,6 +305,7 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string return 'Half 3D Secure'; } } + return 'MPI fallback'; } diff --git a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php index ee352c73..ec1fad14 100644 --- a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php @@ -27,6 +27,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData): array if ($rawPaymentResponseData === []) { return $this->getDefaultPaymentResponse(); } + $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); $status = self::TX_DECLINED; $procReturnCode = $this->getProcReturnCode($rawPaymentResponseData); diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php index 692c78fa..80d89c60 100644 --- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php @@ -30,6 +30,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData): array if (empty($rawPaymentResponseData)) { return $result; } + $status = self::TX_DECLINED; $procReturnCode = $this->getProcReturnCode($rawPaymentResponseData); @@ -49,6 +50,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData): array return $result; } + /** @var array $vPosMessage */ $vPosMessage = $rawPaymentResponseData['VPosMessage']; diff --git a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php index 5c8a7883..9a458f98 100644 --- a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php @@ -88,6 +88,7 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen if (self::PROCEDURE_SUCCESS_CODE === $procReturnCode && $this->getStatusDetail($procReturnCode) === self::TX_APPROVED) { $status = self::TX_APPROVED; } + /** @var array $oosResolveMerchantDataResponse */ $oosResolveMerchantDataResponse = $raw3DAuthResponseData['oosResolveMerchantDataResponse']; @@ -154,6 +155,7 @@ public function mapCancelResponse($rawResponseData): array if (null !== $state) { $transactionType = $this->mapTxType($state); } + $results = [ 'auth_code' => null, 'trans_id' => null, @@ -219,6 +221,7 @@ public function mapStatusResponse(array $rawResponseData): array if (null !== $state) { $transactionType = $this->mapTxType($state); } + $results = [ 'auth_code' => null, 'trans_id' => null, @@ -265,6 +268,7 @@ public function mapHistoryResponse(array $rawResponseData): array $state = $transactionDetails[0]['state']; $authCode = $transactionDetails[0]['authCode']; } + if (count($transactionDetails) > 1) { foreach ($transactionDetails as $key => $_transaction) { if ($key > 0) { diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index fccd61ae..d330a204 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -16,6 +16,7 @@ class VakifBankPosRequestDataMapper extends AbstractRequestDataMapper { public const CREDIT_CARD_EXP_DATE_LONG_FORMAT = 'Ym'; + public const CREDIT_CARD_EXP_DATE_FORMAT = 'ym'; /** @@ -107,12 +108,15 @@ public function create3DEnrollmentCheckRequestData(AbstractPosAccount $account, if ($order->installment) { $requestData['InstallmentCount'] = $this->mapInstallment($order->installment); } + if (isset($order->extraData)) { $requestData['SessionInfo'] = $order->extraData; } + if ($account->isSubBranch()) { $requestData['SubMerchantId'] = $account->getSubMerchantId(); } + if (isset($order->recurringFrequency)) { $requestData['IsRecurring'] = 'true'; // Periyodik İşlem Frekansı diff --git a/src/Entity/Account/AbstractPosAccount.php b/src/Entity/Account/AbstractPosAccount.php index db66aadf..d2a995a1 100644 --- a/src/Entity/Account/AbstractPosAccount.php +++ b/src/Entity/Account/AbstractPosAccount.php @@ -10,6 +10,7 @@ abstract class AbstractPosAccount { /** @var string */ protected $clientId; + /** * account models: regular, 3d, 3d_pay, 3d_host * @var AbstractGateway::MODEL_* @@ -21,6 +22,7 @@ abstract class AbstractPosAccount /** @var string */ protected $password; + /** * required for non regular account models * @var string|null @@ -29,6 +31,7 @@ abstract class AbstractPosAccount /** @var string */ protected $lang; + /** * bank key name used in configuration file * diff --git a/src/Entity/Account/GarantiPosAccount.php b/src/Entity/Account/GarantiPosAccount.php index 4687ff7f..b18bd563 100644 --- a/src/Entity/Account/GarantiPosAccount.php +++ b/src/Entity/Account/GarantiPosAccount.php @@ -11,8 +11,10 @@ class GarantiPosAccount extends AbstractPosAccount { /** @var string */ private $terminalId; + /** @var string */ private $refundUsername; + /** @var string */ private $refundPassword; diff --git a/src/Entity/Account/VakifBankAccount.php b/src/Entity/Account/VakifBankAccount.php index 8972e4b4..66ab60cc 100644 --- a/src/Entity/Account/VakifBankAccount.php +++ b/src/Entity/Account/VakifBankAccount.php @@ -5,7 +5,9 @@ class VakifBankAccount extends AbstractPosAccount { public const MERCHANT_TYPE_STANDARD = 0; + public const MERCHANT_TYPE_MAIN_DEALER = 1; + public const MERCHANT_TYPE_SUB_DEALER = 2; /** @var int[] */ diff --git a/src/Entity/Card/AbstractCreditCard.php b/src/Entity/Card/AbstractCreditCard.php index f089224a..19e22e41 100644 --- a/src/Entity/Card/AbstractCreditCard.php +++ b/src/Entity/Card/AbstractCreditCard.php @@ -10,8 +10,11 @@ abstract class AbstractCreditCard { public const CARD_TYPE_VISA = 'visa'; + public const CARD_TYPE_MASTERCARD = 'master'; + public const CARD_TYPE_AMEX = 'amex'; + public const CARD_TYPE_TROY = 'troy'; /** diff --git a/src/Factory/AccountFactory.php b/src/Factory/AccountFactory.php index 04e4fab9..10cb4147 100644 --- a/src/Factory/AccountFactory.php +++ b/src/Factory/AccountFactory.php @@ -126,9 +126,11 @@ private static function checkParameters(string $model, ?string $storeKey) if (AbstractGateway::MODEL_NON_SECURE === $model) { return; } + if (null !== $storeKey) { return; } + throw new MissingAccountInfoException("$model requires storeKey!"); } @@ -142,6 +144,7 @@ private static function checkVakifBankMerchantType(int $merchantType, ?string $s if (VakifBankAccount::MERCHANT_TYPE_SUB_DEALER === $merchantType && empty($subMerchantId)) { throw new MissingAccountInfoException('SubMerchantId is required for sub branches!'); } + if (!in_array($merchantType, VakifBankAccount::getMerchantTypes())) { throw new MissingAccountInfoException('Invalid MerchantType!'); } diff --git a/src/Factory/CreditCardFactory.php b/src/Factory/CreditCardFactory.php index c1735c42..01ba39e0 100644 --- a/src/Factory/CreditCardFactory.php +++ b/src/Factory/CreditCardFactory.php @@ -46,10 +46,12 @@ public static function create( if (! $expDate instanceof DateTimeImmutable) { throw new DomainException('INVALID DATE FORMAT'); } + $supportedCardTypes = array_keys($pos->getCardTypeMapping()); if ($supportedCardTypes !== [] && empty($cardType)) { throw new CardTypeRequiredException($pos::NAME); } + if ($supportedCardTypes !== [] && !in_array($cardType, $supportedCardTypes)) { throw new CardTypeNotSupportedException($cardType); } diff --git a/src/Factory/PosFactory.php b/src/Factory/PosFactory.php index 6dfd6828..ee4f3382 100644 --- a/src/Factory/PosFactory.php +++ b/src/Factory/PosFactory.php @@ -67,9 +67,11 @@ public static function createPosGateway( if ($logger === null) { $logger = new NullLogger(); } + if ($client === null) { $client = HttpClientFactory::createDefaultHttpClient(); } + if (is_string($config)) { $config = require $config; } elseif (empty($config)) { @@ -92,6 +94,7 @@ public static function createPosGateway( if (isset($config['currencies'])) { $currencies = $config['currencies']; } + $logger->debug('creating gateway for bank', ['bank' => $posAccount->getBank()]); $crypt = self::getGatewayCrypt($class, $logger); @@ -133,9 +136,11 @@ public static function getGatewayRequestMapper(string $gatewayClass, array $curr return new PosNetRequestDataMapper($crypt, $currencies); } } + if ($gatewayClass === VakifBankPos::class) { return new VakifBankPosRequestDataMapper(null, $currencies); } + throw new DomainException('unsupported gateway'); } @@ -163,6 +168,7 @@ public static function getGatewayResponseMapper(string $gatewayClass, AbstractRe case VakifBankPos::class: return new VakifBankPosResponseDataMapper($currencyMappings, $txMappings, $logger); } + throw new DomainException('unsupported gateway'); } diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 88f4fdb9..7f253515 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -25,22 +25,32 @@ */ abstract class AbstractGateway implements PosInterface { - public const LANG_TR = 'tr'; + public const LANG_EN = 'en'; public const TX_PAY = 'pay'; + public const TX_PRE_PAY = 'pre'; + public const TX_POST_PAY = 'post'; + public const TX_CANCEL = 'cancel'; + public const TX_REFUND = 'refund'; + public const TX_STATUS = 'status'; + public const TX_HISTORY = 'history'; public const MODEL_3D_SECURE = '3d'; + public const MODEL_3D_PAY = '3d_pay'; + public const MODEL_3D_PAY_HOSTING = '3d_pay_hosting'; + public const MODEL_3D_HOST = '3d_host'; + public const MODEL_NON_SECURE = 'regular'; /** @var array */ @@ -137,6 +147,7 @@ public function prepare(array $order, string $txType, $card = null) $this->order = $this->prepareHistoryOrder($order); break; } + $this->logger->log(LogLevel::DEBUG, 'gateway prepare - order is prepared', [$this->order]); $this->card = $card; diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index 469ed3a6..780597bd 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -74,6 +74,7 @@ public function make3DPayPayment(Request $request) if (!$this->requestDataMapper->getCrypt()->check3DHash($this->account, $request->request->all())) { throw new HashMismatchException(); } + $this->response = $this->responseDataMapper->map3DPayResponseData($request->request->all()); return $this; @@ -87,6 +88,7 @@ public function make3DHostPayment(Request $request) if (!$this->requestDataMapper->getCrypt()->check3DHash($this->account, $request->request->all())) { throw new HashMismatchException(); } + $this->response = $this->responseDataMapper->map3DHostResponseData($request->request->all()); return $this; @@ -102,6 +104,7 @@ public function get3DFormData(): array throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } + $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); return $this->requestDataMapper->create3DFormData($this->account, $this->order, $this->type, $this->get3DGatewayURL(), $this->card); diff --git a/src/Gateways/GarantiPos.php b/src/Gateways/GarantiPos.php index ee6f4752..1534b1ae 100644 --- a/src/Gateways/GarantiPos.php +++ b/src/Gateways/GarantiPos.php @@ -59,6 +59,7 @@ public function make3DPayment(Request $request) // todo mdstatus 7 oldugunda hash, hashparam deger gelmiyor, check3dhash calismiyor throw new HashMismatchException(); } + if (in_array($request->get('mdstatus'), [1, 2, 3, 4])) { $this->logger->log(LogLevel::DEBUG, 'finishing payment', ['md_status' => $request->get('mdstatus')]); $contents = $this->create3DPaymentXML($request->all()); @@ -108,6 +109,7 @@ public function get3DFormData(): array throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } + $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); return $this->requestDataMapper->create3DFormData($this->account, $this->order, $this->type, $this->get3DGatewayURL(), $this->card); diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 0eca010c..e397ed53 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -129,15 +129,18 @@ public function get3DFormData(): array throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } + $gatewayUrl = $this->get3DHostGatewayURL(); if (self::MODEL_3D_SECURE === $this->account->getModel()) { $gatewayUrl = $this->get3DGatewayURL(); } elseif (self::MODEL_3D_PAY === $this->account->getModel()) { $gatewayUrl = $this->get3DGatewayURL(); } + if (null === $gatewayUrl) { throw new LogicException('Gateway URL\' bulunamadı!'); } + $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); return $this->requestDataMapper->create3DFormData($this->account, $this->order, $this->type, $gatewayUrl, $this->card); diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 442f9048..4a83fecf 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -69,6 +69,7 @@ public function send($contents, string $url = null) if (!$this->isHTML($responseBody)) { throw new Exception($responseBody, $e->getCode(), $e); } + //icinde form olan HTML response dondu $this->data = $responseBody; } @@ -85,6 +86,7 @@ public function make3DPayment(Request $request) if (!is_string($gatewayResponse)) { throw new \LogicException('AuthenticationResponse is missing'); } + $gatewayResponse = urldecode($gatewayResponse); $gatewayResponse = $this->XMLStringToArray($gatewayResponse); $bankResponse = null; @@ -93,6 +95,7 @@ public function make3DPayment(Request $request) if (!$this->requestDataMapper->getCrypt()->check3DHash($this->account, $gatewayResponse)) { throw new HashMismatchException(); } + if ($this->responseDataMapper::PROCEDURE_SUCCESS_CODE === $procReturnCode) { $this->logger->log(LogLevel::DEBUG, 'finishing payment'); @@ -334,11 +337,13 @@ private function builtInputsFromHTMLDoc(DOMNodeList $inputNodes): array /** @var string|null $key */ $key = $attribute->value; } + if ('value' === $attribute->name) { /** @var string|null $value */ $value = $attribute->value; } } + if ($key && null !== $value && !in_array($key, ['submit', 'submitBtn'])) { $inputs[$key] = $value; } diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index a62cb2fb..9b995ac3 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -50,6 +50,7 @@ public function make3DPayment(Request $request) if (!$this->requestDataMapper->getCrypt()->check3DHash($this->account, $request->all())) { throw new HashMismatchException(); } + //if customer 3d verification passed finish payment if ('1' === $request->get('3DStatus')) { //valid ProcReturnCode is V033 in case of success 3D Authentication @@ -124,12 +125,14 @@ public function get3DFormData(): array throw new LogicException('Kredi kartı veya sipariş bilgileri eksik!'); } + $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); $gatewayURL = $this->get3DGatewayURL(); if (self::MODEL_3D_HOST === $this->account->getModel()) { $gatewayURL = $this->get3DHostGatewayURL(); } + if (null === $gatewayURL) { throw new LogicException('Gateway URL\' bulunamadı!'); } diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index 864c5dc7..a1b1eefb 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -99,6 +99,7 @@ public function make3DPayment(Request $request) 'md_status' => $userVerifyResponse['oosResolveMerchantDataResponse']['mdStatus'], ]); } + end: $this->response = $this->responseDataMapper->map3DPaymentData($userVerifyResponse, $bankResponse); $this->logger->log(LogLevel::DEBUG, 'finished 3D payment', ['mapped_response' => $this->response]); @@ -134,6 +135,7 @@ public function get3DFormData(): array $this->logger->log(LogLevel::ERROR, 'enrollment fail response', $data); throw new Exception($data['respText']); } + $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); return $this->requestDataMapper->create3DFormData($this->account, $this->order, $this->type, $this->get3DGatewayURL(), $this->card, $data['oosRequestDataResponse']); diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index 417431df..b9ea47ce 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -61,6 +61,7 @@ public function make3DPayment(Request $request) return $this; } + $this->logger->log(LogLevel::DEBUG, 'finishing payment', ['md_status' => $status]); $contents = $this->create3DPaymentXML($request->all()); $bankResponse = $this->send($contents); @@ -126,15 +127,18 @@ public function get3DFormData(): array $this->logger->log(LogLevel::ERROR, 'enrollment fail response', $data); throw new Exception($data['ErrorMessage'], $data['MessageErrorCode']); } + if ('N' === $status) { //half secure olarak devam et yada satisi iptal et. $this->logger->log(LogLevel::ERROR, 'enrollment fail response', $data); throw new Exception('Kart 3-D Secure programına dâhil değil'); } + if ('U' === $status) { $this->logger->log(LogLevel::ERROR, 'enrollment fail response', $data); throw new Exception('İşlem gerçekleştirilemiyor'); } + $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); return $this->requestDataMapper->create3DFormData($this->account, $this->order, $this->type, '', null, $data['Message']['VERes']); @@ -186,6 +190,7 @@ public function send($contents, ?string $url = null) // if something wrong server responds with HTML content throw new Exception($responseBody, $e->getCode(), $e); } + $this->data = json_decode($responseBody, true); } diff --git a/tests/DataMapper/EstPosRequestDataMapperTest.php b/tests/DataMapper/EstPosRequestDataMapperTest.php index 02467915..04129708 100644 --- a/tests/DataMapper/EstPosRequestDataMapperTest.php +++ b/tests/DataMapper/EstPosRequestDataMapperTest.php @@ -33,6 +33,7 @@ class EstPosRequestDataMapperTest extends TestCase private $requestDataMapper; private $order; + private $config; protected function setUp(): void diff --git a/tests/DataMapper/EstV3PosRequestDataMapperTest.php b/tests/DataMapper/EstV3PosRequestDataMapperTest.php index ab784aa8..a2131b81 100644 --- a/tests/DataMapper/EstV3PosRequestDataMapperTest.php +++ b/tests/DataMapper/EstV3PosRequestDataMapperTest.php @@ -32,6 +32,7 @@ class EstV3PosRequestDataMapperTest extends TestCase private $requestDataMapper; private $order; + private $config; protected function setUp(): void @@ -120,6 +121,7 @@ public function testGet3DFormData() $form['inputs']['Ecom_Payment_Card_ExpDate_Year'] = '22'; $form['inputs']['cv2'] = $card->getCvv(); } + unset($form['inputs']['hash']); $form['inputs']['hash'] = $this->requestDataMapper->getCrypt()->create3DHash($account, $form['inputs'], $txType); diff --git a/tests/DataMapper/GarantiPosRequestDataMapperTest.php b/tests/DataMapper/GarantiPosRequestDataMapperTest.php index cad625e0..4de2475c 100644 --- a/tests/DataMapper/GarantiPosRequestDataMapperTest.php +++ b/tests/DataMapper/GarantiPosRequestDataMapperTest.php @@ -34,6 +34,7 @@ class GarantiPosRequestDataMapperTest extends TestCase private $requestDataMapper; private $order; + private $config; protected function setUp(): void diff --git a/tests/DataMapper/InterPosRequestDataMapperTest.php b/tests/DataMapper/InterPosRequestDataMapperTest.php index c5cf25f8..114830ad 100644 --- a/tests/DataMapper/InterPosRequestDataMapperTest.php +++ b/tests/DataMapper/InterPosRequestDataMapperTest.php @@ -34,6 +34,7 @@ class InterPosRequestDataMapperTest extends TestCase private $requestDataMapper; private $order; + private $config; protected function setUp(): void diff --git a/tests/DataMapper/PayForPosRequestDataMapperTest.php b/tests/DataMapper/PayForPosRequestDataMapperTest.php index c0c58fee..953b86e6 100644 --- a/tests/DataMapper/PayForPosRequestDataMapperTest.php +++ b/tests/DataMapper/PayForPosRequestDataMapperTest.php @@ -33,6 +33,7 @@ class PayForPosRequestDataMapperTest extends TestCase private $requestDataMapper; private $order; + private $config; protected function setUp(): void diff --git a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php index 5114ff1c..d1546100 100644 --- a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php +++ b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php @@ -21,6 +21,7 @@ class VakifBankPosRequestDataMapperTest extends TestCase { /** @var VakifBankAccount */ public $account; + /** @var AbstractGateway */ private $pos; diff --git a/tests/Gateways/EstPosTest.php b/tests/Gateways/EstPosTest.php index 5bb9be03..7c021742 100644 --- a/tests/Gateways/EstPosTest.php +++ b/tests/Gateways/EstPosTest.php @@ -24,12 +24,15 @@ class EstPosTest extends TestCase { /** @var EstPosAccount */ private $account; + /** @var EstPos */ private $pos; + private $config; /** @var AbstractCreditCard */ private $card; + private $order; /** @var EstPosResponseDataMapperTest */ diff --git a/tests/Gateways/GarantiPosTest.php b/tests/Gateways/GarantiPosTest.php index 009a68ba..f77f3d7a 100644 --- a/tests/Gateways/GarantiPosTest.php +++ b/tests/Gateways/GarantiPosTest.php @@ -20,10 +20,12 @@ class GarantiPosTest extends TestCase { /** @var GarantiPosAccount */ private $account; + private $config; /** @var AbstractCreditCard */ private $card; + private $order; /** @var GarantiPos */ diff --git a/tests/Gateways/InterPosTest.php b/tests/Gateways/InterPosTest.php index d769e7e4..84b131ea 100644 --- a/tests/Gateways/InterPosTest.php +++ b/tests/Gateways/InterPosTest.php @@ -22,12 +22,15 @@ class InterPosTest extends TestCase { /** @var InterPosAccount */ private $account; + /** @var InterPos */ private $pos; + /** @var AbstractCreditCard */ private $card; private $config; + private $order; protected function setUp(): void diff --git a/tests/Gateways/KuveytPosTest.php b/tests/Gateways/KuveytPosTest.php index b6046807..19396149 100644 --- a/tests/Gateways/KuveytPosTest.php +++ b/tests/Gateways/KuveytPosTest.php @@ -31,6 +31,7 @@ class KuveytPosTest extends TestCase /** @var AbstractCreditCard */ private $card; + private $order; /** @var KuveytPos */ diff --git a/tests/Gateways/PayForTest.php b/tests/Gateways/PayForTest.php index af6621d7..eb96a3c2 100644 --- a/tests/Gateways/PayForTest.php +++ b/tests/Gateways/PayForTest.php @@ -25,6 +25,7 @@ class PayForTest extends TestCase /** @var AbstractCreditCard */ private $card; + private $order; /** @var PayForPos */ diff --git a/tests/Gateways/PosNetTest.php b/tests/Gateways/PosNetTest.php index 0179038c..38c15389 100644 --- a/tests/Gateways/PosNetTest.php +++ b/tests/Gateways/PosNetTest.php @@ -30,7 +30,9 @@ class PosNetTest extends TestCase /** @var AbstractCreditCard */ private $card; + private $order; + /** @var PosNet */ private $pos; diff --git a/tests/Gateways/VakifBankPosTest.php b/tests/Gateways/VakifBankPosTest.php index 2c7df5a1..fe4d6594 100644 --- a/tests/Gateways/VakifBankPosTest.php +++ b/tests/Gateways/VakifBankPosTest.php @@ -24,8 +24,10 @@ class VakifBankPosTest extends TestCase { /** @var VakifBankAccount */ private $account; + /** @var VakifBankPos */ private $pos; + private $config; /** @var AbstractCreditCard */ From 0305ab9303a5ff831717d1fdfdbafb44d7c413fb Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 23:00:37 +0100 Subject: [PATCH 15/54] pos.php updated comments --- config/pos.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/pos.php b/config/pos.php index f784a941..ecc19831 100644 --- a/config/pos.php +++ b/config/pos.php @@ -3,8 +3,8 @@ return [ //if you need to use custom keys for currency mapping, otherwise leave empty 'currencies' => [ -// 'TRY' => 949, -// 'USD' => 840, +// 'TRY' => '949', +// 'USD' => '840', ], // Banks 'banks' => [ From 8ac2e3e0e7c1e9b1f0f342c6f5c3d7c19a1be009 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 23:09:55 +0100 Subject: [PATCH 16/54] updated CHANGELOG.md --- docs/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index bba16a72..d2b2d60a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [0.12.0] - 2023-02-06 +### Changed +- **EstPos** - `MODEL_3D_PAY_HOSTING` desteği eklendi @umuttaymaz. +- `get3DFormData()` - artık gereken _kart_ veya _sipariş_ bilgileri olmadan çağrıldığında istisna fırlatır. +- `VakifBankPosRequestDataMapper` - `OrderDescription` tanımsız olma durumu giderildi. + ## [0.11.0] - 2023-01-08 ### Changed - Response formatı **object** yerine artık **array** olarak değiştirildi, `$pos->getResponse();` kod artık array döner. From 8ac1fd0648153ddc055b19d32fd2104066d3d82f Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Feb 2023 23:12:23 +0100 Subject: [PATCH 17/54] updated rector config --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 3188cc7e..12c0930d 100644 --- a/rector.php +++ b/rector.php @@ -102,7 +102,7 @@ \Rector\Php71\Rector\FuncCall\CountOnNullRector::class, \Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector::class, \Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector::class, - \Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class, + //\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class, \Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector::class, \Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class, From bfb48f60b4ff2b275e40f091d4ba98b86698e467 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Mar 2023 19:30:45 +0100 Subject: [PATCH 18/54] Revert "rector round 3 - process response mappers" This reverts commit c89bd4e97e3a859259d13fdeffe291e13bb1eae8. --- .../AbstractResponseDataMapper.php | 16 ++++++++++++++- .../EstPosResponseDataMapper.php | 15 +++++++++++++- .../GarantiPosResponseDataMapper.php | 17 +++++++++++++--- .../InterPosResponseDataMapper.php | 20 +++++++++++++------ .../KuveytPosResponseDataMapper.php | 11 ++++++++++ .../PayForPosResponseDataMapper.php | 11 ++++++++++ .../PosNetResponseDataMapper.php | 11 ++++++++++ .../VakifBankPosResponseDataMapper.php | 7 +++++++ .../KuveytPosResponseDataMapperTest.php | 2 +- .../VakifBankPosResponseDataMapperTest.php | 2 +- 10 files changed, 99 insertions(+), 13 deletions(-) diff --git a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php index 7e8bea33..ab414758 100644 --- a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php @@ -25,6 +25,7 @@ abstract class AbstractResponseDataMapper /** * @param array $currencyMappings * @param array $txTypeMappings + * @param LoggerInterface $logger */ public function __construct(array $currencyMappings, array $txTypeMappings, LoggerInterface $logger) { @@ -41,6 +42,11 @@ public function getTxTypeMappings(): array return $this->txTypeMappings; } + /** + * @param string $txType + * + * @return string + */ public function mapTxType(string $txType): string { return $this->txTypeMappings[$txType] ?? $txType; @@ -48,12 +54,20 @@ public function mapTxType(string $txType): string /** * "1000.01" => 1000.01 + * @param string $amount + * + * @return float */ public static function amountFormat(string $amount): float { return (float) $amount; } + /** + * @param string $mdStatus + * + * @return string + */ protected abstract function mapResponseTransactionSecurity(string $mdStatus): string; /** @@ -89,7 +103,7 @@ protected function mergeArraysPreferNonNullValues(array $arr1, array $arr2): arr /** * Returns default payment response data * - * @return array{order_id: null, trans_id: null, auth_code: null, ref_ret_num: null, proc_return_code: null, status: string, status_detail: null, error_code: null, error_message: null, all: null} + * @return array */ protected function getDefaultPaymentResponse(): array { diff --git a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php index e0d58284..39af1339 100644 --- a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php @@ -204,7 +204,6 @@ public function map3DHostResponseData(array $raw3DAuthResponseData): array /** * @param PaymentStatusModel $rawResponseData - * * {@inheritdoc} */ public function mapRefundResponse(array $rawResponseData): array @@ -381,6 +380,9 @@ public function mapRecurringStatusResponse(array $rawResponseData): array /** * "100001" => 1000.01 odeme durum sorgulandiginda gelen amount format * "1000.01" => 1000.01 odeme yapildiginda gelen amount format + * @param string $amount + * + * @return float */ public static function amountFormat(string $amount): float { @@ -416,6 +418,11 @@ public function mapHistoryResponse(array $rawResponseData): array ]; } + /** + * @param string $mdStatus + * + * @return string + */ protected function mapResponseTransactionSecurity(string $mdStatus): string { $transactionSecurity = 'MPI fallback'; @@ -430,6 +437,10 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text + * + * @param string|null $procReturnCode + * + * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -440,6 +451,8 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param array $response + * + * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php index 56d34b02..363e755d 100644 --- a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php @@ -36,7 +36,6 @@ class GarantiPosResponseDataMapper extends AbstractResponseDataMapper implements /** * @param PaymentStatusModel|array $rawPaymentResponseData - * * {@inheritDoc} */ public function mapPaymentResponse(array $rawPaymentResponseData): array @@ -172,7 +171,6 @@ public function mapRefundResponse(array $rawResponseData): array /** * @param PaymentStatusModel|array $rawResponseData - * * {@inheritdoc} */ public function mapCancelResponse(array $rawResponseData): array @@ -205,7 +203,6 @@ public function mapCancelResponse(array $rawResponseData): array /** * @param PaymentStatusModel|array $rawResponseData - * * {@inheritdoc} */ public function mapStatusResponse(array $rawResponseData): array @@ -289,12 +286,20 @@ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array /** * 100001 => 1000.01 + * @param string $amount + * + * @return float */ public static function amountFormat(string $amount): float { return ((float) $amount) / 100; } + /** + * @param string $mdStatus + * + * @return string + */ protected function mapResponseTransactionSecurity(string $mdStatus): string { if (in_array($mdStatus, ['1', '2', '3', '4'])) { @@ -311,6 +316,10 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text + * + * @param string|null $procReturnCode + * + * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -321,6 +330,8 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param PaymentStatusModel $response + * + * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php index ec1fad14..e3f287fa 100644 --- a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php @@ -112,8 +112,6 @@ public function map3DHostResponseData(array $raw3DAuthResponseData): array /** * {@inheritdoc} - * - * @return array{order_id: mixed, group_id: null, auth_code: null, ref_ret_num: mixed, proc_return_code: string|null, trans_id: mixed, error_code: mixed, error_message: mixed, status: string, status_detail: string|null, all: mixed} */ public function mapRefundResponse(array $rawResponseData): array { @@ -141,8 +139,6 @@ public function mapRefundResponse(array $rawResponseData): array /** * {@inheritdoc} - * - * @return array{order_id: mixed, group_id: null, auth_code: mixed, ref_ret_num: mixed, proc_return_code: string|null, trans_id: mixed, error_code: mixed, error_message: mixed, status: string, status_detail: string|null, all: mixed} */ public function mapCancelResponse($rawResponseData): array { @@ -170,8 +166,6 @@ public function mapCancelResponse($rawResponseData): array /** * {@inheritdoc} - * - * @return array{order_id: mixed, proc_return_code: string|null, trans_id: mixed, error_message: mixed, ref_ret_num: null, order_status: null, refund_amount: float, capture_amount: null, status: string, status_detail: string|null, capture: null, all: mixed} */ public function mapStatusResponse(array $rawResponseData): array { @@ -209,12 +203,20 @@ public function mapHistoryResponse(array $rawResponseData): array /** * 0 => 0.0 * 1.056,2 => 1056.2 + * @param string $amount + * + * @return float */ public static function amountFormat(string $amount): float { return (float) str_replace(',', '.', str_replace('.', '', $amount)); } + /** + * @param string $mdStatus + * + * @return string + */ protected function mapResponseTransactionSecurity(string $mdStatus): string { $transactionSecurity = 'MPI fallback'; @@ -229,6 +231,10 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text + * + * @param string|null $procReturnCode + * + * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -239,6 +245,8 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param array $response + * + * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php index 80d89c60..8ff30db5 100644 --- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php @@ -106,6 +106,8 @@ public function map3DHostResponseData(array $raw3DAuthResponseData): array * Get ProcReturnCode * * @param array $response + * + * @return string|null */ protected function getProcReturnCode(array $response): ?string { @@ -113,6 +115,11 @@ protected function getProcReturnCode(array $response): ?string } + /** + * @param string $mdStatus + * + * @return string + */ protected function mapResponseTransactionSecurity(string $mdStatus): string { // todo implement @@ -121,6 +128,10 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text + * + * @param string|null $procReturnCode + * + * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { diff --git a/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php index 784c9254..b43305be 100644 --- a/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php @@ -246,6 +246,11 @@ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array ]; } + /** + * @param string $mdStatus + * + * @return string + */ protected function mapResponseTransactionSecurity(string $mdStatus): string { $transactionSecurity = 'MPI fallback'; @@ -260,6 +265,10 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text + * + * @param string|null $procReturnCode + * + * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -270,6 +279,8 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param array $response + * + * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php index 9a458f98..9f48ea3f 100644 --- a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php @@ -316,6 +316,11 @@ public function mapHistoryResponse(array $rawResponseData): array return array_merge($results, $txResults); } + /** + * @param string $mdStatus + * + * @return string + */ protected function mapResponseTransactionSecurity(string $mdStatus): string { $transactionSecurity = 'MPI fallback'; @@ -330,6 +335,10 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string /** * Get Status Detail Text + * + * @param string|null $procReturnCode + * + * @return string|null */ protected function getStatusDetail(?string $procReturnCode): ?string { @@ -340,6 +349,8 @@ protected function getStatusDetail(?string $procReturnCode): ?string * Get ProcReturnCode * * @param array $response + * + * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php index 130d13e6..8e8b4575 100644 --- a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php @@ -169,6 +169,11 @@ public function mapHistoryResponse(array $rawResponseData): array return $this->emptyStringsToNull($rawResponseData); } + /** + * @param string $mdStatus + * + * @return string + */ protected function mapResponseTransactionSecurity(string $mdStatus): string { return 'MPI fallback'; @@ -178,6 +183,8 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string * Get ProcReturnCode * * @param array $response + * + * @return string|null */ protected function getProcReturnCode(array $response): ?string { diff --git a/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php index 89431be1..8f82b8a7 100644 --- a/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php @@ -366,7 +366,7 @@ public function threeDPaymentDataProvider(): array 'error_code' => null, 'masked_number' => '4025502306586032', ] - ], + ] ]; } } diff --git a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php index afd5e549..969850fb 100644 --- a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php @@ -131,7 +131,7 @@ public function threeDPaymentDataProvider(): array 'proc_return_code' => '0000', 'transaction_type' => 'pay', ] - ], + ] ]; } } From 1ee411090ffd588f803e4f52a5c32da2af52f288 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Mar 2023 20:00:40 +0100 Subject: [PATCH 19/54] updated rector config --- src/Client/HttpClient.php | 5 + src/Crypt/CryptInterface.php | 14 ++- src/Crypt/GarantiPosCrypt.php | 8 ++ src/Crypt/PosNetCrypt.php | 2 + src/DataMapper/AbstractRequestDataMapper.php | 110 ++++++++++++++---- .../AbstractRequestDataMapperCrypt.php | 4 + src/DataMapper/EstPosRequestDataMapper.php | 12 +- src/DataMapper/EstV3PosRequestDataMapper.php | 3 - .../GarantiPosRequestDataMapper.php | 39 ++++--- src/DataMapper/InterPosRequestDataMapper.php | 14 +-- src/DataMapper/KuveytPosRequestDataMapper.php | 9 +- src/DataMapper/PayForPosRequestDataMapper.php | 16 +-- src/DataMapper/PosNetRequestDataMapper.php | 4 +- .../VakifBankPosRequestDataMapper.php | 25 ++-- src/Entity/Account/AbstractPosAccount.php | 52 ++++++--- src/Entity/Account/GarantiPosAccount.php | 13 ++- src/Entity/Account/KuveytPosAccount.php | 10 ++ src/Entity/Account/PosNetAccount.php | 6 + src/Entity/Account/VakifBankAccount.php | 23 +++- src/Entity/Card/AbstractCreditCard.php | 40 +++++-- .../CardTypeNotSupportedException.php | 6 + src/Exceptions/CardTypeRequiredException.php | 10 +- src/Factory/AccountFactory.php | 98 ++++++++++++---- src/Factory/CreditCardFactory.php | 17 +-- src/Factory/PosFactory.php | 25 +++- src/Gateways/AbstractGateway.php | 53 ++++++++- src/Gateways/EstPos.php | 4 +- src/Gateways/InterPos.php | 3 + src/Gateways/KuveytPos.php | 15 ++- src/Gateways/PayForPos.php | 8 +- src/Gateways/VakifBankPos.php | 10 +- src/PosInterface.php | 13 ++- tests/Crypt/KuveytPosCryptTest.php | 14 ++- tests/Crypt/PayForPosCryptTest.php | 12 +- tests/Crypt/PosNetCryptTest.php | 8 +- .../EstPosRequestDataMapperTest.php | 58 ++++++++- .../GarantiPosRequestDataMapperTest.php | 58 +++++++-- .../InterPosRequestDataMapperTest.php | 38 ++++++ .../KuveytPosRequestDataMapperTest.php | 6 +- .../PayForPosRequestDataMapperTest.php | 44 +++++++ .../PosNetRequestDataMapperTest.php | 77 ++++++++++-- .../VakifBankPosRequestDataMapperTest.php | 61 +++++++++- tests/Gateways/KuveytPosTest.php | 14 ++- tests/Gateways/VakifBankPosTest.php | 4 +- 44 files changed, 866 insertions(+), 199 deletions(-) diff --git a/src/Client/HttpClient.php b/src/Client/HttpClient.php index 460a2456..d5c8b880 100644 --- a/src/Client/HttpClient.php +++ b/src/Client/HttpClient.php @@ -24,6 +24,11 @@ class HttpClient /** @var StreamFactoryInterface */ protected $streamFactory; + /** + * @param ClientInterface $client + * @param RequestFactoryInterface $requestFactory + * @param StreamFactoryInterface $streamFactory + */ public function __construct( ClientInterface $client, RequestFactoryInterface $requestFactory, diff --git a/src/Crypt/CryptInterface.php b/src/Crypt/CryptInterface.php index 3cc95b54..1e6370d5 100644 --- a/src/Crypt/CryptInterface.php +++ b/src/Crypt/CryptInterface.php @@ -10,21 +10,33 @@ interface CryptInterface /** * check hash of 3D secure response * + * @param AbstractPosAccount $account * @param array $data + * + * @return bool */ public function check3DHash(AbstractPosAccount $account, array $data): bool; /** * creates hash for 3D secure payments * + * @param AbstractPosAccount $account * @param array $requestData + * @param string|null $txType + * + * @return string */ public function create3DHash(AbstractPosAccount $account, array $requestData, ?string $txType = null): string; /** * create hash for non-3D actions * - * @param array $requestData + * @param AbstractPosAccount $account + * @param array $requestData + * @param string|null $txType + * @param AbstractCreditCard|null $card + * + * @return string */ public function createHash(AbstractPosAccount $account, array $requestData, ?string $txType = null, ?AbstractCreditCard $card = null): string; } diff --git a/src/Crypt/GarantiPosCrypt.php b/src/Crypt/GarantiPosCrypt.php index 5314ac01..74c07779 100644 --- a/src/Crypt/GarantiPosCrypt.php +++ b/src/Crypt/GarantiPosCrypt.php @@ -86,6 +86,9 @@ public function createHash(AbstractPosAccount $account, array $requestData, ?str * Make Security Data * * @param GarantiPosAccount $account + * @param string|null $txType + * + * @return string */ private function createSecurityData(AbstractPosAccount $account, ?string $txType = null): string { @@ -99,6 +102,11 @@ private function createSecurityData(AbstractPosAccount $account, ?string $txType return $this->hashStringUpperCase(implode(static::HASH_SEPARATOR, $map)); } + /** + * @param string $str + * + * @return string + */ protected function hashStringUpperCase(string $str): string { return strtoupper(hash(static::HASH_ALGORITHM, $str)); diff --git a/src/Crypt/PosNetCrypt.php b/src/Crypt/PosNetCrypt.php index 99e1146a..9eae3b54 100644 --- a/src/Crypt/PosNetCrypt.php +++ b/src/Crypt/PosNetCrypt.php @@ -83,6 +83,8 @@ public function createHash(AbstractPosAccount $account, array $requestData, ?str * Make Security Data * * @param PosNetAccount $account + * + * @return string */ public function createSecurityData(AbstractPosAccount $account): string { diff --git a/src/DataMapper/AbstractRequestDataMapper.php b/src/DataMapper/AbstractRequestDataMapper.php index b4907fe4..615c6176 100644 --- a/src/DataMapper/AbstractRequestDataMapper.php +++ b/src/DataMapper/AbstractRequestDataMapper.php @@ -15,7 +15,9 @@ */ abstract class AbstractRequestDataMapper { - /** @var array */ + /** + * @var array + */ protected $secureTypeMappings = []; /** @@ -38,15 +40,15 @@ abstract class AbstractRequestDataMapper * fakat bazi banklar ISO standarti kullanmiyorlar. * Currency mapping * - * @var non-empty-array + * @var array */ protected $currencyMappings = [ - 'TRY' => '949', - 'USD' => '840', - 'EUR' => '978', - 'GBP' => '826', - 'JPY' => '392', - 'RUB' => '643', + 'TRY' => 949, + 'USD' => 840, + 'EUR' => 978, + 'GBP' => 826, + 'JPY' => 392, + 'RUB' => 643, ]; /** @@ -62,7 +64,8 @@ abstract class AbstractRequestDataMapper protected $crypt; /** - * @param array $currencyMappings + * @param CryptInterface|null $crypt + * @param array $currencyMappings */ public function __construct(?CryptInterface $crypt = null, array $currencyMappings = []) { @@ -75,52 +78,101 @@ public function __construct(?CryptInterface $crypt = null, array $currencyMappin /** * @phpstan-param AbstractGateway::TX_* $txType * - * @param $order - * @param array $responseData gateway'den gelen cevap + * @param AbstractPosAccount $account + * @param $order + * @param array $responseData gateway'den gelen cevap + * + * @return array */ abstract public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array; /** - * @param AbstractGateway::TX_* $txType - * @param $order + * @phpstan-param AbstractGateway::TX_* $txType + * + * @param AbstractPosAccount $account + * @param $order + * @param AbstractCreditCard|null $card + * + * @return array */ abstract public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array; + /** + * @param AbstractPosAccount $account + * @param $order + * @param AbstractCreditCard|null $card + * + * @return array + */ abstract public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array; + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ abstract public function createStatusRequestData(AbstractPosAccount $account, $order): array; /** - * @param object $order + * @param AbstractPosAccount $account + * @param object $order + * + * @return array */ abstract public function createCancelRequestData(AbstractPosAccount $account, $order): array; + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ abstract public function createRefundRequestData(AbstractPosAccount $account, $order): array; /** - * @param AbstractGateway::TX_* $txType - * @param $order + * @phpstan-param AbstractGateway::TX_* $txType + * + * @param AbstractPosAccount $account + * @param $order + * @param string $gatewayURL + * @param string $txType + * @param AbstractCreditCard|null $card * - * @return array{gateway: string, inputs: array} + * @return array */ abstract public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array; /** - * @param $order - * @param array $extraData bankaya gore degisen ozel degerler + * @param AbstractPosAccount $account + * @param $order + * @param array $extraData bankaya gore degisen ozel degerler + * + * @return array */ abstract public function createHistoryRequestData(AbstractPosAccount $account, $order, array $extraData = []): array; + /** + * @return CryptInterface + */ public function getCrypt(): CryptInterface { return $this->crypt; } + /** + * @return bool + */ public function isTestMode(): bool { return $this->testMode; } + /** + * @param string $period + * + * @return string + */ public function mapRecurringFrequency(string $period): string { return $this->recurringOrderFrequencyMapping[$period] ?? $period; @@ -151,13 +203,19 @@ public function getTxTypeMappings(): array } /** - * @return non-empty-array + * @return array */ public function getCurrencyMappings(): array { return $this->currencyMappings; } + + /** + * @param bool $testMode + * + * @return AbstractRequestDataMapper + */ public function setTestMode(bool $testMode): self { $this->testMode = $testMode; @@ -178,6 +236,8 @@ public function mapCurrency(string $currency): string /** * @phpstan-param AbstractGateway::TX_* $txType * + * @return string + * * @throws UnsupportedTransactionTypeException */ public function mapTxType(string $txType): string @@ -189,6 +249,11 @@ public function mapTxType(string $txType): string return $this->txTypeMappings[$txType]; } + /** + * @param string $txType + * + * @return bool + */ public function isSupportedTxType(string $txType): bool { return isset($this->txTypeMappings[$txType]); @@ -207,6 +272,11 @@ abstract public function mapInstallment(?int $installment): string; /** * bank returns error messages for specified language value * usually accepted values are tr,en + * + * @param AbstractPosAccount $account + * @param $order + * + * @return string */ protected function getLang(AbstractPosAccount $account, $order): string { diff --git a/src/DataMapper/AbstractRequestDataMapperCrypt.php b/src/DataMapper/AbstractRequestDataMapperCrypt.php index c59d628f..58be17ea 100644 --- a/src/DataMapper/AbstractRequestDataMapperCrypt.php +++ b/src/DataMapper/AbstractRequestDataMapperCrypt.php @@ -16,6 +16,7 @@ abstract class AbstractRequestDataMapperCrypt extends AbstractRequestDataMapper protected $crypt; /** + * @param CryptInterface $crypt * @param array $currencyMappings */ public function __construct(CryptInterface $crypt, array $currencyMappings = []) @@ -23,6 +24,9 @@ public function __construct(CryptInterface $crypt, array $currencyMappings = []) parent::__construct($crypt, $currencyMappings); } + /** + * @return CryptInterface + */ public function getCrypt(): CryptInterface { return $this->crypt; diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index a64f660b..a2ad6208 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -6,7 +6,6 @@ use Mews\Pos\Entity\Account\AbstractPosAccount; use Mews\Pos\Entity\Card\AbstractCreditCard; -use Mews\Pos\Exceptions\UnsupportedTransactionTypeException; use Mews\Pos\Gateways\AbstractGateway; /** @@ -236,10 +235,6 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx /** * @param AbstractGateway::TX_* $txType - * - * @return array{gateway: string, inputs: array} - * - * @throws UnsupportedTransactionTypeException */ public function create3DFormDataCommon(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { @@ -281,7 +276,9 @@ public function mapInstallment(?int $installment): string } /** - * @return array{Name: string, Password: string, ClientId: string} + * @param AbstractPosAccount $account + * + * @return array */ private function getRequestAccountData(AbstractPosAccount $account): array { @@ -292,9 +289,6 @@ private function getRequestAccountData(AbstractPosAccount $account): array ]; } - /** - * @return array{PbOrder: array{OrderType: int, OrderFrequencyInterval: mixed, OrderFrequencyCycle: string, TotalNumberPayments: mixed}} - */ private function getRecurringRequestOrderData($order): array { return [ diff --git a/src/DataMapper/EstV3PosRequestDataMapper.php b/src/DataMapper/EstV3PosRequestDataMapper.php index 3c40d329..25eee0b0 100644 --- a/src/DataMapper/EstV3PosRequestDataMapper.php +++ b/src/DataMapper/EstV3PosRequestDataMapper.php @@ -12,9 +12,6 @@ */ class EstV3PosRequestDataMapper extends EstPosRequestDataMapper { - /** - * @inheritDoc - */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { $data = $this->create3DFormDataCommon($account, $order, $txType, $gatewayURL, $card); diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index 1a1f70b0..081bb7d3 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -60,8 +60,6 @@ class GarantiPosRequestDataMapper extends AbstractRequestDataMapperCrypt * @param GarantiPosAccount $account * * {@inheritDoc} - * - * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed, AddressList: mixed[]}, Transaction: array{Type: mixed, InstallmentCnt: int|string, Amount: mixed, CurrencyCode: mixed, CardholderPresentCode: string, MotoInd: string, Secure3D: array{AuthenticationCode: mixed, SecurityLevel: mixed, TxnID: mixed, Md: mixed}}, Recurring?: mixed[]} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { @@ -110,8 +108,6 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, * @param GarantiPosAccount $account * * {@inheritDoc} - * - * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Card: mixed[], Order: array{OrderID: mixed, AddressList: mixed[]}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string}, Recurring?: mixed[]} */ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array { @@ -154,7 +150,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ /** * @param GarantiPosAccount $account * - * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, Amount: int, CurrencyCode: string, OriginalRetrefNum: mixed}} + * {@inheritDoc} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { @@ -187,7 +183,7 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $ac /** * @param GarantiPosAccount $account * - * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string}} + * {@inheritDoc} */ public function createStatusRequestData(AbstractPosAccount $account, $order): array { @@ -223,8 +219,6 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar * @param GarantiPosAccount $account * * {@inheritDoc} - * - * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string, OriginalRetrefNum: mixed}} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -260,7 +254,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar /** * @param GarantiPosAccount $account * - * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string, OriginalRetrefNum: mixed}} + * {@inheritDoc} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -297,8 +291,6 @@ public function createRefundRequestData(AbstractPosAccount $account, $order): ar * @param GarantiPosAccount $account * * {@inheritDoc} - * - * @return array{Mode: string, Version: string, Terminal: mixed[], Customer: array{IPAddress: mixed, EmailAddress: mixed}, Order: array{OrderID: mixed}, Transaction: array{Type: string, InstallmentCnt: int|string, Amount: int, CurrencyCode: string, CardholderPresentCode: string, MotoInd: string}} */ public function createHistoryRequestData(AbstractPosAccount $account, $order, array $extraData = []): array { @@ -333,10 +325,7 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar /** * @param GarantiPosAccount $account - * * {@inheritDoc} - * - * @return array{gateway: string, inputs: array{secure3dsecuritylevel: string, mode: string, apiversion: string, terminalprovuserid: string, terminaluserid: string, terminalmerchantid: string, terminalid: string, txntype: string, txnamount: mixed, txncurrencycode: mixed, txninstallmentcount: mixed, orderid: mixed, successurl: mixed, errorurl: mixed, customeremailaddress: mixed, customeripaddress: mixed, secure3dhash: string}|array{secure3dsecuritylevel: string, mode: string, apiversion: string, terminalprovuserid: string, terminaluserid: string, terminalmerchantid: string, terminalid: string, txntype: string, txnamount: mixed, txncurrencycode: mixed, txninstallmentcount: mixed, orderid: mixed, successurl: mixed, errorurl: mixed, customeremailaddress: mixed, customeripaddress: mixed, secure3dhash: string, cardnumber: string, cardexpiredatemonth: string, cardexpiredateyear: string, cardcvv2: string}} */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { @@ -385,12 +374,17 @@ public function mapInstallment(?int $installment): string * Amount Formatter * converts 100 to 10000, or 10.01 to 1001 * @param float $amount + * + * @return int */ public static function amountFormat($amount): int { return (int) (round($amount, 2) * 100); } + /** + * @return string + */ private function getMode(): string { return $this->isTestMode() ? 'TEST' : 'PROD'; @@ -398,8 +392,10 @@ private function getMode(): string /** * @param GarantiPosAccount $account + * @param string $hash + * @param bool $isRefund * - * @return array{ProvUserID: string, UserID: string, HashData: string, ID: string, MerchantID: string} + * @return array */ private function getTerminalData(AbstractPosAccount $account, string $hash, bool $isRefund = false): array { @@ -412,6 +408,11 @@ private function getTerminalData(AbstractPosAccount $account, string $hash, bool ]; } + /** + * @param AbstractCreditCard|null $card + * + * @return array + */ private function getCardData(?AbstractCreditCard $card = null): array { if ($card !== null) { @@ -430,9 +431,9 @@ private function getCardData(?AbstractCreditCard $card = null): array } /** - * @param object $order + * @param $order * - * @return array{Address: array{Type: string, Name: mixed, LastName: string, Company: string, Text: string, District: string, City: string, PostalCode: string, Country: string, PhoneNumber: string}} + * @return array */ private function getOrderAddressData($order): array { @@ -468,9 +469,9 @@ private function getOrderAddressData($order): array * * * - * @param object $order + * @param $order * - * @return array{TotalPaymentNum: mixed, FrequencyType: string, FrequencyInterval: mixed, Type: mixed, StartDate: mixed} + * @return array */ private function createRecurringData($order): array { diff --git a/src/DataMapper/InterPosRequestDataMapper.php b/src/DataMapper/InterPosRequestDataMapper.php index d79f43cc..88e3695a 100644 --- a/src/DataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/InterPosRequestDataMapper.php @@ -57,8 +57,6 @@ class InterPosRequestDataMapper extends AbstractRequestDataMapperCrypt /** * {@inheritDoc} - * - * @return array{TxnType: string, SecureType: string, OrderId: mixed, PurchAmount: mixed, Currency: string, InstallmentCount: string, MD: mixed, PayerTxnId: mixed, Eci: mixed, PayerAuthenticationCode: mixed, MOTO: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { @@ -105,7 +103,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ } /** - * @return array{TxnType: string, SecureType: string, OrderId: null, orgOrderId: mixed, PurchAmount: mixed, Currency: string, MOTO: string, UserCode: string, UserPass: string, ShopCode: string} + * {@inheritDoc} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { @@ -121,7 +119,7 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $ac } /** - * @return array{OrderId: null, orgOrderId: mixed, TxnType: string, SecureType: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} + * {@inheritDoc} */ public function createStatusRequestData(AbstractPosAccount $account, $order): array { @@ -136,8 +134,6 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} - * - * @return array{OrderId: null, orgOrderId: mixed, TxnType: string, SecureType: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -151,7 +147,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar } /** - * @return array{OrderId: null, orgOrderId: mixed, PurchAmount: mixed, TxnType: string, SecureType: string, Lang: string, MOTO: string, UserCode: string, UserPass: string, ShopCode: string} + * {@inheritDoc} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -219,7 +215,9 @@ public function mapInstallment(?int $installment): string } /** - * @return array{UserCode: string, UserPass: string, ShopCode: string} + * @param AbstractPosAccount $account + * + * @return array */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/DataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/KuveytPosRequestDataMapper.php index 9ffb5bce..418eaf8e 100644 --- a/src/DataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/KuveytPosRequestDataMapper.php @@ -67,6 +67,10 @@ class KuveytPosRequestDataMapper extends AbstractRequestDataMapperCrypt /** * Amount Formatter * converts 100 to 10000, or 10.01 to 1001 + * + * @param float $amount + * + * @return int */ public static function amountFormat(float $amount): int { @@ -77,8 +81,6 @@ public static function amountFormat(float $amount): int * @param KuveytPosAccount $account * * {@inheritDoc} - * - * @return array{APIVersion: string, HashData: string, CustomerIPAddress: mixed, KuveytTurkVPosAdditionalData: array{AdditionalData: array{Key: string, Data: mixed}}, TransactionType: string, InstallmentCount: mixed, Amount: mixed, DisplayAmount: int, CurrencyCode: mixed, MerchantOrderId: mixed, TransactionSecurity: mixed, MerchantId: string, CustomerId: string, UserName: string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { @@ -107,6 +109,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, } /** + * @param KuveytPosAccount $account * @param AbstractGateway::TX_* $txType */ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array @@ -206,7 +209,7 @@ public function mapInstallment(?int $installment): string /** * @param KuveytPosAccount $account * - * @return array{MerchantId: string, CustomerId: string, UserName: string} + * @return array */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index 77a08a86..01d46bc9 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -48,8 +48,6 @@ class PayForPosRequestDataMapper extends AbstractRequestDataMapper /** * {@inheritDoc} - * - * @return array{RequestGuid: mixed, UserCode: string, UserPass: string, OrderId: mixed, SecureType: string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { @@ -64,8 +62,6 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, /** * {@inheritDoc} - * - * @return array{MbrId: string, MOTO: string, OrderId: mixed, SecureType: string, TxnType: string, PurchAmount: mixed, Currency: string, InstallmentCount: string, Lang: string, CardHolderName: string|null, Pan: string, Expiry: string, Cvv2: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array { @@ -87,7 +83,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ } /** - * @return array{MbrId: string, OrgOrderId: mixed, SecureType: string, TxnType: string, PurchAmount: mixed, Currency: string, Lang: string, MerchantId: string, UserCode: string, UserPass: string} + * {@inheritDoc} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { @@ -103,7 +99,7 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $ac } /** - * @return array{MbrId: string, OrgOrderId: mixed, SecureType: string, Lang: string, TxnType: string, MerchantId: string, UserCode: string, UserPass: string} + * {@inheritDoc} */ public function createStatusRequestData(AbstractPosAccount $account, $order): array { @@ -118,8 +114,6 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} - * - * @return array{MbrId: string, OrgOrderId: mixed, SecureType: string, TxnType: string, Currency: string, Lang: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -134,7 +128,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar } /** - * @return array{MbrId: string, SecureType: string, Lang: string, OrgOrderId: mixed, TxnType: string, PurchAmount: mixed, Currency: string, MerchantId: string, UserCode: string, UserPass: string} + * {@inheritDoc} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -217,7 +211,9 @@ public function mapInstallment(?int $installment): string } /** - * @return array{MerchantId: string, UserCode: string, UserPass: string} + * @param AbstractPosAccount $account + * + * @return array */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/DataMapper/PosNetRequestDataMapper.php b/src/DataMapper/PosNetRequestDataMapper.php index 10aba83b..1652705d 100644 --- a/src/DataMapper/PosNetRequestDataMapper.php +++ b/src/DataMapper/PosNetRequestDataMapper.php @@ -218,10 +218,10 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar /** - * {@inheritDoc} - * * @param PosNetAccount $account * + * {@inheritDoc} + * * @throws Exception */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null, $extraData = null): array diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index d330a204..e75a65c9 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -53,10 +53,7 @@ class VakifBankPosRequestDataMapper extends AbstractRequestDataMapper /** * @param VakifBankAccount $account - * * {@inheritDoc} - * - * @return array{TransactionType: string, TransactionId: mixed, CurrencyAmount: string, CurrencyCode: string, CardHoldersName: string|null, Cvv: string, Pan: string, Expiry: string, ECI: mixed, CAVV: mixed, MpiTransactionId: mixed, OrderId: mixed, OrderDescription: mixed, ClientIp: mixed, TransactionDeviceSource: int, MerchantId: string, Password: string, TerminalNo: string, NumberOfInstallments?: int|string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData, ?AbstractCreditCard $card = null): array { @@ -88,6 +85,9 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, /** * @param VakifBankAccount $account * @param object $order + * @param AbstractCreditCard $card + * + * @return array */ public function create3DEnrollmentCheckRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array { @@ -159,10 +159,11 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ } /** - * @param VakifBankAccount $account - * @param object $order + * @param VakifBankAccount $account + * @param $order + * @param AbstractCreditCard|null $card * - * @return array{TransactionType: string, ReferenceTransactionId: mixed, CurrencyAmount: string, CurrencyCode: string, ClientIp: mixed, MerchantId: string, Password: string, TerminalNo: string} + * @return array */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { @@ -185,8 +186,6 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} - * - * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: mixed, ClientIp: mixed} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -200,7 +199,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar } /** - * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: mixed, ClientIp: mixed, CurrencyAmount: string} + * {@inheritDoc} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -223,9 +222,9 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar } /** - * {@inheritDoc} + * @param array $extraData * - * @return array{gateway: mixed, inputs: array{PaReq: mixed, TermUrl: mixed, MD: mixed}} + * {@inheritDoc} */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null, array $extraData = []): array { @@ -244,6 +243,8 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx /** * Amount Formatter * + * @param float $amount + * * @return string ex: 10.1 => 10.10 */ public static function amountFormat(float $amount): string @@ -259,7 +260,7 @@ public function mapInstallment(?int $installment): string /** * @param VakifBankAccount $account * - * @return array{MerchantId: string, Password: string, TerminalNo: string} + * @return array */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/Entity/Account/AbstractPosAccount.php b/src/Entity/Account/AbstractPosAccount.php index d2a995a1..0c7bd0ce 100644 --- a/src/Entity/Account/AbstractPosAccount.php +++ b/src/Entity/Account/AbstractPosAccount.php @@ -4,23 +4,25 @@ namespace Mews\Pos\Entity\Account; -use Mews\Pos\Gateways\AbstractGateway; - abstract class AbstractPosAccount { - /** @var string */ + /** + * @var string + */ protected $clientId; /** * account models: regular, 3d, 3d_pay, 3d_host - * @var AbstractGateway::MODEL_* + * @var string */ protected $model; - - /** @var string */ + /** + * @var string + */ protected $username; - - /** @var string */ + /** + * @var string + */ protected $password; /** @@ -28,8 +30,9 @@ abstract class AbstractPosAccount * @var string|null */ protected $storeKey; - - /** @var string */ + /** + * @var string + */ protected $lang; /** @@ -41,8 +44,13 @@ abstract class AbstractPosAccount /** * AbstractPosAccount constructor. - * - * @param AbstractGateway::MODEL_* $model + * @param string $bank + * @param string $model + * @param string $clientId + * @param string $username + * @param string $password + * @param string $lang + * @param string|null $storeKey */ public function __construct(string $bank, string $model, string $clientId, string $username, string $password, string $lang, ?string $storeKey = null) { @@ -55,39 +63,57 @@ public function __construct(string $bank, string $model, string $clientId, strin $this->bank = $bank; } + /** + * @return string + */ public function getClientId(): string { return $this->clientId; } /** - * @return AbstractGateway::MODEL_* + * @return string */ public function getModel(): string { return $this->model; } + /** + * @return string + */ public function getUsername(): string { return $this->username; } + /** + * @return string + */ public function getPassword(): string { return $this->password; } + /** + * @return string|null + */ public function getStoreKey(): ?string { return $this->storeKey; } + /** + * @return string + */ public function getLang(): string { return $this->lang; } + /** + * @return string + */ public function getBank(): string { return $this->bank; diff --git a/src/Entity/Account/GarantiPosAccount.php b/src/Entity/Account/GarantiPosAccount.php index b18bd563..ebb8cf62 100644 --- a/src/Entity/Account/GarantiPosAccount.php +++ b/src/Entity/Account/GarantiPosAccount.php @@ -11,10 +11,10 @@ class GarantiPosAccount extends AbstractPosAccount { /** @var string */ private $terminalId; - + /** @var string */ private $refundUsername; - + /** @var string */ private $refundPassword; @@ -37,16 +37,25 @@ public function __construct( $this->refundPassword = $refundPassword; } + /** + * @return string + */ public function getRefundPassword(): string { return $this->refundPassword; } + /** + * @return string + */ public function getRefundUsername(): string { return $this->refundUsername; } + /** + * @return string + */ public function getTerminalId(): string { return $this->terminalId; diff --git a/src/Entity/Account/KuveytPosAccount.php b/src/Entity/Account/KuveytPosAccount.php index 62758e8e..f3c69ecd 100644 --- a/src/Entity/Account/KuveytPosAccount.php +++ b/src/Entity/Account/KuveytPosAccount.php @@ -15,10 +15,14 @@ class KuveytPosAccount extends AbstractPosAccount protected $subMerchantId; /** + * @param string $bank * @param string $merchantId Mağaza Numarası * @param string $username POS panelinizden kullanıcı işlemleri sayfasında APİ rolünde kullanıcı oluşturulmalıdır * @param string $customerId CustomerNumber, Müşteri No * @param string $storeKey Oluşturulan APİ kullanıcısının şifre bilgisidir. + * @param string $model + * @param string $lang + * @param string|null $subMerchantId */ public function __construct( string $bank, @@ -34,11 +38,17 @@ public function __construct( $this->subMerchantId = $subMerchantId; } + /** + * @return string + */ public function getCustomerId(): string { return $this->password; } + /** + * @return string|null + */ public function getSubMerchantId(): ?string { return $this->subMerchantId; diff --git a/src/Entity/Account/PosNetAccount.php b/src/Entity/Account/PosNetAccount.php index 006dcdea..976b52df 100644 --- a/src/Entity/Account/PosNetAccount.php +++ b/src/Entity/Account/PosNetAccount.php @@ -32,11 +32,17 @@ public function __construct( $this->posNetId = $posNetId; } + /** + * @return string + */ public function getTerminalId(): string { return $this->terminalId; } + /** + * @return string + */ public function getPosNetId(): string { return $this->posNetId; diff --git a/src/Entity/Account/VakifBankAccount.php b/src/Entity/Account/VakifBankAccount.php index 66ab60cc..59221207 100644 --- a/src/Entity/Account/VakifBankAccount.php +++ b/src/Entity/Account/VakifBankAccount.php @@ -10,14 +10,18 @@ class VakifBankAccount extends AbstractPosAccount public const MERCHANT_TYPE_SUB_DEALER = 2; - /** @var int[] */ + /** + * @var int[] + */ private static $merchantTypes = [ self::MERCHANT_TYPE_STANDARD, self::MERCHANT_TYPE_MAIN_DEALER, self::MERCHANT_TYPE_SUB_DEALER, ]; - /** @var string */ + /** + * @var string + */ private $terminalId; /** @@ -41,9 +45,12 @@ class VakifBankAccount extends AbstractPosAccount /** * VakifBankAccount constructor. * + * @param string $bank + * @param string $model * @param string $merchantId Isyeri No * @param string $password Isyeri Sifre * @param string $terminalId Terminal No + * @param int $merchantType * @param string|null $subMerchantId */ public function __construct( @@ -62,21 +69,33 @@ public function __construct( $this->subMerchantId = $subMerchantId; } + /** + * @return string + */ public function getTerminalId(): string { return $this->terminalId; } + /** + * @return int + */ public function getMerchantType(): int { return $this->merchantType; } + /** + * @return string|null + */ public function getSubMerchantId(): ?string { return $this->subMerchantId; } + /** + * @return bool + */ public function isSubBranch(): bool { return self::MERCHANT_TYPE_SUB_DEALER === $this->merchantType; diff --git a/src/Entity/Card/AbstractCreditCard.php b/src/Entity/Card/AbstractCreditCard.php index 19e22e41..c7c79f0b 100644 --- a/src/Entity/Card/AbstractCreditCard.php +++ b/src/Entity/Card/AbstractCreditCard.php @@ -34,15 +34,19 @@ abstract class AbstractCreditCard /** * visa, master, troy, amex, ... - * @var self::CARD_TYPE_*|null + * @var string|null */ protected $type; /** * AbstractCreditCard constructor. * - * @param string $number credit card number with or without spaces - * @param self::CARD_TYPE_*|null $cardType + * @param string $number credit card number with or without spaces + * @param DateTimeImmutable $expDate + * @param string $cvv + * @param string|null $cardHolderName + * @param string|null $cardType examples values: 'visa', 'master', '1', '2' + * */ public function __construct(string $number, DateTimeImmutable $expDate, string $cvv, ?string $cardHolderName = null, ?string $cardType = null) { @@ -55,6 +59,7 @@ public function __construct(string $number, DateTimeImmutable $expDate, string $ /** * returns card number without white spaces + * @return string */ public function getNumber(): string { @@ -62,7 +67,11 @@ public function getNumber(): string } /** - * @return string year by default in 2 digit format. + * returns exp year in 2 digit format + * + * @param string $format + * + * @return string */ public function getExpireYear(string $format = 'y'): string { @@ -70,7 +79,11 @@ public function getExpireYear(string $format = 'y'): string } /** - * @return string month number, by default in 2 digit format. i.e '01' '02' '12' + * returns exp year in 2 digit format. i.e '01' '02' '12' + * + * @param string $format + * + * @return string */ public function getExpireMonth(string $format = 'm'): string { @@ -78,30 +91,43 @@ public function getExpireMonth(string $format = 'm'): string } /** - * @return string card exp date month and year combined. + * returns card exp date month and year combined. + * + * @param string $format + * + * @return string */ public function getExpirationDate(string $format = 'ym'): string { return $this->expDate->format($format); } + /** + * @return string + */ public function getCvv(): string { return $this->cvv; } + /** + * @return string|null + */ public function getHolderName(): ?string { return $this->holderName; } + /** + * @param string|null $name + */ public function setHolderName(?string $name) { $this->holderName = $name; } /** - * @return self::CARD_TYPE_*|null + * @return string|null */ public function getType(): ?string { diff --git a/src/Exceptions/CardTypeNotSupportedException.php b/src/Exceptions/CardTypeNotSupportedException.php index 10cb4d5d..74d16e6c 100644 --- a/src/Exceptions/CardTypeNotSupportedException.php +++ b/src/Exceptions/CardTypeNotSupportedException.php @@ -16,6 +16,9 @@ class CardTypeNotSupportedException extends DomainException /** * BankNotFoundException constructor. * + * @param string $type + * @param string $message + * @param int $code * @param Throwable|null $previous */ public function __construct(string $type, string $message = 'Card type is not supported by this gateway!', int $code = 74, Throwable $previous = null) @@ -24,6 +27,9 @@ public function __construct(string $type, string $message = 'Card type is not su $this->type = $type; } + /** + * @return string + */ public function getType(): string { return $this->type; diff --git a/src/Exceptions/CardTypeRequiredException.php b/src/Exceptions/CardTypeRequiredException.php index c01c700e..4785b128 100644 --- a/src/Exceptions/CardTypeRequiredException.php +++ b/src/Exceptions/CardTypeRequiredException.php @@ -10,12 +10,17 @@ */ class CardTypeRequiredException extends DomainException { - /** @var string */ + /** + * @var string + */ private $gatewayName; /** * BankNotFoundException constructor. * + * @param string $gatewayName + * @param string $message + * @param int $code * @param Throwable|null $previous */ public function __construct(string $gatewayName, string $message = 'Card type is required for this gateway!', int $code = 73, Throwable $previous = null) @@ -24,6 +29,9 @@ public function __construct(string $gatewayName, string $message = 'Card type is $this->gatewayName = $gatewayName; } + /** + * @return string + */ public function getGatewayName(): string { return $this->gatewayName; diff --git a/src/Factory/AccountFactory.php b/src/Factory/AccountFactory.php index 10cb4147..dcac1b98 100644 --- a/src/Factory/AccountFactory.php +++ b/src/Factory/AccountFactory.php @@ -20,8 +20,15 @@ class AccountFactory { /** - * @param string $clientId Üye iş yeri numarası - * @param AbstractGateway::MODEL_* $model + * @param string $bank + * @param string $clientId Üye iş yeri numarası + * @param string $kullaniciAdi + * @param string $password + * @param string $model + * @param string|null $storeKey + * @param string $lang + * + * @return EstPosAccount * * @throws MissingAccountInfoException */ @@ -33,7 +40,15 @@ public static function createEstPosAccount(string $bank, string $clientId, strin } /** - * @param AbstractGateway::MODEL_* $model + * @param string $bank + * @param string $merchantId + * @param string $userCode + * @param string $userPassword + * @param string $model + * @param string|null $merchantPass + * @param string $lang + * + * @return PayForAccount * * @throws MissingAccountInfoException */ @@ -45,9 +60,18 @@ public static function createPayForAccount(string $bank, string $merchantId, str } /** - * @param string $merchantId Üye işyeri Numarası - * @param string $password Terminal UserID şifresi - * @param AbstractGateway::MODEL_* $model + * @param string $bank + * @param string $merchantId Üye işyeri Numarası + * @param string $userId + * @param string $password Terminal UserID şifresi + * @param string $terminalId + * @param string $model + * @param string|null $storeKey + * @param string|null $refundUsername + * @param string|null $refundPassword + * @param string $lang + * + * @return GarantiPosAccount * * @throws MissingAccountInfoException */ @@ -60,12 +84,16 @@ public static function createGarantiPosAccount(string $bank, string $merchantId, /** - * @param string $merchantId Mağaza Numarası - * @param string $username POS panelinizden kullanıcı işlemleri sayfasında APİ rolünde - * kullanıcı oluşturulmalıdır - * @param string $customerId CustomerNumber, Müşteri No - * @param string $storeKey Oluşturulan APİ kullanıcısının şifre bilgisidir. - * @param AbstractGateway::MODEL_* $model + * @param string $bank + * @param string $merchantId Mağaza Numarası + * @param string $username POS panelinizden kullanıcı işlemleri sayfasında APİ rolünde kullanıcı oluşturulmalıdır + * @param string $customerId CustomerNumber, Müşteri No + * @param string $storeKey Oluşturulan APİ kullanıcısının şifre bilgisidir. + * @param string $model + * @param string $lang + * @param string|null $subMerchantId + * + * @return KuveytPosAccount */ public static function createKuveytPosAccount(string $bank, string $merchantId, string $username, string $customerId, string $storeKey, string $model = AbstractGateway::MODEL_3D_SECURE, string $lang = AbstractGateway::LANG_TR, ?string $subMerchantId = null): KuveytPosAccount { @@ -73,9 +101,17 @@ public static function createKuveytPosAccount(string $bank, string $merchantId, } /** - * @param string $username kullanilmamakta, bos atayin - * @param string $password kullanilmamakta, bos atayin - * @param AbstractGateway::MODEL_* $model + * @param string $bank + * @param string $merchantId + * @param string $username kullanilmamakta, bos atayin + * @param string $password kullanilmamakta, bos atayin + * @param string $terminalId + * @param string $posNetId + * @param string $model + * @param string|null $storeKey + * @param string $lang + * + * @return PosNetAccount * * @throws MissingAccountInfoException */ @@ -87,15 +123,19 @@ public static function createPosNetAccount(string $bank, string $merchantId, str } /** - * @param string $merchantId Üye işyeri numarası - * @param string $password Üye işyeri şifres - * @param string $terminalNo İşlemin hangi terminal üzerinden gönderileceği bilgisi. VB007000... - * @param AbstractGateway::MODEL_* $model - * @param string|null $subMerchantId + * @param string $bank + * @param string $merchantId Üye işyeri numarası + * @param string $password Üye işyeri şifres + * @param string $terminalNo İşlemin hangi terminal üzerinden gönderileceği bilgisi. VB007000... + * @param string $model + * @param int $merchantType + * @param null $subMerchantId + * + * @return VakifBankAccount * * @throws MissingAccountInfoException */ - public static function createVakifBankAccount(string $bank, string $merchantId, string $password, string $terminalNo, string $model = AbstractGateway::MODEL_NON_SECURE, int $merchantType = VakifBankAccount::MERCHANT_TYPE_STANDARD, string $subMerchantId = null): VakifBankAccount + public static function createVakifBankAccount(string $bank, string $merchantId, string $password, string $terminalNo, string $model = AbstractGateway::MODEL_NON_SECURE, int $merchantType = VakifBankAccount::MERCHANT_TYPE_STANDARD, $subMerchantId = null): VakifBankAccount { self::checkVakifBankMerchantType($merchantType, $subMerchantId); @@ -103,7 +143,15 @@ public static function createVakifBankAccount(string $bank, string $merchantId, } /** - * @param AbstractGateway::MODEL_* $model + * @param string $bank + * @param string $shopCode + * @param string $userCode + * @param string $userPass + * @param string $model + * @param string|null $merchantPass + * @param string $lang + * + * @return InterPosAccount * * @throws MissingAccountInfoException */ @@ -115,7 +163,8 @@ public static function createInterPosAccount(string $bank, string $shopCode, str } /** - * @param AbstractGateway::MODEL_* $model + * @param string $model + * @param string|null $storeKey * * @return void * @@ -135,6 +184,9 @@ private static function checkParameters(string $model, ?string $storeKey) } /** + * @param int $merchantType + * @param string|null $subMerchantId + * * @return void * * @throws MissingAccountInfoException diff --git a/src/Factory/CreditCardFactory.php b/src/Factory/CreditCardFactory.php index 01ba39e0..36fc6658 100644 --- a/src/Factory/CreditCardFactory.php +++ b/src/Factory/CreditCardFactory.php @@ -19,13 +19,16 @@ class CreditCardFactory /** * AbstractCreditCard constructor. * - * @param PosInterface|AbstractGateway $pos - * @param string $number credit card number with or without spaces - * @param string $expireYear accepts year in 1, 2 and 4 digit format. accepted year - * formats '1' (2001), '02' - * (2002), '20' (2020), '2024' (2024) - * @param string $expireMonth single digit or double digit month values are accepted - * @param AbstractCreditCard::CARD_TYPE_*|null $cardType bankaya gore zorunlu + * @param PosInterface|AbstractGateway $pos + * @param string $number credit card number with or without spaces + * @param string $expireYear accepts year in 1, 2 and 4 digit format. accepted year formats '1' (2001), '02' + * (2002), '20' (2020), '2024' (2024) + * @param string $expireMonth single digit or double digit month values are accepted + * @param string $cvv + * @param string|null $cardHolderName + * @param string|null $cardType examples values: visa, master. bankaya gore zorunlu + * + * @return AbstractCreditCard */ public static function create( PosInterface $pos, diff --git a/src/Factory/PosFactory.php b/src/Factory/PosFactory.php index ee4f3382..6cc9701b 100644 --- a/src/Factory/PosFactory.php +++ b/src/Factory/PosFactory.php @@ -52,7 +52,12 @@ class PosFactory { /** - * @param array|string|null $config config path or config array + * @param AbstractPosAccount $posAccount + * @param array|string|null $config config path or config array + * @param HttpClient|null $client + * @param LoggerInterface|null $logger + * + * @return PosInterface * * @throws BankClassNullException * @throws BankNotFoundException @@ -113,8 +118,11 @@ public static function createPosGateway( } /** - * @param class-string $gatewayClass - * @param array $currencies + * @param class-string $gatewayClass + * @param array $currencies + * @param CryptInterface|null $crypt + * + * @return AbstractRequestDataMapper */ public static function getGatewayRequestMapper(string $gatewayClass, array $currencies = [], ?CryptInterface $crypt = null): AbstractRequestDataMapper { @@ -145,7 +153,11 @@ public static function getGatewayRequestMapper(string $gatewayClass, array $curr } /** - * @param class-string $gatewayClass + * @param class-string $gatewayClass + * @param AbstractRequestDataMapper $requestDataMapper + * @param LoggerInterface $logger + * + * @return AbstractResponseDataMapper */ public static function getGatewayResponseMapper(string $gatewayClass, AbstractRequestDataMapper $requestDataMapper, LoggerInterface $logger): AbstractResponseDataMapper { @@ -173,7 +185,10 @@ public static function getGatewayResponseMapper(string $gatewayClass, AbstractRe } /** - * @param class-string $gatewayClass + * @param class-string $gatewayClass + * @param LoggerInterface $logger + * + * @return CryptInterface|null */ public static function getGatewayCrypt(string $gatewayClass, LoggerInterface $logger): ?CryptInterface { diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 7f253515..7254d4d7 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -69,7 +69,9 @@ abstract class AbstractGateway implements PosInterface */ protected $type; - /** @var object|null */ + /** + * @var object|null + */ protected $order; /** @@ -153,13 +155,16 @@ public function prepare(array $order, string $txType, $card = null) $this->card = $card; } + /** + * @return array|null + */ public function getResponse(): ?array { return $this->response; } /** - * @return non-empty-array + * @return array */ public function getCurrencies(): array { @@ -179,11 +184,17 @@ public function getConfig() */ abstract public function getAccount(); + /** + * @return AbstractCreditCard|null + */ public function getCard(): ?AbstractCreditCard { return $this->card; } + /** + * @param AbstractCreditCard|null $card + */ public function setCard(?AbstractCreditCard $card) { $this->card = $card; @@ -219,27 +230,41 @@ public function createXML(array $nodes, string $encoding = 'UTF-8', bool $ignore /** * Is success + * + * @return bool */ public function isSuccess(): bool { return isset($this->response['status']) && $this->responseDataMapper::TX_APPROVED === $this->response['status']; } + /** + * @return string + */ public function getApiURL(): string { return $this->config['urls'][$this->getModeInWord()]; } + /** + * @return string + */ public function get3DGatewayURL(): string { return $this->config['urls']['gateway'][$this->getModeInWord()]; } + /** + * @return string|null + */ public function get3DHostGatewayURL(): ?string { return $this->config['urls']['gateway_3d_host'][$this->getModeInWord()] ?? null; } + /** + * @return bool + */ public function isTestMode(): bool { return $this->testMode; @@ -367,6 +392,8 @@ public function history(array $meta) } /** + * @param bool $testMode + * * @return $this */ public function setTestMode(bool $testMode): self @@ -447,13 +474,15 @@ abstract public function create3DPaymentXML($responseData); /** * returns form data, key values, necessary for 3D payment * - * @return array{gateway: string, inputs: array} + * @return array */ abstract public function get3DFormData(): array; /** * prepares order for payment request * + * @param array $order + * * @return object */ abstract protected function preparePaymentOrder(array $order); @@ -461,6 +490,8 @@ abstract protected function preparePaymentOrder(array $order); /** * prepares order for TX_POST_PAY type request * + * @param array $order + * * @return object */ abstract protected function preparePostPaymentOrder(array $order); @@ -468,6 +499,8 @@ abstract protected function preparePostPaymentOrder(array $order); /** * prepares order for order status request * + * @param array $order + * * @return object */ abstract protected function prepareStatusOrder(array $order); @@ -475,6 +508,8 @@ abstract protected function prepareStatusOrder(array $order); /** * prepares order for history request * + * @param array $order + * * @return object */ abstract protected function prepareHistoryOrder(array $order); @@ -482,6 +517,8 @@ abstract protected function prepareHistoryOrder(array $order); /** * prepares order for cancel request * + * @param array $order + * * @return object */ abstract protected function prepareCancelOrder(array $order); @@ -489,12 +526,16 @@ abstract protected function prepareCancelOrder(array $order); /** * prepares order for refund request * + * @param array $order + * * @return object */ abstract protected function prepareRefundOrder(array $order); /** * @param string $str + * + * @return bool */ protected function isHTML($str): bool { @@ -503,6 +544,11 @@ protected function isHTML($str): bool /** * Converts XML string to array + * + * @param string $data + * @param array $context + * + * @return array */ protected function XMLStringToArray(string $data, array $context = []): array { @@ -513,6 +559,7 @@ protected function XMLStringToArray(string $data, array $context = []): array /** * return values are used as a key in config file + * @return string */ private function getModeInWord(): string { diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index 780597bd..eced3c18 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -24,7 +24,9 @@ class EstPos extends AbstractGateway */ public const NAME = 'EstPos'; - /** @var EstPosAccount */ + /** + * @var EstPosAccount + */ protected $account; /** diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index e397ed53..e063782f 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -33,6 +33,9 @@ class InterPos extends AbstractGateway /** @var InterPosResponseDataMapper */ protected $responseDataMapper; + /** + * @return InterPosAccount + */ public function getAccount(): InterPosAccount { return $this->account; diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 4a83fecf..dc98e667 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -41,6 +41,9 @@ public function createXML(array $nodes, string $encoding = 'ISO-8859-1', bool $i return parent::createXML(['KuveytTurkVPosMessage' => $nodes], $encoding, $ignorePiNode); } + /** + * @return KuveytPosAccount + */ public function getAccount(): KuveytPosAccount { return $this->account; @@ -258,9 +261,13 @@ protected function prepareRefundOrder(array $order) } /** - * @param self::TX_* $txType + * @param KuveytPosAccount $account + * @param $order + * @param self::TX_* $txType + * @param string $gatewayURL + * @param AbstractCreditCard|null $card * - * @return array{gateway: string, inputs: array} + * @return array * * @throws Exception */ @@ -280,8 +287,9 @@ private function getCommon3DFormData(KuveytPosAccount $account, $order, string $ /** * 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. + * @param string $response * - * @return array{gateway: string, inputs: array} + * @return array */ private function transformReceived3DFormData(string $response): array { @@ -317,6 +325,7 @@ private function transformReceived3DFormData(string $response): array /** * html form'da gelen input degeleri array'e donusturur + * @param DOMNodeList $inputNodes * * @return array */ diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index 9b995ac3..a01e4d8b 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -23,7 +23,9 @@ class PayForPos extends AbstractGateway */ public const NAME = 'PayForPOS'; - /** @var PayForAccount */ + /** + * @var PayForAccount + */ protected $account; /** @var PayForPosRequestDataMapper */ @@ -116,7 +118,9 @@ public function history(array $meta) /** - * @inheritDoc + * returns form data needed for 3d, 3d_pay and 3d_host models + * + * @return array */ public function get3DFormData(): array { diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index b9ea47ce..370b7a8b 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -24,7 +24,9 @@ class VakifBankPos extends AbstractGateway */ public const NAME = 'VakifPOS'; - /** @var VakifBankAccount */ + /** + * @var VakifBankAccount + */ protected $account; /** @var VakifBankPosRequestDataMapper */ @@ -100,7 +102,11 @@ public function history(array $meta) } /** - * @inheritDoc + * returns form data needed for 3d model + * + * @return array + * + * @throws Exception */ public function get3DFormData(): array { diff --git a/src/PosInterface.php b/src/PosInterface.php index daab2883..39fe4b82 100644 --- a/src/PosInterface.php +++ b/src/PosInterface.php @@ -17,7 +17,9 @@ interface PosInterface /** * Create XML DOM Document * - * @param bool $ignorePiNode when true it will not wrap it with this node + * @param array $nodes + * @param string $encoding + * @param bool $ignorePiNode when true it will not wrap it with this node * * @return string the XML, or false if an error occurred. */ @@ -32,6 +34,7 @@ public function makeRegularPayment(); /** * Make 3D Payment + * @param Request $request * * @return AbstractGateway */ @@ -39,6 +42,7 @@ public function make3DPayment(Request $request); /** * Make 3D Pay Payment + * @param Request $request * * @return AbstractGateway */ @@ -46,6 +50,7 @@ public function make3DPayPayment(Request $request); /** * Just returns formatted data of host payment response + * @param Request $request * * @return AbstractGateway */ @@ -55,6 +60,7 @@ public function make3DHostPayment(Request $request); * Send contents to WebService * * @param array|string $contents + * @param string|null $url * * @return string|array|null */ @@ -63,6 +69,7 @@ public function send($contents, ?string $url = null); /** * Prepare Order * + * @param array $order * @param AbstractGateway::TX_* $txType * @param AbstractCreditCard|null $card need when 3DFormData requested * @@ -105,6 +112,8 @@ public function status(); /** * Order History * + * @param array $meta + * * @return AbstractGateway */ public function history(array $meta); @@ -119,6 +128,8 @@ public function isSuccess(); /** * Enable/Disable test mode * + * @param bool $testMode + * * @return AbstractGateway */ public function setTestMode(bool $testMode); diff --git a/tests/Crypt/KuveytPosCryptTest.php b/tests/Crypt/KuveytPosCryptTest.php index 096bf8c6..38755704 100644 --- a/tests/Crypt/KuveytPosCryptTest.php +++ b/tests/Crypt/KuveytPosCryptTest.php @@ -11,13 +11,17 @@ class KuveytPosCryptTest extends TestCase { - /** @var array|array */ + /** + * @var array|array + */ public $order; - - /** @var KuveytPosCrypt */ + /** + * @var KuveytPosCrypt + */ public $crypt; - - /** @var KuveytPosAccount */ + /** + * @var KuveytPosAccount + */ private $threeDAccount; protected function setUp(): void diff --git a/tests/Crypt/PayForPosCryptTest.php b/tests/Crypt/PayForPosCryptTest.php index c39d50d9..90fc852a 100644 --- a/tests/Crypt/PayForPosCryptTest.php +++ b/tests/Crypt/PayForPosCryptTest.php @@ -11,13 +11,19 @@ class PayForPosCryptTest extends TestCase { - /** @var array|array */ + /** + * @var array|array + */ public $order; - /** @var PayForPosCrypt */ + /** + * @var PayForPosCrypt + */ public $crypt; - /** @var PayForAccount */ + /** + * @var PayForAccount + */ private $threeDAccount; protected function setUp(): void diff --git a/tests/Crypt/PosNetCryptTest.php b/tests/Crypt/PosNetCryptTest.php index a1fa3764..70855e3e 100644 --- a/tests/Crypt/PosNetCryptTest.php +++ b/tests/Crypt/PosNetCryptTest.php @@ -11,10 +11,14 @@ class PosNetCryptTest extends TestCase { - /** @var PosNetCrypt */ + /** + * @var PosNetCrypt + */ public $crypt; - /** @var PosNetAccount */ + /** + * @var PosNetAccount + */ private $threeDAccount; protected function setUp(): void diff --git a/tests/DataMapper/EstPosRequestDataMapperTest.php b/tests/DataMapper/EstPosRequestDataMapperTest.php index 04129708..860faf3d 100644 --- a/tests/DataMapper/EstPosRequestDataMapperTest.php +++ b/tests/DataMapper/EstPosRequestDataMapperTest.php @@ -425,6 +425,13 @@ public function testCreateRefundRequestData() $this->assertEquals($expectedData, $actual); } + /** + * @param AbstractPosAccount $account + * @param $order + * @param array $responseData + * + * @return array + */ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $order, array $responseData): array { $requestData = [ @@ -463,6 +470,12 @@ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $ord return $requestData; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): array { return [ @@ -474,6 +487,12 @@ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): ar ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleRecurringOrderCancelXMLData(AbstractPosAccount $account, $order): array { return [ @@ -488,6 +507,13 @@ private function getSampleRecurringOrderCancelXMLData(AbstractPosAccount $accoun ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * @param AbstractCreditCard $card + * + * @return array + */ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array { return [ @@ -512,6 +538,12 @@ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $accoun ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, $order): array { return [ @@ -523,6 +555,12 @@ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $ac ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleStatusRequestData(AbstractPosAccount $account, $order): array { return [ @@ -536,6 +574,12 @@ private function getSampleStatusRequestData(AbstractPosAccount $account, $order) ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleRecurringStatusRequestData(AbstractPosAccount $account, $order): array { return [ @@ -549,6 +593,12 @@ private function getSampleRecurringStatusRequestData(AbstractPosAccount $account ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): array { $data = [ @@ -567,7 +617,13 @@ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): ar return $data; } - private function getSampleHistoryRequestData(AbstractPosAccount $account, array $customQueryData): array + /** + * @param AbstractPosAccount $account + * @param $customQueryData + * + * @return array + */ + private function getSampleHistoryRequestData(AbstractPosAccount $account, $customQueryData): array { return [ 'Name' => $account->getUsername(), diff --git a/tests/DataMapper/GarantiPosRequestDataMapperTest.php b/tests/DataMapper/GarantiPosRequestDataMapperTest.php index 4de2475c..07a47bd4 100644 --- a/tests/DataMapper/GarantiPosRequestDataMapperTest.php +++ b/tests/DataMapper/GarantiPosRequestDataMapperTest.php @@ -284,7 +284,14 @@ public function testCreateRefundRequestData() $this->assertEquals($expectedData, $actual); } - private function getSample3DPaymentRequestData(GarantiPosAccount $account, $order, array $responseData): array + /** + * @param GarantiPosAccount $account + * @param $order + * @param array $responseData + * + * @return array + */ + private function getSample3DPaymentRequestData(AbstractPosAccount $account, $order, array $responseData): array { return [ 'Mode' => 'TEST', @@ -334,7 +341,13 @@ private function getSample3DPaymentRequestData(GarantiPosAccount $account, $orde ]; } - private function getSampleCancelXMLData(GarantiPosAccount $account, $order): array + /** + * @param GarantiPosAccount $account + * @param $order + * + * @return array + */ + private function getSampleCancelXMLData(AbstractPosAccount $account, $order): array { return [ 'Mode' => 'TEST', @@ -365,7 +378,14 @@ private function getSampleCancelXMLData(GarantiPosAccount $account, $order): arr ]; } - private function getSampleNonSecurePaymentRequestData(GarantiPosAccount $account, $order, AbstractCreditCard $card): array + /** + * @param GarantiPosAccount $account + * @param $order + * @param AbstractCreditCard $card + * + * @return array + */ + private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array { return [ 'Mode' => 'TEST', @@ -414,7 +434,13 @@ private function getSampleNonSecurePaymentRequestData(GarantiPosAccount $account ]; } - private function getSampleNonSecurePaymentPostRequestData(GarantiPosAccount $account, $order): array + /** + * @param GarantiPosAccount $account + * @param $order + * + * @return array + */ + private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, $order): array { return [ 'Mode' => 'TEST', @@ -442,7 +468,13 @@ private function getSampleNonSecurePaymentPostRequestData(GarantiPosAccount $acc ]; } - private function getSampleStatusRequestData(GarantiPosAccount $account, $order): array + /** + * @param GarantiPosAccount $account + * @param $order + * + * @return array + */ + private function getSampleStatusRequestData(AbstractPosAccount $account, $order): array { return [ 'Mode' => 'TEST', @@ -472,7 +504,13 @@ private function getSampleStatusRequestData(GarantiPosAccount $account, $order): ]; } - private function getSampleRefundXMLData(GarantiPosAccount $account, $order): array + /** + * @param GarantiPosAccount $account + * @param $order + * + * @return array + */ + private function getSampleRefundXMLData(AbstractPosAccount $account, $order): array { return [ 'Mode' => 'TEST', @@ -503,7 +541,13 @@ private function getSampleRefundXMLData(GarantiPosAccount $account, $order): arr ]; } - private function getSampleHistoryRequestData(GarantiPosAccount $account, $order): array + /** + * @param GarantiPosAccount $account + * @param $order + * + * @return array + */ + private function getSampleHistoryRequestData(AbstractPosAccount $account, $order): array { return [ 'Mode' => 'TEST', diff --git a/tests/DataMapper/InterPosRequestDataMapperTest.php b/tests/DataMapper/InterPosRequestDataMapperTest.php index 114830ad..12b22626 100644 --- a/tests/DataMapper/InterPosRequestDataMapperTest.php +++ b/tests/DataMapper/InterPosRequestDataMapperTest.php @@ -328,6 +328,13 @@ public function testCreateRefundRequestData() $this->assertEquals($expectedData, $actual); } + /** + * @param $order + * @param InterPosAccount $account + * @param array $responseData + * + * @return array + */ private function getSample3DPaymentRequestData($order, InterPosAccount $account, array $responseData): array { return [ @@ -349,6 +356,12 @@ private function getSample3DPaymentRequestData($order, InterPosAccount $account, ]; } + /** + * @param $order + * @param InterPosAccount $account + * + * @return array + */ private function getSampleCancelXMLData($order, InterPosAccount $account): array { return [ @@ -363,6 +376,13 @@ private function getSampleCancelXMLData($order, InterPosAccount $account): array ]; } + /** + * @param $order + * @param AbstractCreditCard $card + * @param InterPosAccount $account + * + * @return array + */ private function getSampleNonSecurePaymentRequestData($order, AbstractCreditCard $card, InterPosAccount $account): array { $requestData = [ @@ -387,6 +407,12 @@ private function getSampleNonSecurePaymentRequestData($order, AbstractCreditCard return $requestData; } + /** + * @param $order + * @param InterPosAccount $account + * + * @return array + */ private function getSampleNonSecurePaymentPostRequestData($order, InterPosAccount $account): array { return [ @@ -403,6 +429,12 @@ private function getSampleNonSecurePaymentPostRequestData($order, InterPosAccoun ]; } + /** + * @param $order + * @param InterPosAccount $account + * + * @return array + */ private function getSampleStatusRequestData($order, InterPosAccount $account): array { return [ @@ -417,6 +449,12 @@ private function getSampleStatusRequestData($order, InterPosAccount $account): a ]; } + /** + * @param $order + * @param InterPosAccount $account + * + * @return array + */ private function getSampleRefundXMLData($order, InterPosAccount $account): array { return [ diff --git a/tests/DataMapper/KuveytPosRequestDataMapperTest.php b/tests/DataMapper/KuveytPosRequestDataMapperTest.php index 60b1d7f9..0713ae58 100644 --- a/tests/DataMapper/KuveytPosRequestDataMapperTest.php +++ b/tests/DataMapper/KuveytPosRequestDataMapperTest.php @@ -22,7 +22,9 @@ */ class KuveytPosRequestDataMapperTest extends TestCase { - /** @var KuveytPosAccount */ + /** + * @var KuveytPosAccount + */ public $threeDAccount; /** @var AbstractCreditCard */ @@ -37,6 +39,8 @@ class KuveytPosRequestDataMapperTest extends TestCase private $order; /** + * @return void + * * @throws BankClassNullException * @throws BankNotFoundException */ diff --git a/tests/DataMapper/PayForPosRequestDataMapperTest.php b/tests/DataMapper/PayForPosRequestDataMapperTest.php index 953b86e6..929ca748 100644 --- a/tests/DataMapper/PayForPosRequestDataMapperTest.php +++ b/tests/DataMapper/PayForPosRequestDataMapperTest.php @@ -329,6 +329,13 @@ public function testCreateRefundRequestData() $this->assertEquals($expectedData, $actual); } + /** + * @param AbstractPosAccount $account + * @param $order + * @param array $responseData + * + * @return array + */ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $order, array $responseData): array { return [ @@ -340,6 +347,12 @@ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $ord ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): array { return [ @@ -355,6 +368,13 @@ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): ar ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * @param AbstractCreditCard $card + * + * @return array + */ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array { return [ @@ -377,6 +397,12 @@ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $accoun ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, $order): array { return [ @@ -393,6 +419,12 @@ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $ac ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleStatusRequestData(AbstractPosAccount $account, $order): array { return [ @@ -407,6 +439,12 @@ private function getSampleStatusRequestData(AbstractPosAccount $account, $order) ]; } + /** + * @param AbstractPosAccount $account + * @param $order + * + * @return array + */ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): array { return [ @@ -423,6 +461,12 @@ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): ar ]; } + /** + * @param AbstractPosAccount $account + * @param $customQueryData + * + * @return array + */ private function getSampleHistoryRequestData(AbstractPosAccount $account, $customQueryData): array { $requestData = [ diff --git a/tests/DataMapper/PosNetRequestDataMapperTest.php b/tests/DataMapper/PosNetRequestDataMapperTest.php index 8db564d9..e8f0b148 100644 --- a/tests/DataMapper/PosNetRequestDataMapperTest.php +++ b/tests/DataMapper/PosNetRequestDataMapperTest.php @@ -338,11 +338,14 @@ public function testCreateRefundRequestData() } /** - * @param PosNetAccount $account - * @param $order - * @param array $oosTxResponseData + * @param PosNetAccount $account + * @param $order + * @param $oosTxResponseData + * @param string $gatewayURL + * + * @return array */ - private function getSample3DFormData(AbstractPosAccount $account, $order, array $oosTxResponseData, string $gatewayURL): array + private function getSample3DFormData(AbstractPosAccount $account, $order, $oosTxResponseData, string $gatewayURL): array { $inputs = [ 'posnetData' => $oosTxResponseData['data1'], @@ -362,6 +365,9 @@ private function getSample3DFormData(AbstractPosAccount $account, $order, array ]; } + /** + * @return array + */ private function getSample3DEnrollmentCheckResponseData(): array { return [ @@ -376,7 +382,13 @@ private function getSample3DEnrollmentCheckResponseData(): array ]; } - private function getSample3DPaymentRequestData(PosNetAccount $account, array $responseData): array + /** + * @param PosNetAccount $account + * @param array $responseData + * + * @return array + */ + private function getSample3DPaymentRequestData(AbstractPosAccount $account, array $responseData): array { return [ 'mid' => $account->getClientId(), @@ -391,7 +403,13 @@ private function getSample3DPaymentRequestData(PosNetAccount $account, array $re ]; } - private function getSampleCancelXMLData(PosNetAccount $account, $order): array + /** + * @param PosNetAccount $account + * @param $order + * + * @return array + */ + private function getSampleCancelXMLData(AbstractPosAccount $account, $order): array { $requestData = [ 'mid' => $account->getClientId(), @@ -412,7 +430,14 @@ private function getSampleCancelXMLData(PosNetAccount $account, $order): array return $requestData; } - private function getSampleNonSecurePaymentRequestData(PosNetAccount $account, $order, AbstractCreditCard $card): array + /** + * @param PosNetAccount $account + * @param $order + * @param AbstractCreditCard $card + * + * @return array + */ + private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, AbstractCreditCard $card): array { return [ 'mid' => $account->getClientId(), @@ -430,7 +455,13 @@ private function getSampleNonSecurePaymentRequestData(PosNetAccount $account, $o ]; } - private function getSampleNonSecurePaymentPostRequestData(PosNetAccount $account, $order): array + /** + * @param PosNetAccount $account + * @param $order + * + * @return array + */ + private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, $order): array { return [ 'mid' => $account->getClientId(), @@ -445,7 +476,12 @@ private function getSampleNonSecurePaymentPostRequestData(PosNetAccount $account ]; } - private function getSampleStatusRequestData(PosNetAccount $account): array + /** + * @param PosNetAccount $account + * + * @return array + */ + private function getSampleStatusRequestData(AbstractPosAccount $account): array { return [ 'mid' => $account->getClientId(), @@ -456,7 +492,13 @@ private function getSampleStatusRequestData(PosNetAccount $account): array ]; } - private function getSampleRefundXMLData(PosNetAccount $account, $order): array + /** + * @param PosNetAccount $account + * @param $order + * + * @return array + */ + private function getSampleRefundXMLData(AbstractPosAccount $account, $order): array { $requestData = [ 'mid' => $account->getClientId(), @@ -477,6 +519,13 @@ private function getSampleRefundXMLData(PosNetAccount $account, $order): array return $requestData; } + /** + * @param PosNetAccount $account + * @param $order + * @param AbstractCreditCard $card + * + * @return array + */ private function getSample3DEnrollmentCheckRequestData(PosNetAccount $account, $order, AbstractCreditCard $card): array { return [ @@ -497,7 +546,13 @@ private function getSample3DEnrollmentCheckRequestData(PosNetAccount $account, $ ]; } - private function getSampleResolveMerchantDataXMLData(PosNetAccount $account, array $responseData): array + /** + * @param PosNetAccount $account + * @param array $responseData + * + * @return array + */ + private function getSampleResolveMerchantDataXMLData(AbstractPosAccount $account, array $responseData): array { return [ 'mid' => $account->getClientId(), diff --git a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php index d1546100..58cacebd 100644 --- a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php +++ b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php @@ -19,7 +19,9 @@ */ class VakifBankPosRequestDataMapperTest extends TestCase { - /** @var VakifBankAccount */ + /** + * @var VakifBankAccount + */ public $account; /** @var AbstractGateway */ @@ -250,6 +252,9 @@ public function testCreate3DFormData() $this->assertEquals($expectedValue, $actualData); } + /** + * @return array + */ public function getSampleEnrollmentSuccessResponseData(): array { return [ @@ -281,6 +286,12 @@ public function getSampleEnrollmentFailResponseData(): array ]; } + /** + * @param AbstractPosAccount $account + * @param array $order + * + * @return array + */ private function getSampleCancelRequestData(AbstractPosAccount $account, array $order): array { return [ @@ -292,7 +303,16 @@ private function getSampleCancelRequestData(AbstractPosAccount $account, array $ ]; } - private function getSample3DPaymentRequestData(VakifBankAccount $account, $order, string $txType, array $responseData, ?AbstractCreditCard $card): array + /** + * @param VakifBankAccount $account + * @param $order + * @param string $txType + * @param array $responseData + * @param AbstractCreditCard|null $card + * + * @return array + */ + private function getSample3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData, ?AbstractCreditCard $card): array { $expectedValue = [ 'MerchantId' => $account->getClientId(), @@ -321,7 +341,15 @@ private function getSample3DPaymentRequestData(VakifBankAccount $account, $order return $expectedValue; } - private function getSample3DEnrollmentRequestData(VakifBankAccount $account, $order, ?AbstractCreditCard $card): array + + /** + * @param VakifBankAccount $account + * @param $order + * @param AbstractCreditCard|null $card + * + * @return array + */ + private function getSample3DEnrollmentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card): array { $expectedValue = [ 'MerchantId' => $account->getClientId(), @@ -356,7 +384,15 @@ private function getSample3DEnrollmentRequestData(VakifBankAccount $account, $or return $expectedValue; } - private function getSampleNonSecurePaymentRequestData(VakifBankAccount $account, $order, string $txType, AbstractCreditCard $card): array + /** + * @param VakifBankAccount $account + * @param $order + * @param string $txType + * @param AbstractCreditCard $card + * + * @return array + */ + private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, AbstractCreditCard $card): array { return [ 'MerchantId' => $account->getClientId(), @@ -374,7 +410,13 @@ private function getSampleNonSecurePaymentRequestData(VakifBankAccount $account, ]; } - private function getSampleNonSecurePaymentPostRequestData(VakifBankAccount $account, array $order): array + /** + * @param VakifBankAccount $account + * @param array $order + * + * @return array + */ + private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $account, array $order): array { return [ 'MerchantId' => $account->getClientId(), @@ -388,6 +430,12 @@ private function getSampleNonSecurePaymentPostRequestData(VakifBankAccount $acco ]; } + /** + * @param AbstractPosAccount $account + * @param array $order + * + * @return array + */ private function getSampleRefundRequestData(AbstractPosAccount $account, array $order): array { return [ @@ -400,6 +448,9 @@ private function getSampleRefundRequestData(AbstractPosAccount $account, array $ ]; } + /** + * @return array + */ private function getSample3DFormDataFromEnrollmentResponse(): array { $inputs = [ diff --git a/tests/Gateways/KuveytPosTest.php b/tests/Gateways/KuveytPosTest.php index 19396149..6a135dde 100644 --- a/tests/Gateways/KuveytPosTest.php +++ b/tests/Gateways/KuveytPosTest.php @@ -24,20 +24,28 @@ */ class KuveytPosTest extends TestCase { - /** @var KuveytPosAccount */ + /** + * @var KuveytPosAccount + */ private $threeDAccount; private $config; - /** @var AbstractCreditCard */ + /** + * @var AbstractCreditCard + */ private $card; private $order; - /** @var KuveytPos */ + /** + * @var KuveytPos + */ private $pos; /** + * @return void + * * @throws BankClassNullException * @throws BankNotFoundException */ diff --git a/tests/Gateways/VakifBankPosTest.php b/tests/Gateways/VakifBankPosTest.php index fe4d6594..f469ee86 100644 --- a/tests/Gateways/VakifBankPosTest.php +++ b/tests/Gateways/VakifBankPosTest.php @@ -24,10 +24,10 @@ class VakifBankPosTest extends TestCase { /** @var VakifBankAccount */ private $account; - + /** @var VakifBankPos */ private $pos; - + private $config; /** @var AbstractCreditCard */ From 3f2542c697e5c05039b1a1df6915c75b24504177 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Mar 2023 21:00:37 +0100 Subject: [PATCH 20/54] rerun rector --- phpstan-baseline.neon | 148 +++++++++++++++--- rector.php | 2 - src/DataMapper/AbstractRequestDataMapper.php | 26 ++- src/DataMapper/EstPosRequestDataMapper.php | 8 +- src/DataMapper/EstV3PosRequestDataMapper.php | 3 + .../GarantiPosRequestDataMapper.php | 2 +- src/DataMapper/InterPosRequestDataMapper.php | 2 +- src/DataMapper/KuveytPosRequestDataMapper.php | 2 +- src/DataMapper/PayForPosRequestDataMapper.php | 14 +- .../VakifBankPosRequestDataMapper.php | 10 +- src/Entity/Account/AbstractPosAccount.php | 19 +-- src/Entity/Account/VakifBankAccount.php | 8 +- src/Exceptions/CardTypeRequiredException.php | 4 +- src/Factory/PosFactory.php | 6 +- src/Gateways/AbstractGateway.php | 8 +- src/Gateways/EstPos.php | 4 +- src/Gateways/KuveytPos.php | 4 +- src/Gateways/PayForPos.php | 6 +- src/Gateways/VakifBankPos.php | 6 +- tests/Crypt/KuveytPosCryptTest.php | 14 +- tests/Crypt/PayForPosCryptTest.php | 12 +- tests/Crypt/PosNetCryptTest.php | 8 +- .../KuveytPosRequestDataMapperTest.php | 4 +- .../KuveytPosResponseDataMapperTest.php | 2 +- .../VakifBankPosResponseDataMapperTest.php | 2 +- .../VakifBankPosRequestDataMapperTest.php | 4 +- tests/Gateways/KuveytPosTest.php | 12 +- 27 files changed, 204 insertions(+), 136 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index dd95366d..bbac7888 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -246,67 +246,67 @@ parameters: path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$name\\.$#" + message: "#^Access to an undefined property object\\:\\:\\$ref_ret_num\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$recurringFrequency\\.$#" + message: "#^Cannot call method create3DHash\\(\\) on Mews\\\\Pos\\\\Crypt\\\\CryptInterface\\|null\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$recurringFrequencyType\\.$#" - count: 1 + message: "#^Cannot call method createHash\\(\\) on Mews\\\\Pos\\\\Crypt\\\\CryptInterface\\|null\\.$#" + count: 7 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$recurringInstallmentCount\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$ref_ret_num\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Cannot call method create3DHash\\(\\) on Mews\\\\Pos\\\\Crypt\\\\CryptInterface\\|null\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Cannot call method createHash\\(\\) on Mews\\\\Pos\\\\Crypt\\\\CryptInterface\\|null\\.$#" - count: 7 + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$order with no type specified\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php @@ -315,21 +315,56 @@ parameters: count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/GarantiPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createRecurringData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/GarantiPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/GarantiPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/GarantiPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getCardData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getOrderAddressData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/GarantiPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getOrderAddressData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/GarantiPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getTerminalData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/GarantiPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:mapPaymentOrder\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -365,6 +400,16 @@ parameters: count: 1 path: src/DataMapper/InterPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/InterPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/InterPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" count: 1 @@ -395,16 +440,31 @@ parameters: count: 1 path: src/DataMapper/InterPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/InterPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/InterPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/InterPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/InterPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/InterPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:create3DEnrollmentCheckRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -430,6 +490,11 @@ parameters: count: 1 path: src/DataMapper/KuveytPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/KuveytPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -531,17 +596,17 @@ parameters: path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:create3DFormData\\(\\) should return array\\{gateway\\: string, inputs\\: array\\\\} but returns array\\{gateway\\: string, inputs\\: array\\{MbrId\\: '5', MerchantID\\: string, UserCode\\: string, OrderId\\: mixed, Lang\\: string, SecureType\\: string, TxnType\\: string, PurchAmount\\: mixed, \\.\\.\\.\\}\\|array\\{MbrId\\: '5', MerchantID\\: string, UserCode\\: string, OrderId\\: mixed, Lang\\: string, SecureType\\: string, TxnType\\: string, PurchAmount\\: mixed, \\.\\.\\.\\}\\}\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php @@ -565,21 +630,41 @@ parameters: count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/PayForPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/PayForPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/PayForPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/PayForPosRequestDataMapper.php + - message: "#^Access to an undefined property object\\:\\:\\$id\\.$#" count: 1 @@ -792,12 +877,12 @@ parameters: - message: "#^Access to an undefined property object\\:\\:\\$amount\\.$#" - count: 2 + count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - message: "#^Access to an undefined property object\\:\\:\\$currency\\.$#" - count: 2 + count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - @@ -807,7 +892,7 @@ parameters: - message: "#^Access to an undefined property object\\:\\:\\$id\\.$#" - count: 2 + count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - @@ -817,7 +902,7 @@ parameters: - message: "#^Access to an undefined property object\\:\\:\\$ip\\.$#" - count: 2 + count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - @@ -861,12 +946,12 @@ parameters: path: src/DataMapper/VakifBankPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DEnrollmentCheckRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Default value of the parameter \\#6 \\$extraData \\(array\\{\\}\\) of method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DFormData\\(\\) is incompatible with type array\\{PaReq\\: string, TermUrl\\: string, MD\\: string, ACSUrl\\: string\\}\\.$#" count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DEnrollmentCheckRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php @@ -885,6 +970,11 @@ parameters: count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/VakifBankPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" count: 1 @@ -910,6 +1000,16 @@ parameters: count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/VakifBankPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/VakifBankPosRequestDataMapper.php + - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 diff --git a/rector.php b/rector.php index 12c0930d..9d6e548a 100644 --- a/rector.php +++ b/rector.php @@ -88,8 +88,6 @@ \Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class, \Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class, \Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class, \Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector::class, \Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class, diff --git a/src/DataMapper/AbstractRequestDataMapper.php b/src/DataMapper/AbstractRequestDataMapper.php index 615c6176..180de6a4 100644 --- a/src/DataMapper/AbstractRequestDataMapper.php +++ b/src/DataMapper/AbstractRequestDataMapper.php @@ -15,9 +15,7 @@ */ abstract class AbstractRequestDataMapper { - /** - * @var array - */ + /** @var array */ protected $secureTypeMappings = []; /** @@ -40,15 +38,15 @@ abstract class AbstractRequestDataMapper * fakat bazi banklar ISO standarti kullanmiyorlar. * Currency mapping * - * @var array + * @var non-empty-array */ protected $currencyMappings = [ - 'TRY' => 949, - 'USD' => 840, - 'EUR' => 978, - 'GBP' => 826, - 'JPY' => 392, - 'RUB' => 643, + 'TRY' => '949', + 'USD' => '840', + 'EUR' => '978', + 'GBP' => '826', + 'JPY' => '392', + 'RUB' => '643', ]; /** @@ -64,8 +62,8 @@ abstract class AbstractRequestDataMapper protected $crypt; /** - * @param CryptInterface|null $crypt - * @param array $currencyMappings + * @param CryptInterface|null $crypt + * @param array $currencyMappings */ public function __construct(?CryptInterface $crypt = null, array $currencyMappings = []) { @@ -139,7 +137,7 @@ abstract public function createRefundRequestData(AbstractPosAccount $account, $o * @param string $txType * @param AbstractCreditCard|null $card * - * @return array + * @return array{gateway: string, inputs: array} */ abstract public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array; @@ -203,7 +201,7 @@ public function getTxTypeMappings(): array } /** - * @return array + * @return non-empty-array */ public function getCurrencyMappings(): array { diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index a2ad6208..85e00089 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -161,6 +161,7 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { + $orderData = []; if (isset($order->recurringOrderInstallmentNumber)) { // this method cancels only pending recurring orders, it will not cancel already fulfilled transactions $orderData['Extra']['RECORDTYPE'] = 'Order'; @@ -235,6 +236,8 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx /** * @param AbstractGateway::TX_* $txType + * + * @return array{gateway: string, inputs: array} */ public function create3DFormDataCommon(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { @@ -278,7 +281,7 @@ public function mapInstallment(?int $installment): string /** * @param AbstractPosAccount $account * - * @return array + * @return array{Name: string, Password: string, ClientId: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { @@ -289,6 +292,9 @@ private function getRequestAccountData(AbstractPosAccount $account): array ]; } + /** + * @return array{PbOrder: array{OrderType: int, OrderFrequencyInterval: mixed, OrderFrequencyCycle: string, TotalNumberPayments: mixed}} + */ private function getRecurringRequestOrderData($order): array { return [ diff --git a/src/DataMapper/EstV3PosRequestDataMapper.php b/src/DataMapper/EstV3PosRequestDataMapper.php index 25eee0b0..8e5a6834 100644 --- a/src/DataMapper/EstV3PosRequestDataMapper.php +++ b/src/DataMapper/EstV3PosRequestDataMapper.php @@ -12,6 +12,9 @@ */ class EstV3PosRequestDataMapper extends EstPosRequestDataMapper { + /** + * {@inheritDoc} + */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { $data = $this->create3DFormDataCommon($account, $order, $txType, $gatewayURL, $card); diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index 081bb7d3..6ea53eda 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -471,7 +471,7 @@ private function getOrderAddressData($order): array * * @param $order * - * @return array + * @return array{TotalPaymentNum: mixed, FrequencyType: string, FrequencyInterval: mixed, Type: mixed, StartDate: mixed} */ private function createRecurringData($order): array { diff --git a/src/DataMapper/InterPosRequestDataMapper.php b/src/DataMapper/InterPosRequestDataMapper.php index 88e3695a..d6218ae5 100644 --- a/src/DataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/InterPosRequestDataMapper.php @@ -217,7 +217,7 @@ public function mapInstallment(?int $installment): string /** * @param AbstractPosAccount $account * - * @return array + * @return array{UserCode: string, UserPass: string, ShopCode: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/DataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/KuveytPosRequestDataMapper.php index 418eaf8e..9da44eca 100644 --- a/src/DataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/KuveytPosRequestDataMapper.php @@ -209,7 +209,7 @@ public function mapInstallment(?int $installment): string /** * @param KuveytPosAccount $account * - * @return array + * @return array{MerchantId: string, CustomerId: string, UserName: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index 01d46bc9..c728f9e1 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -7,6 +7,7 @@ use Mews\Pos\Entity\Account\AbstractPosAccount; use Mews\Pos\Entity\Card\AbstractCreditCard; use Mews\Pos\Gateways\AbstractGateway; +use function _PHPStan_4dd92cd93\Symfony\Component\String\s; /** * Creates request data for PayForPos Gateway requests @@ -48,6 +49,7 @@ class PayForPosRequestDataMapper extends AbstractRequestDataMapper /** * {@inheritDoc} + * @return array{RequestGuid: mixed, UserCode: string, UserPass: string, OrderId: mixed, SecureType: string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { @@ -179,16 +181,16 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx 'MbrId' => self::MBR_ID, 'MerchantID' => $account->getClientId(), 'UserCode' => $account->getUsername(), - 'OrderId' => $order->id, + 'OrderId' => (string) $order->id, 'Lang' => $this->getLang($account, $order), 'SecureType' => $this->secureTypeMappings[$account->getModel()], 'TxnType' => $this->mapTxType($txType), - 'PurchAmount' => $order->amount, + 'PurchAmount' => (string) $order->amount, 'InstallmentCount' => $this->mapInstallment($order->installment), 'Currency' => $this->mapCurrency($order->currency), - 'OkUrl' => $order->success_url, - 'FailUrl' => $order->fail_url, - 'Rnd' => $order->rand, + 'OkUrl' => (string) $order->success_url, + 'FailUrl' => (string) $order->fail_url, + 'Rnd' => (string) $order->rand, 'Hash' => $hash, ]; @@ -213,7 +215,7 @@ public function mapInstallment(?int $installment): string /** * @param AbstractPosAccount $account * - * @return array + * @return array{MerchantId: string, UserCode: string, UserPass: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index e75a65c9..265b78ed 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -186,6 +186,7 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: mixed, ClientIp: mixed} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -200,6 +201,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: mixed, ClientIp: mixed, CurrencyAmount: string} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -222,9 +224,11 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar } /** - * @param array $extraData - * * {@inheritDoc} + * + * @param array{PaReq: string, TermUrl: string, MD: string, ACSUrl: string} $extraData + * + * @return array{gateway: string, inputs: array{PaReq: string, TermUrl: string, MD: string}} */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null, array $extraData = []): array { @@ -260,7 +264,7 @@ public function mapInstallment(?int $installment): string /** * @param VakifBankAccount $account * - * @return array + * @return array{MerchantId: string, Password: string, TerminalNo: string} */ private function getRequestAccountData(AbstractPosAccount $account): array { diff --git a/src/Entity/Account/AbstractPosAccount.php b/src/Entity/Account/AbstractPosAccount.php index 0c7bd0ce..81f5a3ef 100644 --- a/src/Entity/Account/AbstractPosAccount.php +++ b/src/Entity/Account/AbstractPosAccount.php @@ -6,9 +6,7 @@ abstract class AbstractPosAccount { - /** - * @var string - */ + /** @var string */ protected $clientId; /** @@ -16,13 +14,11 @@ abstract class AbstractPosAccount * @var string */ protected $model; - /** - * @var string - */ + + /** @var string */ protected $username; - /** - * @var string - */ + + /** @var string */ protected $password; /** @@ -30,9 +26,8 @@ abstract class AbstractPosAccount * @var string|null */ protected $storeKey; - /** - * @var string - */ + + /** @var string */ protected $lang; /** diff --git a/src/Entity/Account/VakifBankAccount.php b/src/Entity/Account/VakifBankAccount.php index 59221207..bf620294 100644 --- a/src/Entity/Account/VakifBankAccount.php +++ b/src/Entity/Account/VakifBankAccount.php @@ -10,18 +10,14 @@ class VakifBankAccount extends AbstractPosAccount public const MERCHANT_TYPE_SUB_DEALER = 2; - /** - * @var int[] - */ + /** @var int[] */ private static $merchantTypes = [ self::MERCHANT_TYPE_STANDARD, self::MERCHANT_TYPE_MAIN_DEALER, self::MERCHANT_TYPE_SUB_DEALER, ]; - /** - * @var string - */ + /** @var string */ private $terminalId; /** diff --git a/src/Exceptions/CardTypeRequiredException.php b/src/Exceptions/CardTypeRequiredException.php index 4785b128..9de0549d 100644 --- a/src/Exceptions/CardTypeRequiredException.php +++ b/src/Exceptions/CardTypeRequiredException.php @@ -10,9 +10,7 @@ */ class CardTypeRequiredException extends DomainException { - /** - * @var string - */ + /** @var string */ private $gatewayName; /** diff --git a/src/Factory/PosFactory.php b/src/Factory/PosFactory.php index 6cc9701b..06ed1c1f 100644 --- a/src/Factory/PosFactory.php +++ b/src/Factory/PosFactory.php @@ -118,9 +118,9 @@ public static function createPosGateway( } /** - * @param class-string $gatewayClass - * @param array $currencies - * @param CryptInterface|null $crypt + * @param class-string $gatewayClass + * @param array $currencies + * @param CryptInterface|null $crypt * * @return AbstractRequestDataMapper */ diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 7254d4d7..dec22555 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -69,9 +69,7 @@ abstract class AbstractGateway implements PosInterface */ protected $type; - /** - * @var object|null - */ + /** @var object|null */ protected $order; /** @@ -164,7 +162,7 @@ public function getResponse(): ?array } /** - * @return array + * @return non-empty-array */ public function getCurrencies(): array { @@ -474,7 +472,7 @@ abstract public function create3DPaymentXML($responseData); /** * returns form data, key values, necessary for 3D payment * - * @return array + * @return array{gateway: string, inputs: array} */ abstract public function get3DFormData(): array; diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index eced3c18..780597bd 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -24,9 +24,7 @@ class EstPos extends AbstractGateway */ public const NAME = 'EstPos'; - /** - * @var EstPosAccount - */ + /** @var EstPosAccount */ protected $account; /** diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index dc98e667..2801a61a 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -267,7 +267,7 @@ protected function prepareRefundOrder(array $order) * @param string $gatewayURL * @param AbstractCreditCard|null $card * - * @return array + * @return array{gateway: string, inputs: array} * * @throws Exception */ @@ -289,7 +289,7 @@ private function getCommon3DFormData(KuveytPosAccount $account, $order, string $ * Kutupahenin islem akisina uymasi icin bu HTML form verilerini array'e donusturup, kendimiz post ediyoruz. * @param string $response * - * @return array + * @return array{gateway: string, inputs: array} */ private function transformReceived3DFormData(string $response): array { diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index a01e4d8b..f93beaba 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -23,9 +23,7 @@ class PayForPos extends AbstractGateway */ public const NAME = 'PayForPOS'; - /** - * @var PayForAccount - */ + /** @var PayForAccount */ protected $account; /** @var PayForPosRequestDataMapper */ @@ -120,7 +118,7 @@ public function history(array $meta) /** * returns form data needed for 3d, 3d_pay and 3d_host models * - * @return array + * @return array{gateway: string, inputs: array} */ public function get3DFormData(): array { diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index 370b7a8b..c21088ce 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -24,9 +24,7 @@ class VakifBankPos extends AbstractGateway */ public const NAME = 'VakifPOS'; - /** - * @var VakifBankAccount - */ + /** @var VakifBankAccount */ protected $account; /** @var VakifBankPosRequestDataMapper */ @@ -104,7 +102,7 @@ public function history(array $meta) /** * returns form data needed for 3d model * - * @return array + * @return array{gateway: string, inputs: array} * * @throws Exception */ diff --git a/tests/Crypt/KuveytPosCryptTest.php b/tests/Crypt/KuveytPosCryptTest.php index 38755704..4f882900 100644 --- a/tests/Crypt/KuveytPosCryptTest.php +++ b/tests/Crypt/KuveytPosCryptTest.php @@ -11,17 +11,13 @@ class KuveytPosCryptTest extends TestCase { - /** - * @var array|array - */ + /** @var array|array */ public $order; - /** - * @var KuveytPosCrypt - */ + + /** @var KuveytPosCrypt */ public $crypt; - /** - * @var KuveytPosAccount - */ + + /** @var KuveytPosAccount */ private $threeDAccount; protected function setUp(): void diff --git a/tests/Crypt/PayForPosCryptTest.php b/tests/Crypt/PayForPosCryptTest.php index 90fc852a..c39d50d9 100644 --- a/tests/Crypt/PayForPosCryptTest.php +++ b/tests/Crypt/PayForPosCryptTest.php @@ -11,19 +11,13 @@ class PayForPosCryptTest extends TestCase { - /** - * @var array|array - */ + /** @var array|array */ public $order; - /** - * @var PayForPosCrypt - */ + /** @var PayForPosCrypt */ public $crypt; - /** - * @var PayForAccount - */ + /** @var PayForAccount */ private $threeDAccount; protected function setUp(): void diff --git a/tests/Crypt/PosNetCryptTest.php b/tests/Crypt/PosNetCryptTest.php index 70855e3e..a1fa3764 100644 --- a/tests/Crypt/PosNetCryptTest.php +++ b/tests/Crypt/PosNetCryptTest.php @@ -11,14 +11,10 @@ class PosNetCryptTest extends TestCase { - /** - * @var PosNetCrypt - */ + /** @var PosNetCrypt */ public $crypt; - /** - * @var PosNetAccount - */ + /** @var PosNetAccount */ private $threeDAccount; protected function setUp(): void diff --git a/tests/DataMapper/KuveytPosRequestDataMapperTest.php b/tests/DataMapper/KuveytPosRequestDataMapperTest.php index 0713ae58..b747eefb 100644 --- a/tests/DataMapper/KuveytPosRequestDataMapperTest.php +++ b/tests/DataMapper/KuveytPosRequestDataMapperTest.php @@ -22,9 +22,7 @@ */ class KuveytPosRequestDataMapperTest extends TestCase { - /** - * @var KuveytPosAccount - */ + /** @var KuveytPosAccount */ public $threeDAccount; /** @var AbstractCreditCard */ diff --git a/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php index 8f82b8a7..89431be1 100644 --- a/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php @@ -366,7 +366,7 @@ public function threeDPaymentDataProvider(): array 'error_code' => null, 'masked_number' => '4025502306586032', ] - ] + ], ]; } } diff --git a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php index 969850fb..afd5e549 100644 --- a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php @@ -131,7 +131,7 @@ public function threeDPaymentDataProvider(): array 'proc_return_code' => '0000', 'transaction_type' => 'pay', ] - ] + ], ]; } } diff --git a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php index 58cacebd..9ecd84bf 100644 --- a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php +++ b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php @@ -19,9 +19,7 @@ */ class VakifBankPosRequestDataMapperTest extends TestCase { - /** - * @var VakifBankAccount - */ + /** @var VakifBankAccount */ public $account; /** @var AbstractGateway */ diff --git a/tests/Gateways/KuveytPosTest.php b/tests/Gateways/KuveytPosTest.php index 6a135dde..adc278af 100644 --- a/tests/Gateways/KuveytPosTest.php +++ b/tests/Gateways/KuveytPosTest.php @@ -24,23 +24,17 @@ */ class KuveytPosTest extends TestCase { - /** - * @var KuveytPosAccount - */ + /** @var KuveytPosAccount */ private $threeDAccount; private $config; - /** - * @var AbstractCreditCard - */ + /** @var AbstractCreditCard */ private $card; private $order; - /** - * @var KuveytPos - */ + /** @var KuveytPos */ private $pos; /** From e850beb1c00f88aa45ae69e58f9e7d146232756d Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Mar 2023 21:56:49 +0100 Subject: [PATCH 21/54] rerun rector --- phpstan-baseline.neon | 75 ------------------- src/DataMapper/EstPosRequestDataMapper.php | 11 ++- .../GarantiPosRequestDataMapper.php | 8 +- src/DataMapper/InterPosRequestDataMapper.php | 22 ++++-- src/DataMapper/PayForPosRequestDataMapper.php | 21 ++++-- .../VakifBankPosRequestDataMapper.php | 6 +- src/Gateways/InterPos.php | 3 + src/Gateways/VakifBankPos.php | 6 +- 8 files changed, 45 insertions(+), 107 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index bbac7888..f5182863 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -190,21 +190,11 @@ parameters: count: 1 path: src/DataMapper/EstPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/EstPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/EstPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/EstPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -355,16 +345,6 @@ parameters: count: 1 path: src/DataMapper/GarantiPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getOrderAddressData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:getTerminalData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/GarantiPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\GarantiPosRequestDataMapper\\:\\:mapPaymentOrder\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -395,21 +375,11 @@ parameters: count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" count: 1 @@ -440,31 +410,16 @@ parameters: count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/InterPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\InterPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/InterPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:create3DEnrollmentCheckRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -605,11 +560,6 @@ parameters: count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" count: 1 @@ -630,41 +580,21 @@ parameters: count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 path: src/DataMapper/PayForPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\PayForPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/PayForPosRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$id\\.$#" count: 1 @@ -1005,11 +935,6 @@ parameters: count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/VakifBankPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index 85e00089..6b0d0aa5 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -127,12 +127,14 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ /** * {@inheritDoc} + * + * @return array{Type: string, OrderId: string, Name: string, Password: string, ClientId: string} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { return $this->getRequestAccountData($account) + [ 'Type' => $this->mapTxType(AbstractGateway::TX_POST_PAY), - 'OrderId' => $order->id, + 'OrderId' => (string) $order->id, ]; } @@ -187,17 +189,18 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * @return array{OrderId: string, Currency: string, Type: string, Total?: string, Name: string, Password: string, ClientId: string} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { $requestData = [ - 'OrderId' => $order->id, + 'OrderId' => (string) $order->id, 'Currency' => $this->mapCurrency($order->currency), 'Type' => $this->mapTxType(AbstractGateway::TX_REFUND), ]; if (isset($order->amount)) { - $requestData['Total'] = $order->amount; + $requestData['Total'] = (string) $order->amount; } return $this->getRequestAccountData($account) + $requestData; @@ -209,7 +212,7 @@ public function createRefundRequestData(AbstractPosAccount $account, $order): ar public function createHistoryRequestData(AbstractPosAccount $account, $order, array $extraData = []): array { $requestData = [ - 'OrderId' => $extraData['order_id'], //todo orderId ya da id olarak degistirilecek, Payfor'da orderId, Garanti'de id + 'OrderId' => (string) $extraData['order_id'], //todo orderId ya da id olarak degistirilecek, Payfor'da orderId, Garanti'de id 'Extra' => [ $this->mapTxType(AbstractGateway::TX_HISTORY) => 'QUERY', ], diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index 6ea53eda..2e96e408 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -155,7 +155,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { $hashData = [ - 'id' => $order->id, + 'id' => (string) $order->id, 'amount' => self::amountFormat($order->amount), ]; $hash = $this->crypt->createHash($account, $hashData, $this->mapTxType(AbstractGateway::TX_POST_PAY), $card); @@ -395,7 +395,7 @@ private function getMode(): string * @param string $hash * @param bool $isRefund * - * @return array + * @return array{ProvUserID: string, UserID: string, HashData: string, ID: string, MerchantID: string} */ private function getTerminalData(AbstractPosAccount $account, string $hash, bool $isRefund = false): array { @@ -433,14 +433,14 @@ private function getCardData(?AbstractCreditCard $card = null): array /** * @param $order * - * @return array + * @return array{Address: array{Type: string, Name: string, LastName: string, Company: string, Text: string, District: string, City: string, PostalCode: string, Country: string, PhoneNumber: string}} */ private function getOrderAddressData($order): array { return [ 'Address' => [ 'Type' => 'B', //S - shipping, B - billing - 'Name' => $order->name, + 'Name' => (string) $order->name, 'LastName' => '', 'Company' => '', 'Text' => '', diff --git a/src/DataMapper/InterPosRequestDataMapper.php b/src/DataMapper/InterPosRequestDataMapper.php index d6218ae5..f088dda0 100644 --- a/src/DataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/InterPosRequestDataMapper.php @@ -57,14 +57,16 @@ class InterPosRequestDataMapper extends AbstractRequestDataMapperCrypt /** * {@inheritDoc} + * + * @param array{MD: string, PayerTxnId: string, Eci: string, PayerAuthenticationCode: string} $responseData */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { return $this->getRequestAccountData($account) + [ 'TxnType' => $this->mapTxType($txType), 'SecureType' => $this->secureTypeMappings[AbstractGateway::MODEL_NON_SECURE], - 'OrderId' => $order->id, - 'PurchAmount' => $order->amount, + 'OrderId' => (string) $order->id, + 'PurchAmount' => (string) $order->amount, 'Currency' => $this->mapCurrency($order->currency), 'InstallmentCount' => $this->mapInstallment($order->installment), 'MD' => $responseData['MD'], @@ -104,6 +106,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ /** * {@inheritDoc} + * @return array{TxnType: string, SecureType: string, OrderId: null, orgOrderId: mixed, PurchAmount: mixed, Currency: string, MOTO: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { @@ -111,8 +114,8 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $ac 'TxnType' => $this->mapTxType(AbstractGateway::TX_POST_PAY), 'SecureType' => $this->secureTypeMappings[AbstractGateway::MODEL_NON_SECURE], 'OrderId' => null, - 'orgOrderId' => $order->id, - 'PurchAmount' => $order->amount, + 'orgOrderId' => (string) $order->id, + 'PurchAmount' => (string) $order->amount, 'Currency' => $this->mapCurrency($order->currency), 'MOTO' => self::MOTO, ]; @@ -120,12 +123,13 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $ac /** * {@inheritDoc} + * @return array{OrderId: null, orgOrderId: string, TxnType: string, SecureType: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createStatusRequestData(AbstractPosAccount $account, $order): array { return $this->getRequestAccountData($account) + [ 'OrderId' => null, //todo buraya hangi deger verilecek? - 'orgOrderId' => $order->id, + 'orgOrderId' => (string) $order->id, 'TxnType' => $this->mapTxType(AbstractGateway::TX_STATUS), 'SecureType' => $this->secureTypeMappings[AbstractGateway::MODEL_NON_SECURE], 'Lang' => $this->getLang($account, $order), @@ -134,12 +138,13 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * @return array{OrderId: null, orgOrderId: string, TxnType: string, SecureType: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { return $this->getRequestAccountData($account) + [ 'OrderId' => null, //todo buraya hangi deger verilecek? - 'orgOrderId' => $order->id, + 'orgOrderId' => (string) $order->id, 'TxnType' => $this->mapTxType(AbstractGateway::TX_CANCEL), 'SecureType' => $this->secureTypeMappings[AbstractGateway::MODEL_NON_SECURE], 'Lang' => $this->getLang($account, $order), @@ -148,13 +153,14 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * @return array{OrderId: null, orgOrderId: string, PurchAmount: string, TxnType: string, SecureType: string, Lang: string, MOTO: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { return $this->getRequestAccountData($account) + [ 'OrderId' => null, - 'orgOrderId' => $order->id, - 'PurchAmount' => $order->amount, + 'orgOrderId' => (string) $order->id, + 'PurchAmount' => (string) $order->amount, 'TxnType' => $this->mapTxType(AbstractGateway::TX_REFUND), 'SecureType' => $this->secureTypeMappings[AbstractGateway::MODEL_NON_SECURE], 'Lang' => $this->getLang($account, $order), diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index c728f9e1..66d429d1 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -64,16 +64,17 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, /** * {@inheritDoc} + * @return array{MbrId: string, MOTO: string, OrderId: string, SecureType: string, TxnType: string, PurchAmount: string, Currency: string, InstallmentCount: string, Lang: string, CardHolderName: string|null, Pan: string, Expiry: string, Cvv2: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array { return $this->getRequestAccountData($account) + [ 'MbrId' => self::MBR_ID, 'MOTO' => self::MOTO, - 'OrderId' => $order->id, + 'OrderId' => (string) $order->id, 'SecureType' => $this->secureTypeMappings[AbstractGateway::MODEL_NON_SECURE], 'TxnType' => $this->mapTxType($txType), - 'PurchAmount' => $order->amount, + 'PurchAmount' => (string) $order->amount, 'Currency' => $this->mapCurrency($order->currency), 'InstallmentCount' => $this->mapInstallment($order->installment), 'Lang' => $this->getLang($account, $order), @@ -86,15 +87,16 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ /** * {@inheritDoc} + * @return array{MbrId: string, OrgOrderId: string, SecureType: string, TxnType: string, PurchAmount: string, Currency: string, Lang: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { return $this->getRequestAccountData($account) + [ 'MbrId' => self::MBR_ID, - 'OrgOrderId' => $order->id, + 'OrgOrderId' => (string) $order->id, 'SecureType' => $this->secureTypeMappings[AbstractGateway::MODEL_NON_SECURE], 'TxnType' => $this->mapTxType(AbstractGateway::TX_POST_PAY), - 'PurchAmount' => $order->amount, + 'PurchAmount' => (string) $order->amount, 'Currency' => $this->mapCurrency($order->currency), 'Lang' => $this->getLang($account, $order), ]; @@ -102,12 +104,13 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $ac /** * {@inheritDoc} + * @return array{MbrId: string, OrgOrderId: string, SecureType: string, Lang: string, TxnType: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createStatusRequestData(AbstractPosAccount $account, $order): array { return $this->getRequestAccountData($account) + [ 'MbrId' => self::MBR_ID, - 'OrgOrderId' => $order->id, + 'OrgOrderId' => (string) $order->id, 'SecureType' => 'Inquiry', 'Lang' => $this->getLang($account, $order), 'TxnType' => $this->mapTxType(AbstractGateway::TX_STATUS), @@ -116,12 +119,13 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * @return array{MbrId: string, OrgOrderId: string, SecureType: string, TxnType: string, Currency: string, Lang: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { return $this->getRequestAccountData($account) + [ 'MbrId' => self::MBR_ID, - 'OrgOrderId' => $order->id, + 'OrgOrderId' => (string) $order->id, 'SecureType' => $this->secureTypeMappings[AbstractGateway::MODEL_NON_SECURE], 'TxnType' => $this->mapTxType(AbstractGateway::TX_CANCEL), 'Currency' => $this->mapCurrency($order->currency), @@ -131,6 +135,7 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} + * @return array{MbrId: string, SecureType: string, Lang: string, OrgOrderId: string, TxnType: string, PurchAmount: string, Currency: string, MerchantId: string, UserCode: string, UserPass: string} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -138,9 +143,9 @@ public function createRefundRequestData(AbstractPosAccount $account, $order): ar 'MbrId' => self::MBR_ID, 'SecureType' => $this->secureTypeMappings[AbstractGateway::MODEL_NON_SECURE], 'Lang' => $this->getLang($account, $order), - 'OrgOrderId' => $order->id, + 'OrgOrderId' => (string) $order->id, 'TxnType' => $this->mapTxType(AbstractGateway::TX_REFUND), - 'PurchAmount' => $order->amount, + 'PurchAmount' => (string) $order->amount, 'Currency' => $this->mapCurrency($order->currency), ]; } diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index 265b78ed..a1637001 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -163,16 +163,16 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ * @param $order * @param AbstractCreditCard|null $card * - * @return array + * @return array{TransactionType: string, ReferenceTransactionId: string, CurrencyAmount: string, CurrencyCode: string, ClientIp: string, MerchantId: string, Password: string, TerminalNo: string} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { return $this->getRequestAccountData($account) + [ 'TransactionType' => $this->mapTxType(AbstractGateway::TX_POST_PAY), - 'ReferenceTransactionId' => $order->id, + 'ReferenceTransactionId' => (string) $order->id, 'CurrencyAmount' => self::amountFormat($order->amount), 'CurrencyCode' => $this->mapCurrency($order->currency), - 'ClientIp' => $order->ip, + 'ClientIp' => (string) $order->ip, ]; } diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index e063782f..34a0d7a7 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -71,6 +71,7 @@ public function make3DPayment(Request $request) { $bankResponse = null; $request = $request->request; + /** @var array{MD: string, PayerTxnId: string, Eci: string, PayerAuthenticationCode: string} $gatewayResponse */ $gatewayResponse = $request->all(); if (!$this->requestDataMapper->getCrypt()->check3DHash($this->account, $gatewayResponse)) { @@ -167,6 +168,8 @@ public function createRegularPostXML() /** * @inheritDoc + * + * @param array{MD: string, PayerTxnId: string, Eci: string, PayerAuthenticationCode: string} $responseData */ public function create3DPaymentXML($responseData) { diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index c21088ce..56948e3d 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -100,11 +100,7 @@ public function history(array $meta) } /** - * returns form data needed for 3d model - * - * @return array{gateway: string, inputs: array} - * - * @throws Exception + * {@inheritDoc} */ public function get3DFormData(): array { From 518ae2f441e1c2b02f49203adef6f8b78637883c Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Mar 2023 22:16:14 +0100 Subject: [PATCH 22/54] rerun rector --- phpstan-baseline.neon | 40 ------------------- src/DataMapper/EstPosRequestDataMapper.php | 27 +++++++------ src/DataMapper/KuveytPosRequestDataMapper.php | 1 + .../VakifBankPosRequestDataMapper.php | 12 +++--- src/Gateways/InterPos.php | 4 ++ src/Gateways/VakifBankPos.php | 6 ++- 6 files changed, 32 insertions(+), 58 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f5182863..eb896547 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -145,11 +145,6 @@ parameters: count: 1 path: src/DataMapper/EstPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/EstPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -180,11 +175,6 @@ parameters: count: 1 path: src/DataMapper/EstPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/EstPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\EstPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" count: 1 @@ -445,11 +435,6 @@ parameters: count: 1 path: src/DataMapper/KuveytPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/KuveytPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\KuveytPosRequestDataMapper\\:\\:createCancelRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -895,11 +880,6 @@ parameters: count: 1 path: src/DataMapper/VakifBankPosRequestDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" - count: 1 - path: src/DataMapper/VakifBankPosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -1400,11 +1380,6 @@ parameters: count: 1 path: src/Gateways/InterPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\InterPos\\:\\:createCancelXML\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/InterPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\InterPos\\:\\:createHistoryXML\\(\\) has parameter \\$customQueryData with no value type specified in iterable type array\\.$#" count: 1 @@ -1415,26 +1390,11 @@ parameters: count: 1 path: src/Gateways/InterPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\InterPos\\:\\:createRefundXML\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/InterPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\InterPos\\:\\:createRegularPaymentXML\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/Gateways/InterPos.php - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\InterPos\\:\\:createRegularPostXML\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/InterPos.php - - - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\InterPos\\:\\:createStatusXML\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Gateways/InterPos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\InterPos\\:\\:history\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#" count: 1 diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index 6b0d0aa5..648dfc30 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -63,16 +63,18 @@ class EstPosRequestDataMapper extends AbstractRequestDataMapperCrypt /** * {@inheritDoc} + * + * @param array{md: string, xid: string, eci: string, cavv: string} $responseData */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { $requestData = $this->getRequestAccountData($account) + [ 'Type' => $this->mapTxType($txType), - 'IPAddress' => $order->ip ?? null, - 'Email' => $order->email, - 'OrderId' => $order->id, - 'UserId' => $order->user_id ?? null, - 'Total' => $order->amount, + 'IPAddress' => (string) ($order->ip ?? ''), + 'Email' => (string) $order->email, + 'OrderId' => (string) $order->id, + 'UserId' => (string) ($order->user_id ?? ''), + 'Total' => (string) $order->amount, 'Currency' => $this->mapCurrency($order->currency), 'Taksit' => $this->mapInstallment($order->installment), 'Number' => $responseData['md'], @@ -84,7 +86,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, if ($order->name) { $requestData['BillTo'] = [ - 'Name' => $order->name, + 'Name' => (string) $order->name, ]; } @@ -97,16 +99,17 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, /** * {@inheritDoc} + * @return array{PbOrder?: array{OrderType: int, OrderFrequencyInterval: mixed, OrderFrequencyCycle: string, TotalNumberPayments: mixed}, Type: string, IPAddress: mixed, Email: mixed, OrderId: mixed, UserId: mixed, Total: mixed, Currency: string, Taksit: string, Number: string, Expires: string, Cvv2Val: string, Mode: string, BillTo: array{Name: mixed}, Name: string, Password: string, ClientId: string} */ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array { $requestData = $this->getRequestAccountData($account) + [ 'Type' => $this->mapTxType($txType), - 'IPAddress' => $order->ip ?? null, - 'Email' => $order->email, - 'OrderId' => $order->id, - 'UserId' => $order->user_id ?? null, - 'Total' => $order->amount, + 'IPAddress' => (string) ($order->ip ?? ''), + 'Email' => (string) $order->email, + 'OrderId' => (string) $order->id, + 'UserId' => (string) ($order->user_id ?? ''), + 'Total' => (string) $order->amount, 'Currency' => $this->mapCurrency($order->currency), 'Taksit' => $this->mapInstallment($order->installment), 'Number' => $card->getNumber(), @@ -114,7 +117,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ 'Cvv2Val' => $card->getCvv(), 'Mode' => 'P', 'BillTo' => [ - 'Name' => $order->name ?: null, + 'Name' => (string) ($order->name ?? ''), ], ]; diff --git a/src/DataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/KuveytPosRequestDataMapper.php index 9da44eca..70a452e6 100644 --- a/src/DataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/KuveytPosRequestDataMapper.php @@ -81,6 +81,7 @@ public static function amountFormat(float $amount): int * @param KuveytPosAccount $account * * {@inheritDoc} + * @return array{APIVersion: string, HashData: string, CustomerIPAddress: mixed, KuveytTurkVPosAdditionalData: array{AdditionalData: array{Key: string, Data: mixed}}, TransactionType: string, InstallmentCount: mixed, Amount: mixed, DisplayAmount: int, CurrencyCode: mixed, MerchantOrderId: mixed, TransactionSecurity: mixed, MerchantId: string, CustomerId: string, UserName: string} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData): array { diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index a1637001..9957ac8c 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -53,13 +53,15 @@ class VakifBankPosRequestDataMapper extends AbstractRequestDataMapper /** * @param VakifBankAccount $account + * @param array{Eci: string, Cavv: string, VerifyEnrollmentRequestId: string} $responseData + * * {@inheritDoc} */ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData, ?AbstractCreditCard $card = null): array { $requestData = $this->getRequestAccountData($account) + [ 'TransactionType' => $this->mapTxType($txType), - 'TransactionId' => $order->id, + 'TransactionId' => (string) $order->id, 'CurrencyAmount' => self::amountFormat($order->amount), 'CurrencyCode' => $this->mapCurrency($order->currency), 'CardHoldersName' => $card->getHolderName(), @@ -69,10 +71,10 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, 'ECI' => $responseData['Eci'], 'CAVV' => $responseData['Cavv'], 'MpiTransactionId' => $responseData['VerifyEnrollmentRequestId'], - 'OrderId' => $order->id, - 'OrderDescription' => $order->description ?? null, - 'ClientIp' => $order->ip, - 'TransactionDeviceSource' => 0, // ECommerce + 'OrderId' => (string) $order->id, + 'OrderDescription' => (string) ($order->description ?? ''), + 'ClientIp' => (string) $order->ip, + 'TransactionDeviceSource' => '0', // ECommerce ]; if ($order->installment) { diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 34a0d7a7..0436652f 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -160,6 +160,7 @@ public function createRegularPaymentXML() /** * @inheritDoc + * @return array{TxnType: string, SecureType: string, OrderId: null, orgOrderId: mixed, PurchAmount: mixed, Currency: string, MOTO: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createRegularPostXML() { @@ -186,6 +187,7 @@ public function createHistoryXML($customQueryData) /** * @inheritDoc + * @return array{OrderId: null, orgOrderId: string, TxnType: string, SecureType: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createStatusXML() { @@ -194,6 +196,7 @@ public function createStatusXML() /** * @inheritDoc + * @return array{OrderId: null, orgOrderId: string, TxnType: string, SecureType: string, Lang: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createCancelXML() { @@ -202,6 +205,7 @@ public function createCancelXML() /** * @inheritDoc + * @return array{OrderId: null, orgOrderId: string, PurchAmount: string, TxnType: string, SecureType: string, Lang: string, MOTO: string, UserCode: string, UserPass: string, ShopCode: string} */ public function createRefundXML() { diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index 56948e3d..0b7f0b7d 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -63,7 +63,9 @@ public function make3DPayment(Request $request) } $this->logger->log(LogLevel::DEBUG, 'finishing payment', ['md_status' => $status]); - $contents = $this->create3DPaymentXML($request->all()); + /** @var array{Eci: string, Cavv: string, VerifyEnrollmentRequestId: string} $requestData */ + $requestData = $request->all(); + $contents = $this->create3DPaymentXML($requestData); $bankResponse = $this->send($contents); $this->response = $this->responseDataMapper->map3DPaymentData($request->all(), $bankResponse); @@ -224,6 +226,8 @@ public function createRegularPostXML() /** * NOT: diger gatewaylerden farkli olarak vakifbank kredit bilgilerini bu asamada da istiyor. * @inheritDoc + * + * @param array{Eci: string, Cavv: string, VerifyEnrollmentRequestId: string} $responseData */ public function create3DPaymentXML($responseData) { From 5e20d7c1bd0936f5129cdd8f5cbedf111f1af22c Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Mar 2023 22:28:11 +0100 Subject: [PATCH 23/54] rerun rector --- src/DataMapper/EstPosRequestDataMapper.php | 10 +++++----- src/DataMapper/GarantiPosRequestDataMapper.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index 648dfc30..c1d6ae8f 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -99,7 +99,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, /** * {@inheritDoc} - * @return array{PbOrder?: array{OrderType: int, OrderFrequencyInterval: mixed, OrderFrequencyCycle: string, TotalNumberPayments: mixed}, Type: string, IPAddress: mixed, Email: mixed, OrderId: mixed, UserId: mixed, Total: mixed, Currency: string, Taksit: string, Number: string, Expires: string, Cvv2Val: string, Mode: string, BillTo: array{Name: mixed}, Name: string, Password: string, ClientId: string} + * @return array{PbOrder?: array{OrderType: string, OrderFrequencyInterval: string, OrderFrequencyCycle: string, TotalNumberPayments: string}, Type: string, IPAddress: mixed, Email: mixed, OrderId: mixed, UserId: mixed, Total: mixed, Currency: string, Taksit: string, Number: string, Expires: string, Cvv2Val: string, Mode: string, BillTo: array{Name: mixed}, Name: string, Password: string, ClientId: string} */ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array { @@ -299,18 +299,18 @@ private function getRequestAccountData(AbstractPosAccount $account): array } /** - * @return array{PbOrder: array{OrderType: int, OrderFrequencyInterval: mixed, OrderFrequencyCycle: string, TotalNumberPayments: mixed}} + * @return array{PbOrder: array{OrderType: string, OrderFrequencyInterval: string, OrderFrequencyCycle: string, TotalNumberPayments: string}} */ private function getRecurringRequestOrderData($order): array { return [ 'PbOrder' => [ - 'OrderType' => 0, + 'OrderType' => '0', // Periyodik İşlem Frekansı - 'OrderFrequencyInterval' => $order->recurringFrequency, + 'OrderFrequencyInterval' => (string) $order->recurringFrequency, //D|M|Y 'OrderFrequencyCycle' => $this->mapRecurringFrequency($order->recurringFrequencyType), - 'TotalNumberPayments' => $order->recurringInstallmentCount, + 'TotalNumberPayments' => (string) $order->recurringInstallmentCount, ], ]; } diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index 2e96e408..557763c8 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -471,14 +471,14 @@ private function getOrderAddressData($order): array * * @param $order * - * @return array{TotalPaymentNum: mixed, FrequencyType: string, FrequencyInterval: mixed, Type: mixed, StartDate: mixed} + * @return array{TotalPaymentNum: string, FrequencyType: string, FrequencyInterval: string, Type: mixed, StartDate: string} */ private function createRecurringData($order): array { return [ - 'TotalPaymentNum' => $order->recurringInstallmentCount, //kac kere tekrarlanacak + 'TotalPaymentNum' => (string) $order->recurringInstallmentCount, //kac kere tekrarlanacak 'FrequencyType' => $this->mapRecurringFrequency($order->recurringFrequencyType), //Monthly, weekly, daily - 'FrequencyInterval' => $order->recurringFrequency, + 'FrequencyInterval' => (string) $order->recurringFrequency, 'Type' => $order->recurringType ?? 'R', //R:Sabit Tutarli G:Degisken Tuta 'StartDate' => $order->startDate ?? '', ]; From 70d3a6502dc5f7d920c848668d77d6f520e342de Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Mar 2023 22:31:08 +0100 Subject: [PATCH 24/54] remove accidentally added code --- src/DataMapper/PayForPosRequestDataMapper.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index 66d429d1..cc0deb6c 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -7,7 +7,6 @@ use Mews\Pos\Entity\Account\AbstractPosAccount; use Mews\Pos\Entity\Card\AbstractCreditCard; use Mews\Pos\Gateways\AbstractGateway; -use function _PHPStan_4dd92cd93\Symfony\Component\String\s; /** * Creates request data for PayForPos Gateway requests From 7dc5f1cdf94d50a202068c172ceb3b9ca791512c Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 4 Mar 2023 22:38:46 +0100 Subject: [PATCH 25/54] update return type of create3DFormData --- src/DataMapper/AbstractRequestDataMapper.php | 2 +- src/DataMapper/PayForPosRequestDataMapper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataMapper/AbstractRequestDataMapper.php b/src/DataMapper/AbstractRequestDataMapper.php index 180de6a4..1992519e 100644 --- a/src/DataMapper/AbstractRequestDataMapper.php +++ b/src/DataMapper/AbstractRequestDataMapper.php @@ -137,7 +137,7 @@ abstract public function createRefundRequestData(AbstractPosAccount $account, $o * @param string $txType * @param AbstractCreditCard|null $card * - * @return array{gateway: string, inputs: array} + * @return array{gateway: string, inputs: array} */ abstract public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array; diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index cc0deb6c..03edaa43 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -199,7 +199,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx ]; if ($card !== null) { - $inputs['CardHolderName'] = $card->getHolderName(); + $inputs['CardHolderName'] = $card->getHolderName() ?? ''; $inputs['Pan'] = $card->getNumber(); $inputs['Expiry'] = $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_FORMAT); $inputs['Cvv2'] = $card->getCvv(); From 086c27e578ab55b9910e3e5414c837184e775508 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Mar 2023 11:22:52 +0100 Subject: [PATCH 26/54] VakifBankAccount update phpdoc --- src/Entity/Account/VakifBankAccount.php | 31 +++++++++++++------------ src/Factory/AccountFactory.php | 14 +++++------ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Entity/Account/VakifBankAccount.php b/src/Entity/Account/VakifBankAccount.php index bf620294..d30c93ad 100644 --- a/src/Entity/Account/VakifBankAccount.php +++ b/src/Entity/Account/VakifBankAccount.php @@ -5,9 +5,9 @@ class VakifBankAccount extends AbstractPosAccount { public const MERCHANT_TYPE_STANDARD = 0; - + public const MERCHANT_TYPE_MAIN_DEALER = 1; - + public const MERCHANT_TYPE_SUB_DEALER = 2; /** @var int[] */ @@ -22,7 +22,7 @@ class VakifBankAccount extends AbstractPosAccount /** * Banka tarafından Üye işyerine iletilmektedir - * @var int + * @var self::MERCHANT_TYPE_* */ private $merchantType; @@ -41,13 +41,13 @@ class VakifBankAccount extends AbstractPosAccount /** * VakifBankAccount constructor. * - * @param string $bank - * @param string $model - * @param string $merchantId Isyeri No - * @param string $password Isyeri Sifre - * @param string $terminalId Terminal No - * @param int $merchantType - * @param string|null $subMerchantId + * @param string $bank + * @param string $model + * @param string $merchantId Isyeri No + * @param string $password Isyeri Sifre + * @param string $terminalId Terminal No + * @param self::MERCHANT_TYPE_* $merchantType + * @param string|null $subMerchantId */ public function __construct( string $bank, @@ -55,13 +55,14 @@ public function __construct( string $merchantId, string $password, string $terminalId, - int $merchantType = self::MERCHANT_TYPE_STANDARD, + int $merchantType = self::MERCHANT_TYPE_STANDARD, string $subMerchantId = null - ) { + ) + { parent::__construct($bank, $model, $merchantId, '', $password, 'tr'); - $this->model = $model; - $this->terminalId = $terminalId; - $this->merchantType = $merchantType; + $this->model = $model; + $this->terminalId = $terminalId; + $this->merchantType = $merchantType; $this->subMerchantId = $subMerchantId; } diff --git a/src/Factory/AccountFactory.php b/src/Factory/AccountFactory.php index dcac1b98..554e86dc 100644 --- a/src/Factory/AccountFactory.php +++ b/src/Factory/AccountFactory.php @@ -123,13 +123,13 @@ public static function createPosNetAccount(string $bank, string $merchantId, str } /** - * @param string $bank - * @param string $merchantId Üye işyeri numarası - * @param string $password Üye işyeri şifres - * @param string $terminalNo İşlemin hangi terminal üzerinden gönderileceği bilgisi. VB007000... - * @param string $model - * @param int $merchantType - * @param null $subMerchantId + * @param string $bank + * @param string $merchantId Üye işyeri numarası + * @param string $password Üye işyeri şifres + * @param string $terminalNo İşlemin hangi terminal üzerinden gönderileceği bilgisi. VB007000... + * @param string $model + * @param VakifBankAccount::MERCHANT_TYPE_* $merchantType + * @param null $subMerchantId * * @return VakifBankAccount * From 905a163d5f0b4ee30cc646718867a9ab51713a4a Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Mar 2023 11:31:37 +0100 Subject: [PATCH 27/54] VakifbankCP integration - added "method" inside 3dFormData --- examples/template/_redirect_form.php | 2 +- src/DataMapper/AbstractRequestDataMapper.php | 2 +- src/DataMapper/EstPosRequestDataMapper.php | 3 ++- src/DataMapper/GarantiPosRequestDataMapper.php | 1 + src/DataMapper/InterPosRequestDataMapper.php | 1 + src/DataMapper/PayForPosRequestDataMapper.php | 1 + src/DataMapper/PosNetRequestDataMapper.php | 1 + src/DataMapper/VakifBankPosRequestDataMapper.php | 3 ++- src/Gateways/AbstractGateway.php | 2 +- src/Gateways/KuveytPos.php | 5 +++-- src/Gateways/PayForPos.php | 4 +--- tests/DataMapper/EstPosRequestDataMapperTest.php | 2 ++ tests/DataMapper/EstV3PosRequestDataMapperTest.php | 14 +++++++------- .../DataMapper/GarantiPosRequestDataMapperTest.php | 1 + tests/DataMapper/InterPosRequestDataMapperTest.php | 2 ++ .../DataMapper/PayForPosRequestDataMapperTest.php | 2 ++ tests/DataMapper/PosNetRequestDataMapperTest.php | 1 + .../VakifBankPosRequestDataMapperTest.php | 1 + tests/Gateways/KuveytPosTest.php | 9 ++++++--- tests/Gateways/VakifBankPosTest.php | 3 ++- 20 files changed, 39 insertions(+), 21 deletions(-) diff --git a/examples/template/_redirect_form.php b/examples/template/_redirect_form.php index c503f4c0..1e1da31a 100644 --- a/examples/template/_redirect_form.php +++ b/examples/template/_redirect_form.php @@ -1,4 +1,4 @@ -
+ $value) : ?> diff --git a/src/DataMapper/AbstractRequestDataMapper.php b/src/DataMapper/AbstractRequestDataMapper.php index 1992519e..6efc752e 100644 --- a/src/DataMapper/AbstractRequestDataMapper.php +++ b/src/DataMapper/AbstractRequestDataMapper.php @@ -137,7 +137,7 @@ abstract public function createRefundRequestData(AbstractPosAccount $account, $o * @param string $txType * @param AbstractCreditCard|null $card * - * @return array{gateway: string, inputs: array} + * @return array{gateway: string, method: 'POST'|'GET', inputs: array} */ abstract public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array; diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index c1d6ae8f..4cfc30dd 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -243,7 +243,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx /** * @param AbstractGateway::TX_* $txType * - * @return array{gateway: string, inputs: array} + * @return array{gateway: string, method: 'POST', inputs: array} */ public function create3DFormDataCommon(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null): array { @@ -275,6 +275,7 @@ public function create3DFormDataCommon(AbstractPosAccount $account, $order, stri return [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; } diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index 557763c8..3dea683c 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -361,6 +361,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx return [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; } diff --git a/src/DataMapper/InterPosRequestDataMapper.php b/src/DataMapper/InterPosRequestDataMapper.php index f088dda0..cc6e9dc7 100644 --- a/src/DataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/InterPosRequestDataMapper.php @@ -211,6 +211,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx return [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; } diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index 03edaa43..bffd842e 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -207,6 +207,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx return [ 'gateway' => $gatewayURL, //to be filled by the caller + 'method' => 'POST', 'inputs' => $inputs, ]; } diff --git a/src/DataMapper/PosNetRequestDataMapper.php b/src/DataMapper/PosNetRequestDataMapper.php index 1652705d..3a8430ba 100644 --- a/src/DataMapper/PosNetRequestDataMapper.php +++ b/src/DataMapper/PosNetRequestDataMapper.php @@ -244,6 +244,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx return [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; } diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index 9957ac8c..93ba2ef5 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -230,7 +230,7 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar * * @param array{PaReq: string, TermUrl: string, MD: string, ACSUrl: string} $extraData * - * @return array{gateway: string, inputs: array{PaReq: string, TermUrl: string, MD: string}} + * @return array{gateway: string, method: 'POST', inputs: array{PaReq: string, TermUrl: string, MD: string}} */ public function create3DFormData(AbstractPosAccount $account, $order, string $txType, string $gatewayURL, ?AbstractCreditCard $card = null, array $extraData = []): array { @@ -242,6 +242,7 @@ public function create3DFormData(AbstractPosAccount $account, $order, string $tx return [ 'gateway' => $extraData['ACSUrl'], + 'method' => 'POST', 'inputs' => $inputs, ]; } diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index dec22555..82751ead 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -472,7 +472,7 @@ abstract public function create3DPaymentXML($responseData); /** * returns form data, key values, necessary for 3D payment * - * @return array{gateway: string, inputs: array} + * @return array{gateway: string, method: 'POST'|'GET', inputs: array} */ abstract public function get3DFormData(): array; diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 2801a61a..1ac01214 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -267,7 +267,7 @@ protected function prepareRefundOrder(array $order) * @param string $gatewayURL * @param AbstractCreditCard|null $card * - * @return array{gateway: string, inputs: array} + * @return array{gateway: string, method: 'POST', inputs: array} * * @throws Exception */ @@ -289,7 +289,7 @@ private function getCommon3DFormData(KuveytPosAccount $account, $order, string $ * Kutupahenin islem akisina uymasi icin bu HTML form verilerini array'e donusturup, kendimiz post ediyoruz. * @param string $response * - * @return array{gateway: string, inputs: array} + * @return array{gateway: string, method: 'POST', inputs: array} */ private function transformReceived3DFormData(string $response): array { @@ -319,6 +319,7 @@ private function transformReceived3DFormData(string $response): array return [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; } diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index f93beaba..44034f28 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -116,9 +116,7 @@ public function history(array $meta) /** - * returns form data needed for 3d, 3d_pay and 3d_host models - * - * @return array{gateway: string, inputs: array} + * {@inheritDoc} */ public function get3DFormData(): array { diff --git a/tests/DataMapper/EstPosRequestDataMapperTest.php b/tests/DataMapper/EstPosRequestDataMapperTest.php index 860faf3d..93621b8f 100644 --- a/tests/DataMapper/EstPosRequestDataMapperTest.php +++ b/tests/DataMapper/EstPosRequestDataMapperTest.php @@ -293,6 +293,7 @@ public function testGet3DFormData() ]; $form = [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; //test without card @@ -358,6 +359,7 @@ public function testGet3DHostFormData() ]; $form = [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; diff --git a/tests/DataMapper/EstV3PosRequestDataMapperTest.php b/tests/DataMapper/EstV3PosRequestDataMapperTest.php index a2131b81..93f35ca7 100644 --- a/tests/DataMapper/EstV3PosRequestDataMapperTest.php +++ b/tests/DataMapper/EstV3PosRequestDataMapperTest.php @@ -103,6 +103,7 @@ public function testGet3DFormData() $inputs['hash'] = $hash; $form = [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; //test without card @@ -114,13 +115,11 @@ public function testGet3DFormData() )); //test with card - if ($card) { - $form['inputs']['cardType'] = '1'; - $form['inputs']['pan'] = $card->getNumber(); - $form['inputs']['Ecom_Payment_Card_ExpDate_Month'] = '01'; - $form['inputs']['Ecom_Payment_Card_ExpDate_Year'] = '22'; - $form['inputs']['cv2'] = $card->getCvv(); - } + $form['inputs']['cardType'] = '1'; + $form['inputs']['pan'] = $card->getNumber(); + $form['inputs']['Ecom_Payment_Card_ExpDate_Month'] = '01'; + $form['inputs']['Ecom_Payment_Card_ExpDate_Year'] = '22'; + $form['inputs']['cv2'] = $card->getCvv(); unset($form['inputs']['hash']); $form['inputs']['hash'] = $this->requestDataMapper->getCrypt()->create3DHash($account, $form['inputs'], $txType); @@ -172,6 +171,7 @@ public function testGet3DHostFormData() ]; $form = [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; $form['inputs']['hash'] = $this->requestDataMapper->getCrypt()->create3DHash($account, $inputs, AbstractGateway::TX_PAY); diff --git a/tests/DataMapper/GarantiPosRequestDataMapperTest.php b/tests/DataMapper/GarantiPosRequestDataMapperTest.php index 07a47bd4..1d6159bb 100644 --- a/tests/DataMapper/GarantiPosRequestDataMapperTest.php +++ b/tests/DataMapper/GarantiPosRequestDataMapperTest.php @@ -231,6 +231,7 @@ public function testGet3DFormData() $form = [ 'inputs' => $inputs, + 'method' => 'POST', 'gateway' => $gatewayURL, ]; diff --git a/tests/DataMapper/InterPosRequestDataMapperTest.php b/tests/DataMapper/InterPosRequestDataMapperTest.php index 12b22626..74c9dab9 100644 --- a/tests/DataMapper/InterPosRequestDataMapperTest.php +++ b/tests/DataMapper/InterPosRequestDataMapperTest.php @@ -216,6 +216,7 @@ public function testGet3DFormData() ]; $form = [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; //test without card @@ -279,6 +280,7 @@ public function testGet3DHostFormData() ]; $form = [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; diff --git a/tests/DataMapper/PayForPosRequestDataMapperTest.php b/tests/DataMapper/PayForPosRequestDataMapperTest.php index 929ca748..3843f7e7 100644 --- a/tests/DataMapper/PayForPosRequestDataMapperTest.php +++ b/tests/DataMapper/PayForPosRequestDataMapperTest.php @@ -216,6 +216,7 @@ public function testGet3DFormData() ]; $form = [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; //test without card @@ -280,6 +281,7 @@ public function testGet3DHostFormData() ]; $form = [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; diff --git a/tests/DataMapper/PosNetRequestDataMapperTest.php b/tests/DataMapper/PosNetRequestDataMapperTest.php index e8f0b148..4eb9d146 100644 --- a/tests/DataMapper/PosNetRequestDataMapperTest.php +++ b/tests/DataMapper/PosNetRequestDataMapperTest.php @@ -361,6 +361,7 @@ private function getSample3DFormData(AbstractPosAccount $account, $order, $oosTx return [ 'gateway' => $gatewayURL, + 'method' => 'POST', 'inputs' => $inputs, ]; } diff --git a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php index 9ecd84bf..c61a8dc0 100644 --- a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php +++ b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php @@ -459,6 +459,7 @@ private function getSample3DFormDataFromEnrollmentResponse(): array return [ 'gateway' => 'http', + 'method' => 'POST', 'inputs' => $inputs, ]; } diff --git a/tests/Gateways/KuveytPosTest.php b/tests/Gateways/KuveytPosTest.php index adc278af..b037ad3f 100644 --- a/tests/Gateways/KuveytPosTest.php +++ b/tests/Gateways/KuveytPosTest.php @@ -258,7 +258,8 @@ public function parseHTMLResponseTestProvider(): array 'html' => '', 'expected' => [ 'gateway' => 'https://boa.kuveytturk.com.tr/sanalposservice/Home/ThreeDModelPayGate', - 'inputs' => [ + 'method' => 'POST', + 'inputs' => [ 'AuthenticationResponse' => '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3CVPosTransactionResponseContract%3E%3CVPosMessage%3E%3CAPIVersion%3E1.0.0%3C%2FAPIVersion%3E%3COkUrl%3Ehttp%3A%2F%2Flocalhost%3A44785%2FHome%2FSuccess%3C%2FOkUrl%3E%3CFailUrl%3Ehttp%3A%2F%2Flocalhost%3A44785%2FHome%2FFail%3C%2FFailUrl%3E%3CHashData%3ElYJYMi%2FgVO9MWr32Pshaa%2FzAbSHY%3D%3C%2FHashData%3E%3CMerchantId%3E80%3C%2FMerchantId%3E%3CSubMerchantId%3E0%3C%2FSubMerchantId%3E%3CCustomerId%3E400235%3C%2FCustomerId%3E%3CUserName%3Eapiuser%3C%2FUserName%3E%3CCardNumber%3E4025502306586032%3C%2FCardNumber%3E%3CCardHolderName%3Eafafa%3C%2FCardHolderName%3E%3CCardType%3EMasterCard%3C%2FCardType%3E%3CBatchID%3E0%3C%2FBatchID%3E%3CTransactionType%3ESale%3C%2FTransactionType%3E%3CInstallmentCount%3E0%3C%2FInstallmentCount%3E%3CAmount%3E100%3C%2FAmount%3E%3CDisplayAmount%3E100%3C%2FDisplayAmount%3E%3CMerchantOrderId%3EOrder+123%3C%2FMerchantOrderId%3E%3CFECAmount%3E0%3C%2FFECAmount%3E%3CCurrencyCode%3E0949%3C%2FCurrencyCode%3E%3CQeryId%3E0%3C%2FQeryId%3E%3CDebtId%3E0%3C%2FDebtId%3E%3CSurchargeAmount%3E0%3C%2FSurchargeAmount%3E%3CSGKDebtAmount%3E0%3C%2FSGKDebtAmount%3E%3CTransactionSecurity%3E3%3C%2FTransactionSecurity%3E%3CTransactionSide%3EAuto%3C%2FTransactionSide%3E%3CEntryGateMethod%3EVPOS_ThreeDModelPayGate%3C%2FEntryGateMethod%3E%3C%2FVPosMessage%3E%3CIsEnrolled%3Etrue%3C%2FIsEnrolled%3E%3CIsVirtual%3Efalse%3C%2FIsVirtual%3E%3COrderId%3E0%3C%2FOrderId%3E%3CTransactionTime%3E0001-01-01T00%3A00%3A00%3C%2FTransactionTime%3E%3CMD%3E67YtBfBRTZ0XBKnAHi8c%2FA%3D%3D%3C%2FMD%3E%3CAuthenticationPacket%3EWYGDgSIrSHDtYwF%2FWEN%2BnfwX63sppA%3D%3C%2FAuthenticationPacket%3E%3CACSURL%3Ehttps%3A%2F%2Facs.bkm.com.tr%2Fmdpayacs%2Fpareq%3C%2FACSURL%3E%3C%2FVPosTransactionResponseContract%3E' ] ], @@ -268,7 +269,8 @@ public function parseHTMLResponseTestProvider(): array 'html' => "\n\n\n\n\n3D Secure Processing\n\n\n
\n
\n
\n

3D Secure Processing

\nPlease wait..\n
\n\n
\n
\n\n\n\n\n\n\n\n\n\n\n\n
\n
\n
\n
\n\n
\n
\n\n\n", 'expected' => [ 'gateway' => 'https://certemvtds.bkm.com.tr/tds/resultFlow', - 'inputs' => [ + 'method' => 'POST', + 'inputs' => [ 'threeDSServerWebFlowStart' => 'eyJhbGciOiJIUzI1NiJ9.ewogICJ0aHJlZURTU2VydmVyV2ViRmxvd1N0YXJ0IiA6IHsKICAgICJhY3F1aXJlcklEIiA6ICIyMDUiLAogICAgInRocmVlRFNTZXJ2ZXJUcmFuc0lEIiA6ICJhN2QyMjQ4Mi1jMjI2LTRkZjUtODkwNC00M2RmOTZmOTJmNDAiLAogICAgInRocmVlRFNSZXF1ZXN0b3JUcmFuc0lEIiA6ICI4ZGVhOGIwYi1mZTg0LTRhZGQtOWI4Mi05MzM2ZWYyMWM1MjciLAogICAgInRpbWVab25lIiA6ICJVVEMrMDM6MDAiLAogICAgInRpbWVTdGFtcCIgOiAiMjAyMjEyMjgxMjU2NDAiLAogICAgInZlcnNpb24iIDogIjEuMC4wIgogIH0KfQ.w7KQvGhrujSZmzyqEBsqJJKb19vJo16pq_PssXcGc6k', 'browserColorDepth' => '', 'browserScreenHeight' => '', @@ -285,7 +287,8 @@ public function parseHTMLResponseTestProvider(): array 'expected' => [ // 3d form data olusturulmasi icin gonderilen istek banka tarafindan reddedillirse, bankadan fail URL'a yonlendirilecek bir response (html) doner. 'gateway' => 'http://localhost/finansbank-payfor/3d/response.php', - 'inputs' => [ + 'method' => 'POST', + 'inputs' => [ 'AuthenticationResponse' => '%3c%3fxml+version%3d%221.0%22+encoding%3d%22utf-8%22%3f%3e%3cVPosTransactionResponseContract+xmlns%3axsd%3d%22http%3a%2f%2fwww.w3.org%2f2001%2fXMLSchema%22+xmlns%3axsi%3d%22http%3a%2f%2fwww.w3.org%2f2001%2fXMLSchema-instance%22%3e%3cIsEnrolled%3etrue%3c%2fIsEnrolled%3e%3cIsVirtual%3efalse%3c%2fIsVirtual%3e%3cResponseCode%3eHashDataError%3c%2fResponseCode%3e%3cResponseMessage%3e%c5%9eifrelenen+veriler+(Hashdata)+uyu%c5%9fmamaktad%c4%b1r.%3c%2fResponseMessage%3e%3cOrderId%3e0%3c%2fOrderId%3e%3cTransactionTime%3e0001-01-01T00%3a00%3a00%3c%2fTransactionTime%3e%3cMerchantOrderId%3e2020110828BC%3c%2fMerchantOrderId%3e%3cReferenceId%3efbab348b4c074d1b9a5247471d91f5d1%3c%2fReferenceId%3e%3cMerchantId%3e496%3c%2fMerchantId%3e%3cBusinessKey%3e0%3c%2fBusinessKey%3e%3c%2fVPosTransactionResponseContract%3e', ] ], diff --git a/tests/Gateways/VakifBankPosTest.php b/tests/Gateways/VakifBankPosTest.php index f469ee86..19c7ae68 100644 --- a/tests/Gateways/VakifBankPosTest.php +++ b/tests/Gateways/VakifBankPosTest.php @@ -152,7 +152,8 @@ public function testGet3DFormDataSuccess() $result = $posMock->get3DFormData(); $expected = [ 'gateway' => $enrollmentResponse['Message']['VERes']['ACSUrl'], - 'inputs' => [ + 'method' => 'POST', + 'inputs' => [ 'PaReq' => $enrollmentResponse['Message']['VERes']['PaReq'], 'TermUrl' => $enrollmentResponse['Message']['VERes']['TermUrl'], 'MD' => $enrollmentResponse['Message']['VERes']['MD'], From e8f449bd8f7b008e367f9ca5c6647da451973de6 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Mar 2023 15:21:09 +0100 Subject: [PATCH 28/54] AbstractRequestDataMapper add type to $langMappingss --- phpstan-baseline.neon | 5 ----- src/DataMapper/AbstractRequestDataMapper.php | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index eb896547..a0d93c8e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -105,11 +105,6 @@ parameters: count: 1 path: src/DataMapper/AbstractRequestDataMapper.php - - - message: "#^Property Mews\\\\Pos\\\\DataMapper\\\\AbstractRequestDataMapper\\:\\:\\$langMappings has no type specified\\.$#" - count: 1 - path: src/DataMapper/AbstractRequestDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$id\\.$#" count: 2 diff --git a/src/DataMapper/AbstractRequestDataMapper.php b/src/DataMapper/AbstractRequestDataMapper.php index 6efc752e..fdbcc50c 100644 --- a/src/DataMapper/AbstractRequestDataMapper.php +++ b/src/DataMapper/AbstractRequestDataMapper.php @@ -28,6 +28,7 @@ abstract class AbstractRequestDataMapper /** @var array */ protected $cardTypeMapping = []; + /** @var array */ protected $langMappings = [ AbstractGateway::LANG_TR => 'tr', AbstractGateway::LANG_EN => 'en', From b83a9fcc8e05ee53c7e9483013970994c8b71075 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Mar 2023 15:48:22 +0100 Subject: [PATCH 29/54] VakifBankPosRequestDataMapper updated phpdoc types --- .../VakifBankPosRequestDataMapper.php | 101 ++++++++++-------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index 93ba2ef5..2c6e032d 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -16,7 +16,7 @@ class VakifBankPosRequestDataMapper extends AbstractRequestDataMapper { public const CREDIT_CARD_EXP_DATE_LONG_FORMAT = 'Ym'; - + public const CREDIT_CARD_EXP_DATE_FORMAT = 'ym'; /** @@ -52,7 +52,7 @@ class VakifBankPosRequestDataMapper extends AbstractRequestDataMapper ]; /** - * @param VakifBankAccount $account + * @param VakifBankAccount $account * @param array{Eci: string, Cavv: string, VerifyEnrollmentRequestId: string} $responseData * * {@inheritDoc} @@ -60,22 +60,22 @@ class VakifBankPosRequestDataMapper extends AbstractRequestDataMapper public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData, ?AbstractCreditCard $card = null): array { $requestData = $this->getRequestAccountData($account) + [ - 'TransactionType' => $this->mapTxType($txType), - 'TransactionId' => (string) $order->id, - 'CurrencyAmount' => self::amountFormat($order->amount), - 'CurrencyCode' => $this->mapCurrency($order->currency), - 'CardHoldersName' => $card->getHolderName(), - 'Cvv' => $card->getCvv(), - 'Pan' => $card->getNumber(), - 'Expiry' => $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_LONG_FORMAT), - 'ECI' => $responseData['Eci'], - 'CAVV' => $responseData['Cavv'], - 'MpiTransactionId' => $responseData['VerifyEnrollmentRequestId'], - 'OrderId' => (string) $order->id, - 'OrderDescription' => (string) ($order->description ?? ''), - 'ClientIp' => (string) $order->ip, - 'TransactionDeviceSource' => '0', // ECommerce - ]; + 'TransactionType' => $this->mapTxType($txType), + 'TransactionId' => (string) $order->id, + 'CurrencyAmount' => self::amountFormat($order->amount), + 'CurrencyCode' => $this->mapCurrency($order->currency), + 'CardHoldersName' => $card->getHolderName(), + 'Cvv' => $card->getCvv(), + 'Pan' => $card->getNumber(), + 'Expiry' => $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_LONG_FORMAT), + 'ECI' => $responseData['Eci'], + 'CAVV' => $responseData['Cavv'], + 'MpiTransactionId' => $responseData['VerifyEnrollmentRequestId'], + 'OrderId' => (string) $order->id, + 'OrderDescription' => (string) ($order->description ?? ''), + 'ClientIp' => (string) $order->ip, + 'TransactionDeviceSource' => '0', // ECommerce + ]; if ($order->installment) { $requestData['NumberOfInstallments'] = $this->mapInstallment($order->installment); @@ -110,15 +110,15 @@ public function create3DEnrollmentCheckRequestData(AbstractPosAccount $account, if ($order->installment) { $requestData['InstallmentCount'] = $this->mapInstallment($order->installment); } - + if (isset($order->extraData)) { $requestData['SessionInfo'] = $order->extraData; } - + if ($account->isSubBranch()) { $requestData['SubMerchantId'] = $account->getSubMerchantId(); } - + if (isset($order->recurringFrequency)) { $requestData['IsRecurring'] = 'true'; // Periyodik İşlem Frekansı @@ -137,24 +137,24 @@ public function create3DEnrollmentCheckRequestData(AbstractPosAccount $account, } /** - * @param VakifBankAccount $account + * @param VakifBankAccount $account * {@inheritDoc} */ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array { $requestData = $this->getRequestAccountData($account) + [ - 'TransactionType' => $this->mapTxType($txType), - 'OrderId' => $order->id, - 'CurrencyAmount' => self::amountFormat($order->amount), - 'CurrencyCode' => $this->mapCurrency($order->currency), - 'ClientIp' => $order->ip, - 'TransactionDeviceSource' => 0, - ]; + 'TransactionType' => $this->mapTxType($txType), + 'OrderId' => (string) $order->id, + 'CurrencyAmount' => self::amountFormat($order->amount), + 'CurrencyCode' => $this->mapCurrency($order->currency), + 'ClientIp' => (string) $order->ip, + 'TransactionDeviceSource' => '0', + ]; - if ($card !== null) { - $requestData['Pan'] = $card->getNumber(); - $requestData['Expiry'] = $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_LONG_FORMAT); - $requestData['Cvv'] = $card->getCvv(); + if ($card instanceof AbstractCreditCard) { + $requestData['Pan'] = $card->getNumber(); + $requestData['Expiry'] = $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_LONG_FORMAT); + $requestData['Cvv'] = $card->getCvv(); } return $requestData; @@ -165,17 +165,24 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $ * @param $order * @param AbstractCreditCard|null $card * - * @return array{TransactionType: string, ReferenceTransactionId: string, CurrencyAmount: string, CurrencyCode: string, ClientIp: string, MerchantId: string, Password: string, TerminalNo: string} + * @return array{TransactionType: string, + * ReferenceTransactionId: string, + * CurrencyAmount: string, + * CurrencyCode: string, + * ClientIp: string, + * MerchantId: string, + * Password: string, + * TerminalNo: string} */ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array { return $this->getRequestAccountData($account) + [ - 'TransactionType' => $this->mapTxType(AbstractGateway::TX_POST_PAY), - 'ReferenceTransactionId' => (string) $order->id, - 'CurrencyAmount' => self::amountFormat($order->amount), - 'CurrencyCode' => $this->mapCurrency($order->currency), - 'ClientIp' => (string) $order->ip, - ]; + 'TransactionType' => $this->mapTxType(AbstractGateway::TX_POST_PAY), + 'ReferenceTransactionId' => (string) $order->id, + 'CurrencyAmount' => self::amountFormat($order->amount), + 'CurrencyCode' => $this->mapCurrency($order->currency), + 'ClientIp' => (string) $order->ip, + ]; } /** @@ -188,7 +195,8 @@ public function createStatusRequestData(AbstractPosAccount $account, $order): ar /** * {@inheritDoc} - * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: mixed, ClientIp: mixed} + * @return array{MerchantId: string, Password: string, TransactionType: string, + * ReferenceTransactionId: string, ClientIp: string} */ public function createCancelRequestData(AbstractPosAccount $account, $order): array { @@ -196,14 +204,15 @@ public function createCancelRequestData(AbstractPosAccount $account, $order): ar 'MerchantId' => $account->getClientId(), 'Password' => $account->getPassword(), 'TransactionType' => $this->mapTxType(AbstractGateway::TX_CANCEL), - 'ReferenceTransactionId' => $order->id, - 'ClientIp' => $order->ip, + 'ReferenceTransactionId' => (string) $order->id, + 'ClientIp' => (string) $order->ip, ]; } /** * {@inheritDoc} - * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: mixed, ClientIp: mixed, CurrencyAmount: string} + * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: string, + * ClientIp: string, CurrencyAmount: string} */ public function createRefundRequestData(AbstractPosAccount $account, $order): array { @@ -211,8 +220,8 @@ public function createRefundRequestData(AbstractPosAccount $account, $order): ar 'MerchantId' => $account->getClientId(), 'Password' => $account->getPassword(), 'TransactionType' => $this->mapTxType(AbstractGateway::TX_REFUND), - 'ReferenceTransactionId' => $order->id, - 'ClientIp' => $order->ip, + 'ReferenceTransactionId' => (string) $order->id, + 'ClientIp' => (string) $order->ip, 'CurrencyAmount' => self::amountFormat($order->amount), ]; } From c90866792cc6b188b122184bf5de2efa18fa7290 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Mar 2023 20:54:32 +0100 Subject: [PATCH 30/54] fix some phpstan errors --- phpstan-baseline.neon | 30 ------------------------------ src/Client/HttpClient.php | 2 +- src/Gateways/InterPos.php | 3 ++- src/Gateways/PosNet.php | 18 +++++++++++------- 4 files changed, 14 insertions(+), 39 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a0d93c8e..12cf350a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1255,11 +1255,6 @@ parameters: count: 1 path: src/Gateways/EstPos.php - - - message: "#^Parameter \\#2 \\$payload of method Mews\\\\Pos\\\\Client\\\\HttpClient\\:\\:post\\(\\) expects array\\{body\\?\\: array\\, headers\\?\\: array\\, form_params\\?\\: array\\\\}\\|null, array\\{body\\: array\\|string\\} given\\.$#" - count: 1 - path: src/Gateways/EstPos.php - - message: "#^Parameter \\#2 \\$rawPaymentResponseData of method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\PaymentResponseMapperInterface\\:\\:map3DPaymentData\\(\\) expects array\\\\|null, array\\|string\\|null given\\.$#" count: 1 @@ -1355,11 +1350,6 @@ parameters: count: 1 path: src/Gateways/GarantiPos.php - - - message: "#^Parameter \\#2 \\$payload of method Mews\\\\Pos\\\\Client\\\\HttpClient\\:\\:post\\(\\) expects array\\{body\\?\\: array\\, headers\\?\\: array\\, form_params\\?\\: array\\\\}\\|null, array\\{body\\: array\\|string\\} given\\.$#" - count: 1 - path: src/Gateways/GarantiPos.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\\|string\\|null given\\.$#" count: 1 @@ -1440,11 +1430,6 @@ parameters: count: 1 path: src/Gateways/InterPos.php - - - message: "#^Parameter \\#2 \\$payload of method Mews\\\\Pos\\\\Client\\\\HttpClient\\:\\:post\\(\\) expects array\\{body\\?\\: array\\, headers\\?\\: array\\, form_params\\?\\: array\\\\}\\|null, array\\{form_params\\: array\\|string\\} given\\.$#" - count: 1 - path: src/Gateways/InterPos.php - - message: "#^Parameter \\#2 \\$rawPaymentResponseData of method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\InterPosResponseDataMapper\\:\\:map3DPaymentData\\(\\) expects array\\\\|null, array\\|string\\|null given\\.$#" count: 1 @@ -1560,11 +1545,6 @@ parameters: count: 1 path: src/Gateways/KuveytPos.php - - - message: "#^Parameter \\#2 \\$payload of method Mews\\\\Pos\\\\Client\\\\HttpClient\\:\\:post\\(\\) expects array\\{body\\?\\: array\\, headers\\?\\: array\\, form_params\\?\\: array\\\\}\\|null, array\\{body\\: array\\|string, headers\\: array\\{Content\\-Type\\: 'text/xml; charset…'\\}\\} given\\.$#" - count: 1 - path: src/Gateways/KuveytPos.php - - message: "#^Parameter \\#2 \\$rawPaymentResponseData of method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\KuveytPosResponseDataMapper\\:\\:map3DPaymentData\\(\\) expects array\\\\|null, array\\|string\\|null given\\.$#" count: 1 @@ -1675,11 +1655,6 @@ parameters: count: 1 path: src/Gateways/PayForPos.php - - - message: "#^Parameter \\#2 \\$payload of method Mews\\\\Pos\\\\Client\\\\HttpClient\\:\\:post\\(\\) expects array\\{body\\?\\: array\\, headers\\?\\: array\\, form_params\\?\\: array\\\\}\\|null, array\\{headers\\: array\\{Content\\-Type\\: 'text/xml; charset…'\\}, body\\: array\\|string\\} given\\.$#" - count: 1 - path: src/Gateways/PayForPos.php - - message: "#^Parameter \\#2 \\$rawPaymentResponseData of method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\PayForPosResponseDataMapper\\:\\:map3DPaymentData\\(\\) expects array\\\\|null, array\\|string\\|null given\\.$#" count: 1 @@ -1810,11 +1785,6 @@ parameters: count: 1 path: src/Gateways/PosNet.php - - - message: "#^Part \\$contents \\(array\\|string\\) of encapsed string cannot be cast to string\\.$#" - count: 1 - path: src/Gateways/PosNet.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankPos\\:\\:create3DPaymentXML\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 diff --git a/src/Client/HttpClient.php b/src/Client/HttpClient.php index d5c8b880..bcb60456 100644 --- a/src/Client/HttpClient.php +++ b/src/Client/HttpClient.php @@ -10,7 +10,7 @@ use function http_build_query; /** - * @phpstan-type PostPayload array{body?: array, headers?: array, form_params?: array} + * @phpstan-type PostPayload array{body?: array|string, headers?: array, form_params?: array} * PSR18 HTTP Client wrapper */ class HttpClient diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 0436652f..5ec2c4ed 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -48,7 +48,8 @@ public function send($contents, ?string $url = null) { $url = $url ?: $this->getApiURL(); $this->logger->log(LogLevel::DEBUG, 'sending request', ['url' => $url]); - $response = $this->client->post($url, ['form_params' => $contents]); + $payload = is_array($contents) ? ['form_params' => $contents] : ['body' => $contents]; + $response = $this->client->post($url, $payload); $this->logger->log(LogLevel::DEBUG, 'request completed', ['status_code' => $response->getStatusCode()]); //genelde ;; delimiter kullanilmis, ama bazen arasinda ;;; boyle delimiter de var. diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index a1b1eefb..37ce9d4e 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -149,13 +149,17 @@ public function send($contents, ?string $url = null) $url = $this->getApiURL(); $this->logger->log(LogLevel::DEBUG, 'sending request', ['url' => $url]); - /** @phpstan-ignore-next-line */ - $response = $this->client->post($url, [ - 'headers' => [ - 'Content-Type' => 'application/x-www-form-urlencoded', - ], - 'body' => "xmldata=$contents", - ]); + if (is_string($contents)) { + $response = $this->client->post($url, [ + 'headers' => [ + 'Content-Type' => 'application/x-www-form-urlencoded', + ], + 'body' => "xmldata=$contents", + ]); + } else { + $response = $this->client->post($url, ['form_params' => $contents]); + } + $this->logger->log(LogLevel::DEBUG, 'request completed', ['status_code' => $response->getStatusCode()]); $this->data = $this->XMLStringToArray($response->getBody()->getContents()); From e947e6ea22f6582a5d2926dccd7dd868e2c599a4 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Mar 2023 21:05:58 +0100 Subject: [PATCH 31/54] VakifbankCP integration - part 1 --- config/pos.php | 16 + examples/template/_header.php | 1 + examples/vakifbank-cp/3d-host/_config.php | 23 ++ examples/vakifbank-cp/3d-host/index.php | 3 + examples/vakifbank-cp/3d-host/response.php | 4 + examples/vakifbank-cp/3d-pay/_config.php | 23 ++ examples/vakifbank-cp/3d-pay/form.php | 3 + examples/vakifbank-cp/3d-pay/index.php | 3 + examples/vakifbank-cp/3d-pay/response.php | 8 + examples/vakifbank-cp/_payment_config.php | 78 ++++ examples/vakifbank-cp/index.php | 6 + examples/vakifbank-cp/regular/_config.php | 21 + examples/vakifbank-cp/regular/cancel.php | 24 ++ examples/vakifbank-cp/regular/form.php | 3 + examples/vakifbank-cp/regular/index.php | 3 + examples/vakifbank-cp/regular/post-auth.php | 20 + examples/vakifbank-cp/regular/refund.php | 23 ++ phpstan-baseline.neon | 200 ++++++++++ src/Crypt/VakifBankCPCrypt.php | 47 +++ .../AbstractResponseDataMapper.php | 3 +- .../VakifBankCPPosResponseDataMapper.php | 223 +++++++++++ .../VakifBankCPPosRequestDataMapper.php | 309 +++++++++++++++ src/Factory/PosFactory.php | 10 + src/Gateways/AbstractGateway.php | 4 +- src/Gateways/VakifBankCPPos.php | 360 ++++++++++++++++++ 25 files changed, 1415 insertions(+), 3 deletions(-) create mode 100644 examples/vakifbank-cp/3d-host/_config.php create mode 100644 examples/vakifbank-cp/3d-host/index.php create mode 100644 examples/vakifbank-cp/3d-host/response.php create mode 100644 examples/vakifbank-cp/3d-pay/_config.php create mode 100644 examples/vakifbank-cp/3d-pay/form.php create mode 100644 examples/vakifbank-cp/3d-pay/index.php create mode 100644 examples/vakifbank-cp/3d-pay/response.php create mode 100644 examples/vakifbank-cp/_payment_config.php create mode 100644 examples/vakifbank-cp/index.php create mode 100644 examples/vakifbank-cp/regular/_config.php create mode 100644 examples/vakifbank-cp/regular/cancel.php create mode 100644 examples/vakifbank-cp/regular/form.php create mode 100644 examples/vakifbank-cp/regular/index.php create mode 100644 examples/vakifbank-cp/regular/post-auth.php create mode 100644 examples/vakifbank-cp/regular/refund.php create mode 100644 src/Crypt/VakifBankCPCrypt.php create mode 100644 src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php create mode 100644 src/DataMapper/VakifBankCPPosRequestDataMapper.php create mode 100644 src/Gateways/VakifBankCPPos.php diff --git a/config/pos.php b/config/pos.php index ecc19831..f44127ca 100644 --- a/config/pos.php +++ b/config/pos.php @@ -160,6 +160,22 @@ ], ], ], + 'vakifbank-cp' => [ + 'name' => 'VakifBank-POS-Common-Payment', + 'class' => Mews\Pos\Gateways\VakifBankCPPos::class, + 'urls' => [ + 'production' => 'https://cpweb.vakifbank.com.tr/CommonPayment/api/RegisterTransaction', + 'test' => 'https://cptest.vakifbank.com.tr/CommonPayment/api/RegisterTransaction', + 'gateway' => [ + 'production' => 'https://cpweb.vakifbank.com.tr/CommonPayment/SecurePayment', + 'test' => 'https://cptest.vakifbank.com.tr/CommonPayment/SecurePayment', + ], + 'query' => [ + 'production' => 'https://cpweb.vakifbank.com.tr/CommonPayment/api/VposTransaction', + 'test' => 'https://cptest.vakifbank.com.tr/CommonPayment/api/VposTransaction', + ], + ], + ], 'denizbank' => [ 'name' => 'DenizBank-InterPos', 'class' => Mews\Pos\Gateways\InterPos::class, diff --git a/examples/template/_header.php b/examples/template/_header.php index 88cf1be5..d0764177 100644 --- a/examples/template/_header.php +++ b/examples/template/_header.php @@ -31,6 +31,7 @@
  • Garanti POS
  • InterPos (Deniz bank)
  • VPOS (VakifBank bank)
  • +
  • Common Payment (VakifBank bank)
  • PosNet (YKB)
  • KuveytPOS
  • diff --git a/examples/vakifbank-cp/3d-host/_config.php b/examples/vakifbank-cp/3d-host/_config.php new file mode 100644 index 00000000..38d6b010 --- /dev/null +++ b/examples/vakifbank-cp/3d-host/_config.php @@ -0,0 +1,23 @@ +get('card'); +$card = createCard($pos, $savedCard); + +require '../../template/_payment_response.php'; diff --git a/examples/vakifbank-cp/_payment_config.php b/examples/vakifbank-cp/_payment_config.php new file mode 100644 index 00000000..105b5f98 --- /dev/null +++ b/examples/vakifbank-cp/_payment_config.php @@ -0,0 +1,78 @@ + [ + 'path' => '/3d-pay/index.php', + 'label' => '3D Pay Ödeme', + ], + AbstractGateway::MODEL_3D_HOST => [ + 'path' => '/3d-host/index.php', + 'label' => '3D Host Ödeme', + ], + AbstractGateway::MODEL_NON_SECURE => [ + 'path' => '/regular/index.php', + 'label' => 'Non Secure Ödeme', + ], + AbstractGateway::TX_CANCEL => [ + 'path' => '/regular/cancel.php', + 'label' => 'İptal', + ], + AbstractGateway::TX_REFUND => [ + 'path' => '/regular/refund.php', + 'label' => 'İade', + ], +]; + + +$installments = [ + 0 => 'Peşin', + 2 => '2 Taksit', + 6 => '6 Taksit', + 12 => '12 Taksit', +]; + +function getNewOrder( + string $baseUrl, + string $ip, + string $currency, + \Symfony\Component\HttpFoundation\Session\Session $session, + ?int $installment = 0, + bool $tekrarlanan = false, + string $lang = AbstractGateway::LANG_TR +): array { + $order = createNewPaymentOrderCommon($baseUrl, $ip, $currency, $installment, $lang); + + $order['extraData'] = $session->getId(); //optional, istekte SessionInfo degere atanir + + return $order; +} + +function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\Entity\Card\AbstractCreditCard $card) +{ + if (\Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY !== $transaction) { + /** + * diger banklaradan farkli olarak 3d islemler icin de Vakifbank bu asamada kredi kart bilgileri istiyor + */ + $pos->payment($card); + } else { + $pos->payment(); + } +} + +$testCards = [ + 'visa1' => [ + 'number' => '4938460158754205', + 'year' => '24', + 'month' => '11', + 'cvv' => '715', + 'name' => 'John Doe', + 'type' => AbstractCreditCard::CARD_TYPE_VISA, + ], +]; diff --git a/examples/vakifbank-cp/index.php b/examples/vakifbank-cp/index.php new file mode 100644 index 00000000..c9f420d1 --- /dev/null +++ b/examples/vakifbank-cp/index.php @@ -0,0 +1,6 @@ +get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); + +$order = [ + 'id' => $order['id'], //ReferenceTransactionId + 'ip' => $order['ip'], +]; +$transaction = AbstractGateway::TX_CANCEL; +$pos->prepare($order, $transaction); + +// Cancel Order +$pos->cancel(); + +$response = $pos->getResponse(); + +require '../../template/_simple_response_dump.php'; +require '../../template/_footer.php'; diff --git a/examples/vakifbank-cp/regular/form.php b/examples/vakifbank-cp/regular/form.php new file mode 100644 index 00000000..2d74d020 --- /dev/null +++ b/examples/vakifbank-cp/regular/form.php @@ -0,0 +1,3 @@ +get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); + +$order = [ + 'id' => $order['id'], + 'amount' => $order['amount'], + 'currency' => $order['currency'], + 'ip' => $order['ip'], +]; + +$session->set('post_order', $order); +$transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; +$card = null; + +require '../../template/_payment_response.php'; diff --git a/examples/vakifbank-cp/regular/refund.php b/examples/vakifbank-cp/regular/refund.php new file mode 100644 index 00000000..9440d95c --- /dev/null +++ b/examples/vakifbank-cp/regular/refund.php @@ -0,0 +1,23 @@ +get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); +// Refund Order +$order = [ + 'id' => $order['id'], //ReferenceTransactionId + 'amount' => $order['amount'], + 'ip' => $order['ip'], +]; +$transaction = AbstractGateway::TX_REFUND; +$pos->prepare($order, $transaction); + +$pos->refund(); + +$response = $pos->getResponse(); +require '../../template/_simple_response_dump.php'; +require '../../template/_footer.php'; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 12cf350a..d88fc055 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -785,6 +785,106 @@ parameters: count: 1 path: src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php + - + message: "#^Access to an undefined property object\\:\\:\\$amount\\.$#" + count: 2 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Access to an undefined property object\\:\\:\\$currency\\.$#" + count: 2 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Access to an undefined property object\\:\\:\\$fail_url\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Access to an undefined property object\\:\\:\\$id\\.$#" + count: 2 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Access to an undefined property object\\:\\:\\$installment\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Access to an undefined property object\\:\\:\\$ip\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Access to an undefined property object\\:\\:\\$success_url\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Default value of the parameter \\#6 \\$extraData \\(array\\{\\}\\) of method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:create3DFormData\\(\\) is incompatible with type array\\{CommonPaymentUrl\\: string, PaymentToken\\: string\\}\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) has parameter \\$responseData with no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:create3DPaymentRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$extraData with no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:createNonSecurePaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:createNonSecurePostAuthPaymentRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:createRefundRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) has parameter \\$order with no type specified\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + + - + message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:createStatusRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/DataMapper/VakifBankCPPosRequestDataMapper.php + - message: "#^Access to an undefined property object\\:\\:\\$amount\\.$#" count: 1 @@ -1785,6 +1885,106 @@ parameters: count: 1 path: src/Gateways/PosNet.php + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:create3DPaymentXML\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:createCancelXML\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:createHistoryXML\\(\\) has parameter \\$customQueryData with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:createHistoryXML\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:createRefundXML\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:createRegularPaymentXML\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:createRegularPostXML\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:createStatusXML\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:createXML\\(\\) has parameter \\$nodes with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:history\\(\\) has parameter \\$meta with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:prepareCancelOrder\\(\\) has parameter \\$order with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:prepareHistoryOrder\\(\\) has parameter \\$order with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:preparePaymentOrder\\(\\) has parameter \\$order with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:preparePostPaymentOrder\\(\\) has parameter \\$order with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:prepareRefundOrder\\(\\) has parameter \\$order with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:prepareStatusOrder\\(\\) has parameter \\$order with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:registerPayment\\(\\) should return array\\{CommonPaymentUrl\\: string\\|null, PaymentToken\\: string\\|null, ErrorCode\\: string\\|null, ResponseMessage\\: string\\|null\\} but returns array\\|string\\|null\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:send\\(\\) has parameter \\$contents with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankCPPos\\:\\:send\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + + - + message: "#^Parameter \\#6 \\$extraData of method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:create3DFormData\\(\\) expects array\\{CommonPaymentUrl\\: string, PaymentToken\\: string\\}, array\\{CommonPaymentUrl\\: string\\|null, PaymentToken\\: string\\|null, ErrorCode\\: null, ResponseMessage\\: string\\|null\\} given\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\VakifBankPos\\:\\:create3DPaymentXML\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 diff --git a/src/Crypt/VakifBankCPCrypt.php b/src/Crypt/VakifBankCPCrypt.php new file mode 100644 index 00000000..e9469a9d --- /dev/null +++ b/src/Crypt/VakifBankCPCrypt.php @@ -0,0 +1,47 @@ + "5029" + * "ResponseMessage" => "Geçersiz İstek" hash ile istek gonderince hatasi aliyoruz. + * + * {@inheritDoc} + */ + public function create3DHash(AbstractPosAccount $account, array $requestData, ?string $txType = null): string + { + $hashData = [ + $account->getClientId(), + $requestData['currency'], + $requestData['amount'], + $account->getPassword(), + '', + 'VBank3DPay2014', // todo + ]; + + $hashStr = implode(static::HASH_SEPARATOR, $hashData); + + return ''; + //return $this->hashString($hashStr); + } + + /** + * todo implement + * {@inheritdoc} + */ + public function check3DHash(AbstractPosAccount $account, array $data): bool + { + return true; + } + + public function createHash(AbstractPosAccount $account, array $requestData, ?string $txType = null, ?AbstractCreditCard $card = null): string + { + throw new NotImplementedException(); + } +} diff --git a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php index ab414758..b581a3b2 100644 --- a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php @@ -103,7 +103,8 @@ protected function mergeArraysPreferNonNullValues(array $arr1, array $arr2): arr /** * Returns default payment response data * - * @return array + * @return array{order_id: null, trans_id: null, auth_code: null, ref_ret_num: null, proc_return_code: null, + * status: string, status_detail: null, error_code: null, error_message: null, all: null} */ protected function getDefaultPaymentResponse(): array { diff --git a/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php new file mode 100644 index 00000000..7151ec13 --- /dev/null +++ b/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php @@ -0,0 +1,223 @@ + + */ + protected $codes = [ + self::PROCEDURE_SUCCESS_CODE => self::TX_APPROVED, + ]; + + /** + * TODO implement + * {@inheritdoc} + */ + public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymentResponseData): array + { + throw new NotImplementedException(); + } + + /** + * @param array{ErrorCode: string}|array{ + * Rc: string, + * AuthCode: string, + * TransactionId: string, + * PaymentToken: string, + * MaskedPan: string}|array{ + * Rc: string, + * Message: string, + * TransactionId: string, + * PaymentToken: string} $raw3DAuthResponseData + * {@inheritdoc} + */ + public function map3DPayResponseData(array $raw3DAuthResponseData): array + { + $raw3DAuthResponseData = $this->emptyStringsToNull($raw3DAuthResponseData); + + /** + * Bir işlem sanal posa gönderilemeden hatayla sonuçlandıysa response'da ErrorCode degeri yer alacak. + */ + $errorCode = $raw3DAuthResponseData['ErrorCode'] ?? null; + if (null !== $errorCode) { + $paymentResponse = $this->getDefaultPaymentResponse(); + $paymentResponse['error_code'] = $errorCode; + + return $paymentResponse; + } + + $paymentResponse = $this->getCommonPaymentResponse($raw3DAuthResponseData); + + $paymentResponse['trans_id'] = $raw3DAuthResponseData['TransactionId']; + $paymentResponse['masked_number'] = $raw3DAuthResponseData['MaskedPan']; + + if (self::TX_APPROVED === $paymentResponse['status']) { + $paymentResponse['auth_code'] = $raw3DAuthResponseData['AuthCode']; + $paymentResponse['ref_ret_num'] = $raw3DAuthResponseData['TransactionId']; + } else { + /** + * Sanal POS gönderilmiş ve hata oluşmuş + */ + $paymentResponse['error_message'] = $raw3DAuthResponseData['Message']; + } + + return $paymentResponse; + } + + /** + * {@inheritdoc} + * @param array{ErrorCode: string}|array{ + * Rc: string, + * AuthCode: string, + * TransactionId: string, + * PaymentToken: string, + * MaskedPan: string}|array{ + * Rc: string, + * Message: string, + * TransactionId: string, + * PaymentToken: string} $raw3DAuthResponseData + */ + public function map3DHostResponseData(array $raw3DAuthResponseData): array + { + return $this->map3DPayResponseData($raw3DAuthResponseData); + } + + /** + * {@inheritdoc} + */ + public function mapRefundResponse(array $rawResponseData): array + { + return $this->mapCancelResponse($rawResponseData); + } + + /** + * {@inheritdoc} + */ + public function mapCancelResponse(array $rawResponseData): array + { + $rawResponseData = $this->emptyStringsToNull($rawResponseData); + + $response = $this->getCommonPaymentResponse($rawResponseData); + + if (self::TX_APPROVED === $response['status']) { + $response['order_id'] = $rawResponseData['TransactionId']; + $response['ref_ret_num'] = $rawResponseData['Rrn']; + $response['auth_code'] = $rawResponseData['AuthCode']; + $response['trans_id'] = $rawResponseData['TransactionId']; + } + + return $response; + } + + /** + * {@inheritdoc} + */ + public function mapStatusResponse(array $rawResponseData): array + { + return $this->emptyStringsToNull($rawResponseData); + } + + /** + * {@inheritDoc} + */ + public function mapPaymentResponse(array $rawPaymentResponseData): array + { + $this->logger->log(LogLevel::DEBUG, 'mapping payment response', $rawPaymentResponseData); + $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); + $commonResponse = $this->getCommonPaymentResponse($rawPaymentResponseData); + + if (self::TX_APPROVED === $commonResponse['status']) { + $commonResponse['trans_id'] = $rawPaymentResponseData['TransactionId']; + $commonResponse['auth_code'] = $rawPaymentResponseData['AuthCode']; + $commonResponse['ref_ret_num'] = $rawPaymentResponseData['Rrn']; + $commonResponse['order_id'] = $rawPaymentResponseData['OrderId']; + $commonResponse['transaction_type'] = $this->mapTxType($rawPaymentResponseData['TransactionType']); + $commonResponse['eci'] = $rawPaymentResponseData['ECI']; + } + + $this->logger->log(LogLevel::DEBUG, 'mapped payment response', $commonResponse); + + return $commonResponse; + } + + /** + * @param array $responseData + * + * @return array{order_id: string|null, trans_id: string|null, auth_code: string|null, + * ref_ret_num: string|null, proc_return_code: string|null, + * status: string, status_detail: string|null, error_code: string|null, + * error_message: string|null, all: array} + */ + private function getCommonPaymentResponse(array $responseData): array + { + $status = self::TX_DECLINED; + $resultCode = $this->getProcReturnCode($responseData); + + $errorCode = $responseData['ErrorCode'] ?? null; + $statusDetail = null; + if (null !== $errorCode) { + $resultCode = $errorCode; + $statusDetail = $responseData['ResponseMessage']; + } else { + if (self::PROCEDURE_SUCCESS_CODE === $resultCode) { + $status = self::TX_APPROVED; + } else { + $statusDetail = $responseData['ResultDetail']; + } + } + + $response = $this->getDefaultPaymentResponse(); + + $response['proc_return_code'] = $resultCode; + $response['status'] = $status; + $response['status_detail'] = $statusDetail; + $response['error_code'] = (self::TX_DECLINED === $status) ? $resultCode : null; + $response['error_message'] = $statusDetail; + $response['all'] = $responseData; + + return $response; + } + + /** + * {@inheritDoc} + */ + public function mapHistoryResponse(array $rawResponseData): array + { + return $this->emptyStringsToNull($rawResponseData); + } + + /** + * @param string $mdStatus + * + * @return string + */ + protected function mapResponseTransactionSecurity(string $mdStatus): string + { + return 'MPI fallback'; + } + + /** + * Get ProcReturnCode + * + * @param array $response + * + * @return string|null + */ + protected function getProcReturnCode(array $response): ?string + { + if (isset($response['Rc'])) { + return $response['Rc']; + } + + return $response['ResultCode'] ?? null; + } +} diff --git a/src/DataMapper/VakifBankCPPosRequestDataMapper.php b/src/DataMapper/VakifBankCPPosRequestDataMapper.php new file mode 100644 index 00000000..a18dfdf2 --- /dev/null +++ b/src/DataMapper/VakifBankCPPosRequestDataMapper.php @@ -0,0 +1,309 @@ + 'Sale', + AbstractGateway::TX_PRE_PAY => 'Auth', + AbstractGateway::TX_POST_PAY => 'Capture', + AbstractGateway::TX_CANCEL => 'Cancel', + AbstractGateway::TX_REFUND => 'Refund', + AbstractGateway::TX_HISTORY => 'TxnHistory', + AbstractGateway::TX_STATUS => 'OrderInquiry', + ]; + + /** + * {@inheritdoc} + */ + protected $cardTypeMapping = [ + AbstractCreditCard::CARD_TYPE_VISA => '100', + AbstractCreditCard::CARD_TYPE_MASTERCARD => '200', + AbstractCreditCard::CARD_TYPE_TROY => '300', + AbstractCreditCard::CARD_TYPE_AMEX => '400', + ]; + + /** + * {@inheritdoc} + */ + protected $langMappings = [ + AbstractGateway::LANG_TR => 'tr-TR', + AbstractGateway::LANG_EN => 'en-US', + ]; + + /** + * {@inheritdoc} + */ + protected $recurringOrderFrequencyMapping = [ + 'DAY' => 'Day', + 'MONTH' => 'Month', + 'YEAR' => 'Year', + ]; + + /** + * todo implement + * {@inheritDoc} + * + * @param VakifBankAccount $account + */ + public function create3DPaymentRequestData(AbstractPosAccount $account, $order, string $txType, array $responseData, ?AbstractCreditCard $card = null): array + { + throw new NotImplementedException(); + } + + + /** + * @param VakifBankAccount $account + * @param array{TransactionId: string, Ptkn: string} $responseData + * + * @return array{HostMerchantId: string, Password: string, TransactionId: string, PaymentToken: string} + */ + public function create3DPaymentStatusRequestData(AbstractPosAccount $account, array $responseData): array + { + return $this->getRequestAccountData($account) + [ + 'HostMerchantId' => $account->getClientId(), + 'Password' => $account->getPassword(), + 'TransactionId' => $responseData['TransactionId'], + 'PaymentToken' => $responseData['Ptkn'], + ]; + } + + /** + * @param VakifBankAccount $account + * @param object $order + * @param AbstractGateway::TX_* $txType + * @param AbstractCreditCard|null $card + * + * @return array + */ + public function create3DEnrollmentCheckRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array + { + $mappedOrder = (array) $order; + $mappedOrder['currency'] = $this->mapCurrency($order->currency); + $mappedOrder['amount'] = self::amountFormat($order->amount); + $hashData = $this->crypt->create3DHash($account, $mappedOrder, $txType); + + $requestData = [ + 'HostMerchantId' => $account->getClientId(), + 'MerchantPassword' => $account->getPassword(), + 'HostTerminalId' => $account->getTerminalId(), + 'TransactionType' => $this->mapTxType($txType), + 'AmountCode' => $this->mapCurrency($order->currency), + 'Amount' => self::amountFormat($order->amount), + 'OrderID' => (string) $order->id, + 'OrderDescription' => '', + 'IsSecure' => 'true', // Işlemin 3D yapılıp yapılmayacağına dair flag, alabileceği değerler: 'true', 'false' + /** + * Kart sahibi 3D Secure programına dahil değil + * ise işlemin Vposa gönderilip + * gönderilmeyeceği ile ilgili flag. + * Alabileceği değerler: 'true', 'false' + */ + 'AllowNotEnrolledCard' => 'false', + 'SuccessUrl' => (string) $order->success_url, + 'FailUrl' => (string) $order->fail_url, + 'HashedData' => $hashData, + 'RequestLanguage' => $this->getLang($account, $order), + /** + * Bu alanda gönderilecek değer kart hamili + * ektresinde işlem açıklamasında çıkacaktır. + * (Abone no vb. bilgiler gönderilebilir) + */ + 'Extract' => '', + /** + * Uye işyeri tarafından işleme ait ek bilgiler varsa CustomItems alanında gönderilir. + * İçeriğinde "name" ve "value" attirbutelarını barındırır. + * Örnek: İsim1:Değer1 İsim2:Değer2 İsim3:Değer3 + */ + 'CustomItems' => '', + ]; + + if ($card instanceof AbstractCreditCard) { + $requestData += [ + 'BrandNumber' => $this->cardTypeMapping[$card->getType()], + 'CVV' => $card->getCvv(), + 'PAN' => $card->getNumber(), + 'ExpireMonth' => $card->getExpireMonth(), + 'ExpireYear' => $card->getExpireYear(), + 'CardHoldersName' => (string) $card->getHolderName(), + ]; + } + + if ($order->installment) { + $requestData['InstallmentCount'] = $this->mapInstallment($order->installment); + } + + return $requestData; + } + + /** + * TODO implement + * {@inheritDoc} + * + * @param VakifBankAccount $account + * + * @return array + */ + public function createNonSecurePaymentRequestData(AbstractPosAccount $account, $order, string $txType, ?AbstractCreditCard $card = null): array + { + $requestData = $this->getRequestAccountData($account) + [ + 'TransactionType' => $this->mapTxType($txType), + 'OrderId' => (string) $order->id, + 'CurrencyAmount' => self::amountFormat($order->amount), + 'CurrencyCode' => $this->mapCurrency($order->currency), + 'ClientIp' => (string) $order->ip, + 'TransactionDeviceSource' => '0', + ]; + + if ($card instanceof AbstractCreditCard) { + $requestData['Pan'] = $card->getNumber(); + $requestData['Expiry'] = $card->getExpirationDate(self::CREDIT_CARD_EXP_DATE_LONG_FORMAT); + $requestData['Cvv'] = $card->getCvv(); + } + + return $requestData; + } + + /** + * @param VakifBankAccount $account + * @param $order + * @param AbstractCreditCard|null $card + * + * @return array{TransactionType: string, ReferenceTransactionId: string, + * CurrencyAmount: string, CurrencyCode: string, ClientIp: string, + * MerchantId: string, Password: string} + */ + public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $account, $order, ?AbstractCreditCard $card = null): array + { + return $this->getRequestAccountData($account) + [ + 'TransactionType' => $this->mapTxType(AbstractGateway::TX_POST_PAY), + 'ReferenceTransactionId' => (string) $order->id, + 'CurrencyAmount' => self::amountFormat($order->amount), + 'CurrencyCode' => $this->mapCurrency($order->currency), + 'ClientIp' => (string) $order->ip, + ]; + } + + /** + * {@inheritDoc} + */ + public function createStatusRequestData(AbstractPosAccount $account, $order): array + { + throw new NotImplementedException(); + } + + /** + * {@inheritDoc} + * + * @param VakifBankAccount $account + * + * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: string, + * ClientIp: string} + */ + public function createCancelRequestData(AbstractPosAccount $account, $order): array + { + return $this->getRequestAccountData($account) + [ + 'TransactionType' => $this->mapTxType(AbstractGateway::TX_CANCEL), + 'ReferenceTransactionId' => (string) $order->id, + 'ClientIp' => (string) $order->ip, + ]; + } + + /** + * {@inheritDoc} + * + * @param VakifBankAccount $account + * + * @return array{MerchantId: string, Password: string, TransactionType: string, ReferenceTransactionId: string, + * ClientIp: string, CurrencyAmount: string} + */ + public function createRefundRequestData(AbstractPosAccount $account, $order): array + { + return $this->getRequestAccountData($account) + [ + 'TransactionType' => $this->mapTxType(AbstractGateway::TX_REFUND), + 'ReferenceTransactionId' => (string) $order->id, + 'ClientIp' => (string) $order->ip, + 'CurrencyAmount' => self::amountFormat($order->amount), + ]; + } + + /** + * {@inheritDoc} + */ + public function createHistoryRequestData(AbstractPosAccount $account, $order, array $extraData = []): array + { + throw new NotImplementedException(); + } + + /** + * {@inheritDoc} + * + * @param array{CommonPaymentUrl: string, PaymentToken: string} $extraData + * + * @return array{gateway: string, method: 'GET', inputs: array{Ptkn: string}} + */ + public function create3DFormData( + AbstractPosAccount $account, + $order, + string $txType, + string $gatewayURL, + ?AbstractCreditCard $card = null, + array $extraData = []): array + { + return [ + 'gateway' => $gatewayURL, + 'method' => 'GET', + 'inputs' => [ + 'Ptkn' => $extraData['PaymentToken'], + ], + ]; + } + + /** + * Amount Formatter + * + * @param float $amount + * + * @return string ex: 10.1 => 10.10 + */ + public static function amountFormat(float $amount): string + { + return number_format($amount, 2, '.', ''); + } + + public function mapInstallment(?int $installment): string + { + return $installment > 1 ? (string) $installment : '0'; + } + + /** + * @param VakifBankAccount $account + * + * @return array{MerchantId: string, Password: string} + */ + private function getRequestAccountData(AbstractPosAccount $account): array + { + return [ + 'MerchantId' => $account->getClientId(), + 'Password' => $account->getPassword(), + ]; + } +} diff --git a/src/Factory/PosFactory.php b/src/Factory/PosFactory.php index 06ed1c1f..ed3ab1b1 100644 --- a/src/Factory/PosFactory.php +++ b/src/Factory/PosFactory.php @@ -14,6 +14,7 @@ use Mews\Pos\Crypt\KuveytPosCrypt; use Mews\Pos\Crypt\PayForPosCrypt; use Mews\Pos\Crypt\PosNetCrypt; +use Mews\Pos\Crypt\VakifBankCPCrypt; use Mews\Pos\DataMapper\AbstractRequestDataMapper; use Mews\Pos\DataMapper\EstPosRequestDataMapper; use Mews\Pos\DataMapper\EstV3PosRequestDataMapper; @@ -29,7 +30,9 @@ use Mews\Pos\DataMapper\ResponseDataMapper\KuveytPosResponseDataMapper; use Mews\Pos\DataMapper\ResponseDataMapper\PayForPosResponseDataMapper; use Mews\Pos\DataMapper\ResponseDataMapper\PosNetResponseDataMapper; +use Mews\Pos\DataMapper\ResponseDataMapper\VakifBankCPPosResponseDataMapper; use Mews\Pos\DataMapper\ResponseDataMapper\VakifBankPosResponseDataMapper; +use Mews\Pos\DataMapper\VakifBankCPPosRequestDataMapper; use Mews\Pos\DataMapper\VakifBankPosRequestDataMapper; use Mews\Pos\Entity\Account\AbstractPosAccount; use Mews\Pos\Exceptions\BankClassNullException; @@ -41,6 +44,7 @@ use Mews\Pos\Gateways\KuveytPos; use Mews\Pos\Gateways\PayForPos; use Mews\Pos\Gateways\PosNet; +use Mews\Pos\Gateways\VakifBankCPPos; use Mews\Pos\Gateways\VakifBankPos; use Mews\Pos\PosInterface; use Psr\Log\LoggerInterface; @@ -142,6 +146,8 @@ public static function getGatewayRequestMapper(string $gatewayClass, array $curr return new PayForPosRequestDataMapper($crypt, $currencies); case PosNet::class: return new PosNetRequestDataMapper($crypt, $currencies); + case VakifBankCPPos::class: + return new VakifBankCPPosRequestDataMapper($crypt, $currencies); } } @@ -179,6 +185,8 @@ public static function getGatewayResponseMapper(string $gatewayClass, AbstractRe return new PosNetResponseDataMapper($currencyMappings, $txMappings, $logger); case VakifBankPos::class: return new VakifBankPosResponseDataMapper($currencyMappings, $txMappings, $logger); + case VakifBankCPPos::class: + return new VakifBankCPPosResponseDataMapper($currencyMappings, $txMappings, $logger); } throw new DomainException('unsupported gateway'); @@ -207,6 +215,8 @@ public static function getGatewayCrypt(string $gatewayClass, LoggerInterface $lo return new PayForPosCrypt($logger); case PosNet::class: return new PosNetCrypt($logger); + case VakifBankCPPos::class: + return new VakifBankCPCrypt($logger); default: return null; } diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 82751ead..d9a458f0 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -54,7 +54,7 @@ abstract class AbstractGateway implements PosInterface public const MODEL_NON_SECURE = 'regular'; /** @var array */ - private $config; + protected $config; /** @var AbstractPosAccount */ protected $account; @@ -559,7 +559,7 @@ protected function XMLStringToArray(string $data, array $context = []): array * return values are used as a key in config file * @return string */ - private function getModeInWord(): string + protected function getModeInWord(): string { return $this->isTestMode() ? 'test' : 'production'; } diff --git a/src/Gateways/VakifBankCPPos.php b/src/Gateways/VakifBankCPPos.php new file mode 100644 index 00000000..2affea10 --- /dev/null +++ b/src/Gateways/VakifBankCPPos.php @@ -0,0 +1,360 @@ +account; + } + + /** + * todo implement + * @inheritDoc + */ + public function make3DPayment(Request $request) + { + throw new UnsupportedPaymentModelException(); + } + + /** + * TODO check if it is working + * @inheritDoc + */ + public function make3DPayPayment(Request $request) + { + $errorCode = $request->query->get('RC'); + $errorMsg = $request->query->get('MSG'); + if (null !== $errorCode) { + $this->logger->error('received error response from the bank', $request->query->all()); + $bankResponse = [ + 'ErrorCode' => (string) $errorCode, + ]; + $this->response = $this->responseDataMapper->map3DPayResponseData($bankResponse); + + return $this; + } + + /** @var array{TransactionId: string, Ptkn: string} $queryParams */ + $queryParams = $request->query->all(); + + $statusRequestData = $this->requestDataMapper->create3DPaymentStatusRequestData($this->account, $queryParams); + + /** @var array{ErrorCode: string}|array{ + * Rc: string, + * AuthCode: string, + * TransactionId: string, + * PaymentToken: string, + * MaskedPan: string}|array{ + * Rc: string, + * Message: string, + * TransactionId: string, + * PaymentToken: string} $bankResponse */ + $bankResponse = $this->send($statusRequestData, $this->getQueryAPIUrl()); + + $this->response = $this->responseDataMapper->map3DPayResponseData($bankResponse); + + $this->logger->log(LogLevel::DEBUG, 'finished 3D payment', ['mapped_response' => $this->response]); + + return $this; + } + + /** + * @inheritDoc + */ + public function make3DHostPayment(Request $request) + { + return $this->make3DPayPayment($request); + } + + /** + * TODO implement + * @inheritDoc + */ + public function history(array $meta) + { + throw new UnsupportedPaymentModelException(); + } + + /** + * {@inheritDoc} + */ + public function get3DFormData(): array + { + if (null === $this->order) { + $this->logger->log(LogLevel::ERROR, 'tried to get 3D form data without setting order', [ + 'order' => $this->order, + 'card_provided' => (bool) $this->card, + ]); + + throw new LogicException('Sipariş bilgileri eksik!'); + } + + /** @var array{CommonPaymentUrl: string|null, PaymentToken: string|null, ErrorCode: string|null, ResponseMessage: string|null} $data */ + $data = $this->registerPayment(); + + if (null !== $data['ErrorCode']) { + $this->logger->log(LogLevel::ERROR, 'payment register fail response', $data); + throw new Exception('İşlem gerçekleştirilemiyor'); + } + + /** @var string $gatewayUrl */ + $gatewayUrl = $data['CommonPaymentUrl']; + + $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); + + return $this->requestDataMapper->create3DFormData( + $this->account, + $this->order, + $this->type, + $gatewayUrl, + null, + $data + ); + } + + /** + * @inheritDoc + */ + public function createXML(array $nodes, string $encoding = 'UTF-8', bool $ignorePiNode = true): string + { + return parent::createXML(['VposRequest' => $nodes], $encoding, $ignorePiNode); + } + + /** + * @inheritDoc + */ + public function send($contents, ?string $url = null) + { + $url = $url ?? $this->getApiURL(); + $this->logger->log(LogLevel::DEBUG, 'sending request', ['url' => $url]); + + $isXML = is_string($contents); + $body = $isXML ? ['body' => $contents] : ['form_params' => $contents]; + + $response = $this->client->post($url, $body); + $this->logger->log(LogLevel::DEBUG, 'request completed', ['status_code' => $response->getStatusCode()]); + + $responseBody = $response->getBody()->getContents(); + + try { + $this->data = $this->XMLStringToArray($responseBody); + } catch (NotEncodableValueException $e) { + if ($this->isHTML($responseBody)) { + // if something wrong server responds with HTML content + throw new Exception($responseBody, $e->getCode(), $e); + } + + $this->data = json_decode($responseBody, true); + } + + return $this->data; + } + + /** + * @inheritDoc + */ + public function createRegularPaymentXML() + { + $requestData = $this->requestDataMapper->createNonSecurePaymentRequestData($this->account, $this->order, $this->type, $this->card); + + return $this->createXML($requestData); + } + + /** + * @inheritDoc + */ + public function createRegularPostXML() + { + if (null === $this->order) { + throw new LogicException('sipariş bilgileri eksik!'); + } + + $requestData = $this->requestDataMapper->createNonSecurePostAuthPaymentRequestData($this->account, $this->order); + + return $this->createXML($requestData); + } + + /** + * TODO implement + * @inheritDoc + */ + public function create3DPaymentXML($responseData) + { + throw new NotImplementedException(); + } + + /** + * TODO check if it is working + * @inheritDoc + */ + public function createStatusXML() + { + return $this->requestDataMapper->createStatusRequestData($this->account, $this->order); + } + + /** + * TODO check if it is working + * @inheritDoc + */ + public function createHistoryXML($customQueryData) + { + return $this->requestDataMapper->createHistoryRequestData($this->account, $this->order, $customQueryData); + } + + /** + * @inheritDoc + */ + public function createRefundXML() + { + $requestData = $this->requestDataMapper->createRefundRequestData($this->account, $this->order); + + return $this->createXML($requestData); + } + + /** + * @inheritDoc + */ + public function createCancelXML() + { + if (null === $this->order) { + $this->logger->log(LogLevel::ERROR, 'cancel data create without order data', [ + 'order' => $this->order, + ]); + + throw new LogicException('Sipariş bilgileri eksik!'); + } + + $requestData = $this->requestDataMapper->createCancelRequestData($this->account, $this->order); + + return $this->createXML($requestData); + } + + /** + * @inheritDoc + */ + protected function preparePaymentOrder(array $order) + { + return (object) array_merge($order, [ + 'installment' => $order['installment'] ?? 0, + 'currency' => $order['currency'] ?? 'TRY', + 'amount' => $order['amount'], + ]); + } + + /** + * @inheritDoc + */ + protected function preparePostPaymentOrder(array $order) + { + return (object) [ + 'id' => $order['id'], + 'amount' => $order['amount'], + 'currency' => $order['currency'] ?? 'TRY', + 'ip' => $order['ip'], + ]; + } + + /** + * @inheritDoc + */ + protected function prepareStatusOrder(array $order) + { + return (object) $order; + } + + /** + * @inheritDoc + */ + protected function prepareHistoryOrder(array $order) + { + return (object) [ + 'id' => $order['id'] ?? null, + ]; + } + + /** + * @inheritDoc + */ + protected function prepareCancelOrder(array $order) + { + return (object) $order; + } + + /** + * @inheritDoc + */ + protected function prepareRefundOrder(array $order) + { + return (object) $order; + } + + + /** + * @return string + */ + private function getQueryAPIUrl(): string + { + return $this->config['urls']['query'][$this->getModeInWord()]; + } + + + /** + * ORTAK ÖDEME SİSTEMİNE İŞLEM KAYDETME + * Basarili durumda donen cevap formati: array{CommonPaymentUrl: string, PaymentToken: string, ErrorCode: null, ResponseMessage: null} + * Basarisiz durumda donen cevap formati: array{CommonPaymentUrl: null, PaymentToken: null, ErrorCode: string, ResponseMessage: string} + * @return array{CommonPaymentUrl: string|null, PaymentToken: string|null, ErrorCode: string|null, ResponseMessage: string|null} + * + * @throws Exception + */ + private function registerPayment(): array + { + if (null === $this->order) { + $this->logger->log(LogLevel::ERROR, 'register payment without setting order', [ + 'order' => $this->order, + 'card_provided' => (bool) $this->card, + ]); + + throw new LogicException('Sipariş bilgileri eksik!'); + } + + $requestData = $this->requestDataMapper->create3DEnrollmentCheckRequestData( + $this->account, + $this->order, + $this->type, + $this->card + ); + + return $this->send($requestData); + } +} From 16dd1fef2bfea623c5aac931bc7b80b0b54f8825 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 5 Mar 2023 21:06:37 +0100 Subject: [PATCH 32/54] rector.php - remove examples folder --- rector.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rector.php b/rector.php index 9d6e548a..8f56253c 100644 --- a/rector.php +++ b/rector.php @@ -8,7 +8,6 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->paths([ __DIR__.'/config', - __DIR__.'/examples', __DIR__.'/src', __DIR__.'/tests', ]); @@ -67,7 +66,7 @@ \Rector\CodeQuality\Rector\Assign\CombinedAssignRector::class, \Rector\CodingStyle\Rector\If_\NullableCompareToNullRector::class, - \Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::class, + //\Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::class, \Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class, \Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class, \Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector::class, From 1ea4c7ff8dc104403a63357de74430357290cdec Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Thu, 9 Mar 2023 21:30:47 +0100 Subject: [PATCH 33/54] VakifBankCP - added support for 3dPay ve 3dHost --- examples/template/_payment_response.php | 5 +- examples/vakifbank-cp/regular/cancel.php | 6 +- phpstan-baseline.neon | 5 + .../VakifBankCPPosResponseDataMapper.php | 60 +++++-- .../VakifBankCPPosRequestDataMapper.php | 15 +- src/Gateways/VakifBankCPPos.php | 27 ++- .../VakifBankCPPosResponseDataMapperTest.php | 153 ++++++++++++++++ tests/Gateways/VakifBankCPPosTest.php | 164 ++++++++++++++++++ 8 files changed, 390 insertions(+), 45 deletions(-) create mode 100644 tests/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapperTest.php create mode 100644 tests/Gateways/VakifBankCPPosTest.php diff --git a/examples/template/_payment_response.php b/examples/template/_payment_response.php index 0b0d138f..9fb83b89 100644 --- a/examples/template/_payment_response.php +++ b/examples/template/_payment_response.php @@ -7,7 +7,10 @@ require_once '_config.php'; require '../../template/_header.php'; -if ($request->getMethod() !== 'POST' && AbstractGateway::TX_POST_PAY !== $transaction) { +if (($request->getMethod() !== 'POST' && AbstractGateway::TX_POST_PAY !== $transaction) + // Vakifbank-CP GET request ile cevapliyor + && ($request->getMethod() === 'GET' && [] === $request->query->all()) +) { echo new RedirectResponse($baseUrl); exit(); } diff --git a/examples/vakifbank-cp/regular/cancel.php b/examples/vakifbank-cp/regular/cancel.php index 232628be..83c0c1b9 100644 --- a/examples/vakifbank-cp/regular/cancel.php +++ b/examples/vakifbank-cp/regular/cancel.php @@ -6,11 +6,9 @@ $templateTitle = 'Cancel Order'; require '../../template/_header.php'; -$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); - $order = [ - 'id' => $order['id'], //ReferenceTransactionId - 'ip' => $order['ip'], + 'id' => $session->get('ref_ret_num'), //ReferenceTransactionId + 'ip' => $request->getClientIp(), ]; $transaction = AbstractGateway::TX_CANCEL; $pos->prepare($order, $transaction); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d88fc055..32bf448b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1980,6 +1980,11 @@ parameters: count: 1 path: src/Gateways/VakifBankCPPos.php + - + message: "#^Parameter \\#1 \\$raw3DAuthResponseData of method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\VakifBankCPPosResponseDataMapper\\:\\: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\\.$#" + count: 1 + path: src/Gateways/VakifBankCPPos.php + - message: "#^Parameter \\#6 \\$extraData of method Mews\\\\Pos\\\\DataMapper\\\\VakifBankCPPosRequestDataMapper\\:\\:create3DFormData\\(\\) expects array\\{CommonPaymentUrl\\: string, PaymentToken\\: string\\}, array\\{CommonPaymentUrl\\: string\\|null, PaymentToken\\: string\\|null, ErrorCode\\: null, ResponseMessage\\: string\\|null\\} given\\.$#" count: 1 diff --git a/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php index 7151ec13..28eb49e9 100644 --- a/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php @@ -44,18 +44,10 @@ public function map3DPayResponseData(array $raw3DAuthResponseData): array { $raw3DAuthResponseData = $this->emptyStringsToNull($raw3DAuthResponseData); - /** - * Bir işlem sanal posa gönderilemeden hatayla sonuçlandıysa response'da ErrorCode degeri yer alacak. - */ - $errorCode = $raw3DAuthResponseData['ErrorCode'] ?? null; - if (null !== $errorCode) { - $paymentResponse = $this->getDefaultPaymentResponse(); - $paymentResponse['error_code'] = $errorCode; - - return $paymentResponse; - } - $paymentResponse = $this->getCommonPaymentResponse($raw3DAuthResponseData); + $paymentResponse['md_status'] = null; + $paymentResponse['md_error_message'] = null; + $paymentResponse['transaction_security'] = null; $paymentResponse['trans_id'] = $raw3DAuthResponseData['TransactionId']; $paymentResponse['masked_number'] = $raw3DAuthResponseData['MaskedPan']; @@ -63,11 +55,7 @@ public function map3DPayResponseData(array $raw3DAuthResponseData): array if (self::TX_APPROVED === $paymentResponse['status']) { $paymentResponse['auth_code'] = $raw3DAuthResponseData['AuthCode']; $paymentResponse['ref_ret_num'] = $raw3DAuthResponseData['TransactionId']; - } else { - /** - * Sanal POS gönderilmiş ve hata oluşmuş - */ - $paymentResponse['error_message'] = $raw3DAuthResponseData['Message']; + $paymentResponse['order_id'] = $raw3DAuthResponseData['OrderID']; } return $paymentResponse; @@ -106,7 +94,7 @@ public function mapCancelResponse(array $rawResponseData): array { $rawResponseData = $this->emptyStringsToNull($rawResponseData); - $response = $this->getCommonPaymentResponse($rawResponseData); + $response = $this->getCommonNonSecureResponse($rawResponseData); if (self::TX_APPROVED === $response['status']) { $response['order_id'] = $rawResponseData['TransactionId']; @@ -162,6 +150,44 @@ private function getCommonPaymentResponse(array $responseData): array $status = self::TX_DECLINED; $resultCode = $this->getProcReturnCode($responseData); + $errorCode = $responseData['ErrorCode'] ?? null; + $errorMsg = null; + if (null !== $errorCode) { + $resultCode = $errorCode; + $errorMsg = $responseData['Message']; + } else { + if (self::PROCEDURE_SUCCESS_CODE === $resultCode) { + $status = self::TX_APPROVED; + } else { + $errorMsg = $responseData['Message']; + } + } + + $response = $this->getDefaultPaymentResponse(); + + $response['proc_return_code'] = $resultCode; + $response['status'] = $status; + $response['status_detail'] = null; + $response['error_code'] = (self::TX_DECLINED === $status) ? $resultCode : null; + $response['error_message'] = $errorMsg; + $response['all'] = $responseData; + + return $response; + } + + /** + * @param array $responseData + * + * @return array{order_id: string|null, trans_id: string|null, auth_code: string|null, + * ref_ret_num: string|null, proc_return_code: string|null, + * status: string, status_detail: string|null, error_code: string|null, + * error_message: string|null, all: array} + */ + private function getCommonNonSecureResponse(array $responseData): array + { + $status = self::TX_DECLINED; + $resultCode = $this->getProcReturnCode($responseData); + $errorCode = $responseData['ErrorCode'] ?? null; $statusDetail = null; if (null !== $errorCode) { diff --git a/src/DataMapper/VakifBankCPPosRequestDataMapper.php b/src/DataMapper/VakifBankCPPosRequestDataMapper.php index a18dfdf2..a46d9584 100644 --- a/src/DataMapper/VakifBankCPPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankCPPosRequestDataMapper.php @@ -72,7 +72,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $account, $order, /** * @param VakifBankAccount $account - * @param array{TransactionId: string, Ptkn: string} $responseData + * @param array{TransactionId: string, PaymentToken: string} $responseData * * @return array{HostMerchantId: string, Password: string, TransactionId: string, PaymentToken: string} */ @@ -82,7 +82,7 @@ public function create3DPaymentStatusRequestData(AbstractPosAccount $account, ar 'HostMerchantId' => $account->getClientId(), 'Password' => $account->getPassword(), 'TransactionId' => $responseData['TransactionId'], - 'PaymentToken' => $responseData['Ptkn'], + 'PaymentToken' => $responseData['PaymentToken'], ]; } @@ -109,13 +109,14 @@ public function create3DEnrollmentCheckRequestData(AbstractPosAccount $account, 'AmountCode' => $this->mapCurrency($order->currency), 'Amount' => self::amountFormat($order->amount), 'OrderID' => (string) $order->id, - 'OrderDescription' => '', + 'OrderDescription' => (string) ($order->description ?? null), 'IsSecure' => 'true', // Işlemin 3D yapılıp yapılmayacağına dair flag, alabileceği değerler: 'true', 'false' /** - * Kart sahibi 3D Secure programına dahil değil - * ise işlemin Vposa gönderilip - * gönderilmeyeceği ile ilgili flag. - * Alabileceği değerler: 'true', 'false' + * 3D Programına Dahil Olmayan Kartlar ile İşlem Yapma Flagi: "3D İşlem Flagi" (IsSecure) "true" gönderilmiş + * işlemler için bir alt seçenektir. Kart sahibi "3D Secure" programına dahil değilse Ortak Ödemenin işlemi + * Sanal Pos'a gönderip göndermeyeceğini belirtir. "true" gönderilmesi durumunda kart sahibi + * 3D Secure programına dahil olmasa bile işlemi Sanal Pos'a gönderecektir. + * Bu tür işlemler "Half Secure" olarak işaretlenecektir. */ 'AllowNotEnrolledCard' => 'false', 'SuccessUrl' => (string) $order->success_url, diff --git a/src/Gateways/VakifBankCPPos.php b/src/Gateways/VakifBankCPPos.php index 2affea10..f5e2e0f7 100644 --- a/src/Gateways/VakifBankCPPos.php +++ b/src/Gateways/VakifBankCPPos.php @@ -16,8 +16,7 @@ use Symfony\Component\Serializer\Exception\NotEncodableValueException; /** - * ORTAK ÖDEME - * Class VakifBankCommonPaymentPos + * ORTAK ÖDEME (Common Payment) API */ class VakifBankCPPos extends AbstractGateway { @@ -33,7 +32,7 @@ class VakifBankCPPos extends AbstractGateway protected $responseDataMapper; /** @return VakifBankAccount */ - public function getAccount() + public function getAccount(): VakifBankAccount { return $this->account; } @@ -48,29 +47,25 @@ public function make3DPayment(Request $request) } /** - * TODO check if it is working * @inheritDoc */ - public function make3DPayPayment(Request $request) + public function make3DPayPayment(Request $request): self { - $errorCode = $request->query->get('RC'); - $errorMsg = $request->query->get('MSG'); - if (null !== $errorCode) { + $resultCode = $request->query->get('Rc'); + if (null !== $resultCode && $this->responseDataMapper::PROCEDURE_SUCCESS_CODE !== $resultCode) { $this->logger->error('received error response from the bank', $request->query->all()); - $bankResponse = [ - 'ErrorCode' => (string) $errorCode, - ]; - $this->response = $this->responseDataMapper->map3DPayResponseData($bankResponse); + $this->response = $this->responseDataMapper->map3DPayResponseData($request->query->all()); return $this; } - /** @var array{TransactionId: string, Ptkn: string} $queryParams */ + /** @var array{TransactionId: string, PaymentToken: string} $queryParams */ $queryParams = $request->query->all(); $statusRequestData = $this->requestDataMapper->create3DPaymentStatusRequestData($this->account, $queryParams); - - /** @var array{ErrorCode: string}|array{ + /** + * sending request to make sure that payment was successful + * @var array{ErrorCode: string}|array{ * Rc: string, * AuthCode: string, * TransactionId: string, @@ -92,7 +87,7 @@ public function make3DPayPayment(Request $request) /** * @inheritDoc */ - public function make3DHostPayment(Request $request) + public function make3DHostPayment(Request $request): self { return $this->make3DPayPayment($request); } diff --git a/tests/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapperTest.php new file mode 100644 index 00000000..514033b1 --- /dev/null +++ b/tests/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapperTest.php @@ -0,0 +1,153 @@ +responseDataMapper = new VakifBankCPPosResponseDataMapper( + $requestDataMapper->getCurrencyMappings(), + $requestDataMapper->getTxTypeMappings(), + new NullLogger() + ); + } + + /** + * @dataProvider threesDPayResponseSamplesProvider + */ + public function testMap3DPayResponseData(array $bankResponse, array $expected): void + { + $actual = $this->responseDataMapper->map3DPayResponseData($bankResponse); + + $this->assertNotEmpty($actual['all']); + unset($actual['all']); + $this->assertSame($expected, $actual); + } + + public static function threesDPayResponseSamplesProvider(): Generator + { + yield 'fail_response_from_gateway_1' => [ + 'bank_response' => [ + 'Rc' => '2053', + 'Message' => 'VeRes status is E Message : Directory server communication error', + 'PaymentToken' => '68244b7e3dfd4b3ebea1afbe0185b9ed', + 'TransactionId' => '0cb6a57715144178a014afbe0185b9ed', + 'MaskedPan' => '49384601****4205', + ], + 'expected' => [ + 'order_id' => null, + 'trans_id' => '0cb6a57715144178a014afbe0185b9ed', + 'auth_code' => null, + 'ref_ret_num' => null, + 'proc_return_code' => '2053', + 'status' => 'declined', + 'status_detail' => null, + 'error_code' => '2053', + 'error_message' => 'VeRes status is E Message : Directory server communication error', + 'md_status' => null, + 'md_error_message' => null, + 'transaction_security' => null, + 'masked_number' => '49384601****4205', + ], + ]; + + yield 'fail_response_from_gateway_2' => [ + 'bank_response' => [ + 'Rc' => '0057', + 'AuthCode' => '000000', + 'ErrorCode' => '0057', + 'Message' => 'RED-KARTIN İŞLEM İZNİ YOK', + 'PaymentToken' => '5aeb359892f8400b9d0fafbd016c7636', + 'TransactionId' => '868382724da7480c949dafbd016c7636', + 'MaskedPan' => '49384601****4205', + ], + 'expected' => [ + 'order_id' => null, + 'trans_id' => '868382724da7480c949dafbd016c7636', + 'auth_code' => null, + 'ref_ret_num' => null, + 'proc_return_code' => '0057', + 'status' => 'declined', + 'status_detail' => null, + 'error_code' => '0057', + 'error_message' => 'RED-KARTIN İŞLEM İZNİ YOK', + 'md_status' => null, + 'md_error_message' => null, + 'transaction_security' => null, + 'masked_number' => '49384601****4205', + ], + ]; + + yield 'success_response_from_gateway_1' => [ + 'bank_response' => [ + 'Rc' => '0000', + 'AuthCode' => '735879', + 'Rrn' => '306822971283', + 'Message' => 'İŞLEM BAŞARILI', + 'TransactionId' => '3ee068d5b5a747ada65dafc0016d5887', + 'PaymentToken' => 'b35a56bf37334872a945afc0016d5887', + 'MaskedPan' => '49384601****4205', + 'HostMerchantId' => '000100000013506', + 'HostTerminalId' => 'VP000579', + 'AmountCode' => '949', + 'Amount' => '1,01', + 'TransactionType' => 'Sale', + 'OrderID' => '2023030913ED', + 'OrderDescription' => null, + 'InstallmentCount' => '', + 'IsSecure' => 'True', + 'AllowNotEnrolledCard' => 'True', + 'SuccessUrl' => 'http://localhost/vakifbank-cp/3d-host/response.php', + 'FailUrl' => 'http://localhost/vakifbank-cp/3d-host/response.php', + 'RequestLanguage' => 'tr-TR', + 'Extract' => null, + 'CardHoldersName' => 'Jo* Do*', + 'CustomItems' => null, + 'ExpireMonth' => '11', + 'ExpireYear' => '2024', + 'BrandNumber' => '100', + 'HostDate' => '20230309221037', + 'HostRc' => null, + 'CampaignResult' => [ + 'CampaignInfo' => [], + ], + 'ErrorCode' => null, + 'ResponseMessage' => null, + ], + 'expected' => [ + 'order_id' => '2023030913ED', + 'trans_id' => '3ee068d5b5a747ada65dafc0016d5887', + 'auth_code' => '735879', + 'ref_ret_num' => '3ee068d5b5a747ada65dafc0016d5887', + 'proc_return_code' => '0000', + 'status' => 'approved', + 'status_detail' => null, + 'error_code' => null, + 'error_message' => null, + 'md_status' => null, + 'md_error_message' => null, + 'transaction_security' => null, + 'masked_number' => '49384601****4205', + ], + ]; + } +} diff --git a/tests/Gateways/VakifBankCPPosTest.php b/tests/Gateways/VakifBankCPPosTest.php new file mode 100644 index 00000000..f9e5369a --- /dev/null +++ b/tests/Gateways/VakifBankCPPosTest.php @@ -0,0 +1,164 @@ +config = require __DIR__.'/../../config/pos.php'; + + $this->account = AccountFactory::createVakifBankAccount( + 'vakifbank-cp', + '000000000111111', + '3XTgER89as', + 'VP999999', + AbstractGateway::MODEL_3D_SECURE + ); + + + $this->order = [ + 'id' => 'order222', + 'name' => 'siparis veren', + 'email' => 'test@test.com', + 'amount' => 100.00, + 'installment' => 0, + 'currency' => 'TRY', + 'success_url' => 'https://domain.com/success', + 'fail_url' => 'https://domain.com/fail_url', + 'rand' => microtime(true), + 'extraData' => microtime(true), + 'ip' => '127.0.0.1', + ]; + + $this->pos = PosFactory::createPosGateway($this->account); + + $this->pos->setTestMode(true); + $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '2021', '12', '122', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA); + } + + /** + * @return void + */ + public function testInit(): void + { + $this->assertEquals($this->config['banks'][$this->account->getBank()], $this->pos->getConfig()); + $this->assertEquals($this->account, $this->pos->getAccount()); + $this->assertNotEmpty($this->pos->getCurrencies()); + } + + /** + * @return void + */ + public function testPrepare(): void + { + $this->pos->prepare($this->order, AbstractGateway::TX_PAY, $this->card); + $this->assertEquals($this->card, $this->pos->getCard()); + + $this->pos->prepare($this->order, AbstractGateway::TX_POST_PAY); + } + + /** + * @return void + * + * @throws Exception + */ + public function testGet3DFormDataEnrollmentFail(): void + { + $this->expectException(Exception::class); + $this->expectExceptionCode(2005); + $vakifBankPosRequestDataMapperTest = new VakifBankPosRequestDataMapperTest(); + + $requestMapper = PosFactory::getGatewayRequestMapper(VakifBankPos::class); + $responseMapper = PosFactory::getGatewayResponseMapper(VakifBankPos::class, $requestMapper, new NullLogger()); + + $posMock = $this->getMockBuilder(VakifBankPos::class) + ->setConstructorArgs([ + [], + $this->account, + $requestMapper, + $responseMapper, + HttpClientFactory::createDefaultHttpClient(), + new NullLogger() + ]) + ->onlyMethods(['sendEnrollmentRequest']) + ->getMock(); + $posMock->setTestMode(true); + $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); + $posMock->expects($this->once())->method('sendEnrollmentRequest') + ->willReturn($vakifBankPosRequestDataMapperTest->getSampleEnrollmentFailResponseData()); + + $posMock->get3DFormData(); + } + + + public function testGet3DFormDataSuccess(): void + { + $vakifBankPosRequestDataMapperTest = new VakifBankPosRequestDataMapperTest(); + $enrollmentResponse = $vakifBankPosRequestDataMapperTest->getSampleEnrollmentSuccessResponseData(); + + $requestMapper = PosFactory::getGatewayRequestMapper(VakifBankPos::class); + $responseMapper = PosFactory::getGatewayResponseMapper(VakifBankPos::class, $requestMapper, new NullLogger()); + + $posMock = $this->getMockBuilder(VakifBankPos::class) + ->setConstructorArgs([ + [], + $this->account, + $requestMapper, + $responseMapper, + HttpClientFactory::createDefaultHttpClient(), + new NullLogger() + ]) + ->onlyMethods(['sendEnrollmentRequest']) + ->getMock(); + $posMock->setTestMode(true); + $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); + $posMock->expects($this->once())->method('sendEnrollmentRequest') + ->willReturn($enrollmentResponse); + + $result = $posMock->get3DFormData(); + $expected = [ + 'gateway' => $enrollmentResponse['Message']['VERes']['ACSUrl'], + 'method' => 'POST', + 'inputs' => [ + 'PaReq' => $enrollmentResponse['Message']['VERes']['PaReq'], + 'TermUrl' => $enrollmentResponse['Message']['VERes']['TermUrl'], + 'MD' => $enrollmentResponse['Message']['VERes']['MD'], + ], + ]; + + $this->assertSame($expected, $result); + } +} From af3efc6362533e81184e1520bd2e27ae1414ee86 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Fri, 10 Mar 2023 18:21:21 +0100 Subject: [PATCH 34/54] VakifBank VPOS - fix undefined index errors --- examples/vakifbank/_payment_config.php | 6 +- examples/vakifbank/regular/cancel.php | 6 +- examples/vakifbank/regular/refund.php | 4 +- phpstan-baseline.neon | 10 - .../VakifBankPosResponseDataMapper.php | 47 +-- .../VakifBankPosResponseDataMapperTest.php | 308 +++++++++++++++++- 6 files changed, 327 insertions(+), 54 deletions(-) diff --git a/examples/vakifbank/_payment_config.php b/examples/vakifbank/_payment_config.php index be2c4a50..8ceaf2aa 100644 --- a/examples/vakifbank/_payment_config.php +++ b/examples/vakifbank/_payment_config.php @@ -76,10 +76,10 @@ function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\ $testCards = [ 'visa1' => [ - 'number' => '4543600299100712', - 'year' => '23', + 'number' => '4938460158754205', + 'year' => '24', 'month' => '11', - 'cvv' => '454', + 'cvv' => '715', 'name' => 'John Doe', 'type' => AbstractCreditCard::CARD_TYPE_VISA, ], diff --git a/examples/vakifbank/regular/cancel.php b/examples/vakifbank/regular/cancel.php index 232628be..83c0c1b9 100644 --- a/examples/vakifbank/regular/cancel.php +++ b/examples/vakifbank/regular/cancel.php @@ -6,11 +6,9 @@ $templateTitle = 'Cancel Order'; require '../../template/_header.php'; -$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); - $order = [ - 'id' => $order['id'], //ReferenceTransactionId - 'ip' => $order['ip'], + 'id' => $session->get('ref_ret_num'), //ReferenceTransactionId + 'ip' => $request->getClientIp(), ]; $transaction = AbstractGateway::TX_CANCEL; $pos->prepare($order, $transaction); diff --git a/examples/vakifbank/regular/refund.php b/examples/vakifbank/regular/refund.php index 9440d95c..f0ae4d18 100644 --- a/examples/vakifbank/regular/refund.php +++ b/examples/vakifbank/regular/refund.php @@ -9,9 +9,9 @@ $order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); // Refund Order $order = [ - 'id' => $order['id'], //ReferenceTransactionId + 'id' => $session->get('ref_ret_num'), //ReferenceTransactionId + 'ip' => $request->getClientIp(), 'amount' => $order['amount'], - 'ip' => $order['ip'], ]; $transaction = AbstractGateway::TX_REFUND; $pos->prepare($order, $transaction); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 32bf448b..355d5eb3 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -775,16 +775,6 @@ parameters: count: 1 path: src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\VakifBankPosResponseDataMapper\\:\\:map3DPaymentData\\(\\) should return array\\ but returns array\\\\|float\\|string\\|null\\>\\.$#" - count: 1 - path: src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php - - - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\VakifBankPosResponseDataMapper\\:\\:map3DPaymentData\\(\\) should return array\\ but returns array\\\\|string\\|null\\>\\.$#" - count: 1 - path: src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php - - message: "#^Access to an undefined property object\\:\\:\\$amount\\.$#" count: 2 diff --git a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php index 8e8b4575..ba99671f 100644 --- a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php @@ -26,31 +26,32 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen '3d_auth_response' => $raw3DAuthResponseData, 'provision_response' => $rawPaymentResponseData, ]); - $threeDAuthStatus = ('Y' === $raw3DAuthResponseData['Status']) ? self::TX_APPROVED : self::TX_DECLINED; - $paymentResponseData = []; + $raw3DAuthResponseData = $this->emptyStringsToNull($raw3DAuthResponseData); + $threeDAuthStatus = ('Y' === $raw3DAuthResponseData['Status']) ? self::TX_APPROVED : self::TX_DECLINED; if (self::TX_APPROVED === $threeDAuthStatus && null !== $rawPaymentResponseData) { $paymentResponseData = $this->mapPaymentResponse($rawPaymentResponseData); + } else { + $paymentResponseData = $this->getDefaultPaymentResponse(); } $threeDResponse = [ - 'eci' => $raw3DAuthResponseData['Eci'], - 'cavv' => $raw3DAuthResponseData['Cavv'], - 'auth_code' => null, - 'order_id' => $raw3DAuthResponseData['VerifyEnrollmentRequestId'], - 'status' => $threeDAuthStatus, - 'status_detail' => null, - 'error_code' => self::TX_DECLINED === $threeDAuthStatus ? $raw3DAuthResponseData['ErrorCode'] : null, - 'error_message' => self::TX_DECLINED === $threeDAuthStatus ? $raw3DAuthResponseData['ErrorMessage'] : null, - 'all' => $rawPaymentResponseData, - '3d_all' => $raw3DAuthResponseData, + 'eci' => $raw3DAuthResponseData['Eci'], + 'cavv' => $raw3DAuthResponseData['Cavv'], + 'auth_code' => null, + 'order_id' => $raw3DAuthResponseData['VerifyEnrollmentRequestId'], + 'status' => $threeDAuthStatus, + 'status_detail' => null, + 'error_code' => self::TX_DECLINED === $threeDAuthStatus ? $raw3DAuthResponseData['ErrorCode'] : null, + 'error_message' => self::TX_DECLINED === $threeDAuthStatus ? $raw3DAuthResponseData['ErrorMessage'] : null, + 'md_status' => $raw3DAuthResponseData['Status'], + 'md_error_message' => self::TX_DECLINED === $threeDAuthStatus ? $raw3DAuthResponseData['ErrorMessage'] : null, + 'transaction_security' => null, + 'all' => $rawPaymentResponseData, + '3d_all' => $raw3DAuthResponseData, ]; - if ($paymentResponseData === []) { - return array_merge($this->getDefaultPaymentResponse(), $threeDResponse); - } - - return array_merge($threeDResponse, $paymentResponseData); + return $this->mergeArraysPreferNonNullValues($threeDResponse, $paymentResponseData); } /** @@ -95,7 +96,7 @@ public function mapCancelResponse($rawResponseData): array 'ref_ret_num' => $rawResponseData['Rrn'] ?? null, 'proc_return_code' => $resultCode, 'trans_id' => $rawResponseData['TransactionId'] ?? null, - 'error_code' => (self::TX_DECLINED === $status) ? $rawResponseData['ResultDetail'] : null, + 'error_code' => (self::TX_DECLINED === $status) ? $resultCode : null, 'error_message' => (self::TX_DECLINED === $status) ? $rawResponseData['ResultDetail'] : null, 'status' => $status, 'status_detail' => $rawResponseData['ResultDetail'], @@ -117,15 +118,15 @@ public function mapStatusResponse(array $rawResponseData): array public function mapPaymentResponse(array $rawPaymentResponseData): array { $this->logger->log(LogLevel::DEBUG, 'mapping payment response', [$rawPaymentResponseData]); - $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); - $commonResponse = $this->getCommonPaymentResponse($rawPaymentResponseData); + $rawPaymentResponseData = $this->emptyStringsToNull($rawPaymentResponseData); + $commonResponse = $this->getCommonPaymentResponse($rawPaymentResponseData); + $commonResponse['order_id'] = $rawPaymentResponseData['OrderId'] ?? null; + if (self::TX_APPROVED === $commonResponse['status']) { $commonResponse['trans_id'] = $rawPaymentResponseData['TransactionId']; $commonResponse['auth_code'] = $rawPaymentResponseData['AuthCode']; - $commonResponse['ref_ret_num'] = $rawPaymentResponseData['Rrn']; - $commonResponse['order_id'] = $rawPaymentResponseData['OrderId']; + $commonResponse['ref_ret_num'] = $rawPaymentResponseData['TransactionId']; $commonResponse['transaction_type'] = $this->mapTxType($rawPaymentResponseData['TransactionType']); - $commonResponse['eci'] = $rawPaymentResponseData['ECI']; } $this->logger->log(LogLevel::DEBUG, 'mapped payment response', $commonResponse); diff --git a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php index afd5e549..2024b2f4 100644 --- a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php @@ -27,7 +27,7 @@ protected function setUp(): void /** * @dataProvider threeDPaymentDataProvider */ - public function testMap3DPaymentData(array $threeDResponseData, array $paymentResponse, array $expectedData) + public function testMap3DPaymentData(array $threeDResponseData, array $paymentResponse, array $expectedData): void { $actualData = $this->responseDataMapper->map3DPaymentData($threeDResponseData, $paymentResponse); unset($actualData['all']); @@ -35,7 +35,226 @@ public function testMap3DPaymentData(array $threeDResponseData, array $paymentRe $this->assertSame($expectedData, $actualData); } - public function threeDPaymentDataProvider(): array + /** + * @dataProvider paymentDataProvider + */ + public function testMapPaymentResponse(array $paymentResponse, array $expectedData): void + { + $actualData = $this->responseDataMapper->mapPaymentResponse($paymentResponse); + unset($actualData['all']); + $this->assertSame($expectedData, $actualData); + } + + /** + * @dataProvider cancelDataProvider + */ + public function testMapCancelResponse(array $paymentResponse, array $expectedData): void + { + $actualData = $this->responseDataMapper->mapCancelResponse($paymentResponse); + unset($actualData['all']); + $this->assertSame($expectedData, $actualData); + } + + /** + * @dataProvider refundDataProvider + */ + public function testMapRefundResponse(array $paymentResponse, array $expectedData) + { + $actualData = $this->responseDataMapper->mapRefundResponse($paymentResponse); + unset($actualData['all']); + $this->assertSame($expectedData, $actualData); + } + + public static function refundDataProvider(): iterable + { + yield 'success_1' => [ + 'responseData' => [ + 'MerchantId' => '000100000013506', + 'TransactionType' => 'Refund', + 'TransactionId' => '455ae6c09140434ea6edafc0018acbb9', + 'ReferenceTransactionId' => '6d491ea480564068976fafc0018a9def', + 'ResultCode' => '0000', + 'ResultDetail' => 'İŞLEM BAŞARILI', + 'InstallmentTable' => null, + 'CampaignResult' => null, + 'AuthCode' => '752800', + 'HostDate' => '20230309235724', + 'Rrn' => '306823971382', + 'TerminalNo' => 'VP000579', + 'CurrencyAmount' => '1.01', + 'CurrencyCode' => '949', + 'BatchNo' => '300', + 'TLAmount' => '1.01', + ], + 'expectedData' => [ + 'order_id' => '455ae6c09140434ea6edafc0018acbb9', + 'auth_code' => '752800', + 'ref_ret_num' => '306823971382', + 'proc_return_code' => '0000', + 'trans_id' => '455ae6c09140434ea6edafc0018acbb9', + 'error_code' => null, + 'error_message' => null, + 'status' => 'approved', + 'status_detail' => 'İŞLEM BAŞARILI', + ], + ]; + + yield 'fail_1' => [ + 'responseData' => [ + 'ResultCode' => '1059', + 'ResultDetail' => 'İşlemin tamamı iade edilmiş.', + 'InstallmentTable' => null, + ], + 'expectedData' => [ + 'order_id' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'proc_return_code' => '1059', + 'trans_id' => null, + 'error_code' => '1059', + 'error_message' => 'İşlemin tamamı iade edilmiş.', + 'status' => 'declined', + 'status_detail' => 'İşlemin tamamı iade edilmiş.' + ], + ]; + } + + public static function cancelDataProvider(): iterable + { + yield 'success_1' => [ + 'responseData' => [ + 'MerchantId' => '000100000013506', + 'TransactionType' => 'Cancel', + 'TransactionId' => '4a8e979308de4568b500afc00187a501', + 'ReferenceTransactionId' => '3f30ab117aa74826b448afc0018789fa', + 'ResultCode' => '0000', + 'ResultDetail' => 'İŞLEM BAŞARILI', + 'InstallmentTable' => null, + 'CampaignResult' => null, + 'AuthCode' => '836044', + 'HostDate' => '20230309234556', + 'Rrn' => '306823971363', + 'TerminalNo' => 'VP000579', + 'CurrencyAmount' => '1.01', + 'CurrencyCode' => '949', + 'BatchNo' => '300', + 'TLAmount' => '1.01', + ], + 'expectedData' => [ + 'order_id' => '4a8e979308de4568b500afc00187a501', + 'auth_code' => '836044', + 'ref_ret_num' => '306823971363', + 'proc_return_code' => '0000', + 'trans_id' => '4a8e979308de4568b500afc00187a501', + 'error_code' => null, + 'error_message' => null, + 'status' => 'approved', + 'status_detail' => 'İŞLEM BAŞARILI', + ], + ]; + + yield 'fail_1' => [ + 'responseData' => [ + 'ResultCode' => '1083', + 'ResultDetail' => 'Referans islem daha önceden iptal edilmis.', + 'InstallmentTable' => null, + ], + 'expectedData' => [ + 'order_id' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'proc_return_code' => '1083', + 'trans_id' => null, + 'error_code' => '1083', + 'error_message' => 'Referans islem daha önceden iptal edilmis.', + 'status' => 'declined', + 'status_detail' => 'Referans islem daha önceden iptal edilmis.', + ], + ]; + } + public static function paymentDataProvider(): iterable + { + yield 'success_1' => [ + 'responseData' => [ + 'MerchantId' => '000100000013506', + 'TransactionType' => 'Sale', + 'TransactionId' => '9972767117b3400eb2acafc0018643df', + 'ResultCode' => '0000', + 'ResultDetail' => 'İŞLEM BAŞARILI', + 'CustomItems' => [ + 'Item' => [ + '@name' => 'CardHolderName', + '@value' => 'AR* ÖZ*', + '#' => null, + ], + ], + 'InstallmentTable' => null, + 'CampaignResult' => null, + 'AuthCode' => '961451', + 'HostDate' => '20230309234054', + 'Rrn' => '306823971358', + 'TerminalNo' => 'VP000579', + 'GainedPoint' => '10.00', + 'TotalPoint' => '103032.52', + 'CurrencyAmount' => '1.01', + 'CurrencyCode' => '949', + 'OrderId' => '202303095646', + 'ThreeDSecureType' => '1', + 'TransactionDeviceSource' => '0', + 'BatchNo' => '300', + 'TLAmount' => '1.01', + ], + 'expectedData' => [ + 'trans_id' => '9972767117b3400eb2acafc0018643df', + 'auth_code' => '961451', + 'ref_ret_num' => '9972767117b3400eb2acafc0018643df', + 'order_id' => '202303095646', + 'eci' => null, + 'proc_return_code' => '0000', + 'status' => 'approved', + 'status_detail' => 'İŞLEM BAŞARILI', + 'error_code' => null, + 'error_message' => null, + 'transaction_type' => 'pay', + ], + ]; + + yield 'fail_1' => [ + 'responseData' => [ + 'MerchantId' => '000100000013506', + 'TransactionType' => 'Sale', + 'TransactionId' => '9b47227c275246d39454afc00186dfba', + 'ResultCode' => '0312', + 'ResultDetail' => 'RED-GEÇERSİZ KART', + 'InstallmentTable' => null, + 'CampaignResult' => null, + 'AuthCode' => '000000', + 'HostDate' => '20230309234307', + 'Rrn' => '306823971359', + 'TerminalNo' => 'VP000579', + 'CurrencyAmount' => '1.01', + 'CurrencyCode' => '949', + 'OrderId' => '20230309EF68', + 'ThreeDSecureType' => '1', + 'TransactionDeviceSource' => '0', + 'BatchNo' => '300', + 'TLAmount' => '1.01' + ], + 'expectedData' => [ + 'trans_id' => null, + 'auth_code' => null, + 'ref_ret_num' => null, + 'order_id' => '20230309EF68', + 'eci' => null, + 'proc_return_code' => '0312', + 'status' => 'declined', + 'status_detail' => 'RED-GEÇERSİZ KART', + 'error_code' => '0312', + 'error_message' => 'RED-GEÇERSİZ KART', + ], + ]; + } + public static function threeDPaymentDataProvider(): array { return [ 'authFail1' => [ @@ -61,17 +280,79 @@ public function threeDPaymentDataProvider(): array ], 'paymentData' => [], 'expectedData' => [ - 'order_id' => 'order-id-123', + 'eci' => '02', + 'cavv' => 'AAABBBBBBBBBBBBBBBIIIIII=', + 'md_status' => 'E', + 'md_error_message' => 'Üye isyeri IP si sistemde tanimli degil', + 'transaction_security' => null, 'trans_id' => null, - 'auth_code' => null, 'ref_ret_num' => null, 'proc_return_code' => null, + 'auth_code' => null, + 'order_id' => 'order-id-123', 'status' => 'declined', 'status_detail' => null, 'error_code' => '1105', 'error_message' => 'Üye isyeri IP si sistemde tanimli degil', - 'eci' => '02', - 'cavv' => 'AAABBBBBBBBBBBBBBBIIIIII=', + ], + ], + 'auth_success_payment_fail' => [ + 'threeDResponseData' => [ + 'MerchantId' => '000100000013506', + 'Pan' => '4938460158754205', + 'Expiry' => '2411', + 'PurchAmount' => '101', + 'PurchCurrency' => '949', + 'VerifyEnrollmentRequestId' => 'ce06048a3e9c0cd1d437803fb38b5ad0', + 'Xid' => 'ondg8d9t5besgt88sk8h', + 'SessionInfo' => 'jpf58sdjj8p9mpb9shurh47v64', + 'Status' => 'Y', + 'Cavv' => 'ABIBCBgAAAEnAAABAQAAAAAAAAA=', + 'Eci' => '05', + 'ExpSign' => null, + 'InstallmentCount' => null, + 'SubMerchantNo' => null, + 'SubMerchantName' => null, + 'SubMerchantNumber' => null, + 'ErrorCode' => null, + 'ErrorMessage' => null, + ], + 'paymentData' => [ + 'MerchantId' => '000100000013506', + 'TransactionType' => 'Sale', + 'TransactionId' => '202303091489', + 'ResultCode' => '0312', + 'ResultDetail' => 'RED-GEÇERSİZ KART', + 'InstallmentTable' => null, + 'CampaignResult' => null, + 'AuthCode' => '000000', + 'HostDate' => '20230309235359', + 'Rrn' => '306823971380', + 'TerminalNo' => 'VP000579', + 'CurrencyAmount' => '1.01', + 'CurrencyCode' => '949', + 'OrderId' => '202303091489', + 'ECI' => '05', + 'ThreeDSecureType' => '2', + 'TransactionDeviceSource' => '0', + 'BatchNo' => '300', + 'TLAmount' => '1.01', + ], + 'expectedData' => [ + 'cavv' => 'ABIBCBgAAAEnAAABAQAAAAAAAAA=', + 'md_status' => 'Y', + 'md_error_message' => null, + 'transaction_security' => null, + 'trans_id' => null, + 'ref_ret_num' => null, + 'proc_return_code' => '0312', + 'eci' => '05', + 'auth_code' => null, + 'order_id' => '202303091489', + 'status' => 'declined', + 'status_detail' => 'RED-GEÇERSİZ KART', + 'error_code' => '0312', + 'error_message' => 'RED-GEÇERSİZ KART', ], ], 'success1' => [ @@ -99,7 +380,7 @@ public function threeDPaymentDataProvider(): array 'MerchantId' => '000000000111111', 'TerminalNo' => 'VP999999', 'TransactionType' => 'Sale', - 'TransactionId' => null, + 'TransactionId' => '20230309B838', 'ResultCode' => '0000', 'ResultDetail' => 'İŞLEM BAŞARILI', 'CustomItems' => [], @@ -118,18 +399,21 @@ public function threeDPaymentDataProvider(): array 'BatchNo' => '1', ], 'expectedData' => [ - 'eci' => '02', 'cavv' => 'AAABBBBBBBBBBBBBBBIIIIII=', + 'md_status' => 'Y', + 'md_error_message' => null, + 'transaction_security' => null, + 'trans_id' => '20230309B838', + 'ref_ret_num' => '20230309B838', + 'proc_return_code' => '0000', + 'transaction_type' => 'pay', + 'eci' => '02', 'auth_code' => '822641', 'order_id' => 'order-id-123', 'status' => 'approved', 'status_detail' => 'İŞLEM BAŞARILI', 'error_code' => null, 'error_message' => null, - 'trans_id' => null, - 'ref_ret_num' => '209411062014', - 'proc_return_code' => '0000', - 'transaction_type' => 'pay', ] ], ]; From 1cbe9ea47fc75a7d5d2216f64c6e899b8085ca88 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Fri, 10 Mar 2023 22:12:24 +0100 Subject: [PATCH 35/54] PosFactory - refactor --- src/Factory/PosFactory.php | 124 +++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 66 deletions(-) diff --git a/src/Factory/PosFactory.php b/src/Factory/PosFactory.php index ed3ab1b1..adeab91a 100644 --- a/src/Factory/PosFactory.php +++ b/src/Factory/PosFactory.php @@ -2,6 +2,7 @@ /** * @license MIT */ + namespace Mews\Pos\Factory; use DomainException; @@ -76,11 +77,11 @@ public static function createPosGateway( if ($logger === null) { $logger = new NullLogger(); } - + if ($client === null) { $client = HttpClientFactory::createDefaultHttpClient(); } - + if (is_string($config)) { $config = require $config; } elseif (empty($config)) { @@ -92,10 +93,10 @@ public static function createPosGateway( throw new BankNotFoundException(); } - /** @var class-string $class Gateway Class*/ - $class = $config['banks'][$posAccount->getBank()]['class']; + /** @var class-string|null $class Gateway Class */ + $class = $config['banks'][$posAccount->getBank()]['class'] ?? null; - if (!$class) { + if (null === $class) { throw new BankClassNullException(); } @@ -103,7 +104,7 @@ public static function createPosGateway( if (isset($config['currencies'])) { $currencies = $config['currencies']; } - + $logger->debug('creating gateway for bank', ['bank' => $posAccount->getBank()]); $crypt = self::getGatewayCrypt($class, $logger); @@ -130,31 +131,28 @@ public static function createPosGateway( */ public static function getGatewayRequestMapper(string $gatewayClass, array $currencies = [], ?CryptInterface $crypt = null): AbstractRequestDataMapper { - if (null !== $crypt) { - switch ($gatewayClass) { - case EstPos::class: - return new EstPosRequestDataMapper($crypt, $currencies); - case EstV3Pos::class: - return new EstV3PosRequestDataMapper($crypt, $currencies); - case GarantiPos::class: - return new GarantiPosRequestDataMapper($crypt, $currencies); - case InterPos::class: - return new InterPosRequestDataMapper($crypt, $currencies); - case KuveytPos::class: - return new KuveytPosRequestDataMapper($crypt, $currencies); - case PayForPos::class: - return new PayForPosRequestDataMapper($crypt, $currencies); - case PosNet::class: - return new PosNetRequestDataMapper($crypt, $currencies); - case VakifBankCPPos::class: - return new VakifBankCPPosRequestDataMapper($crypt, $currencies); + $classMappings = [ + EstPos::class => EstPosRequestDataMapper::class, + EstV3Pos::class => EstV3PosRequestDataMapper::class, + GarantiPos::class => GarantiPosRequestDataMapper::class, + InterPos::class => InterPosRequestDataMapper::class, + KuveytPos::class => KuveytPosRequestDataMapper::class, + PayForPos::class => PayForPosRequestDataMapper::class, + PosNet::class => PosNetRequestDataMapper::class, + VakifBankCPPos::class => VakifBankCPPosRequestDataMapper::class, + ]; + if (isset($classMappings[$gatewayClass])) { + if (null === $crypt) { + throw new \InvalidArgumentException(sprintf('Gateway %s requires Crypt instance', $gatewayClass)); } + + return new $classMappings[$gatewayClass]($crypt, $currencies); } - + if ($gatewayClass === VakifBankPos::class) { return new VakifBankPosRequestDataMapper(null, $currencies); } - + throw new DomainException('unsupported gateway'); } @@ -167,28 +165,26 @@ public static function getGatewayRequestMapper(string $gatewayClass, array $curr */ public static function getGatewayResponseMapper(string $gatewayClass, AbstractRequestDataMapper $requestDataMapper, LoggerInterface $logger): AbstractResponseDataMapper { - $currencyMappings = $requestDataMapper->getCurrencyMappings(); - $txMappings = $requestDataMapper->getTxTypeMappings(); - switch ($gatewayClass) { - case EstV3Pos::class: - case EstPos::class: - return new EstPosResponseDataMapper($currencyMappings, $txMappings, $logger); - case GarantiPos::class: - return new GarantiPosResponseDataMapper($currencyMappings, $txMappings, $logger); - case InterPos::class: - return new InterPosResponseDataMapper($currencyMappings, $txMappings, $logger); - case KuveytPos::class: - return new KuveytPosResponseDataMapper($currencyMappings, $txMappings, $logger); - case PayForPos::class: - return new PayForPosResponseDataMapper($currencyMappings, $txMappings, $logger); - case PosNet::class: - return new PosNetResponseDataMapper($currencyMappings, $txMappings, $logger); - case VakifBankPos::class: - return new VakifBankPosResponseDataMapper($currencyMappings, $txMappings, $logger); - case VakifBankCPPos::class: - return new VakifBankCPPosResponseDataMapper($currencyMappings, $txMappings, $logger); + $classMappings = [ + EstV3Pos::class => EstPosResponseDataMapper::class, + EstPos::class => EstPosResponseDataMapper::class, + GarantiPos::class => GarantiPosResponseDataMapper::class, + InterPos::class => InterPosResponseDataMapper::class, + KuveytPos::class => KuveytPosResponseDataMapper::class, + PayForPos::class => PayForPosResponseDataMapper::class, + PosNet::class => PosNetResponseDataMapper::class, + VakifBankPos::class => VakifBankPosResponseDataMapper::class, + VakifBankCPPos::class => VakifBankCPPosResponseDataMapper::class, + ]; + + if (isset($classMappings[$gatewayClass])) { + return new $classMappings[$gatewayClass]( + $requestDataMapper->getCurrencyMappings(), + $requestDataMapper->getTxTypeMappings(), + $logger + ); } - + throw new DomainException('unsupported gateway'); } @@ -200,25 +196,21 @@ public static function getGatewayResponseMapper(string $gatewayClass, AbstractRe */ public static function getGatewayCrypt(string $gatewayClass, LoggerInterface $logger): ?CryptInterface { - switch ($gatewayClass) { - case EstV3Pos::class: - return new EstV3PosCrypt($logger); - case EstPos::class: - return new EstPosCrypt($logger); - case GarantiPos::class: - return new GarantiPosCrypt($logger); - case InterPos::class: - return new InterPosCrypt($logger); - case KuveytPos::class: - return new KuveytPosCrypt($logger); - case PayForPos::class: - return new PayForPosCrypt($logger); - case PosNet::class: - return new PosNetCrypt($logger); - case VakifBankCPPos::class: - return new VakifBankCPCrypt($logger); - default: - return null; + $classMappings = [ + EstV3Pos::class => EstV3PosCrypt::class, + EstPos::class => EstPosCrypt::class, + GarantiPos::class => GarantiPosCrypt::class, + InterPos::class => InterPosCrypt::class, + KuveytPos::class => KuveytPosCrypt::class, + PayForPos::class => PayForPosCrypt::class, + PosNet::class => PosNetCrypt::class, + VakifBankCPPos::class => VakifBankCPCrypt::class, + ]; + + if (isset($classMappings[$gatewayClass])) { + return new $classMappings[$gatewayClass]($logger); } + + return null; } } From 83c780359c676d59a148af203fb31d03d99cc1b8 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Fri, 10 Mar 2023 22:15:59 +0100 Subject: [PATCH 36/54] VakifBankCP - some refactorings --- src/DataMapper/VakifBankCPPosRequestDataMapper.php | 14 +++++++------- src/Gateways/VakifBankCPPos.php | 13 +++++-------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/DataMapper/VakifBankCPPosRequestDataMapper.php b/src/DataMapper/VakifBankCPPosRequestDataMapper.php index a46d9584..6bd65532 100644 --- a/src/DataMapper/VakifBankCPPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankCPPosRequestDataMapper.php @@ -262,15 +262,15 @@ public function createHistoryRequestData(AbstractPosAccount $account, $order, ar * @return array{gateway: string, method: 'GET', inputs: array{Ptkn: string}} */ public function create3DFormData( - AbstractPosAccount $account, - $order, - string $txType, - string $gatewayURL, - ?AbstractCreditCard $card = null, - array $extraData = []): array + ?AbstractPosAccount $account, + $order, + ?string $txType, + ?string $gatewayURL, + ?AbstractCreditCard $card = null, + array $extraData = []): array { return [ - 'gateway' => $gatewayURL, + 'gateway' => $extraData['CommonPaymentUrl'], 'method' => 'GET', 'inputs' => [ 'Ptkn' => $extraData['PaymentToken'], diff --git a/src/Gateways/VakifBankCPPos.php b/src/Gateways/VakifBankCPPos.php index f5e2e0f7..da235dc1 100644 --- a/src/Gateways/VakifBankCPPos.php +++ b/src/Gateways/VakifBankCPPos.php @@ -123,16 +123,13 @@ public function get3DFormData(): array throw new Exception('İşlem gerçekleştirilemiyor'); } - /** @var string $gatewayUrl */ - $gatewayUrl = $data['CommonPaymentUrl']; - $this->logger->log(LogLevel::DEBUG, 'preparing 3D form data'); return $this->requestDataMapper->create3DFormData( - $this->account, - $this->order, - $this->type, - $gatewayUrl, + null, + null, + null, + null, null, $data ); @@ -332,7 +329,7 @@ private function getQueryAPIUrl(): string * * @throws Exception */ - private function registerPayment(): array + public function registerPayment(): array { if (null === $this->order) { $this->logger->log(LogLevel::ERROR, 'register payment without setting order', [ From 017fe16da5bb4a29839f88fbe0a2528256a88770 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Fri, 10 Mar 2023 22:17:10 +0100 Subject: [PATCH 37/54] VakifBankCPPosTest - fixed tests --- tests/Gateways/VakifBankCPPosTest.php | 73 ++++++++++----------------- 1 file changed, 28 insertions(+), 45 deletions(-) diff --git a/tests/Gateways/VakifBankCPPosTest.php b/tests/Gateways/VakifBankCPPosTest.php index f9e5369a..2369bb60 100644 --- a/tests/Gateways/VakifBankCPPosTest.php +++ b/tests/Gateways/VakifBankCPPosTest.php @@ -5,6 +5,8 @@ namespace Mews\Pos\Tests\Gateways; use Exception; +use Mews\Pos\DataMapper\ResponseDataMapper\VakifBankCPPosResponseDataMapper; +use Mews\Pos\DataMapper\VakifBankCPPosRequestDataMapper; use Mews\Pos\Entity\Account\VakifBankAccount; use Mews\Pos\Entity\Card\AbstractCreditCard; use Mews\Pos\Factory\AccountFactory; @@ -13,8 +15,7 @@ use Mews\Pos\Factory\PosFactory; use Mews\Pos\Gateways\AbstractGateway; use Mews\Pos\Gateways\VakifBankCPPos; -use Mews\Pos\Gateways\VakifBankPos; -use Mews\Pos\Tests\DataMapper\VakifBankPosRequestDataMapperTest; +use Mews\Pos\Tests\DataMapper\VakifBankCPPosRequestDataMapperTest; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; @@ -90,21 +91,13 @@ public function testPrepare(): void $this->pos->prepare($this->order, AbstractGateway::TX_POST_PAY); } - /** - * @return void - * - * @throws Exception - */ - public function testGet3DFormDataEnrollmentFail(): void + public function testGet3DFormDataSuccess(): void { - $this->expectException(Exception::class); - $this->expectExceptionCode(2005); - $vakifBankPosRequestDataMapperTest = new VakifBankPosRequestDataMapperTest(); + $crypt = PosFactory::getGatewayCrypt(VakifBankCPPos::class, new NullLogger()); + $requestMapper = PosFactory::getGatewayRequestMapper(VakifBankCPPos::class, [], $crypt); + $responseMapper = PosFactory::getGatewayResponseMapper(VakifBankCPPos::class, $requestMapper, new NullLogger()); - $requestMapper = PosFactory::getGatewayRequestMapper(VakifBankPos::class); - $responseMapper = PosFactory::getGatewayResponseMapper(VakifBankPos::class, $requestMapper, new NullLogger()); - - $posMock = $this->getMockBuilder(VakifBankPos::class) + $posMock = $this->getMockBuilder(VakifBankCPPos::class) ->setConstructorArgs([ [], $this->account, @@ -113,52 +106,42 @@ public function testGet3DFormDataEnrollmentFail(): void HttpClientFactory::createDefaultHttpClient(), new NullLogger() ]) - ->onlyMethods(['sendEnrollmentRequest']) + ->onlyMethods(['registerPayment']) ->getMock(); $posMock->setTestMode(true); $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); - $posMock->expects($this->once())->method('sendEnrollmentRequest') - ->willReturn($vakifBankPosRequestDataMapperTest->getSampleEnrollmentFailResponseData()); + $posMock->expects($this->once())->method('registerPayment') + ->willReturn(VakifBankCPPosRequestDataMapperTest::threeDFormDataProvider()->current()['queryParams']); - $posMock->get3DFormData(); - } + $result = $posMock->get3DFormData(); + $this->assertSame(VakifBankCPPosRequestDataMapperTest::threeDFormDataProvider()->current()['expected'], $result); + } - public function testGet3DFormDataSuccess(): void + public function testGet3DFormDataFail(): void { - $vakifBankPosRequestDataMapperTest = new VakifBankPosRequestDataMapperTest(); - $enrollmentResponse = $vakifBankPosRequestDataMapperTest->getSampleEnrollmentSuccessResponseData(); - - $requestMapper = PosFactory::getGatewayRequestMapper(VakifBankPos::class); - $responseMapper = PosFactory::getGatewayResponseMapper(VakifBankPos::class, $requestMapper, new NullLogger()); - - $posMock = $this->getMockBuilder(VakifBankPos::class) + $this->expectException(Exception::class); + $posMock = $this->getMockBuilder(VakifBankCPPos::class) ->setConstructorArgs([ [], $this->account, - $requestMapper, - $responseMapper, + $this->createMock(VakifBankCPPosRequestDataMapper::class), + $this->createMock(VakifBankCPPosResponseDataMapper::class), HttpClientFactory::createDefaultHttpClient(), new NullLogger() ]) - ->onlyMethods(['sendEnrollmentRequest']) + ->onlyMethods(['registerPayment']) ->getMock(); $posMock->setTestMode(true); $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); - $posMock->expects($this->once())->method('sendEnrollmentRequest') - ->willReturn($enrollmentResponse); + $posMock->expects($this->once())->method('registerPayment') + ->willReturn([ + 'CommonPaymentUrl' => null, + 'PaymentToken' => null, + 'ErrorCode' => '5007', + 'ResponseMessage' => 'Güvenlik Numarası Hatalı', + ]); - $result = $posMock->get3DFormData(); - $expected = [ - 'gateway' => $enrollmentResponse['Message']['VERes']['ACSUrl'], - 'method' => 'POST', - 'inputs' => [ - 'PaReq' => $enrollmentResponse['Message']['VERes']['PaReq'], - 'TermUrl' => $enrollmentResponse['Message']['VERes']['TermUrl'], - 'MD' => $enrollmentResponse['Message']['VERes']['MD'], - ], - ]; - - $this->assertSame($expected, $result); + $posMock->get3DFormData(); } } From 96787e60c5f72f2226289265d3ed49815e9a7e01 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Fri, 10 Mar 2023 22:18:07 +0100 Subject: [PATCH 38/54] created VakifBankCPPosRequestDataMapperTest --- .../VakifBankCPPosRequestDataMapperTest.php | 226 ++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 tests/DataMapper/VakifBankCPPosRequestDataMapperTest.php diff --git a/tests/DataMapper/VakifBankCPPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankCPPosRequestDataMapperTest.php new file mode 100644 index 00000000..e119810d --- /dev/null +++ b/tests/DataMapper/VakifBankCPPosRequestDataMapperTest.php @@ -0,0 +1,226 @@ +account = AccountFactory::createVakifBankAccount( + 'vakifbank-cp', + '000000000111111', + '3XTgER89as', + 'VP999999', + AbstractGateway::MODEL_3D_SECURE + ); + + $this->pos = PosFactory::createPosGateway($this->account); + $this->pos->setTestMode(true); + $crypt = PosFactory::getGatewayCrypt(VakifBankCPPos::class, new NullLogger()); + $this->requestDataMapper = new VakifBankCPPosRequestDataMapper($crypt); + } + + /** + * @return void + */ + public function testAmountFormat() + { + $this->assertEquals('1000.00', VakifBankCPPosRequestDataMapper::amountFormat(1000)); + } + + /** + * @return void + */ + public function testMapRecurringFrequency() + { + $this->assertEquals('Month', $this->requestDataMapper->mapRecurringFrequency('MONTH')); + $this->assertEquals('Month', $this->requestDataMapper->mapRecurringFrequency('Month')); + } + + /** + * @return void + */ + public function testMapCurrency() + { + $this->assertEquals('949', $this->requestDataMapper->mapCurrency('TRY')); + $this->assertEquals('978', $this->requestDataMapper->mapCurrency('EUR')); + } + + /** + * @param string|int|null $installment + * @param string|int $expected + * + * @testWith ["0", "0"] + * ["1", "0"] + * ["2", "2"] + * [2, "2"] + * + * @return void + */ + public function testMapInstallment($installment, $expected) + { + $actual = $this->requestDataMapper->mapInstallment($installment); + $this->assertSame($expected, $actual); + } + + /** + * @dataProvider registerDataProvider + */ + public function testCreate3DEnrollmentCheckData(AbstractPosAccount $account, array $order, string $txType, ?CreditCard $card, array $expectedData): void + { + $pos = $this->pos; + $pos->prepare($order, AbstractGateway::TX_PAY, $card); + $actual = $this->requestDataMapper->create3DEnrollmentCheckRequestData($account, $pos->getOrder(), $txType, $card); + $this->assertEquals($expectedData, $actual); + } + + /** + * @dataProvider threeDFormDataProvider + */ + public function testCreate3DFormData(array $queryParams, array $expected): void + { + $actualData = $this->requestDataMapper->create3DFormData( + null, + null, + null, + null, + null, + $queryParams + ); + + $this->assertSame($expected, $actualData); + } + + public static function registerDataProvider(): iterable + { + $account = AccountFactory::createVakifBankAccount( + 'vakifbank-cp', + '000000000111111', + '3XTgER89as', + 'VP999999', + AbstractGateway::MODEL_3D_SECURE + ); + + $order = [ + 'id' => 'order222', + 'name' => 'siparis veren', + 'email' => 'test@test.com', + 'amount' => 100.00, + 'installment' => 0, + 'currency' => 'TRY', + 'success_url' => 'https://domain.com/success', + 'fail_url' => 'https://domain.com/fail_url', + 'rand' => microtime(true), + 'extraData' => microtime(true), + 'ip' => '127.0.0.1', + ]; + + $pos = PosFactory::createPosGateway($account); + $pos->setTestMode(true); + $card = CreditCardFactory::create($pos, '5555444433332222', '2021', '12', '122', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA); + + yield 'with_card_1' => [ + 'account' => $account, + 'order' => $order, + 'txType' => AbstractGateway::TX_PAY, + 'card' => $card, + 'expected' => [ + 'HostMerchantId' => '000000000111111', + 'MerchantPassword' => '3XTgER89as', + 'HostTerminalId' => 'VP999999', + 'TransactionType' => 'Sale', + 'AmountCode' => '949', + 'Amount' => '100.00', + 'OrderID' => 'order222', + 'OrderDescription' => '', + 'IsSecure' => 'true', + 'AllowNotEnrolledCard' => 'false', + 'SuccessUrl' => 'https://domain.com/success', + 'FailUrl' => 'https://domain.com/fail_url', + 'HashedData' => '', + 'RequestLanguage' => 'tr-TR', + 'Extract' => '', + 'CustomItems' => '', + 'BrandNumber' => '100', + 'CVV' => '122', + 'PAN' => '5555444433332222', + 'ExpireMonth' => '12', + 'ExpireYear' => '21', + 'CardHoldersName' => 'ahmet', + ], + ]; + + yield 'without_card_1_pre_pay' => [ + 'account' => $account, + 'order' => $order, + 'txType' => AbstractGateway::TX_PRE_PAY, + 'card' => null, + 'expected' => [ + 'HostMerchantId' => '000000000111111', + 'MerchantPassword' => '3XTgER89as', + 'HostTerminalId' => 'VP999999', + 'TransactionType' => 'Auth', + 'AmountCode' => '949', + 'Amount' => '100.00', + 'OrderID' => 'order222', + 'OrderDescription' => '', + 'IsSecure' => 'true', + 'AllowNotEnrolledCard' => 'false', + 'SuccessUrl' => 'https://domain.com/success', + 'FailUrl' => 'https://domain.com/fail_url', + 'HashedData' => '', + 'RequestLanguage' => 'tr-TR', + 'Extract' => '', + 'CustomItems' => '', + ], + ]; + } + + public static function threeDFormDataProvider(): iterable + { + yield 'success_1' => [ + 'queryParams' => [ + 'CommonPaymentUrl' => 'https://cptest.vakifbank.com.tr/CommonPayment/SecurePayment', + 'PaymentToken' => 'c5e076e7bf234a339c40afc10166c06d', + 'ErrorCode' => null, + 'ResponseMessage' => null, + ], + 'expected' => [ + 'gateway' => 'https://cptest.vakifbank.com.tr/CommonPayment/SecurePayment', + 'method' => 'GET', + 'inputs' => [ + 'Ptkn' => 'c5e076e7bf234a339c40afc10166c06d' + ], + ], + ]; + } +} From 646c4ca3b44f603934132b21c49eeb35e0c2efcd Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 11:29:12 +0100 Subject: [PATCH 39/54] examples - added comments --- examples/vakifbank-cp/_payment_config.php | 1 + examples/vakifbank/_payment_config.php | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/vakifbank-cp/_payment_config.php b/examples/vakifbank-cp/_payment_config.php index 105b5f98..d8c1e073 100644 --- a/examples/vakifbank-cp/_payment_config.php +++ b/examples/vakifbank-cp/_payment_config.php @@ -68,6 +68,7 @@ function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\ $testCards = [ 'visa1' => [ + // NOTE: 3D Secure sifre 123456 'number' => '4938460158754205', 'year' => '24', 'month' => '11', diff --git a/examples/vakifbank/_payment_config.php b/examples/vakifbank/_payment_config.php index 8ceaf2aa..dd891908 100644 --- a/examples/vakifbank/_payment_config.php +++ b/examples/vakifbank/_payment_config.php @@ -76,6 +76,7 @@ function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\ $testCards = [ 'visa1' => [ + // NOTE: 3D Secure sifre 123456 'number' => '4938460158754205', 'year' => '24', 'month' => '11', From 75686537c7ec5cc1af1a0595b588ffa90a6b0bfc Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 11:32:51 +0100 Subject: [PATCH 40/54] VakifBankCPPos - added more tests --- src/Gateways/VakifBankCPPos.php | 2 +- tests/Gateways/VakifBankCPPosTest.php | 71 +++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/Gateways/VakifBankCPPos.php b/src/Gateways/VakifBankCPPos.php index da235dc1..57c2ed03 100644 --- a/src/Gateways/VakifBankCPPos.php +++ b/src/Gateways/VakifBankCPPos.php @@ -315,7 +315,7 @@ protected function prepareRefundOrder(array $order) /** * @return string */ - private function getQueryAPIUrl(): string + public function getQueryAPIUrl(): string { return $this->config['urls']['query'][$this->getModeInWord()]; } diff --git a/tests/Gateways/VakifBankCPPosTest.php b/tests/Gateways/VakifBankCPPosTest.php index 2369bb60..875e3eec 100644 --- a/tests/Gateways/VakifBankCPPosTest.php +++ b/tests/Gateways/VakifBankCPPosTest.php @@ -15,9 +15,11 @@ use Mews\Pos\Factory\PosFactory; use Mews\Pos\Gateways\AbstractGateway; use Mews\Pos\Gateways\VakifBankCPPos; +use Mews\Pos\Tests\DataMapper\ResponseDataMapper\VakifBankCPPosResponseDataMapperTest; use Mews\Pos\Tests\DataMapper\VakifBankCPPosRequestDataMapperTest; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; +use Symfony\Component\HttpFoundation\Request; class VakifBankCPPosTest extends TestCase { @@ -77,6 +79,7 @@ public function testInit(): void { $this->assertEquals($this->config['banks'][$this->account->getBank()], $this->pos->getConfig()); $this->assertEquals($this->account, $this->pos->getAccount()); + $this->assertNotEmpty($this->pos->getQueryAPIUrl()); $this->assertNotEmpty($this->pos->getCurrencies()); } @@ -144,4 +147,72 @@ public function testGet3DFormDataFail(): void $posMock->get3DFormData(); } + + public function testMake3dPayPaymentFail(): void + { + $failResponseData = iterator_to_array( + VakifBankCPPosResponseDataMapperTest::threesDPayResponseSamplesProvider() + )['fail_response_from_gateway_1']['bank_response']; + $request = Request::create('', 'GET', $failResponseData); + + $requestMapper = $this->createMock(VakifBankCPPosRequestDataMapper::class); + $requestMapper->expects($this->never()) + ->method('create3DPaymentStatusRequestData'); + + $responseMapper = $this->createMock(VakifBankCPPosResponseDataMapper::class); + $responseMapper->expects($this->once()) + ->method('map3DPayResponseData')->with($failResponseData); + + $pos = new VakifBankCPPos( + [], + $this->account, + $requestMapper, + $responseMapper, + HttpClientFactory::createDefaultHttpClient(), + new NullLogger()); + + $pos->prepare($this->order, AbstractGateway::TX_PAY, $this->card); + + $pos->make3DPayPayment($request); + } + + public function testMake3dPayPaymentSuccess(): void + { + $bankResponses = iterator_to_array(VakifBankCPPosResponseDataMapperTest::threesDPayResponseSamplesProvider()); + $bankQueryResponse = [ + 'Rc' => '0000', + 'AuthCode' => '368513', + 'Message' => 'İŞLEM BAŞARILI', + 'TransactionId' => '28d2b9c27af545f48d49afc300db246b', + 'PaymentToken' => 'c6b7cecc2a1846088a4eafc300db246b', + 'MaskedPan' => '49384601****4205', + ]; + $bankApiResponse = $bankResponses['success_response_from_gateway_1']['bank_response']; + + $request = Request::create('', 'GET', $bankQueryResponse); + + $requestMapper = $this->createMock(VakifBankCPPosRequestDataMapper::class); + $requestMapper->expects($this->once()) + ->method('create3DPaymentStatusRequestData')->with($this->account, $bankQueryResponse); + + $responseMapper = $this->createMock(VakifBankCPPosResponseDataMapper::class); + $responseMapper->expects($this->once()) + ->method('map3DPayResponseData'); + + $posMock = $this->getMockBuilder(VakifBankCPPos::class) + ->setConstructorArgs([ + [], + $this->account, + $requestMapper, + $responseMapper, + HttpClientFactory::createDefaultHttpClient(), + new NullLogger() + ]) + ->onlyMethods(['send', 'getQueryAPIUrl']) + ->getMock(); + $posMock->expects($this->once())->method('getQueryAPIUrl')->willReturn($this->pos->getQueryAPIUrl()); + $posMock->expects($this->once())->method('send')->willReturn([$bankApiResponse]); + + $posMock->make3DPayPayment($request); + } } From 8068b320d98efcd1b2972601077b297f212f4a96 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 12:52:57 +0100 Subject: [PATCH 41/54] rector - add types to the constants --- src/Crypt/AbstractCrypt.php | 2 ++ src/Crypt/EstV3PosCrypt.php | 2 ++ src/Crypt/PosNetCrypt.php | 2 ++ src/DataMapper/EstPosRequestDataMapper.php | 3 +++ src/DataMapper/GarantiPosRequestDataMapper.php | 9 +++++++-- src/DataMapper/InterPosRequestDataMapper.php | 2 ++ src/DataMapper/KuveytPosRequestDataMapper.php | 3 +++ src/DataMapper/PayForPosRequestDataMapper.php | 3 +++ .../AbstractResponseDataMapper.php | 3 +++ .../PosNetResponseDataMapper.php | 1 + .../VakifBankCPPosResponseDataMapper.php | 1 + .../VakifBankPosResponseDataMapper.php | 1 + src/DataMapper/VakifBankCPPosRequestDataMapper.php | 1 + src/DataMapper/VakifBankPosRequestDataMapper.php | 2 ++ src/Entity/Account/VakifBankAccount.php | 3 +++ src/Entity/Card/AbstractCreditCard.php | 4 ++++ src/Gateways/AbstractGateway.php | 14 ++++++++++++++ src/Gateways/EstPos.php | 4 +--- src/Gateways/GarantiPos.php | 4 +--- src/Gateways/InterPos.php | 4 +--- src/Gateways/KuveytPos.php | 1 + src/Gateways/PayForPos.php | 4 +--- src/Gateways/PosNet.php | 1 + src/Gateways/VakifBankCPPos.php | 1 + src/Gateways/VakifBankPos.php | 4 +--- 25 files changed, 62 insertions(+), 17 deletions(-) diff --git a/src/Crypt/AbstractCrypt.php b/src/Crypt/AbstractCrypt.php index b48dd7c2..1ef7dfac 100644 --- a/src/Crypt/AbstractCrypt.php +++ b/src/Crypt/AbstractCrypt.php @@ -6,8 +6,10 @@ abstract class AbstractCrypt implements CryptInterface { + /** @var string */ protected const HASH_ALGORITHM = 'sha1'; + /** @var string */ protected const HASH_SEPARATOR = ''; /** @var LoggerInterface */ diff --git a/src/Crypt/EstV3PosCrypt.php b/src/Crypt/EstV3PosCrypt.php index e4305893..7e13da8f 100644 --- a/src/Crypt/EstV3PosCrypt.php +++ b/src/Crypt/EstV3PosCrypt.php @@ -9,8 +9,10 @@ class EstV3PosCrypt extends AbstractCrypt { + /** @var string */ protected const HASH_ALGORITHM = 'sha512'; + /** @var string */ protected const HASH_SEPARATOR = '|'; /** diff --git a/src/Crypt/PosNetCrypt.php b/src/Crypt/PosNetCrypt.php index 9eae3b54..5d812a8b 100644 --- a/src/Crypt/PosNetCrypt.php +++ b/src/Crypt/PosNetCrypt.php @@ -11,8 +11,10 @@ class PosNetCrypt extends AbstractCrypt { + /** @var string */ protected const HASH_ALGORITHM = 'sha256'; + /** @var string */ protected const HASH_SEPARATOR = ';'; /** diff --git a/src/DataMapper/EstPosRequestDataMapper.php b/src/DataMapper/EstPosRequestDataMapper.php index 4cfc30dd..122b6c17 100644 --- a/src/DataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/EstPosRequestDataMapper.php @@ -13,10 +13,13 @@ */ class EstPosRequestDataMapper extends AbstractRequestDataMapperCrypt { + /** @var string */ public const CREDIT_CARD_EXP_DATE_FORMAT = 'm/y'; + /** @var string */ public const CREDIT_CARD_EXP_MONTH_FORMAT = 'm'; + /** @var string */ public const CREDIT_CARD_EXP_YEAR_FORMAT = 'y'; /** diff --git a/src/DataMapper/GarantiPosRequestDataMapper.php b/src/DataMapper/GarantiPosRequestDataMapper.php index 3dea683c..8219fc49 100644 --- a/src/DataMapper/GarantiPosRequestDataMapper.php +++ b/src/DataMapper/GarantiPosRequestDataMapper.php @@ -16,14 +16,21 @@ */ class GarantiPosRequestDataMapper extends AbstractRequestDataMapperCrypt { + /** @var string */ public const API_VERSION = 'v0.01'; + /** @var string */ public const CREDIT_CARD_EXP_DATE_FORMAT = 'my'; + /** @var string */ public const CREDIT_CARD_EXP_MONTH_FORMAT = 'm'; + /** @var string */ public const CREDIT_CARD_EXP_YEAR_FORMAT = 'y'; + /** @var string */ + private const MOTO = 'N'; + /** * {@inheritDoc} */ @@ -45,8 +52,6 @@ class GarantiPosRequestDataMapper extends AbstractRequestDataMapperCrypt AbstractGateway::TX_STATUS => 'orderinq', ]; - private const MOTO = 'N'; - protected $recurringOrderFrequencyMapping = [ 'DAY' => 'D', 'WEEK' => 'W', diff --git a/src/DataMapper/InterPosRequestDataMapper.php b/src/DataMapper/InterPosRequestDataMapper.php index cc6e9dc7..f6839f37 100644 --- a/src/DataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/InterPosRequestDataMapper.php @@ -14,10 +14,12 @@ */ class InterPosRequestDataMapper extends AbstractRequestDataMapperCrypt { + /** @var string */ public const CREDIT_CARD_EXP_DATE_FORMAT = 'my'; /** * MOTO (Mail Order Telephone Order) 0 for false, 1 for true + * @var string */ protected const MOTO = '0'; diff --git a/src/DataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/KuveytPosRequestDataMapper.php index 70a452e6..071963f4 100644 --- a/src/DataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/KuveytPosRequestDataMapper.php @@ -17,10 +17,13 @@ */ class KuveytPosRequestDataMapper extends AbstractRequestDataMapperCrypt { + /** @var string */ public const API_VERSION = '1.0.0'; + /** @var string */ public const CREDIT_CARD_EXP_YEAR_FORMAT = 'y'; + /** @var string */ public const CREDIT_CARD_EXP_MONTH_FORMAT = 'm'; /** diff --git a/src/DataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/PayForPosRequestDataMapper.php index bffd842e..27a25012 100644 --- a/src/DataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/PayForPosRequestDataMapper.php @@ -15,14 +15,17 @@ class PayForPosRequestDataMapper extends AbstractRequestDataMapper { /** * Kurum kodudur. (Banka tarafından verilir) + * @var string */ public const MBR_ID = '5'; /** * MOTO (Mail Order Telephone Order) 0 for false, 1 for true + * @var string */ public const MOTO = '0'; + /** @var string */ public const CREDIT_CARD_EXP_DATE_FORMAT = 'my'; /** {@inheritdoc} */ diff --git a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php index b581a3b2..e37b4027 100644 --- a/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php @@ -7,10 +7,13 @@ abstract class AbstractResponseDataMapper { + /** @var string */ public const TX_APPROVED = 'approved'; + /** @var string */ public const TX_DECLINED = 'declined'; + /** @var string */ public const PROCEDURE_SUCCESS_CODE = '00'; /** @var LoggerInterface */ diff --git a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php index 9f48ea3f..d81a56bc 100644 --- a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php @@ -6,6 +6,7 @@ class PosNetResponseDataMapper extends AbstractResponseDataMapper implements PaymentResponseMapperInterface, NonPaymentResponseMapperInterface { + /** @var string */ public const PROCEDURE_SUCCESS_CODE = '1'; /** diff --git a/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php index 28eb49e9..80160d9e 100644 --- a/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php @@ -7,6 +7,7 @@ class VakifBankCPPosResponseDataMapper extends AbstractResponseDataMapper implements PaymentResponseMapperInterface, NonPaymentResponseMapperInterface { + /** @var string */ public const PROCEDURE_SUCCESS_CODE = '0000'; /** diff --git a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php index ba99671f..c11b869e 100644 --- a/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapper.php @@ -6,6 +6,7 @@ class VakifBankPosResponseDataMapper extends AbstractResponseDataMapper implements PaymentResponseMapperInterface, NonPaymentResponseMapperInterface { + /** @var string */ public const PROCEDURE_SUCCESS_CODE = '0000'; /** diff --git a/src/DataMapper/VakifBankCPPosRequestDataMapper.php b/src/DataMapper/VakifBankCPPosRequestDataMapper.php index 6bd65532..347a43fd 100644 --- a/src/DataMapper/VakifBankCPPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankCPPosRequestDataMapper.php @@ -16,6 +16,7 @@ */ class VakifBankCPPosRequestDataMapper extends AbstractRequestDataMapperCrypt { + /** @var string */ public const CREDIT_CARD_EXP_DATE_LONG_FORMAT = 'Ym'; /** diff --git a/src/DataMapper/VakifBankPosRequestDataMapper.php b/src/DataMapper/VakifBankPosRequestDataMapper.php index 2c6e032d..43aa2e99 100644 --- a/src/DataMapper/VakifBankPosRequestDataMapper.php +++ b/src/DataMapper/VakifBankPosRequestDataMapper.php @@ -15,8 +15,10 @@ */ class VakifBankPosRequestDataMapper extends AbstractRequestDataMapper { + /** @var string */ public const CREDIT_CARD_EXP_DATE_LONG_FORMAT = 'Ym'; + /** @var string */ public const CREDIT_CARD_EXP_DATE_FORMAT = 'ym'; /** diff --git a/src/Entity/Account/VakifBankAccount.php b/src/Entity/Account/VakifBankAccount.php index d30c93ad..bfbc2ad5 100644 --- a/src/Entity/Account/VakifBankAccount.php +++ b/src/Entity/Account/VakifBankAccount.php @@ -4,10 +4,13 @@ class VakifBankAccount extends AbstractPosAccount { + /** @var int */ public const MERCHANT_TYPE_STANDARD = 0; + /** @var int */ public const MERCHANT_TYPE_MAIN_DEALER = 1; + /** @var int */ public const MERCHANT_TYPE_SUB_DEALER = 2; /** @var int[] */ diff --git a/src/Entity/Card/AbstractCreditCard.php b/src/Entity/Card/AbstractCreditCard.php index c7c79f0b..fbde0dbd 100644 --- a/src/Entity/Card/AbstractCreditCard.php +++ b/src/Entity/Card/AbstractCreditCard.php @@ -9,12 +9,16 @@ */ abstract class AbstractCreditCard { + /** @var string */ public const CARD_TYPE_VISA = 'visa'; + /** @var string */ public const CARD_TYPE_MASTERCARD = 'master'; + /** @var string */ public const CARD_TYPE_AMEX = 'amex'; + /** @var string */ public const CARD_TYPE_TROY = 'troy'; /** diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index d9a458f0..f9e8e012 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -25,32 +25,46 @@ */ abstract class AbstractGateway implements PosInterface { + /** @var string */ public const LANG_TR = 'tr'; + /** @var string */ public const LANG_EN = 'en'; + /** @var string */ public const TX_PAY = 'pay'; + /** @var string */ public const TX_PRE_PAY = 'pre'; + /** @var string */ public const TX_POST_PAY = 'post'; + /** @var string */ public const TX_CANCEL = 'cancel'; + /** @var string */ public const TX_REFUND = 'refund'; + /** @var string */ public const TX_STATUS = 'status'; + /** @var string */ public const TX_HISTORY = 'history'; + /** @var string */ public const MODEL_3D_SECURE = '3d'; + /** @var string */ public const MODEL_3D_PAY = '3d_pay'; + /** @var string */ public const MODEL_3D_PAY_HOSTING = '3d_pay_hosting'; + /** @var string */ public const MODEL_3D_HOST = '3d_host'; + /** @var string */ public const MODEL_NON_SECURE = 'regular'; /** @var array */ diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index 780597bd..0b14a5ae 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -19,9 +19,7 @@ */ class EstPos extends AbstractGateway { - /** - * @const string - */ + /** @var string */ public const NAME = 'EstPos'; /** @var EstPosAccount */ diff --git a/src/Gateways/GarantiPos.php b/src/Gateways/GarantiPos.php index 1534b1ae..c956a6b8 100644 --- a/src/Gateways/GarantiPos.php +++ b/src/Gateways/GarantiPos.php @@ -18,9 +18,7 @@ */ class GarantiPos extends AbstractGateway { - /** - * @const string - */ + /** @var string */ public const NAME = 'GarantiPay'; /** @var GarantiPosAccount */ diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 5ec2c4ed..5d289361 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -19,9 +19,7 @@ */ class InterPos extends AbstractGateway { - /** - * @const string - */ + /** @var string */ public const NAME = 'InterPos'; /** @var InterPosAccount */ diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 1ac01214..7f11ecc6 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -22,6 +22,7 @@ */ class KuveytPos extends AbstractGateway { + /** @var string */ public const NAME = 'KuveytPos'; /** @var KuveytPosAccount */ diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index 44034f28..8862e7bb 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -18,9 +18,7 @@ */ class PayForPos extends AbstractGateway { - /** - * @const string - */ + /** @var string */ public const NAME = 'PayForPOS'; /** @var PayForAccount */ diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index 37ce9d4e..adc4fca8 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -19,6 +19,7 @@ */ class PosNet extends AbstractGateway { + /** @var string */ public const NAME = 'PosNet'; /** @var PosNetAccount */ diff --git a/src/Gateways/VakifBankCPPos.php b/src/Gateways/VakifBankCPPos.php index 57c2ed03..b823edf7 100644 --- a/src/Gateways/VakifBankCPPos.php +++ b/src/Gateways/VakifBankCPPos.php @@ -20,6 +20,7 @@ */ class VakifBankCPPos extends AbstractGateway { + /** @var string */ public const NAME = 'Vakif-Common-Payment'; /** @var VakifBankAccount */ diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index 0b7f0b7d..f54f3dd4 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -19,9 +19,7 @@ */ class VakifBankPos extends AbstractGateway { - /** - * @const string - */ + /** @var string */ public const NAME = 'VakifPOS'; /** @var VakifBankAccount */ From 46b7271f613127bbf02371dc7f0b34e8de431b1d Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 12:59:35 +0100 Subject: [PATCH 42/54] rector - refactor counts --- src/DataMapper/AbstractRequestDataMapper.php | 2 +- src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataMapper/AbstractRequestDataMapper.php b/src/DataMapper/AbstractRequestDataMapper.php index fdbcc50c..1eb46070 100644 --- a/src/DataMapper/AbstractRequestDataMapper.php +++ b/src/DataMapper/AbstractRequestDataMapper.php @@ -69,7 +69,7 @@ abstract class AbstractRequestDataMapper public function __construct(?CryptInterface $crypt = null, array $currencyMappings = []) { $this->crypt = $crypt; - if (count($currencyMappings) > 0) { + if ($currencyMappings !== []) { $this->currencyMappings = $currencyMappings; } } diff --git a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php index d81a56bc..1409e87e 100644 --- a/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PosNetResponseDataMapper.php @@ -265,7 +265,7 @@ public function mapHistoryResponse(array $rawResponseData): array $authCode = $transactionDetails['authCode'] ?? null; if (is_array($transactionDetails)) { - if (count($transactionDetails) > 0) { + if ($transactionDetails !== []) { $state = $transactionDetails[0]['state']; $authCode = $transactionDetails[0]['authCode']; } From c214462b50ba9d7fb876c1a834fb6607641a5979 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 13:05:55 +0100 Subject: [PATCH 43/54] rector - EncapsedStringsToSprintfRector --- .../EstPosResponseDataMapper.php | 26 +++++++++---------- src/Factory/AccountFactory.php | 2 +- src/Gateways/PosNet.php | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php index 39af1339..03aeb504 100644 --- a/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/EstPosResponseDataMapper.php @@ -351,22 +351,22 @@ public function mapRecurringStatusResponse(array $rawResponseData): array 'all' => $rawResponseData, ]; - for ($i = 1; isset($extra["ORD_ID_$i"]); $i++) { + for ($i = 1; isset($extra[sprintf('ORD_ID_%d', $i)]); ++$i) { $recurringOrder = [ - 'order_id' => $extra["ORD_ID_$i"], - 'order_status' => $extra["ORDERSTATUS_$i"], - 'masked_number' => $extra["PAN_$i"], - 'status' => $extra["TRANS_STAT_$i"], //C => Completed, PN => Pending, CNCL => Canceled + 'order_id' => $extra[sprintf('ORD_ID_%d', $i)], + 'order_status' => $extra[sprintf('ORDERSTATUS_%d', $i)], + 'masked_number' => $extra[sprintf('PAN_%d', $i)], + 'status' => $extra[sprintf('TRANS_STAT_%d', $i)], //C => Completed, PN => Pending, CNCL => Canceled // following fields are null until transaction is done for respective installment: - 'auth_code' => $extra["AUTH_CODE_$i"] ?? null, - 'auth_time' => $extra["AUTH_DTTM_$i"] ?? null, - 'proc_return_code' => $extra["PROC_RET_CD_$i"] ?? null, - 'trans_id' => $extra["TRANS_ID_$i"] ?? null, - 'ref_ret_num' => $extra["HOST_REF_NUM_$i"] ?? null, - 'first_amount' => $extra["ORIG_TRANS_AMT_$i"], - 'capture_amount' => $extra["CAPTURE_AMT_$i"] ?? null, - 'capture_time' => $extra["CAPTURE_DTTM_$i"] ?? null, + 'auth_code' => $extra[sprintf('AUTH_CODE_%d', $i)] ?? null, + 'auth_time' => $extra[sprintf('AUTH_DTTM_%d', $i)] ?? null, + 'proc_return_code' => $extra[sprintf('PROC_RET_CD_%d', $i)] ?? null, + 'trans_id' => $extra[sprintf('TRANS_ID_%d', $i)] ?? null, + 'ref_ret_num' => $extra[sprintf('HOST_REF_NUM_%d', $i)] ?? null, + 'first_amount' => $extra[sprintf('ORIG_TRANS_AMT_%d', $i)], + 'capture_amount' => $extra[sprintf('CAPTURE_AMT_%d', $i)] ?? null, + 'capture_time' => $extra[sprintf('CAPTURE_DTTM_%d', $i)] ?? null, ]; $recurringOrder['capture'] = $recurringOrder['first_amount'] === $recurringOrder['capture_amount']; diff --git a/src/Factory/AccountFactory.php b/src/Factory/AccountFactory.php index 554e86dc..1e1d1376 100644 --- a/src/Factory/AccountFactory.php +++ b/src/Factory/AccountFactory.php @@ -180,7 +180,7 @@ private static function checkParameters(string $model, ?string $storeKey) return; } - throw new MissingAccountInfoException("$model requires storeKey!"); + throw new MissingAccountInfoException(sprintf('%s requires storeKey!', $model)); } /** diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index adc4fca8..da4d942c 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -155,7 +155,7 @@ public function send($contents, ?string $url = null) 'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded', ], - 'body' => "xmldata=$contents", + 'body' => sprintf('xmldata=%s', $contents), ]); } else { $response = $this->client->post($url, ['form_params' => $contents]); From 8e2a1f0a5ec9efdb009d0bf5d58230caa23db0fc Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 13:08:52 +0100 Subject: [PATCH 44/54] rector - early return and if conditions --- .../GarantiPosResponseDataMapper.php | 18 +++++++++--------- .../VakifBankCPPosResponseDataMapper.php | 16 ++++++---------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php index 363e755d..0bd05300 100644 --- a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php @@ -302,16 +302,16 @@ public static function amountFormat(string $amount): float */ protected function mapResponseTransactionSecurity(string $mdStatus): string { - if (in_array($mdStatus, ['1', '2', '3', '4'])) { - if ('1' === $mdStatus) { - return 'Full 3D Secure'; - } else { - // ['2', '3', '4'] - return 'Half 3D Secure'; - } + if (!in_array($mdStatus, ['1', '2', '3', '4'])) { + return 'MPI fallback'; } - - return 'MPI fallback'; + + if ('1' === $mdStatus) { + return 'Full 3D Secure'; + } + + // ['2', '3', '4'] + return 'Half 3D Secure'; } /** diff --git a/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php index 80160d9e..7e561e80 100644 --- a/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapper.php @@ -156,12 +156,10 @@ private function getCommonPaymentResponse(array $responseData): array if (null !== $errorCode) { $resultCode = $errorCode; $errorMsg = $responseData['Message']; + } elseif (self::PROCEDURE_SUCCESS_CODE === $resultCode) { + $status = self::TX_APPROVED; } else { - if (self::PROCEDURE_SUCCESS_CODE === $resultCode) { - $status = self::TX_APPROVED; - } else { - $errorMsg = $responseData['Message']; - } + $errorMsg = $responseData['Message']; } $response = $this->getDefaultPaymentResponse(); @@ -194,12 +192,10 @@ private function getCommonNonSecureResponse(array $responseData): array if (null !== $errorCode) { $resultCode = $errorCode; $statusDetail = $responseData['ResponseMessage']; + } elseif (self::PROCEDURE_SUCCESS_CODE === $resultCode) { + $status = self::TX_APPROVED; } else { - if (self::PROCEDURE_SUCCESS_CODE === $resultCode) { - $status = self::TX_APPROVED; - } else { - $statusDetail = $responseData['ResultDetail']; - } + $statusDetail = $responseData['ResultDetail']; } $response = $this->getDefaultPaymentResponse(); From dad7fabfea6c16dd49618d57dfdfa8811011fb01 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 13:14:25 +0100 Subject: [PATCH 45/54] rector - add line breaks before assign statements --- src/Crypt/EstV3PosCrypt.php | 1 + src/Gateways/KuveytPos.php | 1 + tests/DataMapper/EstPosRequestDataMapperTest.php | 2 ++ tests/DataMapper/EstV3PosRequestDataMapperTest.php | 1 + tests/DataMapper/GarantiPosRequestDataMapperTest.php | 4 ++++ tests/DataMapper/InterPosRequestDataMapperTest.php | 1 + tests/DataMapper/KuveytPosRequestDataMapperTest.php | 1 + tests/DataMapper/PayForPosRequestDataMapperTest.php | 2 ++ tests/DataMapper/PosNetRequestDataMapperTest.php | 2 ++ .../VakifBankCPPosResponseDataMapperTest.php | 4 +--- .../VakifBankPosResponseDataMapperTest.php | 2 ++ .../VakifBankCPPosRequestDataMapperTest.php | 4 ++++ .../DataMapper/VakifBankPosRequestDataMapperTest.php | 4 ++++ tests/Gateways/EstPosTest.php | 11 +++++++++++ tests/Gateways/GarantiPosTest.php | 1 + tests/Gateways/InterPosTest.php | 1 + tests/Gateways/KuveytPosTest.php | 2 ++ tests/Gateways/PayForTest.php | 1 + tests/Gateways/PosNetTest.php | 2 ++ tests/Gateways/VakifBankCPPosTest.php | 1 + tests/Gateways/VakifBankPosTest.php | 1 + 21 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/Crypt/EstV3PosCrypt.php b/src/Crypt/EstV3PosCrypt.php index 7e13da8f..c87bb3a0 100644 --- a/src/Crypt/EstV3PosCrypt.php +++ b/src/Crypt/EstV3PosCrypt.php @@ -32,6 +32,7 @@ public function create3DHash(AbstractPosAccount $account, array $requestData, ?s // escape | and \ characters $data = str_replace("\\", "\\\\", array_values($requestData)); $data = str_replace(self::HASH_SEPARATOR, "\\".self::HASH_SEPARATOR, $data); + $hashStr = implode(self::HASH_SEPARATOR, $data); return $this->hashString($hashStr); diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 7f11ecc6..6051f0fb 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -93,6 +93,7 @@ public function make3DPayment(Request $request) $gatewayResponse = urldecode($gatewayResponse); $gatewayResponse = $this->XMLStringToArray($gatewayResponse); + $bankResponse = null; $procReturnCode = $gatewayResponse['ResponseCode']; diff --git a/tests/DataMapper/EstPosRequestDataMapperTest.php b/tests/DataMapper/EstPosRequestDataMapperTest.php index 93621b8f..a3f07673 100644 --- a/tests/DataMapper/EstPosRequestDataMapperTest.php +++ b/tests/DataMapper/EstPosRequestDataMapperTest.php @@ -67,6 +67,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->threeDAccount); $this->pos->setTestMode(true); + $this->requestDataMapper = new EstPosRequestDataMapper(PosFactory::getGatewayCrypt(EstPos::class, new NullLogger())); $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '22', '01', '123', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA); } @@ -340,6 +341,7 @@ public function testGet3DHostFormData() $pos = PosFactory::createPosGateway($account); $pos->setTestMode(true); $pos->prepare($this->order, AbstractGateway::TX_PAY); + $gatewayURL = $this->config['banks'][$this->threeDAccount->getBank()]['urls']['gateway_3d_host']['test']; $inputs = [ 'clientid' => $account->getClientId(), diff --git a/tests/DataMapper/EstV3PosRequestDataMapperTest.php b/tests/DataMapper/EstV3PosRequestDataMapperTest.php index 93f35ca7..725230ff 100644 --- a/tests/DataMapper/EstV3PosRequestDataMapperTest.php +++ b/tests/DataMapper/EstV3PosRequestDataMapperTest.php @@ -66,6 +66,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->threeDAccount); $this->pos->setTestMode(true); + $crypt = PosFactory::getGatewayCrypt(EstV3Pos::class, new NullLogger()); $this->requestDataMapper = new EstV3PosRequestDataMapper($crypt); $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '22', '01', '123', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA); diff --git a/tests/DataMapper/GarantiPosRequestDataMapperTest.php b/tests/DataMapper/GarantiPosRequestDataMapperTest.php index 1d6159bb..73362410 100644 --- a/tests/DataMapper/GarantiPosRequestDataMapperTest.php +++ b/tests/DataMapper/GarantiPosRequestDataMapperTest.php @@ -70,9 +70,11 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->threeDAccount); $this->pos->setTestMode(true); + $crypt = PosFactory::getGatewayCrypt(GarantiPos::class, new NullLogger()); $this->requestDataMapper = new GarantiPosRequestDataMapper($crypt); $this->requestDataMapper->setTestMode(true); + $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '22', '01', '123', 'ahmet'); } @@ -172,6 +174,7 @@ public function testCreateHistoryRequestData() $order = $this->order; $pos = $this->pos; $pos->prepare($order, AbstractGateway::TX_HISTORY); + $actual = $this->requestDataMapper->createHistoryRequestData($pos->getAccount(), $pos->getOrder()); $expectedData = $this->getSampleHistoryRequestData($pos->getAccount(), $pos->getOrder()); @@ -201,6 +204,7 @@ public function testGet3DFormData() { $this->pos->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $pos = $this->pos; + $account = $pos->getAccount(); $order = $pos->getOrder(); $card = $pos->getCard(); diff --git a/tests/DataMapper/InterPosRequestDataMapperTest.php b/tests/DataMapper/InterPosRequestDataMapperTest.php index 74c9dab9..fff3e99c 100644 --- a/tests/DataMapper/InterPosRequestDataMapperTest.php +++ b/tests/DataMapper/InterPosRequestDataMapperTest.php @@ -261,6 +261,7 @@ public function testGet3DHostFormData() $pos = PosFactory::createPosGateway($account); $pos->setTestMode(true); $pos->prepare($this->order, AbstractGateway::TX_PAY); + $order = $pos->getOrder(); $gatewayURL = $this->config['banks'][$account->getBank()]['urls']['gateway_3d_host']['test']; diff --git a/tests/DataMapper/KuveytPosRequestDataMapperTest.php b/tests/DataMapper/KuveytPosRequestDataMapperTest.php index b747eefb..36fd2663 100644 --- a/tests/DataMapper/KuveytPosRequestDataMapperTest.php +++ b/tests/DataMapper/KuveytPosRequestDataMapperTest.php @@ -70,6 +70,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->threeDAccount); $this->pos->setTestMode(true); + $this->card = CreditCardFactory::create( $this->pos, '4155650100416111', diff --git a/tests/DataMapper/PayForPosRequestDataMapperTest.php b/tests/DataMapper/PayForPosRequestDataMapperTest.php index 3843f7e7..231f4bc7 100644 --- a/tests/DataMapper/PayForPosRequestDataMapperTest.php +++ b/tests/DataMapper/PayForPosRequestDataMapperTest.php @@ -66,6 +66,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->threeDAccount); $this->pos->setTestMode(true); + $crypt = PosFactory::getGatewayCrypt(PayForPos::class, new NullLogger()); $this->requestDataMapper = new PayForPosRequestDataMapper($crypt); $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '22', '01', '123', 'ahmet'); @@ -261,6 +262,7 @@ public function testGet3DHostFormData() $pos = PosFactory::createPosGateway($account); $pos->setTestMode(true); $pos->prepare($this->order, AbstractGateway::TX_PAY); + $order = $pos->getOrder(); $gatewayURL = $this->config['banks'][$this->threeDAccount->getBank()]['urls']['gateway_3d_host']['test']; $inputs = [ diff --git a/tests/DataMapper/PosNetRequestDataMapperTest.php b/tests/DataMapper/PosNetRequestDataMapperTest.php index 4eb9d146..6ed6d329 100644 --- a/tests/DataMapper/PosNetRequestDataMapperTest.php +++ b/tests/DataMapper/PosNetRequestDataMapperTest.php @@ -64,6 +64,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($threeDAccount); $this->pos->setTestMode(true); + $crypt = PosFactory::getGatewayCrypt(PosNet::class, new NullLogger()); $this->requestDataMapper = new PosNetRequestDataMapper($crypt); $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '22', '01', '123', 'ahmet'); @@ -229,6 +230,7 @@ public function testCreate3DEnrollmentCheckRequestData() { $pos = $this->pos; $pos->prepare($this->order, AbstractGateway::TX_PAY, $this->card); + $expected = $this->getSample3DEnrollmentCheckRequestData($pos->getAccount(), $pos->getOrder(), $pos->getCard()); $actual = $this->requestDataMapper->create3DEnrollmentCheckRequestData($pos->getAccount(), $pos->getOrder(), AbstractGateway::TX_PAY, $pos->getCard()); $this->assertEquals($expected, $actual); diff --git a/tests/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapperTest.php index 514033b1..53f7df1a 100644 --- a/tests/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/VakifBankCPPosResponseDataMapperTest.php @@ -13,9 +13,7 @@ class VakifBankCPPosResponseDataMapperTest extends TestCase { - /** - * @var VakifBankCPPosResponseDataMapper - */ + /** @var VakifBankCPPosResponseDataMapper */ private $responseDataMapper; protected function setUp(): void diff --git a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php index 2024b2f4..a7175baf 100644 --- a/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php +++ b/tests/DataMapper/ResponseDataMapper/VakifBankPosResponseDataMapperTest.php @@ -172,6 +172,7 @@ public static function cancelDataProvider(): iterable ], ]; } + public static function paymentDataProvider(): iterable { yield 'success_1' => [ @@ -254,6 +255,7 @@ public static function paymentDataProvider(): iterable ], ]; } + public static function threeDPaymentDataProvider(): array { return [ diff --git a/tests/DataMapper/VakifBankCPPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankCPPosRequestDataMapperTest.php index e119810d..1644af45 100644 --- a/tests/DataMapper/VakifBankCPPosRequestDataMapperTest.php +++ b/tests/DataMapper/VakifBankCPPosRequestDataMapperTest.php @@ -31,6 +31,7 @@ class VakifBankCPPosRequestDataMapperTest extends TestCase /** @var VakifBankCPPosRequestDataMapper */ private $requestDataMapper; + protected function setUp(): void { parent::setUp(); @@ -45,6 +46,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->account); $this->pos->setTestMode(true); + $crypt = PosFactory::getGatewayCrypt(VakifBankCPPos::class, new NullLogger()); $this->requestDataMapper = new VakifBankCPPosRequestDataMapper($crypt); } @@ -99,6 +101,7 @@ public function testCreate3DEnrollmentCheckData(AbstractPosAccount $account, arr { $pos = $this->pos; $pos->prepare($order, AbstractGateway::TX_PAY, $card); + $actual = $this->requestDataMapper->create3DEnrollmentCheckRequestData($account, $pos->getOrder(), $txType, $card); $this->assertEquals($expectedData, $actual); } @@ -146,6 +149,7 @@ public static function registerDataProvider(): iterable $pos = PosFactory::createPosGateway($account); $pos->setTestMode(true); + $card = CreditCardFactory::create($pos, '5555444433332222', '2021', '12', '122', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA); yield 'with_card_1' => [ diff --git a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php index c61a8dc0..7a9121e0 100644 --- a/tests/DataMapper/VakifBankPosRequestDataMapperTest.php +++ b/tests/DataMapper/VakifBankPosRequestDataMapperTest.php @@ -62,6 +62,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->account); $this->pos->setTestMode(true); + $this->requestDataMapper = new VakifBankPosRequestDataMapper(); $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '2021', '12', '122', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA); } @@ -118,6 +119,7 @@ public function testCreate3DPaymentRequestData() $order['amount'] = 10.1; $pos = $this->pos; $pos->prepare($order, AbstractGateway::TX_PAY, $this->card); + $txType = AbstractGateway::TX_PAY; $gatewayResponse = [ 'Eci' => (string) random_int(1, 100), @@ -143,6 +145,7 @@ public function testCreate3DEnrollmentCheckData() { $pos = $this->pos; $pos->prepare($this->order, AbstractGateway::TX_PAY, $this->card); + $expectedValue = $this->getSample3DEnrollmentRequestData($pos->getAccount(), $pos->getOrder(), $pos->getCard()); $actual = $this->requestDataMapper->create3DEnrollmentCheckRequestData($pos->getAccount(), $pos->getOrder(), $pos->getCard()); $this->assertEquals($expectedValue, $actual); @@ -237,6 +240,7 @@ public function testCreate3DFormData() { $pos = $this->pos; $pos->prepare($this->order, AbstractGateway::TX_PAY, $this->card); + $expectedValue = $this->getSample3DFormDataFromEnrollmentResponse(); $actualData = $this->requestDataMapper->create3DFormData( $pos->getAccount(), diff --git a/tests/Gateways/EstPosTest.php b/tests/Gateways/EstPosTest.php index 7c021742..f1c2ea6c 100644 --- a/tests/Gateways/EstPosTest.php +++ b/tests/Gateways/EstPosTest.php @@ -118,6 +118,7 @@ public function testMake3DPaymentAuthFail() $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $posMock->make3DPayment($request); + $result = $posMock->getResponse(); $this->assertIsArray($result); $this->assertFalse($posMock->isSuccess()); @@ -134,6 +135,7 @@ public function testMake3DHostPaymentSuccess() $pos->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $pos->make3DHostPayment($request); + $result = $pos->getResponse(); $this->assertIsArray($result); $this->assertTrue($pos->isSuccess()); @@ -150,6 +152,7 @@ public function testMake3DPayPaymentSuccess() $pos->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $pos->make3DHostPayment($request); + $result = $pos->getResponse(); $this->assertIsArray($result); $this->assertTrue($pos->isSuccess()); @@ -182,6 +185,7 @@ public function testMake3DPayPayment3DAuthFail() $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $posMock->make3DPayment($request); + $result = $posMock->getResponse(); $this->assertIsArray($result); $this->assertFalse($posMock->isSuccess()); @@ -216,6 +220,7 @@ public function testStatusSuccess() $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $posMock->status(); + $result = $posMock->getResponse(); $this->assertIsArray($result); $this->assertTrue($posMock->isSuccess()); @@ -250,6 +255,7 @@ public function testStatusFail() $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $posMock->status(); + $result = $posMock->getResponse(); $this->assertIsArray($result); $this->assertFalse($posMock->isSuccess()); @@ -284,6 +290,7 @@ public function testHistorySuccess() $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $posMock->history([]); + $result = $posMock->getResponse(); $this->assertIsArray($result); $this->assertTrue($posMock->isSuccess()); @@ -318,6 +325,7 @@ public function testHistoryFail() $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $posMock->history([]); + $result = $posMock->getResponse(); $this->assertIsArray($result); $this->assertFalse($posMock->isSuccess()); @@ -352,6 +360,7 @@ public function testCancelSuccess() $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $posMock->cancel(); + $result = $posMock->getResponse(); $this->assertIsArray($result); $this->assertTrue($posMock->isSuccess()); @@ -386,6 +395,7 @@ public function testCancelFail() $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $posMock->cancel(); + $result = $posMock->getResponse(); $this->assertIsArray($result); $this->assertFalse($posMock->isSuccess()); @@ -420,6 +430,7 @@ public function testRefundFail() $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); $posMock->refund(); + $result = $posMock->getResponse(); $this->assertIsArray($result); $this->assertFalse($posMock->isSuccess()); diff --git a/tests/Gateways/GarantiPosTest.php b/tests/Gateways/GarantiPosTest.php index f77f3d7a..3b21be69 100644 --- a/tests/Gateways/GarantiPosTest.php +++ b/tests/Gateways/GarantiPosTest.php @@ -65,6 +65,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->account); $this->pos->setTestMode(true); + $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '21', '12', '122'); } diff --git a/tests/Gateways/InterPosTest.php b/tests/Gateways/InterPosTest.php index 84b131ea..1b3b2201 100644 --- a/tests/Gateways/InterPosTest.php +++ b/tests/Gateways/InterPosTest.php @@ -67,6 +67,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->account); $this->pos->setTestMode(true); + $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '21', '12', '122', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA); } diff --git a/tests/Gateways/KuveytPosTest.php b/tests/Gateways/KuveytPosTest.php index b037ad3f..b19b0761 100644 --- a/tests/Gateways/KuveytPosTest.php +++ b/tests/Gateways/KuveytPosTest.php @@ -73,6 +73,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->threeDAccount); $this->pos->setTestMode(true); + $this->card = CreditCardFactory::create( $this->pos, '4155650100416111', @@ -238,6 +239,7 @@ public function testMake3DPaymentAuthSuccessProvisionSuccess() ->getMock(); $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); + $paymentResponse = $kuveytPosResponseDataMapperTest->threeDPaymentDataProvider()['success1']['paymentData']; $posMock->expects($this->once())->method('send')->willReturn($paymentResponse); diff --git a/tests/Gateways/PayForTest.php b/tests/Gateways/PayForTest.php index eb96a3c2..c353a421 100644 --- a/tests/Gateways/PayForTest.php +++ b/tests/Gateways/PayForTest.php @@ -62,6 +62,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->threeDAccount); $this->pos->setTestMode(true); + $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '22', '01', '123', 'ahmet'); } diff --git a/tests/Gateways/PosNetTest.php b/tests/Gateways/PosNetTest.php index 38c15389..6d8ef1ff 100644 --- a/tests/Gateways/PosNetTest.php +++ b/tests/Gateways/PosNetTest.php @@ -70,6 +70,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->account); $this->pos->setTestMode(true); + $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '21', '12', '122', 'ahmet'); } @@ -158,6 +159,7 @@ public function testMake3DPaymentSuccess() ->getMock(); $posMock->setTestMode(true); $posMock->prepare($this->order, AbstractGateway::TX_PAY, $this->card); + $bankResponses = $responseMapperTest->threeDPaymentDataProvider()['success1']; $posMock->expects($this->exactly(2))->method('send')->will( $this->onConsecutiveCalls( diff --git a/tests/Gateways/VakifBankCPPosTest.php b/tests/Gateways/VakifBankCPPosTest.php index 875e3eec..c3ebf585 100644 --- a/tests/Gateways/VakifBankCPPosTest.php +++ b/tests/Gateways/VakifBankCPPosTest.php @@ -69,6 +69,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->account); $this->pos->setTestMode(true); + $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '2021', '12', '122', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA); } diff --git a/tests/Gateways/VakifBankPosTest.php b/tests/Gateways/VakifBankPosTest.php index 19c7ae68..44207c92 100644 --- a/tests/Gateways/VakifBankPosTest.php +++ b/tests/Gateways/VakifBankPosTest.php @@ -68,6 +68,7 @@ protected function setUp(): void $this->pos = PosFactory::createPosGateway($this->account); $this->pos->setTestMode(true); + $this->card = CreditCardFactory::create($this->pos, '5555444433332222', '2021', '12', '122', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA); } From 7db30e3c8aae225ad2a284651de99a507edf5c5c Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 13:17:10 +0100 Subject: [PATCH 46/54] rector - RenameParamToMatchTypeRector --- src/Gateways/KuveytPos.php | 4 ++-- src/Gateways/PayForPos.php | 2 +- src/Gateways/VakifBankCPPos.php | 4 ++-- src/Gateways/VakifBankPos.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index 6051f0fb..49a1d22f 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -69,9 +69,9 @@ public function send($contents, string $url = null) $responseBody = $response->getBody()->getContents(); try { $this->data = $this->XMLStringToArray($responseBody); - } catch (Exception $e) { + } catch (Exception $exception) { if (!$this->isHTML($responseBody)) { - throw new Exception($responseBody, $e->getCode(), $e); + throw new Exception($responseBody, $exception->getCode(), $exception); } //icinde form olan HTML response dondu diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index 8862e7bb..b0a150fd 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -169,7 +169,7 @@ public function send($contents, ?string $url = null) try { $this->data = $this->XMLStringToArray($response); - } catch (NotEncodableValueException $e) { + } catch (NotEncodableValueException $notEncodableValueException) { //Finansbank's history request response is in JSON format $this->data = json_decode($response, true); } diff --git a/src/Gateways/VakifBankCPPos.php b/src/Gateways/VakifBankCPPos.php index b823edf7..e51da3e7 100644 --- a/src/Gateways/VakifBankCPPos.php +++ b/src/Gateways/VakifBankCPPos.php @@ -162,10 +162,10 @@ public function send($contents, ?string $url = null) try { $this->data = $this->XMLStringToArray($responseBody); - } catch (NotEncodableValueException $e) { + } catch (NotEncodableValueException $notEncodableValueException) { if ($this->isHTML($responseBody)) { // if something wrong server responds with HTML content - throw new Exception($responseBody, $e->getCode(), $e); + throw new Exception($responseBody, $notEncodableValueException->getCode(), $notEncodableValueException); } $this->data = json_decode($responseBody, true); diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index f54f3dd4..2f887838 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -185,10 +185,10 @@ public function send($contents, ?string $url = null) try { $this->data = $this->XMLStringToArray($responseBody); - } catch (NotEncodableValueException $e) { + } catch (NotEncodableValueException $notEncodableValueException) { if ($this->isHTML($responseBody)) { // if something wrong server responds with HTML content - throw new Exception($responseBody, $e->getCode(), $e); + throw new Exception($responseBody, $notEncodableValueException->getCode(), $notEncodableValueException); } $this->data = json_decode($responseBody, true); From 767481628e1baea7a8d49c4b0981a5abbc18eb45 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 13:19:45 +0100 Subject: [PATCH 47/54] rector tests - AddArrayDefaultToArrayPropertyRector --- tests/Crypt/KuveytPosCryptTest.php | 2 +- tests/Crypt/PayForPosCryptTest.php | 2 +- tests/Gateways/VakifBankCPPosTest.php | 2 +- tests/Gateways/VakifBankPosTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Crypt/KuveytPosCryptTest.php b/tests/Crypt/KuveytPosCryptTest.php index 4f882900..d96a5318 100644 --- a/tests/Crypt/KuveytPosCryptTest.php +++ b/tests/Crypt/KuveytPosCryptTest.php @@ -12,7 +12,7 @@ class KuveytPosCryptTest extends TestCase { /** @var array|array */ - public $order; + public $order = []; /** @var KuveytPosCrypt */ public $crypt; diff --git a/tests/Crypt/PayForPosCryptTest.php b/tests/Crypt/PayForPosCryptTest.php index c39d50d9..881f3180 100644 --- a/tests/Crypt/PayForPosCryptTest.php +++ b/tests/Crypt/PayForPosCryptTest.php @@ -12,7 +12,7 @@ class PayForPosCryptTest extends TestCase { /** @var array|array */ - public $order; + public $order = []; /** @var PayForPosCrypt */ public $crypt; diff --git a/tests/Gateways/VakifBankCPPosTest.php b/tests/Gateways/VakifBankCPPosTest.php index c3ebf585..733fb74c 100644 --- a/tests/Gateways/VakifBankCPPosTest.php +++ b/tests/Gateways/VakifBankCPPosTest.php @@ -35,7 +35,7 @@ class VakifBankCPPosTest extends TestCase private $card; /** @var array */ - private $order; + private $order = []; protected function setUp(): void { diff --git a/tests/Gateways/VakifBankPosTest.php b/tests/Gateways/VakifBankPosTest.php index 44207c92..5dfa9c4b 100644 --- a/tests/Gateways/VakifBankPosTest.php +++ b/tests/Gateways/VakifBankPosTest.php @@ -34,7 +34,7 @@ class VakifBankPosTest extends TestCase private $card; /** @var array */ - private $order; + private $order = []; protected function setUp(): void { From 494729425a31c5bb0b27bc1abb9c41c8fd06dda8 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 13:39:49 +0100 Subject: [PATCH 48/54] update rector rules --- rector.php | 87 ++++++++---------------------------------------------- 1 file changed, 12 insertions(+), 75 deletions(-) diff --git a/rector.php b/rector.php index 8f56253c..8764720d 100644 --- a/rector.php +++ b/rector.php @@ -3,7 +3,6 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { $rectorConfig->paths([ @@ -12,67 +11,19 @@ __DIR__.'/tests', ]); - $rectorConfig->rules([ - \Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector::class, - \Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class, - \Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector::class, - \Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class, - \Rector\CodeQuality\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector::class, - \Rector\CodeQuality\Rector\FuncCall\ArrayKeysAndInArrayToArrayKeyExistsRector::class, - \Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector::class, - \Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class, - \Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector::class, - \Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector::class, - \Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector::class, - \Rector\CodeQuality\Rector\FuncCall\StrvalToTypeCastRector::class, - \Rector\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector::class, - \Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessLastVariableAssignRector::class, - \Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessLastVariableAssignRector::class, - \Rector\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector::class, - \Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector::class, - \Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class, - \Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector::class, - \Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector::class, - \Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector::class, - \Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector::class, - \Rector\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector::class, - \Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector::class, - \Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector::class, - \Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class, - \Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector::class, - \Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector::class, - \Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class, - \Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector::class, - \Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector::class, - \Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector::class, - \Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class, - \Rector\CodeQuality\Rector\If_\CombineIfRector::class, - \Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, - \Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector::class, - \Rector\CodeQuality\Rector\If_\ShortenElseIfRector::class, - \Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector::class, - \Rector\CodeQuality\Rector\If_\SimplifyIfExactValueReturnValueRector::class, - \Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector::class, - \Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector::class, - \Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector::class, - \Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector::class, - \Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector::class, - \Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, - \Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector::class, - \Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector::class, - \Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector::class, - \Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector::class, - \Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector::class, - \Rector\CodeQuality\Rector\Assign\CombinedAssignRector::class, + $rectorConfig->sets([ + \Rector\Set\ValueObject\SetList::CODE_QUALITY, + \Rector\Set\ValueObject\SetList::CODING_STYLE, + \Rector\Set\ValueObject\SetList::EARLY_RETURN, + \Rector\Set\ValueObject\SetList::PSR_4, + \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_72, + ]); - \Rector\CodingStyle\Rector\If_\NullableCompareToNullRector::class, - //\Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::class, - \Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class, - \Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class, - \Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector::class, + $rectorConfig->rules([ + \Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::class, \Rector\CodingStyle\Rector\ClassMethod\DataProviderArrayItemsNewlinedRector::class, - \Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector::class, + // DEAD_CODE rules \Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class, \Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class, \Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class, @@ -89,25 +40,11 @@ \Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class, \Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector::class, - \Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class, - \Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector::class, - - \Rector\Php53\Rector\Ternary\TernaryToElvisRector::class, - \Rector\Php54\Rector\Array_\LongArrayToShortArrayRector::class, - \Rector\Php70\Rector\FuncCall\RandomFunctionRector::class, - \Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector::class, - \Rector\Php71\Rector\FuncCall\CountOnNullRector::class, - \Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector::class, - \Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector::class, - //\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class, \Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector::class, - - \Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class, ]); - // define sets of rules - $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_72, + $rectorConfig->ruleWithConfiguration(\Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class, [ + \Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::DELIMITER => '/', ]); $rectorConfig->ruleWithConfiguration(\Rector\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector::class, [ From 8122da2a5ccb994ff0b893b52a941f203bdbc5b1 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 14:00:53 +0100 Subject: [PATCH 49/54] updated docs --- README.md | 2 ++ docs/CHANGELOG.md | 11 ++++++++++- src/Gateways/VakifBankPos.php | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a9e30612..9493eb1b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal - **VakifBank GET 7/24 MPI ve VPOS 7/24** 3D Secure ödemesi çalışır durumda, diğer işlemlerde sorunlar ortaya çıktıkça giderilecek. +- **VakifBank Common Payment (Ortak Ödeme)** 3DPay ve 3DHost ödeme desteği eklendi. + - **InterPOS (Deniz bank)** destegi eklenmiştir, test edildikçe, sorunlar bulundukça hatalar giderilecek. - **Kuveyt POS** 3d secure ödeme desteği eklenmiştir - testleri yapıldı, calışıyor. diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d2b2d60a..1669c21e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,11 +1,20 @@ # Changelog -## [0.12.0] - 2023-02-06 +## [0.12.0] - 2023-03-13 +### New Features +- Vakıfbank Common Payment (Ortak Ödeme) gateway desteği eklendi (`VakifBankCPPos`). + Sadece **3DPay** ve **3DHost** ödeme destekleri eklendi. + Örnek kodlar "examples/vakifbank-cp." altında yer almaktadır. + ### Changed - **EstPos** - `MODEL_3D_PAY_HOSTING` desteği eklendi @umuttaymaz. - `get3DFormData()` - artık gereken _kart_ veya _sipariş_ bilgileri olmadan çağrıldığında istisna fırlatır. +- `get3DFormData()` - dönen değere artık HTTP methodu eklendi. Örn: `'method' => 'POST'` (ya da GET); - `VakifBankPosRequestDataMapper` - `OrderDescription` tanımsız olma durumu giderildi. +### Fixed +- **Vakifbank** - bazı _undefined index_ hatalar giderildi. + ## [0.11.0] - 2023-01-08 ### Changed - Response formatı **object** yerine artık **array** olarak değiştirildi, `$pos->getResponse();` kod artık array döner. diff --git a/src/Gateways/VakifBankPos.php b/src/Gateways/VakifBankPos.php index 2f887838..bb708440 100644 --- a/src/Gateways/VakifBankPos.php +++ b/src/Gateways/VakifBankPos.php @@ -15,7 +15,7 @@ use Symfony\Component\Serializer\Exception\NotEncodableValueException; /** - * Class VakifBankPos + * Vakifbank VPOS 7/24 gateway'i destekler */ class VakifBankPos extends AbstractGateway { From 1de03d6fe14d98b045e13bfd321cc2eb3e971a5b Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 20:19:38 +0100 Subject: [PATCH 50/54] examples - rename folder --- examples/_common-codes/3d-host/index.php | 6 +++--- examples/_common-codes/3d/form.php | 6 +++--- examples/_common-codes/3d/index.php | 6 +++--- examples/_common-codes/regular/form.php | 2 +- examples/{template => _templates}/_credit_card_form.php | 0 examples/{template => _templates}/_footer.php | 0 examples/{template => _templates}/_header.php | 0 examples/{template => _templates}/_payment_response.php | 0 examples/{template => _templates}/_redirect_form.php | 0 examples/{template => _templates}/_simple_response_dump.php | 0 examples/akbank/3d-host/response.php | 2 +- examples/akbank/3d-pay-hosting/response.php | 2 +- examples/akbank/3d-pay/response.php | 2 +- examples/akbank/3d/response.php | 2 +- examples/akbank/index.php | 4 ++-- examples/akbank/regular/cancel.php | 6 +++--- examples/akbank/regular/history.php | 6 +++--- examples/akbank/regular/post-auth.php | 2 +- examples/akbank/regular/refund.php | 6 +++--- examples/akbank/regular/status.php | 6 +++--- examples/finansbank-payfor/3d-host/response.php | 2 +- examples/finansbank-payfor/3d-pay/response.php | 2 +- examples/finansbank-payfor/3d/response.php | 2 +- examples/finansbank-payfor/index.php | 4 ++-- examples/finansbank-payfor/regular/cancel.php | 6 +++--- examples/finansbank-payfor/regular/history.php | 6 +++--- examples/finansbank-payfor/regular/post-auth.php | 2 +- examples/finansbank-payfor/regular/refund.php | 6 +++--- examples/finansbank-payfor/regular/status.php | 6 +++--- examples/garanti/3d-pay/response.php | 2 +- examples/garanti/3d/response.php | 2 +- examples/garanti/index.php | 4 ++-- examples/garanti/regular/cancel.php | 6 +++--- examples/garanti/regular/history.php | 6 +++--- examples/garanti/regular/post-auth.php | 2 +- examples/garanti/regular/refund.php | 6 +++--- examples/garanti/regular/status.php | 6 +++--- examples/index.php | 4 ++-- examples/interpos/3d-host/response.php | 2 +- examples/interpos/3d-pay/response.php | 2 +- examples/interpos/3d/response.php | 2 +- examples/interpos/index.php | 4 ++-- examples/interpos/regular/cancel.php | 6 +++--- examples/interpos/regular/post-auth.php | 2 +- examples/interpos/regular/refund.php | 6 +++--- examples/interpos/regular/status.php | 6 +++--- examples/kuveytpos/3d/response.php | 2 +- examples/kuveytpos/index.php | 4 ++-- examples/vakifbank-cp/3d-host/response.php | 2 +- examples/vakifbank-cp/3d-pay/response.php | 2 +- examples/vakifbank-cp/index.php | 4 ++-- examples/vakifbank-cp/regular/cancel.php | 6 +++--- examples/vakifbank-cp/regular/post-auth.php | 2 +- examples/vakifbank-cp/regular/refund.php | 6 +++--- examples/vakifbank/3d/response.php | 2 +- examples/vakifbank/index.php | 4 ++-- examples/vakifbank/regular/cancel.php | 6 +++--- examples/vakifbank/regular/post-auth.php | 2 +- examples/vakifbank/regular/refund.php | 6 +++--- examples/ykb/3d/response.php | 2 +- examples/ykb/index.php | 4 ++-- examples/ykb/regular/cancel.php | 6 +++--- examples/ykb/regular/post-auth.php | 2 +- examples/ykb/regular/refund.php | 6 +++--- examples/ykb/regular/status.php | 6 +++--- 65 files changed, 118 insertions(+), 118 deletions(-) rename examples/{template => _templates}/_credit_card_form.php (100%) rename examples/{template => _templates}/_footer.php (100%) rename examples/{template => _templates}/_header.php (100%) rename examples/{template => _templates}/_payment_response.php (100%) rename examples/{template => _templates}/_redirect_form.php (100%) rename examples/{template => _templates}/_simple_response_dump.php (100%) diff --git a/examples/_common-codes/3d-host/index.php b/examples/_common-codes/3d-host/index.php index c9ee9956..ce3ed78d 100644 --- a/examples/_common-codes/3d-host/index.php +++ b/examples/_common-codes/3d-host/index.php @@ -1,7 +1,7 @@ get3DFormData(); -require '../../template/_redirect_form.php'; -require '../../template/_footer.php'; +require '../../_templates/_redirect_form.php'; +require '../../_templates/_footer.php'; diff --git a/examples/_common-codes/3d/form.php b/examples/_common-codes/3d/form.php index ac7478d3..a0c6de21 100644 --- a/examples/_common-codes/3d/form.php +++ b/examples/_common-codes/3d/form.php @@ -3,7 +3,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; require '_config.php'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; if ($request->getMethod() !== 'POST') { echo new RedirectResponse($baseUrl.'index.php'); @@ -38,5 +38,5 @@ } -require '../../template/_redirect_form.php'; -require '../../template/_footer.php'; +require '../../_templates/_redirect_form.php'; +require '../../_templates/_footer.php'; diff --git a/examples/_common-codes/3d/index.php b/examples/_common-codes/3d/index.php index a66cc79a..83ba496f 100644 --- a/examples/_common-codes/3d/index.php +++ b/examples/_common-codes/3d/index.php @@ -1,10 +1,10 @@ request->all()); -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/template/_credit_card_form.php b/examples/_templates/_credit_card_form.php similarity index 100% rename from examples/template/_credit_card_form.php rename to examples/_templates/_credit_card_form.php diff --git a/examples/template/_footer.php b/examples/_templates/_footer.php similarity index 100% rename from examples/template/_footer.php rename to examples/_templates/_footer.php diff --git a/examples/template/_header.php b/examples/_templates/_header.php similarity index 100% rename from examples/template/_header.php rename to examples/_templates/_header.php diff --git a/examples/template/_payment_response.php b/examples/_templates/_payment_response.php similarity index 100% rename from examples/template/_payment_response.php rename to examples/_templates/_payment_response.php diff --git a/examples/template/_redirect_form.php b/examples/_templates/_redirect_form.php similarity index 100% rename from examples/template/_redirect_form.php rename to examples/_templates/_redirect_form.php diff --git a/examples/template/_simple_response_dump.php b/examples/_templates/_simple_response_dump.php similarity index 100% rename from examples/template/_simple_response_dump.php rename to examples/_templates/_simple_response_dump.php diff --git a/examples/akbank/3d-host/response.php b/examples/akbank/3d-host/response.php index 3b26165b..04d1c82f 100644 --- a/examples/akbank/3d-host/response.php +++ b/examples/akbank/3d-host/response.php @@ -1,4 +1,4 @@ get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); @@ -29,5 +29,5 @@ $pos->cancel(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/akbank/regular/history.php b/examples/akbank/regular/history.php index d01ff502..7f09112e 100644 --- a/examples/akbank/regular/history.php +++ b/examples/akbank/regular/history.php @@ -3,7 +3,7 @@ $templateTitle = 'History Order'; require '_config.php'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $ord = $session->get('order'); @@ -16,5 +16,5 @@ $query = $pos->history($order); $response = $query->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/akbank/regular/post-auth.php b/examples/akbank/regular/post-auth.php index dd7c0f74..bba4a57e 100644 --- a/examples/akbank/regular/post-auth.php +++ b/examples/akbank/regular/post-auth.php @@ -14,4 +14,4 @@ $transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; $card = null; -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/akbank/regular/refund.php b/examples/akbank/regular/refund.php index 066bfc5e..50b44494 100644 --- a/examples/akbank/regular/refund.php +++ b/examples/akbank/regular/refund.php @@ -4,7 +4,7 @@ $templateTitle = 'Refund Order'; require '_config.php'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); @@ -21,5 +21,5 @@ $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/akbank/regular/status.php b/examples/akbank/regular/status.php index 9ba2ae1a..73e5bb2d 100644 --- a/examples/akbank/regular/status.php +++ b/examples/akbank/regular/status.php @@ -4,7 +4,7 @@ $templateTitle = 'Order Status'; require '_config.php'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $ord = $session->get('order'); $lastResponse = $session->get('last_response'); @@ -28,5 +28,5 @@ $pos->status(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/finansbank-payfor/3d-host/response.php b/examples/finansbank-payfor/3d-host/response.php index 3b26165b..04d1c82f 100644 --- a/examples/finansbank-payfor/3d-host/response.php +++ b/examples/finansbank-payfor/3d-host/response.php @@ -1,4 +1,4 @@ getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/finansbank-payfor/regular/history.php b/examples/finansbank-payfor/regular/history.php index ba831b33..d4c69272 100644 --- a/examples/finansbank-payfor/regular/history.php +++ b/examples/finansbank-payfor/regular/history.php @@ -3,7 +3,7 @@ $templateTitle = 'History Order'; require '_config.php'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $ord = $session->get('order'); @@ -20,5 +20,5 @@ $response = $query->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/finansbank-payfor/regular/post-auth.php b/examples/finansbank-payfor/regular/post-auth.php index 79392727..e4fe75ed 100644 --- a/examples/finansbank-payfor/regular/post-auth.php +++ b/examples/finansbank-payfor/regular/post-auth.php @@ -10,4 +10,4 @@ $transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; $card = null; -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/finansbank-payfor/regular/refund.php b/examples/finansbank-payfor/regular/refund.php index 367e394b..7bc5a384 100644 --- a/examples/finansbank-payfor/regular/refund.php +++ b/examples/finansbank-payfor/regular/refund.php @@ -2,7 +2,7 @@ $templateTitle = 'Refund Order'; require '_config.php'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; use Mews\Pos\Gateways\AbstractGateway; @@ -21,5 +21,5 @@ $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/finansbank-payfor/regular/status.php b/examples/finansbank-payfor/regular/status.php index 13ed2a29..3b1328ca 100644 --- a/examples/finansbank-payfor/regular/status.php +++ b/examples/finansbank-payfor/regular/status.php @@ -2,7 +2,7 @@ $templateTitle = 'Order Status'; require '_config.php'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; use Mews\Pos\Gateways\AbstractGateway; @@ -18,5 +18,5 @@ $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/garanti/3d-pay/response.php b/examples/garanti/3d-pay/response.php index 3b26165b..04d1c82f 100644 --- a/examples/garanti/3d-pay/response.php +++ b/examples/garanti/3d-pay/response.php @@ -1,4 +1,4 @@ cancel(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/garanti/regular/history.php b/examples/garanti/regular/history.php index e30005c2..645db02e 100644 --- a/examples/garanti/regular/history.php +++ b/examples/garanti/regular/history.php @@ -2,7 +2,7 @@ require '_config.php'; $templateTitle = 'History Order'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); @@ -18,5 +18,5 @@ $query = $pos->history([]); $response = $query->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/garanti/regular/post-auth.php b/examples/garanti/regular/post-auth.php index 84b7ef77..76413834 100644 --- a/examples/garanti/regular/post-auth.php +++ b/examples/garanti/regular/post-auth.php @@ -18,4 +18,4 @@ $transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; $card = null; -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/garanti/regular/refund.php b/examples/garanti/regular/refund.php index c7b71917..23ad80da 100644 --- a/examples/garanti/regular/refund.php +++ b/examples/garanti/regular/refund.php @@ -2,7 +2,7 @@ require '_config.php'; $templateTitle = 'Refund Order'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; use Mews\Pos\Gateways\AbstractGateway; @@ -22,5 +22,5 @@ $pos->refund(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/garanti/regular/status.php b/examples/garanti/regular/status.php index 31acb932..4a38491c 100644 --- a/examples/garanti/regular/status.php +++ b/examples/garanti/regular/status.php @@ -2,7 +2,7 @@ require '_config.php'; $templateTitle = 'Order Status'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; use Mews\Pos\Gateways\AbstractGateway; @@ -19,5 +19,5 @@ $pos->status(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/index.php b/examples/index.php index 8ae8553b..7d2c104b 100644 --- a/examples/index.php +++ b/examples/index.php @@ -5,5 +5,5 @@ */ $templateTitle = 'POS'; require './_main_config.php'; -require './template/_header.php'; -require './template/_footer.php'; +require './_templates/_header.php'; +require './_templates/_footer.php'; diff --git a/examples/interpos/3d-host/response.php b/examples/interpos/3d-host/response.php index 3b26165b..04d1c82f 100644 --- a/examples/interpos/3d-host/response.php +++ b/examples/interpos/3d-host/response.php @@ -1,4 +1,4 @@ get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); @@ -19,5 +19,5 @@ $pos->cancel(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/interpos/regular/post-auth.php b/examples/interpos/regular/post-auth.php index 79392727..e4fe75ed 100644 --- a/examples/interpos/regular/post-auth.php +++ b/examples/interpos/regular/post-auth.php @@ -10,4 +10,4 @@ $transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; $card = null; -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/interpos/regular/refund.php b/examples/interpos/regular/refund.php index 0d4c01eb..983205cb 100644 --- a/examples/interpos/regular/refund.php +++ b/examples/interpos/regular/refund.php @@ -4,7 +4,7 @@ require '_config.php'; $templateTitle = 'Refund Order'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); @@ -20,5 +20,5 @@ $pos->refund(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/interpos/regular/status.php b/examples/interpos/regular/status.php index 7d315848..ce1e2ce3 100644 --- a/examples/interpos/regular/status.php +++ b/examples/interpos/regular/status.php @@ -4,7 +4,7 @@ require '_config.php'; $templateTitle = 'Order Status'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $ord = $session->get('order'); @@ -17,5 +17,5 @@ $pos->status(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/kuveytpos/3d/response.php b/examples/kuveytpos/3d/response.php index 3b26165b..04d1c82f 100644 --- a/examples/kuveytpos/3d/response.php +++ b/examples/kuveytpos/3d/response.php @@ -1,4 +1,4 @@ get('card'); $card = createCard($pos, $savedCard); -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/vakifbank-cp/index.php b/examples/vakifbank-cp/index.php index c9f420d1..b38cf2ef 100644 --- a/examples/vakifbank-cp/index.php +++ b/examples/vakifbank-cp/index.php @@ -2,5 +2,5 @@ require './_payment_config.php'; $templateTitle = 'Common Payment (VakifBank bank)'; -require '../template/_header.php'; -require '../template/_footer.php'; +require '../_templates/_header.php'; +require '../_templates/_footer.php'; diff --git a/examples/vakifbank-cp/regular/cancel.php b/examples/vakifbank-cp/regular/cancel.php index 83c0c1b9..31773b5f 100644 --- a/examples/vakifbank-cp/regular/cancel.php +++ b/examples/vakifbank-cp/regular/cancel.php @@ -4,7 +4,7 @@ require '_config.php'; $templateTitle = 'Cancel Order'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $order = [ 'id' => $session->get('ref_ret_num'), //ReferenceTransactionId @@ -18,5 +18,5 @@ $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/vakifbank-cp/regular/post-auth.php b/examples/vakifbank-cp/regular/post-auth.php index f370b71a..aa052295 100644 --- a/examples/vakifbank-cp/regular/post-auth.php +++ b/examples/vakifbank-cp/regular/post-auth.php @@ -17,4 +17,4 @@ $transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; $card = null; -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/vakifbank-cp/regular/refund.php b/examples/vakifbank-cp/regular/refund.php index 9440d95c..83d794b2 100644 --- a/examples/vakifbank-cp/regular/refund.php +++ b/examples/vakifbank-cp/regular/refund.php @@ -4,7 +4,7 @@ require '_config.php'; $templateTitle = 'Refund Order'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); // Refund Order @@ -19,5 +19,5 @@ $pos->refund(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/vakifbank/3d/response.php b/examples/vakifbank/3d/response.php index d85e7523..5288543c 100644 --- a/examples/vakifbank/3d/response.php +++ b/examples/vakifbank/3d/response.php @@ -5,4 +5,4 @@ $savedCard = $session->get('card'); $card = createCard($pos, $savedCard); -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/vakifbank/index.php b/examples/vakifbank/index.php index 235791dc..0a3563a2 100644 --- a/examples/vakifbank/index.php +++ b/examples/vakifbank/index.php @@ -2,5 +2,5 @@ require './_payment_config.php'; $templateTitle = 'VPOS (VakifBank bank)'; -require '../template/_header.php'; -require '../template/_footer.php'; +require '../_templates/_header.php'; +require '../_templates/_footer.php'; diff --git a/examples/vakifbank/regular/cancel.php b/examples/vakifbank/regular/cancel.php index 83c0c1b9..31773b5f 100644 --- a/examples/vakifbank/regular/cancel.php +++ b/examples/vakifbank/regular/cancel.php @@ -4,7 +4,7 @@ require '_config.php'; $templateTitle = 'Cancel Order'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $order = [ 'id' => $session->get('ref_ret_num'), //ReferenceTransactionId @@ -18,5 +18,5 @@ $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/vakifbank/regular/post-auth.php b/examples/vakifbank/regular/post-auth.php index f370b71a..aa052295 100644 --- a/examples/vakifbank/regular/post-auth.php +++ b/examples/vakifbank/regular/post-auth.php @@ -17,4 +17,4 @@ $transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; $card = null; -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/vakifbank/regular/refund.php b/examples/vakifbank/regular/refund.php index f0ae4d18..1268afa9 100644 --- a/examples/vakifbank/regular/refund.php +++ b/examples/vakifbank/regular/refund.php @@ -4,7 +4,7 @@ require '_config.php'; $templateTitle = 'Refund Order'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); // Refund Order @@ -19,5 +19,5 @@ $pos->refund(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/ykb/3d/response.php b/examples/ykb/3d/response.php index 3b26165b..04d1c82f 100644 --- a/examples/ykb/3d/response.php +++ b/examples/ykb/3d/response.php @@ -1,4 +1,4 @@ get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); @@ -25,5 +25,5 @@ $pos->cancel(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/ykb/regular/post-auth.php b/examples/ykb/regular/post-auth.php index 3c88ff08..97113795 100644 --- a/examples/ykb/regular/post-auth.php +++ b/examples/ykb/regular/post-auth.php @@ -18,4 +18,4 @@ $transaction = \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY; $card = null; -require '../../template/_payment_response.php'; +require '../../_templates/_payment_response.php'; diff --git a/examples/ykb/regular/refund.php b/examples/ykb/regular/refund.php index 2019852a..aca4c3be 100644 --- a/examples/ykb/regular/refund.php +++ b/examples/ykb/regular/refund.php @@ -4,7 +4,7 @@ require '_config.php'; $templateTitle = 'Refund Order'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); @@ -19,5 +19,5 @@ $pos->refund(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; diff --git a/examples/ykb/regular/status.php b/examples/ykb/regular/status.php index 65e1a210..e26ed876 100644 --- a/examples/ykb/regular/status.php +++ b/examples/ykb/regular/status.php @@ -4,7 +4,7 @@ require '_config.php'; $templateTitle = 'Order Status'; -require '../../template/_header.php'; +require '../../_templates/_header.php'; $ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', 'TRY'), $session); @@ -18,5 +18,5 @@ $pos->status(); $response = $pos->getResponse(); -require '../../template/_simple_response_dump.php'; -require '../../template/_footer.php'; +require '../../_templates/_simple_response_dump.php'; +require '../../_templates/_footer.php'; From 27766aae387ba1053fbab8e006fb16360a5c1ae9 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 20:27:47 +0100 Subject: [PATCH 51/54] examples - naming changes --- examples/_templates/_header.php | 4 ++-- examples/vakifbank-cp/index.php | 2 +- examples/vakifbank/index.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/_templates/_header.php b/examples/_templates/_header.php index d0764177..f67586d6 100644 --- a/examples/_templates/_header.php +++ b/examples/_templates/_header.php @@ -30,8 +30,8 @@
  • PayFor (Finansbank)
  • Garanti POS
  • InterPos (Deniz bank)
  • -
  • VPOS (VakifBank bank)
  • -
  • Common Payment (VakifBank bank)
  • +
  • VPOS 7/24 (VakifBank)
  • +
  • Common Payment (VakifBank)
  • PosNet (YKB)
  • KuveytPOS
  • diff --git a/examples/vakifbank-cp/index.php b/examples/vakifbank-cp/index.php index b38cf2ef..28334452 100644 --- a/examples/vakifbank-cp/index.php +++ b/examples/vakifbank-cp/index.php @@ -1,6 +1,6 @@ Date: Sun, 12 Mar 2023 20:28:13 +0100 Subject: [PATCH 52/54] updated CHANGELOG.md --- docs/CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1669c21e..ffc3cddd 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,16 +4,16 @@ ### New Features - Vakıfbank Common Payment (Ortak Ödeme) gateway desteği eklendi (`VakifBankCPPos`). Sadece **3DPay** ve **3DHost** ödeme destekleri eklendi. - Örnek kodlar "examples/vakifbank-cp." altında yer almaktadır. + Örnek kodlar `examples/vakifbank-cp/` altında yer almaktadır. ### Changed - **EstPos** - `MODEL_3D_PAY_HOSTING` desteği eklendi @umuttaymaz. -- `get3DFormData()` - artık gereken _kart_ veya _sipariş_ bilgileri olmadan çağrıldığında istisna fırlatır. -- `get3DFormData()` - dönen değere artık HTTP methodu eklendi. Örn: `'method' => 'POST'` (ya da GET); -- `VakifBankPosRequestDataMapper` - `OrderDescription` tanımsız olma durumu giderildi. +- `get3DFormData()` - artık zorunlu _kart_ veya _sipariş_ bilgileri olmadan çağrıldığında istisna fırlatır. +- `get3DFormData()` - dönen değere HTTP methodu eklendi. Örn: `'method' => 'POST'` (ya da GET); ### Fixed - **Vakifbank** - bazı _undefined index_ hatalar giderildi. +- `VakifBankPosRequestDataMapper` - `OrderDescription` tanımsız olma durumu giderildi. ## [0.11.0] - 2023-01-08 ### Changed From 9827d1bd180180064f132cf3a7225c5d09b264af Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 20:53:04 +0100 Subject: [PATCH 53/54] update rector rules --- rector.php | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/rector.php b/rector.php index 8764720d..06bdc485 100644 --- a/rector.php +++ b/rector.php @@ -3,6 +3,8 @@ declare(strict_types=1); use Rector\Config\RectorConfig; +use Rector\Set\ValueObject\LevelSetList; +use Rector\Set\ValueObject\SetList; return static function (RectorConfig $rectorConfig): void { $rectorConfig->paths([ @@ -12,37 +14,28 @@ ]); $rectorConfig->sets([ - \Rector\Set\ValueObject\SetList::CODE_QUALITY, - \Rector\Set\ValueObject\SetList::CODING_STYLE, - \Rector\Set\ValueObject\SetList::EARLY_RETURN, - \Rector\Set\ValueObject\SetList::PSR_4, - \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_72, + SetList::CODE_QUALITY, + SetList::CODING_STYLE, + SetList::EARLY_RETURN, + SetList::DEAD_CODE, + SetList::PSR_4, + LevelSetList::UP_TO_PHP_72, ]); $rectorConfig->rules([ \Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::class, \Rector\CodingStyle\Rector\ClassMethod\DataProviderArrayItemsNewlinedRector::class, - - // DEAD_CODE rules - \Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class, - \Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class, - \Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class, - \Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector::class, - \Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class, - \Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector::class, - \Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector::class, - \Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class, - \Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector::class, - \Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class, - \Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector::class, - \Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class, - \Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class, - \Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class, - \Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector::class, - \Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector::class, ]); + $rectorConfig->skip([ + \Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class, + \Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class, + \Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector::class => [ + __DIR__ . '/src/DataMapper/ResponseDataMapper', + ], + ]); + $rectorConfig->ruleWithConfiguration(\Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class, [ \Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::DELIMITER => '/', ]); From 9ba706247f842bc5cabca139469915b256fccfc7 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 12 Mar 2023 21:04:36 +0100 Subject: [PATCH 54/54] rename github template files to fix composer errors --- .../ISSUE_TEMPLATE/hata-bildirimi-icin.md | 0 .../ISSUE_TEMPLATE/sorulariniz-icin.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename ".github/ISSUE_TEMPLATE/hata-bildirimi-i\303\247in.md" => .github/ISSUE_TEMPLATE/hata-bildirimi-icin.md (100%) rename ".github/ISSUE_TEMPLATE/sorular\304\261n\304\261z-i\303\247in.md" => .github/ISSUE_TEMPLATE/sorulariniz-icin.md (100%) diff --git "a/.github/ISSUE_TEMPLATE/hata-bildirimi-i\303\247in.md" b/.github/ISSUE_TEMPLATE/hata-bildirimi-icin.md similarity index 100% rename from ".github/ISSUE_TEMPLATE/hata-bildirimi-i\303\247in.md" rename to .github/ISSUE_TEMPLATE/hata-bildirimi-icin.md diff --git "a/.github/ISSUE_TEMPLATE/sorular\304\261n\304\261z-i\303\247in.md" b/.github/ISSUE_TEMPLATE/sorulariniz-icin.md similarity index 100% rename from ".github/ISSUE_TEMPLATE/sorular\304\261n\304\261z-i\303\247in.md" rename to .github/ISSUE_TEMPLATE/sorulariniz-icin.md