diff --git a/phpunit.xml b/phpunit.xml index e7cb9eca..869f911e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -19,4 +19,20 @@ tests/Functional + + + + + + + + + src + + diff --git a/src/Crypt/AkbankPosCrypt.php b/src/Crypt/AkbankPosCrypt.php index 82bbdb53..a7cdde01 100644 --- a/src/Crypt/AkbankPosCrypt.php +++ b/src/Crypt/AkbankPosCrypt.php @@ -27,34 +27,34 @@ public function generateRandomString(int $length = 128): string * @param AkbankPosAccount $posAccount * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { $hashData = [ - $requestData['paymentModel'], - $requestData['txnCode'], + $formInputs['paymentModel'], + $formInputs['txnCode'], $posAccount->getClientId(), $posAccount->getTerminalId(), - $requestData['orderId'], - $requestData['lang'], - $requestData['amount'], - $requestData['ccbRewardAmount'] ?? '', - $requestData['pcbRewardAmount'] ?? '', - $requestData['xcbRewardAmount'] ?? '', - $requestData['currencyCode'], - $requestData['installCount'], - $requestData['okUrl'], - $requestData['failUrl'], - $requestData['emailAddress'] ?? '', + $formInputs['orderId'], + $formInputs['lang'], + $formInputs['amount'], + $formInputs['ccbRewardAmount'] ?? '', + $formInputs['pcbRewardAmount'] ?? '', + $formInputs['xcbRewardAmount'] ?? '', + $formInputs['currencyCode'], + $formInputs['installCount'], + $formInputs['okUrl'], + $formInputs['failUrl'], + $formInputs['emailAddress'] ?? '', $posAccount->getSubMerchantId() ?? '', // 3D hosting model does not have credit card information - $requestData['creditCard'] ?? '', - $requestData['expiredDate'] ?? '', - $requestData['cvv'] ?? '', + $formInputs['creditCard'] ?? '', + $formInputs['expiredDate'] ?? '', + $formInputs['cvv'] ?? '', - $requestData['randomNumber'], - $requestData['requestDateTime'], - $requestData['b2bIdentityNumber'] ?? '', + $formInputs['randomNumber'], + $formInputs['requestDateTime'], + $formInputs['b2bIdentityNumber'] ?? '', ]; $hashStr = \implode(static::HASH_SEPARATOR, $hashData); @@ -89,10 +89,7 @@ public function check3DHash(AbstractPosAccount $posAccount, array $data): bool } /** - * @param AbstractPosAccount $posAccount - * @param array $requestData - * - * @return string + * @inheritDoc */ public function createHash(AbstractPosAccount $posAccount, array $requestData): string { diff --git a/src/Crypt/CryptInterface.php b/src/Crypt/CryptInterface.php index 3bd01c67..dece7069 100644 --- a/src/Crypt/CryptInterface.php +++ b/src/Crypt/CryptInterface.php @@ -31,11 +31,11 @@ public function check3DHash(AbstractPosAccount $posAccount, array $data): bool; * creates hash for 3D form data * * @param AbstractPosAccount $posAccount - * @param array $requestData + * @param array $formInputs * * @return string */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string; + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string; /** * create hash for API requests diff --git a/src/Crypt/EstPosCrypt.php b/src/Crypt/EstPosCrypt.php index 32afddfb..51266e47 100644 --- a/src/Crypt/EstPosCrypt.php +++ b/src/Crypt/EstPosCrypt.php @@ -13,17 +13,17 @@ class EstPosCrypt extends AbstractCrypt /** * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { $hashData = [ $posAccount->getClientId(), - $requestData['oid'], - $requestData['amount'], - $requestData['okUrl'], - $requestData['failUrl'], - $requestData['islemtipi'], - $requestData['taksit'], - $requestData['rnd'], + $formInputs['oid'], + $formInputs['amount'], + $formInputs['okUrl'], + $formInputs['failUrl'], + $formInputs['islemtipi'], + $formInputs['taksit'], + $formInputs['rnd'], $posAccount->getStoreKey(), ]; @@ -59,10 +59,7 @@ public function check3DHash(AbstractPosAccount $posAccount, array $data): bool } /** - * @param AbstractPosAccount $posAccount - * @param array $requestData - * - * @return string + * @inheritDoc */ public function createHash(AbstractPosAccount $posAccount, array $requestData): string { diff --git a/src/Crypt/EstV3PosCrypt.php b/src/Crypt/EstV3PosCrypt.php index c0a0c5d0..0250c6d4 100644 --- a/src/Crypt/EstV3PosCrypt.php +++ b/src/Crypt/EstV3PosCrypt.php @@ -19,10 +19,10 @@ class EstV3PosCrypt extends AbstractCrypt /** * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { - \ksort($requestData, SORT_NATURAL | SORT_FLAG_CASE); - foreach (\array_keys($requestData) as $key) { + \ksort($formInputs, SORT_NATURAL | SORT_FLAG_CASE); + foreach (\array_keys($formInputs) as $key) { /** * this part is needed only to create hash from the bank response * @@ -31,13 +31,13 @@ public function create3DHash(AbstractPosAccount $posAccount, array $requestData) * Payten tarafından hash içerisinde olmaması gerektiği teyidi alındı. */ if (\in_array(\strtolower($key), ['hash', 'encoding' , 'nationalidno'])) { - unset($requestData[$key]); + unset($formInputs[$key]); } } - $requestData[] = $posAccount->getStoreKey(); + $formInputs[] = $posAccount->getStoreKey(); // escape | and \ characters - $data = \str_replace("\\", "\\\\", \array_values($requestData)); + $data = \str_replace("\\", "\\\\", \array_values($formInputs)); $data = \str_replace(self::HASH_SEPARATOR, "\\".self::HASH_SEPARATOR, $data); $hashStr = \implode(self::HASH_SEPARATOR, $data); @@ -68,10 +68,7 @@ public function check3DHash(AbstractPosAccount $posAccount, array $data): bool } /** - * @param AbstractPosAccount $posAccount - * @param array $requestData - * - * @return string + * @inheritDoc */ public function createHash(AbstractPosAccount $posAccount, array $requestData): string { diff --git a/src/Crypt/GarantiPosCrypt.php b/src/Crypt/GarantiPosCrypt.php index 39c6aba5..b20eb362 100644 --- a/src/Crypt/GarantiPosCrypt.php +++ b/src/Crypt/GarantiPosCrypt.php @@ -17,19 +17,19 @@ class GarantiPosCrypt extends AbstractCrypt * @param GarantiPosAccount $posAccount * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { $map = [ $posAccount->getTerminalId(), - $requestData['orderid'], - $requestData['txnamount'], - $requestData['txncurrencycode'], - $requestData['successurl'], - $requestData['errorurl'], - $requestData['txntype'], - $requestData['txninstallmentcount'], + $formInputs['orderid'], + $formInputs['txnamount'], + $formInputs['txncurrencycode'], + $formInputs['successurl'], + $formInputs['errorurl'], + $formInputs['txntype'], + $formInputs['txninstallmentcount'], $posAccount->getStoreKey(), - $this->createSecurityData($posAccount, $requestData['txntype']), + $this->createSecurityData($posAccount, $formInputs['txntype']), ]; return $this->hashStringUpperCase(implode(static::HASH_SEPARATOR, $map), self::HASH_ALGORITHM); diff --git a/src/Crypt/InterPosCrypt.php b/src/Crypt/InterPosCrypt.php index 4b37454e..ae5b3253 100644 --- a/src/Crypt/InterPosCrypt.php +++ b/src/Crypt/InterPosCrypt.php @@ -13,17 +13,17 @@ class InterPosCrypt extends AbstractCrypt /** * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { $hashData = [ $posAccount->getClientId(), - $requestData['OrderId'], - $requestData['PurchAmount'], - $requestData['OkUrl'], - $requestData['FailUrl'], - $requestData['TxnType'], - $requestData['InstallmentCount'], - $requestData['Rnd'], + $formInputs['OrderId'], + $formInputs['PurchAmount'], + $formInputs['OkUrl'], + $formInputs['FailUrl'], + $formInputs['TxnType'], + $formInputs['InstallmentCount'], + $formInputs['Rnd'], $posAccount->getStoreKey(), ]; diff --git a/src/Crypt/KuveytPosCrypt.php b/src/Crypt/KuveytPosCrypt.php index ba8bda28..19adb0c1 100644 --- a/src/Crypt/KuveytPosCrypt.php +++ b/src/Crypt/KuveytPosCrypt.php @@ -13,7 +13,7 @@ class KuveytPosCrypt extends AbstractCrypt /** * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { throw new NotImplementedException(); } diff --git a/src/Crypt/NullCrypt.php b/src/Crypt/NullCrypt.php index bf2b4d4e..cf7dcf66 100644 --- a/src/Crypt/NullCrypt.php +++ b/src/Crypt/NullCrypt.php @@ -15,7 +15,7 @@ class NullCrypt extends AbstractCrypt /** * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { return ''; } diff --git a/src/Crypt/PayFlexCPV4Crypt.php b/src/Crypt/PayFlexCPV4Crypt.php index 619eb298..9ca94c52 100644 --- a/src/Crypt/PayFlexCPV4Crypt.php +++ b/src/Crypt/PayFlexCPV4Crypt.php @@ -13,7 +13,7 @@ class PayFlexCPV4Crypt extends AbstractCrypt /** * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { throw new NotImplementedException(); } diff --git a/src/Crypt/PayForPosCrypt.php b/src/Crypt/PayForPosCrypt.php index 3393a719..e5aa8c97 100644 --- a/src/Crypt/PayForPosCrypt.php +++ b/src/Crypt/PayForPosCrypt.php @@ -13,17 +13,17 @@ class PayForPosCrypt extends AbstractCrypt /** * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { $hashData = [ - $requestData['MbrId'], - $requestData['OrderId'], - $requestData['PurchAmount'], - $requestData['OkUrl'], - $requestData['FailUrl'], - $requestData['TxnType'], - $requestData['InstallmentCount'], - $requestData['Rnd'], + $formInputs['MbrId'], + $formInputs['OrderId'], + $formInputs['PurchAmount'], + $formInputs['OkUrl'], + $formInputs['FailUrl'], + $formInputs['TxnType'], + $formInputs['InstallmentCount'], + $formInputs['Rnd'], $posAccount->getStoreKey(), ]; $hashStr = implode(static::HASH_SEPARATOR, $hashData); diff --git a/src/Crypt/PosNetCrypt.php b/src/Crypt/PosNetCrypt.php index be3df6e2..45eafab2 100644 --- a/src/Crypt/PosNetCrypt.php +++ b/src/Crypt/PosNetCrypt.php @@ -20,7 +20,7 @@ class PosNetCrypt extends AbstractCrypt /** * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData, ?string $txType = null): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs, ?string $txType = null): string { throw new NotImplementedException(); } diff --git a/src/Crypt/PosNetV1PosCrypt.php b/src/Crypt/PosNetV1PosCrypt.php index 8426ddfd..4106e8f2 100644 --- a/src/Crypt/PosNetV1PosCrypt.php +++ b/src/Crypt/PosNetV1PosCrypt.php @@ -21,17 +21,17 @@ class PosNetV1PosCrypt extends AbstractCrypt * * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData, ?string $txType = null): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs, ?string $txType = null): string { $hashData = [ $posAccount->getClientId(), $posAccount->getTerminalId(), // no card data for 3D host payment - $requestData['CardNo'] ?? null, - $requestData['Cvv'] ?? null, - $requestData['ExpiredDate'] ?? null, + $formInputs['CardNo'] ?? null, + $formInputs['Cvv'] ?? null, + $formInputs['ExpiredDate'] ?? null, - $requestData['Amount'], + $formInputs['Amount'], $posAccount->getStoreKey(), ]; $hashStr = \implode(static::HASH_SEPARATOR, $hashData); diff --git a/src/Crypt/ToslaPosCrypt.php b/src/Crypt/ToslaPosCrypt.php index 58311108..3679e049 100644 --- a/src/Crypt/ToslaPosCrypt.php +++ b/src/Crypt/ToslaPosCrypt.php @@ -16,7 +16,7 @@ class ToslaPosCrypt extends AbstractCrypt /** * {@inheritDoc} */ - public function create3DHash(AbstractPosAccount $posAccount, array $requestData): string + public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string { throw new NotImplementedException(); } @@ -51,10 +51,7 @@ public function check3DHash(AbstractPosAccount $posAccount, array $data): bool } /** - * @param AbstractPosAccount $posAccount - * @param array $requestData - * - * @return string + * @inheritDoc */ public function createHash(AbstractPosAccount $posAccount, array $requestData): string {