From cba63550dd42adaef597d862af415eaf9d929b0a Mon Sep 17 00:00:00 2001 From: Aboozar Ghaffari Date: Wed, 28 Jun 2023 16:12:54 +0330 Subject: [PATCH] fixed code style using Pint tool --- config/shaparak.php | 34 +++--- src/Contracts/Factory.php | 2 - src/Contracts/Provider.php | 59 +++------- src/Contracts/Transaction.php | 58 ---------- src/Exception.php | 5 +- src/Exceptions/RefundException.php | 1 - src/Exceptions/RequestTokenException.php | 1 - src/Exceptions/SettlementException.php | 1 - src/Exceptions/VerificationException.php | 1 - src/Facades/Shaparak.php | 1 + src/Helper/Pasargad/RSA.php | 63 ++++++----- src/Helper/Pasargad/RSAKeyType.php | 2 +- src/Helper/Pasargad/RSAProcessor.php | 35 +++--- src/Provider/AbstractProvider.php | 85 ++++++--------- src/Provider/AsanPardakhtProvider.php | 100 ++++++++--------- src/Provider/Exception.php | 1 - src/Provider/MellatProvider.php | 125 +++++++++++----------- src/Provider/MelliProvider.php | 99 ++++++++--------- src/Provider/ParsianProvider.php | 130 ++++++++++++----------- src/Provider/PasargadProvider.php | 102 +++++++++--------- src/Provider/SaderatProvider.php | 52 ++++----- src/Provider/SamanProvider.php | 77 +++++++------- src/Provider/ZarinpalProvider.php | 73 +++++++------ src/ShaparakManager.php | 26 +---- src/ShaparakServiceProvider.php | 10 +- translations/en/shaparak.php | 26 ++--- 26 files changed, 521 insertions(+), 648 deletions(-) diff --git a/config/shaparak.php b/config/shaparak.php index ef78cc7..6295a44 100644 --- a/config/shaparak.php +++ b/config/shaparak.php @@ -41,9 +41,9 @@ |-------------------------------------------------------------------------- */ 'saman' => [ - 'terminal_id' => env('SAMAN_TERMINAL_ID'), + 'terminal_id' => env('SAMAN_TERMINAL_ID'), 'terminal_pass' => env('SAMAN_TERMINAL_PASS'), - ], + ], /* |-------------------------------------------------------------------------- | Parsian gateway configuration @@ -58,18 +58,18 @@ |-------------------------------------------------------------------------- */ 'pasargad' => [ - 'terminal_id' => env('PASARGAD_TERMINAL_ID'), - 'merchant_id' => env('PASARGAD_MERCHANT_ID'), - 'certificate_path' => env('PASARGAD_CERT_PATH', storage_path('shaparak/pasargad/certificate.xml')), + 'terminal_id' => env('PASARGAD_TERMINAL_ID'), + 'merchant_id' => env('PASARGAD_MERCHANT_ID'), + 'certificate_path' => env('PASARGAD_CERT_PATH', storage_path('shaparak/pasargad/certificate.xml')), ], /* |-------------------------------------------------------------------------- | Mellat gateway configuration |-------------------------------------------------------------------------- */ - 'mellat' => [ - 'username' => env('MELLAT_USERNAME'), - 'password' => env('MELLAT_PASSWORD'), + 'mellat' => [ + 'username' => env('MELLAT_USERNAME'), + 'password' => env('MELLAT_PASSWORD'), 'terminal_id' => env('MELLAT_TERMINAL_ID'), ], /* @@ -77,9 +77,9 @@ | Melli/Sadad gateway configuration |-------------------------------------------------------------------------- */ - 'melli' => [ - 'merchant_id' => env('MELLI_MERCHANT_ID'), - 'terminal_id' => env('MELLI_TERMINAL_ID'), + 'melli' => [ + 'merchant_id' => env('MELLI_MERCHANT_ID'), + 'terminal_id' => env('MELLI_TERMINAL_ID'), 'transaction_key' => env('MELLI_TRANS_KEY'), ], /* @@ -87,16 +87,16 @@ | Zarinpal gateway configuration |-------------------------------------------------------------------------- */ - 'saderat' => [ - 'terminal_id' => env('SADERAT_MERCHANT_ID'), + 'saderat' => [ + 'terminal_id' => env('SADERAT_MERCHANT_ID'), ], /* |-------------------------------------------------------------------------- | Zarinpal gateway configuration |-------------------------------------------------------------------------- */ - 'zarinpal' => [ - 'merchant_id' => env('ZARINPAL_MERCHANT_ID'), + 'zarinpal' => [ + 'merchant_id' => env('ZARINPAL_MERCHANT_ID'), ], ], @@ -109,7 +109,7 @@ | */ 'httpClientOptions' => [ - 'soap' => [], - 'curl' => [], + 'soap' => [], + 'curl' => [], ], ]; diff --git a/src/Contracts/Factory.php b/src/Contracts/Factory.php index 7c39689..22f610f 100644 --- a/src/Contracts/Factory.php +++ b/src/Contracts/Factory.php @@ -2,8 +2,6 @@ namespace PhpMonsters\Shaparak\Contracts; -use InvalidArgumentException; - interface Factory { /** diff --git a/src/Contracts/Provider.php b/src/Contracts/Provider.php index 5f1af9f..b051b4f 100755 --- a/src/Contracts/Provider.php +++ b/src/Contracts/Provider.php @@ -9,107 +9,80 @@ interface Provider { /** * Determines whether the provider supports reverse transaction - * - * @return bool */ - function refundSupport(): bool; + public function refundSupport(): bool; /** - * @param array $parameters operation parameters - * - * @return Provider + * @param array $parameters operation parameters */ - function setParameters(array $parameters = []): Provider; + public function setParameters(array $parameters = []): Provider; /** - * @param string|null $key - * - * @param null $default - * + * @param null $default * @return mixed */ - function getParameters(string $key = null, $default = null); + public function getParameters(string $key = null, $default = null); /** * return rendered goto gate form - * - * @return View */ - function getForm(): View; + public function getForm(): View; /** * return parameters that require for generating goto gate form - * - * @return array */ - function getFormParameters(): array; + public function getFormParameters(): array; /** * get the transaction - * - * @return Transaction */ - function getTransaction(): Transaction; + public function getTransaction(): Transaction; /** * verify transaction - * - * @return bool */ - function verifyTransaction(): bool; + public function verifyTransaction(): bool; /** * for handling after verify methods like settle in Mellat gateway * * @return mixed */ - function settleTransaction(): bool; + public function settleTransaction(): bool; /** * reverse/refund transaction if supported by the provider - * - * @return bool */ - function refundTransaction(): bool; + public function refundTransaction(): bool; /** * accomplish transaction. It means the transaction is immutable from now on - * - * @return bool */ - function accomplishTransaction(): bool; + public function accomplishTransaction(): bool; /** * fetch bak gateway reference id from callback parameters - * - * @return string */ - function getGatewayReferenceId(): string; + public function getGatewayReferenceId(): string; /** * get the Url of different parts of a payment process of the gateway * - * @param string $action * - * @return string * @throws Exception - * */ - function getUrlFor(string $action): string; + public function getUrlFor(string $action): string; /** * Specifies whether it is possible to continue payment process with the return parameters from the bank gateway - * - * @return bool */ - function canContinueWithCallbackParameters(): bool; + public function canContinueWithCallbackParameters(): bool; /** * check for required parameters * - * @param array $parameters * * @throws Exception */ - function checkRequiredActionParameters(array $parameters): void; + public function checkRequiredActionParameters(array $parameters): void; } diff --git a/src/Contracts/Transaction.php b/src/Contracts/Transaction.php index 5057942..f5fbb21 100644 --- a/src/Contracts/Transaction.php +++ b/src/Contracts/Transaction.php @@ -6,63 +6,42 @@ interface Transaction { /** * return the callback url of the transaction process - * - * @return string */ public function getCallbackUrl(): string; /** * set gateway token of transaction - * - * @param string $token - * @param bool $save - * - * @return bool */ public function setGatewayToken(string $token, bool $save = true): bool; /** * set reference ID of transaction شناسه/کد پیگیری - * - * @param string $referenceId - * @param bool $save - * - * @return bool */ public function setReferenceId(string $referenceId, bool $save = true): bool; /** * get reference ID of the - * @return string */ public function getReferenceId(): string; /** * return an order id for the transaction to requesting a payment token from the gateway - * - * @return int */ public function getGatewayOrderId(): int; /** * check if transaction is ready for requesting token from payment gateway or not - * - * @return boolean */ public function isReadyForTokenRequest(): bool; /** * check if transaction is ready for requesting verify method from payment gateway or not - * - * @return bool */ public function isReadyForVerify(): bool; /** * check if transaction is ready for requesting inquiry method from payment gateway or not * This feature does not append to all payment gateways - * - * @return bool */ public function isReadyForInquiry(): bool; @@ -70,90 +49,53 @@ public function isReadyForInquiry(): bool; * check if transaction is ready for requesting settlement method from payment gateway or not * This feature does not append to all payment gateways. * for example in Mellat gateway this method can assume as SETTLE method - * - * @return bool */ public function isReadyForSettle(): bool; /** * check if transaction is ready for requesting refund method from payment gateway or not * This feature does not append to all payment gateways - * - * @return bool */ public function isReadyForRefund(): bool; /** * Mark transaction as a verified transaction - * - * @param bool $save - * - * @return bool */ public function setVerified(bool $save = true): bool; /** * Mark transaction as a after verified transaction * For example SETTLED in Mellat gateway - * - * @param bool $save - * - * @return bool */ public function setSettled(bool $save = true): bool; /** * Mark transaction as a paid/successful transaction - * - * @param bool $save - * - * @return bool */ public function setAccomplished(bool $save = true): bool; /** * Mark transaction as a refunded transaction - * - * @param bool $save - * - * @return bool */ public function setRefunded(bool $save = true): bool; /** * Returns the payable amount af the transaction - * - * @return int */ public function getPayableAmount(): int; /** * save the pan/card number that used for paying the transaction - * @param string $cardNumber - * @param bool $save - * - * @return bool */ public function setCardNumber(string $cardNumber, bool $save = false): bool; /** * Set callback parameters from payment gateway - * - * @param array $parameters - * @param bool $save - * - * @return bool */ public function setCallBackParameters(array $parameters, bool $save = true): bool; /** * Set extra values of the transaction. Every key/value pair that you want to bind to the transaction - * - * @param string $key - * @param $value - * @param bool $save - * - * @return bool */ public function addExtra(string $key, $value, bool $save = true): bool; } diff --git a/src/Exception.php b/src/Exception.php index 96398f9..bf294eb 100755 --- a/src/Exception.php +++ b/src/Exception.php @@ -1,4 +1,7 @@ = 0; $i--) { - $digit = ord($data[$i]); + $digit = ord($data[$i]); $part_res = bcmul($digit, $radix); - $result = bcadd($result, $part_res); - $radix = bcmul($radix, $base); + $result = bcadd($result, $part_res); + $radix = bcmul($radix, $base); } return $result; @@ -141,13 +140,13 @@ public static function binary_to_number($data) public static function number_to_binary($number, $blocksize) { - $base = "256"; - $result = ""; - $div = $number; + $base = '256'; + $result = ''; + $div = $number; while ($div > 0) { - $mod = bcmod($div, $base); - $div = bcdiv($div, $base); - $result = chr($mod) . $result; + $mod = bcmod($div, $base); + $div = bcdiv($div, $base); + $result = chr($mod).$result; } return str_pad($result, $blocksize, "\x00", STR_PAD_LEFT); diff --git a/src/Helper/Pasargad/RSAKeyType.php b/src/Helper/Pasargad/RSAKeyType.php index d1c05bf..70e46f4 100644 --- a/src/Helper/Pasargad/RSAKeyType.php +++ b/src/Helper/Pasargad/RSAKeyType.php @@ -4,10 +4,10 @@ /** * Class RSAKeyType - * @package PhpMonsters\Shaparak\Helper\Pasargad */ class RSAKeyType { const XMLFile = 0; + const XMLString = 1; } diff --git a/src/Helper/Pasargad/RSAProcessor.php b/src/Helper/Pasargad/RSAProcessor.php index 04e62a4..fdb7731 100644 --- a/src/Helper/Pasargad/RSAProcessor.php +++ b/src/Helper/Pasargad/RSAProcessor.php @@ -1,24 +1,27 @@ modulus = RSA::binary_to_number(base64_decode($xmlObj->Modulus)); - $this->public_key = RSA::binary_to_number(base64_decode($xmlObj->Exponent)); + $this->modulus = RSA::binary_to_number(base64_decode($xmlObj->Modulus)); + $this->public_key = RSA::binary_to_number(base64_decode($xmlObj->Exponent)); $this->private_key = RSA::binary_to_number(base64_decode($xmlObj->D)); - $this->key_length = strlen(base64_decode($xmlObj->Modulus)) * 8; + $this->key_length = strlen(base64_decode($xmlObj->Modulus)) * 8; } - public function getPublicKey () + public function getPublicKey() { return $this->public_key; } - public function getPrivateKey () + public function getPrivateKey() { return $this->private_key; } - public function getKeyLength (): int + public function getKeyLength(): int { return $this->key_length; } - public function getModulus () + public function getModulus() { return $this->modulus; } - public function encrypt ($data): string + public function encrypt($data): string { return base64_encode(RSA::rsa_encrypt($data, $this->public_key, $this->modulus, $this->key_length)); } - public function decrypt ($data) + public function decrypt($data) { return RSA::rsa_decrypt($data, $this->private_key, $this->modulus, $this->key_length); } - public function sign ($data): string + public function sign($data): string { return RSA::rsa_sign($data, $this->private_key, $this->modulus, $this->key_length); } - public function verify ($data) + public function verify($data) { return RSA::rsa_verify($data, $this->public_key, $this->modulus, $this->key_length); } diff --git a/src/Provider/AbstractProvider.php b/src/Provider/AbstractProvider.php index a3e9502..500a438 100755 --- a/src/Provider/AbstractProvider.php +++ b/src/Provider/AbstractProvider.php @@ -14,72 +14,63 @@ * Class AbstractProvider * * @author Aboozar Ghaffari - * @package Shaparak - * @package PhpMonsters\Shaparak + * * @version v1.0 + * * @license https://github.com/php-monsters/shaparak/blob/master/LICENSE */ abstract class AbstractProvider implements ProviderContract { public const URL_GATEWAY = 'gateway'; + public const URL_TOKEN = 'token'; + public const URL_VERIFY = 'verify'; + public const URL_REFUND = 'refund'; + public const URL_CANCEL = 'cancel'; + public const URL_MULTIPLEX = 'multiplex'; protected bool $provideTransactionResult = true; + /** * shaparak operation environment - * - * @var string */ protected string $environment; /** * The custom parameters to be sent with the request. - * - * @var array */ protected array $parameters = []; - /** - * @var Transaction - */ protected Transaction $transaction; /** * specifies whether the gateway supports transaction reverse/refund or not - * @var bool */ protected bool $refundSupport = false; /** * specifies whether the gateway supports transaction settlement or not - * @var bool */ protected bool $settlementSupport = false; /** * The custom Guzzle/SoapClient configuration options. - * - * @var array */ protected array $httpClientOptions = []; /** * banktest mock service base url - * @var string */ protected string $bankTestBaseUrl; /** * AdapterAbstract constructor. * - * @param Transaction $transaction - * @param array $configs * @param string $environment Shaparak module mode - * @param array $httpClientOptions */ public function __construct( Transaction $transaction, @@ -95,7 +86,7 @@ public function __construct( } /** - * @inheritDoc + * {@inheritDoc} */ public function getForm(): \Illuminate\View\View { @@ -104,19 +95,19 @@ public function getForm(): \Illuminate\View\View return view( 'shaparak::goto-gate-form', array_merge($formParameters, [ - 'buttonLabel' => $this->getParameters('submit_label') ?: __("shaparak::shaparak.goto_gate"), + 'buttonLabel' => $this->getParameters('submit_label') ?: __('shaparak::shaparak.goto_gate'), 'autoSubmit' => (bool) $this->getParameters('auto_submit', true), ]) ); } /** - * @inheritDoc + * {@inheritDoc} */ abstract public function getFormParameters(): array; /** - * @inheritDoc + * {@inheritDoc} */ public function getParameters(string $key = null, $default = null) { @@ -130,11 +121,11 @@ public function getParameters(string $key = null, $default = null) } /** - * @inheritDoc + * {@inheritDoc} */ public function setParameters(array $parameters = []): ProviderContract { - $parameters = array_change_key_case($parameters, CASE_LOWER); + $parameters = array_change_key_case($parameters); $parameters = array_map('trim', $parameters); $this->parameters = array_merge($this->parameters, $parameters); @@ -143,53 +134,50 @@ public function setParameters(array $parameters = []): ProviderContract } /** - * @inheritDoc + * {@inheritDoc} */ abstract public function verifyTransaction(): bool; /** - * @inheritDoc + * {@inheritDoc} */ public function settleTransaction(): bool { // default behavior - return $this->getTransaction()->setSettled(true); + return $this->getTransaction()->setSettled(); } /** - * @inheritDoc + * {@inheritDoc} */ public function accomplishTransaction(): bool { // default behavior - return $this->getTransaction()->setAccomplished(true); + return $this->getTransaction()->setAccomplished(); } - /** - * @return Transaction - */ public function getTransaction(): Transaction { return $this->transaction; } /** - * @inheritDoc + * {@inheritDoc} */ abstract public function refundTransaction(): bool; /** - * @inheritDoc + * {@inheritDoc} */ abstract public function getGatewayReferenceId(): string; /** - * @inheritDoc + * {@inheritDoc} */ abstract public function canContinueWithCallbackParameters(): bool; /** - * @inheritDoc + * {@inheritDoc} */ public function refundSupport(): bool { @@ -197,7 +185,7 @@ public function refundSupport(): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function settlementSupport(): bool { @@ -205,23 +193,20 @@ public function settlementSupport(): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function checkRequiredActionParameters(array $parameters): void { $parameters = array_map('strtolower', $parameters); foreach ($parameters as $parameter) { - if (!array_key_exists($parameter, $this->parameters) || trim($this->parameters[$parameter]) === '') { + if (! array_key_exists($parameter, $this->parameters) || trim($this->parameters[$parameter]) === '') { throw new Exception("Parameters array must have a not null value for key: '$parameter'"); } } } /** - * @param string $action - * - * @return SoapClient * @throws SoapFault|Exception */ protected function getSoapClient(string $action): SoapClient @@ -233,13 +218,12 @@ protected function getSoapClient(string $action): SoapClient } /** - * @inheritDoc + * {@inheritDoc} */ abstract public function getUrlFor(string $action): string; /** * fetches callback url from parameters - * @return string */ protected function getCallbackUrl(): string { @@ -250,22 +234,20 @@ protected function getCallbackUrl(): string /** * fetches payable amount of the transaction - * @return int */ protected function getAmount(): int { - return (is_int($this->getParameters('amount')) && !empty($this->getParameters('amount'))) ? + return (is_int($this->getParameters('amount')) && ! empty($this->getParameters('amount'))) ? $this->getParameters('amount') : $this->getTransaction()->getPayableAmount(); } /** * fetches payable amount of the transaction - * @return int */ protected function getGatewayOrderId(): int { - return (is_int($this->getParameters('order_id')) && !empty($this->getParameters('order_id'))) ? + return (is_int($this->getParameters('order_id')) && ! empty($this->getParameters('order_id'))) ? $this->getParameters('order_id') : $this->getTransaction()->getGatewayOrderId(); } @@ -275,23 +257,16 @@ protected function log(string $message, array $params = [], string $level = 'deb $reflect = new ReflectionClass($this); $provider = strtolower(str_replace('Provider', '', $reflect->getShortName())); - $message = $provider.": ".$message; + $message = $provider.': '.$message; Shaparak::log($message, $params, $level); } - /** - * @return bool - */ public function getTransactionResult(): bool { return $this->provideTransactionResult; } - /** - * @param array $parameters - * @return bool - */ public function setCallBackParameters(array $parameters): bool { return $this->getTransaction()->setCallBackParameters($parameters); diff --git a/src/Provider/AsanPardakhtProvider.php b/src/Provider/AsanPardakhtProvider.php index baf3186..50d178b 100755 --- a/src/Provider/AsanPardakhtProvider.php +++ b/src/Provider/AsanPardakhtProvider.php @@ -13,22 +13,18 @@ class AsanPardakhtProvider extends AbstractProvider { public const URL_RESULT = 'result'; + public const GET_METHOD = 'get'; + public const POST_METHOD = 'post'; + public const URL_SETTLEMENT = 'settlement'; - /** - * @var bool - */ protected bool $refundSupport = true; - /** - * @var bool - */ protected bool $settlementSupport = true; /** - * @return array * @throws Exception * @throws RequestTokenException */ @@ -46,78 +42,77 @@ public function getFormParameters(): array } /** - * @inheritDoc + * {@inheritDoc} */ public function getUrlFor(string $action): string { if ($this->environment === 'production') { switch ($action) { case self::URL_GATEWAY: - { + return 'https://asan.shaparak.ir'; - } + case self::URL_TOKEN: - { + return 'https://ipgrest.asanpardakht.ir/v1/Token'; - } + case self::URL_VERIFY: - { + return 'https://ipgrest.asanpardakht.ir/v1/Verify'; - } + case self::URL_RESULT: - { + return 'https://ipgrest.asanpardakht.ir/v1/TranResult'; - } + case self::URL_SETTLEMENT: - { + return 'https://ipgrest.asanpardakht.ir/v1/Settlement'; - } + case self::URL_REFUND: - { + return 'https://ipgrest.asanpardakht.ir/v1/Reverse'; - } + case self::URL_CANCEL: - { + return 'https://ipgrest.asanpardakht.ir/v1/Cancel'; - } + } } else { switch ($action) { case self::URL_GATEWAY: - { + return $this->bankTestBaseUrl.'/ap/asan.shaparak.ir'; - } + case self::URL_TOKEN: - { + return $this->bankTestBaseUrl.'/ap/ipgrest.asanpardakht.ir/v1/Token'; - } + case self::URL_VERIFY: - { + return $this->bankTestBaseUrl.'/ap/ipgrest.asanpardakht.ir/v1/Verify'; - } + case self::URL_RESULT: - { + return $this->bankTestBaseUrl.'/ap/ipgrest.asanpardakht.ir/v1/TranResult'; - } + case self::URL_SETTLEMENT: - { + return $this->bankTestBaseUrl.'/ap/ipgrest.asanpardakht.ir/v1/Settlement'; - } + case self::URL_REFUND: - { + return $this->bankTestBaseUrl.'/ap/ipgrest.asanpardakht.ir/v1/Reverse'; - } + case self::URL_CANCEL: - { + return $this->bankTestBaseUrl.'/ap/ipgrest.asanpardakht.ir/v1/Cancel'; - } + } } throw new Exception("could not find url for {$action} action"); } /** - * @return string * @throws Exception * @throws RequestTokenException */ @@ -137,7 +132,7 @@ public function requestToken(): string self::POST_METHOD ); - if ($response->successful() && !empty($response->body())) { + if ($response->successful() && ! empty($response->body())) { $this->getTransaction()->setGatewayToken( json_decode($response->body(), false, 512, JSON_THROW_ON_ERROR), true @@ -153,7 +148,6 @@ public function requestToken(): string } /** - * @return array * @throws Exception */ public function requestTokenData(): array @@ -165,6 +159,7 @@ public function requestTokenData(): array 'local_date', 'local_time', ]); + return [ 'serviceTypeId' => 1, 'merchantConfigurationId' => $this->getParameters('terminal_id'), @@ -176,12 +171,6 @@ public function requestTokenData(): array ]; } - /** - * @param array $params - * @param string $url - * @param string $method - * @return mixed - */ public function sendParamToAp(array $params, string $url, string $method): mixed { return Http::acceptJson()->withHeaders([ @@ -195,9 +184,8 @@ public function sendParamToAp(array $params, string $url, string $method): mixed ); } - /** - * @inheritDoc + * {@inheritDoc} */ public function verifyTransaction(): bool { @@ -224,7 +212,6 @@ public function verifyTransaction(): bool } /** - * @return bool * @throws Exception */ public function getTransactionResult(): bool @@ -239,19 +226,19 @@ public function getTransactionResult(): bool 'merchantConfigurationId' => $this->getParameters('terminal_id'), ], $this->getUrlFor(self::URL_RESULT), self::GET_METHOD); - if ($response->successful() && $response->status() === 200 && !empty($response->body())) { + if ($response->successful() && $response->status() === 200 && ! empty($response->body())) { $this->getTransaction()->setCallBackParameters($response->json()); $this->getTransaction()->setReferenceId($response->json('rrn')); return true; } + return false; } /** * Send settle request * - * @return bool * * @throws Exception * @throws SettlementException @@ -287,9 +274,9 @@ public function settleTransaction(): bool } } - /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception * @throws RefundException */ @@ -330,9 +317,8 @@ public function refundTransaction(): bool } } - /** - * @inheritDoc + * {@inheritDoc} */ public function canContinueWithCallbackParameters(): bool { @@ -344,7 +330,7 @@ public function canContinueWithCallbackParameters(): bool return false; } - if (!empty($this->getParameters('ReturningParams'))) { + if (! empty($this->getParameters('ReturningParams'))) { return $this->getTransactionResult(); } @@ -352,7 +338,7 @@ public function canContinueWithCallbackParameters(): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function getGatewayReferenceId(): string { @@ -364,8 +350,6 @@ public function getGatewayReferenceId(): string } /** - * @param $method - * @return bool * @throws Exception */ protected function generateComplementaryOperation($method): bool diff --git a/src/Provider/Exception.php b/src/Provider/Exception.php index 3452501..d60459a 100755 --- a/src/Provider/Exception.php +++ b/src/Provider/Exception.php @@ -4,7 +4,6 @@ /** * Class Exception - * @package PhpMonsters\Shaparak\Adapter */ class Exception extends \PhpMonsters\Shaparak\Exception { diff --git a/src/Provider/MellatProvider.php b/src/Provider/MellatProvider.php index beb574e..9543616 100644 --- a/src/Provider/MellatProvider.php +++ b/src/Provider/MellatProvider.php @@ -3,17 +3,18 @@ namespace PhpMonsters\Shaparak\Provider; use SoapFault; -use PhpMonsters\Shaparak\Contracts\Provider as ProviderContract; class MellatProvider extends AbstractProvider { public const URL_INQUIRY = 'inquiry'; - public const URL_SETTLE = 'settle'; + + public const URL_SETTLE = 'settle'; protected bool $refundSupport = true; /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ protected function requestToken(): string @@ -32,16 +33,16 @@ protected function requestToken(): string ]); $sendParams = [ - 'terminalId' => (int) $this->getParameters('terminal_id'), - 'userName' => $this->getParameters('username'), - 'userPassword' => $this->getParameters('password'), - 'orderId' => $this->getGatewayOrderId(), - 'amount' => $this->getAmount(), - 'localDate' => $this->getParameters('local_date', date('Ymd')), - 'localTime' => $this->getParameters('local_time', date('His')), + 'terminalId' => (int) $this->getParameters('terminal_id'), + 'userName' => $this->getParameters('username'), + 'userPassword' => $this->getParameters('password'), + 'orderId' => $this->getGatewayOrderId(), + 'amount' => $this->getAmount(), + 'localDate' => $this->getParameters('local_date', date('Ymd')), + 'localTime' => $this->getParameters('local_time', date('His')), 'additionalData' => (string) $this->getParameters('additional_data'), - 'callBackUrl' => $this->getCallbackUrl(), - 'payerId' => (int) $this->getParameters('payer_id'), + 'callBackUrl' => $this->getCallbackUrl(), + 'payerId' => (int) $this->getParameters('payer_id'), ]; try { @@ -63,20 +64,21 @@ protected function requestToken(): string throw new Exception('shaparak::shaparak.token_failed'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function getFormParameters(): array { return [ - 'gateway' => 'mellat', - 'method' => 'post', - 'action' => $this->getUrlFor(self::URL_GATEWAY), + 'gateway' => 'mellat', + 'method' => 'post', + 'action' => $this->getUrlFor(self::URL_GATEWAY), 'parameters' => [ 'RefId' => $this->requestToken(), ], @@ -84,7 +86,8 @@ public function getFormParameters(): array } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function verifyTransaction(): bool @@ -108,11 +111,11 @@ public function verifyTransaction(): bool try { $sendParams = [ - 'terminalId' => (int) $this->getParameters('terminal_id'), - 'userName' => $this->getParameters('username'), - 'userPassword' => $this->getParameters('password'), - 'orderId' => (int) $this->getParameters('SaleOrderId'), // same as SaleOrderId - 'saleOrderId' => (int) $this->getParameters('SaleOrderId'), + 'terminalId' => (int) $this->getParameters('terminal_id'), + 'userName' => $this->getParameters('username'), + 'userPassword' => $this->getParameters('password'), + 'orderId' => (int) $this->getParameters('SaleOrderId'), // same as SaleOrderId + 'saleOrderId' => (int) $this->getParameters('SaleOrderId'), 'saleReferenceId' => (int) $this->getParameters('SaleReferenceId'), ]; @@ -133,12 +136,13 @@ public function verifyTransaction(): bool throw new Exception('shaparak::shaparak.verify_failed'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** * @return bool + * * @throws Exception */ public function inquiryTransaction() @@ -159,11 +163,11 @@ public function inquiryTransaction() ]); $sendParams = [ - 'terminalId' => (int) $this->getParameters('terminal_id'), - 'userName' => $this->getParameters('username'), - 'userPassword' => $this->getParameters('password'), - 'orderId' => (int) $this->getParameters('SaleOrderId'), // same as SaleOrderId - 'saleOrderId' => (int) $this->getParameters('SaleOrderId'), + 'terminalId' => (int) $this->getParameters('terminal_id'), + 'userName' => $this->getParameters('username'), + 'userPassword' => $this->getParameters('password'), + 'orderId' => (int) $this->getParameters('SaleOrderId'), // same as SaleOrderId + 'saleOrderId' => (int) $this->getParameters('SaleOrderId'), 'saleReferenceId' => (int) $this->getParameters('SaleReferenceId'), ]; @@ -179,15 +183,13 @@ public function inquiryTransaction() throw new Exception('shaparak::shaparak.inquiry_failed'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } - /** * Send settle request * - * @return bool * * @throws Exception */ @@ -209,11 +211,11 @@ public function settleTransaction(): bool ]); $sendParams = [ - 'terminalId' => (int) $this->getParameters('terminal_id'), - 'userName' => $this->getParameters('username'), - 'userPassword' => $this->getParameters('password'), - 'orderId' => (int) $this->getParameters('SaleOrderId'), // same as SaleOrderId - 'saleOrderId' => (int) $this->getParameters('SaleOrderId'), + 'terminalId' => (int) $this->getParameters('terminal_id'), + 'userName' => $this->getParameters('username'), + 'userPassword' => $this->getParameters('password'), + 'orderId' => (int) $this->getParameters('SaleOrderId'), // same as SaleOrderId + 'saleOrderId' => (int) $this->getParameters('SaleOrderId'), 'saleReferenceId' => (int) $this->getParameters('SaleReferenceId'), ]; @@ -234,13 +236,14 @@ public function settleTransaction(): bool throw new Exception('shaparak::shaparak.invalid_response'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function refundTransaction(): bool @@ -262,11 +265,11 @@ public function refundTransaction(): bool try { $sendParams = [ - 'terminalId' => (int) $this->getParameters('terminal_id'), - 'userName' => $this->getParameters('username'), - 'userPassword' => $this->getParameters('password'), - 'orderId' => (int) $this->getParameters('SaleOrderId'), // same as SaleOrderId - 'saleOrderId' => (int) $this->getParameters('SaleOrderId'), + 'terminalId' => (int) $this->getParameters('terminal_id'), + 'userName' => $this->getParameters('username'), + 'userPassword' => $this->getParameters('password'), + 'orderId' => (int) $this->getParameters('SaleOrderId'), // same as SaleOrderId + 'saleOrderId' => (int) $this->getParameters('SaleOrderId'), 'saleReferenceId' => (int) $this->getParameters('SaleReferenceId'), ]; @@ -281,17 +284,17 @@ public function refundTransaction(): bool return true; } - throw new Exception('shaparak::mellat.error_' . strval($response->return)); + throw new Exception('shaparak::mellat.error_'.strval($response->return)); } throw new Exception('shaparak::mellat.errors.invalid_response'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** - * @inheritDoc + * {@inheritDoc} */ public function canContinueWithCallbackParameters(): bool { @@ -307,7 +310,7 @@ public function canContinueWithCallbackParameters(): bool return false; } - if (!empty($this->getParameters('RefId'))) { + if (! empty($this->getParameters('RefId'))) { return true; } @@ -315,7 +318,8 @@ public function canContinueWithCallbackParameters(): bool } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function getGatewayReferenceId(): string @@ -327,33 +331,32 @@ public function getGatewayReferenceId(): string return $this->getParameters('RefId'); } - /** - * @inheritDoc + * {@inheritDoc} */ public function getUrlFor(string $action): string { if ($this->environment === 'production') { switch ($action) { case self::URL_GATEWAY: - { + return 'https://bpm.shaparak.ir/pgwchannel/startpay.mellat'; - } + default: - { + return 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl'; - } + } } else { switch ($action) { case self::URL_GATEWAY: - { - return $this->bankTestBaseUrl . '/mellat/bpm.shaparak.ir/pgwchannel/startpay.mellat'; - } + + return $this->bankTestBaseUrl.'/mellat/bpm.shaparak.ir/pgwchannel/startpay.mellat'; + default: - { - return $this->bankTestBaseUrl . '/mellat/bpm.shaparak.ir/pgwchannel/services/pgw?wsdl'; - } + + return $this->bankTestBaseUrl.'/mellat/bpm.shaparak.ir/pgwchannel/services/pgw?wsdl'; + } } } diff --git a/src/Provider/MelliProvider.php b/src/Provider/MelliProvider.php index 5939251..33a05d4 100644 --- a/src/Provider/MelliProvider.php +++ b/src/Provider/MelliProvider.php @@ -7,7 +7,8 @@ class MelliProvider extends AbstractProvider { /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ protected function requestToken(): string @@ -25,25 +26,26 @@ protected function requestToken(): string ]); $terminalId = $this->getParameters('terminal_id'); - $amount = $this->getAmount(); - $key = $this->getParameters('transaction_key'); - $orderId = $this->getGatewayOrderId(); + $amount = $this->getAmount(); + $key = $this->getParameters('transaction_key'); + $orderId = $this->getGatewayOrderId(); $response = Http::acceptJson() ->throw() ->post($this->getUrlFor(self::URL_TOKEN), [ - 'TerminalId' => $terminalId, - 'MerchantId' => $this->getParameters('merchant_id'), - 'Amount' => $amount, - 'SignData' => $this->encryptPKCS7("{$terminalId};{$orderId};{$amount}", "{$key}"), - 'ReturnUrl' => $this->getCallbackUrl(), - 'LocalDateTime' => date("m/d/Y g:i:s a"), - 'OrderId' => $orderId, + 'TerminalId' => $terminalId, + 'MerchantId' => $this->getParameters('merchant_id'), + 'Amount' => $amount, + 'SignData' => $this->encryptPKCS7("{$terminalId};{$orderId};{$amount}", "{$key}"), + 'ReturnUrl' => $this->getCallbackUrl(), + 'LocalDateTime' => date('m/d/Y g:i:s a'), + 'OrderId' => $orderId, ]); $resCode = $response->json('ResCode'); - if (is_numeric($resCode) && (int)$resCode === 0) { + if (is_numeric($resCode) && (int) $resCode === 0) { $transaction->setGatewayToken($response->json('Token'), true); // update transaction reference id + return $response->json('Token'); } @@ -51,15 +53,16 @@ protected function requestToken(): string } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function getFormParameters(): array { return [ - 'gateway' => 'melli', - 'method' => 'get', - 'action' => $this->getUrlFor(self::URL_GATEWAY), + 'gateway' => 'melli', + 'method' => 'get', + 'action' => $this->getUrlFor(self::URL_GATEWAY), 'parameters' => [ 'Token' => $this->requestToken(), ], @@ -67,7 +70,8 @@ public function getFormParameters(): array } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function verifyTransaction(): bool @@ -86,24 +90,23 @@ public function verifyTransaction(): bool ]); if ((int) $this->getParameters('ResCode') !== 0) { - throw new Exception('could not verify transaction with ResCode: ' . $this->getParameters('ResCode')); + throw new Exception('could not verify transaction with ResCode: '.$this->getParameters('ResCode')); } - $key = $this->getParameters('transaction_key'); + $key = $this->getParameters('transaction_key'); $token = $this->getParameters('Token'); $signature = $this->encryptPKCS7($token, $key); - $response = Http::acceptJson() ->throw() ->post($this->getUrlFor(self::URL_VERIFY), [ - 'Token' => $token, + 'Token' => $token, 'SignData' => $signature, ]); $resCode = $response->json('ResCode'); - if (is_numeric($resCode) && (int)$resCode === 0 && (int)$response->json('Amount') === $this->getAmount()) {// got string token + if (is_numeric($resCode) && (int) $resCode === 0 && (int) $response->json('Amount') === $this->getAmount()) {// got string token foreach ($response->json() as $k => $v) { $this->getTransaction()->addExtra($k, $v, false); } @@ -126,7 +129,7 @@ public function refundTransaction(): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function canContinueWithCallbackParameters(): bool { @@ -140,11 +143,11 @@ public function canContinueWithCallbackParameters(): bool return false; } - return (int)$this->getParameters('ResCode') === 0; + return (int) $this->getParameters('ResCode') === 0; } /** - * @inheritDoc + * {@inheritDoc} */ public function getGatewayReferenceId(): string { @@ -156,39 +159,39 @@ public function getGatewayReferenceId(): string } /** - * @inheritDoc + * {@inheritDoc} */ public function getUrlFor(string $action = null): string { if ($this->environment === 'production') { switch ($action) { case self::URL_GATEWAY: - { + return 'https://sadad.shaparak.ir/VPG/Purchase'; - } - case self::URL_TOKEN : - { + + case self::URL_TOKEN: + return 'https://sadad.shaparak.ir/vpg/api/v0/Request/PaymentRequest'; - } - case self::URL_VERIFY : - { + + case self::URL_VERIFY: + return 'https://sadad.shaparak.ir/vpg/api/v0/Advice/Verify'; - } + } } else { switch ($action) { case self::URL_GATEWAY: - { - return $this->bankTestBaseUrl . '/melli/sadad.shaparak.ir/VPG/Purchase'; - } - case self::URL_TOKEN : - { - return $this->bankTestBaseUrl . '/melli/sadad.shaparak.ir/VPG/api/v0/Request/PaymentRequest'; - } - case self::URL_VERIFY : - { - return $this->bankTestBaseUrl . '/melli/sadad.shaparak.ir/VPG/api/v0/Advice/Verify'; - } + + return $this->bankTestBaseUrl.'/melli/sadad.shaparak.ir/VPG/Purchase'; + + case self::URL_TOKEN: + + return $this->bankTestBaseUrl.'/melli/sadad.shaparak.ir/VPG/api/v0/Request/PaymentRequest'; + + case self::URL_VERIFY: + + return $this->bankTestBaseUrl.'/melli/sadad.shaparak.ir/VPG/api/v0/Advice/Verify'; + } } @@ -200,13 +203,11 @@ public function getUrlFor(string $action = null): string * * @param string data * @param string key - * - * @return string */ protected function encryptPKCS7(string $str, string $key): string { - $key = base64_decode($key); - $cipherText = openssl_encrypt($str, "DES-EDE3", $key, OPENSSL_RAW_DATA); + $key = base64_decode($key); + $cipherText = openssl_encrypt($str, 'DES-EDE3', $key, OPENSSL_RAW_DATA); return base64_encode($cipherText); } diff --git a/src/Provider/ParsianProvider.php b/src/Provider/ParsianProvider.php index 7056de9..59fb03d 100644 --- a/src/Provider/ParsianProvider.php +++ b/src/Provider/ParsianProvider.php @@ -2,18 +2,20 @@ namespace PhpMonsters\Shaparak\Provider; -use SoapFault; use Exception; +use SoapFault; class ParsianProvider extends AbstractProvider { - public const URL_SALE = 'sale'; + public const URL_SALE = 'sale'; + public const URL_CONFIRM = 'confirm'; protected bool $refundSupport = true; /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ protected function requestToken(): string @@ -29,22 +31,22 @@ protected function requestToken(): string ]); $sendParams = [ - 'LoginAccount' => $this->getParameters('pin'), - 'Amount' => $transaction->getPayableAmount(), - 'OrderId' => $transaction->getGatewayOrderId(), - 'CallBackUrl' => $this->getCallbackUrl(), - 'AdditionalData' => (string)$this->getParameters('additional_date'), + 'LoginAccount' => $this->getParameters('pin'), + 'Amount' => $transaction->getPayableAmount(), + 'OrderId' => $transaction->getGatewayOrderId(), + 'CallBackUrl' => $this->getCallbackUrl(), + 'AdditionalData' => (string) $this->getParameters('additional_date'), ]; try { $soapClient = $this->getSoapClient(self::URL_SALE); - $response = $soapClient->SalePaymentRequest(["requestData" => $sendParams]); + $response = $soapClient->SalePaymentRequest(['requestData' => $sendParams]); if (isset($response->SalePaymentRequestResult, $response->SalePaymentRequestResult->Status, $response->SalePaymentRequestResult->Token)) { - if ((int)$response->SalePaymentRequestResult->Status === 0) { + if ((int) $response->SalePaymentRequestResult->Status === 0) { $this->log("fetched token from gateway: {$response->SalePaymentRequestResult->Token}"); $this->getTransaction()->setGatewayToken($response->SalePaymentRequestResult->Token); @@ -57,12 +59,13 @@ protected function requestToken(): string throw new Exception('shaparak::shaparak.token_failed'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function getFormParameters(): array @@ -70,9 +73,9 @@ public function getFormParameters(): array $token = $this->requestToken(); return [ - 'gateway' => 'parsian', - 'method' => 'get', - 'action' => $this->getUrlFor(self::URL_GATEWAY), + 'gateway' => 'parsian', + 'method' => 'get', + 'action' => $this->getUrlFor(self::URL_GATEWAY), 'parameters' => [ 'token' => $token, ], @@ -80,7 +83,8 @@ public function getFormParameters(): array } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function verifyTransaction(): bool @@ -95,24 +99,24 @@ public function verifyTransaction(): bool 'Status', ]); - if ((int)$this->getParameters('Status') !== 0) { + if ((int) $this->getParameters('Status') !== 0) { throw new Exception( - 'could not verify transaction with callback state: ' . $this->getParameters('Status') + 'could not verify transaction with callback state: '.$this->getParameters('Status') ); } try { $sendParams = [ 'LoginAccount' => $this->getParameters('pin'), - 'Token' => $this->getParameters('Token'), + 'Token' => $this->getParameters('Token'), ]; $soapClient = $this->getSoapClient(self::URL_CONFIRM); - $response = $soapClient->ConfirmPayment(["requestData" => $sendParams]); + $response = $soapClient->ConfirmPayment(['requestData' => $sendParams]); if (isset($response->ConfirmPaymentResult, $response->ConfirmPaymentResult->Status)) { - if ((int)$response->ConfirmPaymentResult->Status === 0) { + if ((int) $response->ConfirmPaymentResult->Status === 0) { //$this->getTransaction()->setCardNumber($this->getParameters('CardNumberMasked'), false); // no save() $this->getTransaction()->setVerified(true); // save() @@ -126,12 +130,13 @@ public function verifyTransaction(): bool throw new Exception('shaparak::shaparak.could_not_verify_transaction'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function refundTransaction(): bool @@ -148,15 +153,15 @@ public function refundTransaction(): bool try { $sendParams = [ 'LoginAccount' => $this->getParameters('pin'), - 'Token' => $this->getParameters('Token'), + 'Token' => $this->getParameters('Token'), ]; $soapClient = $this->getSoapClient(self::URL_REFUND); - $response = $soapClient->ReversalRequest(["requestData" => $sendParams]); + $response = $soapClient->ReversalRequest(['requestData' => $sendParams]); if (isset($response->ReversalRequestResult, $response->ReversalRequestResult->Status)) { - if ((int)$response->ReversalRequestResult->Status === 0) { + if ((int) $response->ReversalRequestResult->Status === 0) { $this->getTransaction()->setRefunded(true); return true; @@ -169,12 +174,12 @@ public function refundTransaction(): bool throw new Exception('larapay::parsian.errors.invalid_response'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** - * @inheritDoc + * {@inheritDoc} */ public function canContinueWithCallbackParameters(): bool { @@ -187,11 +192,12 @@ public function canContinueWithCallbackParameters(): bool return false; } - return (int)$this->getParameters('Status') === 0; + return (int) $this->getParameters('Status') === 0; } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function getGatewayReferenceId(): string @@ -204,55 +210,55 @@ public function getGatewayReferenceId(): string } /** - * @inheritDoc + * {@inheritDoc} */ public function getUrlFor(string $action): string { if ($this->environment === 'production') { switch ($action) { case self::URL_GATEWAY: - { + return 'https://pec.shaparak.ir/NewIPG/'; - } - case self::URL_SALE : - { + + case self::URL_SALE: + return 'https://pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx?WSDL'; - } - case self::URL_CONFIRM : - { + + case self::URL_CONFIRM: + return 'https://pec.shaparak.ir/NewIPGServices/Confirm/ConfirmService.asmx?WSDL'; - } - case self::URL_REFUND : - { + + case self::URL_REFUND: + return 'https://pec.shaparak.ir/NewIPGServices/Reverse/ReversalService.asmx?WSDL'; - } + case self::URL_MULTIPLEX: - { + return 'https://pec.shaparak.ir/NewIPGServices/MultiplexedSale/OnlineMultiplexedSalePaymentService.asmx?WSDL'; - } + } } else { switch ($action) { case self::URL_GATEWAY: - { - return $this->bankTestBaseUrl . '/parsian/pec.shaparak.ir/NewIPG'; - } - case self::URL_SALE : - { - return $this->bankTestBaseUrl . '/parsian/pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx?wsdl'; - } - case self::URL_CONFIRM : - { - return $this->bankTestBaseUrl . '/parsian/pec.shaparak.ir/NewIPGServices/Confirm/ConfirmService.asmx?wsdl'; - } - case self::URL_REFUND : - { - return $this->bankTestBaseUrl . '/parsian/pec.shaparak.ir/NewIPGServices/Reverse/ReversalService.asmx?wsdl'; - } + + return $this->bankTestBaseUrl.'/parsian/pec.shaparak.ir/NewIPG'; + + case self::URL_SALE: + + return $this->bankTestBaseUrl.'/parsian/pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx?wsdl'; + + case self::URL_CONFIRM: + + return $this->bankTestBaseUrl.'/parsian/pec.shaparak.ir/NewIPGServices/Confirm/ConfirmService.asmx?wsdl'; + + case self::URL_REFUND: + + return $this->bankTestBaseUrl.'/parsian/pec.shaparak.ir/NewIPGServices/Reverse/ReversalService.asmx?wsdl'; + case self::URL_MULTIPLEX: - { - return $this->bankTestBaseUrl . '/parsian/pec.shaparak.ir/NewIPGServices/MultiplexedSale/OnlineMultiplexedSalePaymentService.asmx?wsdl'; - } + + return $this->bankTestBaseUrl.'/parsian/pec.shaparak.ir/NewIPGServices/MultiplexedSale/OnlineMultiplexedSalePaymentService.asmx?wsdl'; + } } throw new Exception("could not find url for {$action} action"); diff --git a/src/Provider/PasargadProvider.php b/src/Provider/PasargadProvider.php index ec21293..49c9a3e 100644 --- a/src/Provider/PasargadProvider.php +++ b/src/Provider/PasargadProvider.php @@ -1,6 +1,5 @@ 'GET', 'action' => $this->getUrlFor(self::URL_GATEWAY), 'parameters' => [ - 'n' => $this->requestToken() + 'n' => $this->requestToken(), ], ]; } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function requestToken(): string @@ -58,14 +63,14 @@ public function requestToken(): string $response = $this->callApi($this->getUrlFor(self::URL_TOKEN), [ 'invoicenumber' => $this->getGatewayOrderId(), - 'invoiceDate' => date("Y/m/d H:i:s", strtotime($this->getTransaction()->created_at)), + 'invoiceDate' => date('Y/m/d H:i:s', strtotime($this->getTransaction()->created_at)), 'amount' => $this->getAmount(), 'terminalCode' => $this->getParameters('terminal_id'), 'merchantCode' => $this->getParameters('merchant_id'), 'redirectAddress' => $this->getCallbackUrl(), - 'timeStamp' => date("Y/m/d H:i:s"), + 'timeStamp' => date('Y/m/d H:i:s'), 'action' => self::ACTION_GET_TOKEN, - 'subpaymentlist' => $this->getParameters('subpaymentlist') + 'subpaymentlist' => $this->getParameters('subpaymentlist'), ]); $this->log(__METHOD__, $response); @@ -74,7 +79,7 @@ public function requestToken(): string } /** - * @inheritDoc + * {@inheritDoc} */ public function verifyTransaction(): bool { @@ -94,7 +99,7 @@ public function verifyTransaction(): bool ]); // update transaction reference number - if (!empty($this->getParameters('tref'))) { + if (! empty($this->getParameters('tref'))) { $this->getTransaction()->setGatewayToken( $this->getParameters('tref'), true @@ -109,7 +114,7 @@ public function verifyTransaction(): bool 'invoiceNumber' => $this->getParameters('iN'), 'invoiceDate' => $this->getParameters('iD'), 'amount' => $this->getAmount(), - 'timeStamp' => date("Y/m/d H:i:s"), + 'timeStamp' => date('Y/m/d H:i:s'), ]); $this->log(__METHOD__, $response); @@ -127,7 +132,7 @@ public function verifyTransaction(): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function refundTransaction(): bool { @@ -151,7 +156,7 @@ public function refundTransaction(): bool 'invoiceDate' => $this->getParameters('iD'), 'terminalCode' => $this->getParameters('terminal_id'), 'merchantCode' => $this->getParameters('merchant_id'), - 'timeStamp' => date("Y/m/d H:i:s"), + 'timeStamp' => date('Y/m/d H:i:s'), ]); $this->log(__METHOD__, $response); @@ -179,7 +184,6 @@ private function callApi(string $url, array $body, $method = 'post'): array ->throw() ->{$method}($url, $body); - $this->log($response->json('Message'), $response->json()); if ($response->json('IsSuccess') === false) { @@ -189,30 +193,26 @@ private function callApi(string $url, array $body, $method = 'post'): array return $response->json(); } - /** - * @param string $string - * @return string - */ private function sign(string $string): string { $string = sha1($string, true); $string = $this->getProcessor()->sign($string); // digital signature + return base64_encode($string); // base64_encode } /** * @param string $certificatePath - * - * @return RSAProcessor */ private function getProcessor(string $certificatePath = null): RSAProcessor { $path = $certificatePath ?: $this->getParameters('certificate_path'); + return new RSAProcessor($path, RSAKeyType::XMLFile); } /** - * @inheritDoc + * {@inheritDoc} */ public function canContinueWithCallbackParameters(): bool { @@ -226,7 +226,7 @@ public function canContinueWithCallbackParameters(): bool return false; } - if (!empty($this->getParameters('tref'))) { + if (! empty($this->getParameters('tref'))) { return true; } @@ -234,7 +234,7 @@ public function canContinueWithCallbackParameters(): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function getGatewayReferenceId(): string { @@ -246,71 +246,71 @@ public function getGatewayReferenceId(): string } /** - * @inheritDoc + * {@inheritDoc} */ public function getUrlFor(string $action): string { if ($this->environment === 'production') { switch ($action) { case self::URL_GATEWAY: - { + return 'https://pep.shaparak.ir/gateway.aspx'; - } + case self::URL_TOKEN: - { + return 'https://pep.shaparak.ir/Api/v1/Payment/GetToken'; - } + case self::URL_CHECK: - { + return 'https://pep.shaparak.ir/Api/v1/Payment/CheckTransactionResult'; - } + case self::URL_VERIFY: - { + return 'https://pep.shaparak.ir/Api/v1/Payment/VerifyPayment'; - } + case self::URL_REFUND: - { + return 'https://pep.shaparak.ir/Api/v1/Payment/RefundPayment'; - } + case self::UPDATE_SUBPAYMENT: - { + return 'https://pep.shaparak.ir/Api/v1/Payment/UpdateInvoiceSubPayment'; - } + case self::GET_SUBPAYMENT: - { + return 'https://pep.shaparak.ir/Api/v1/Payment/GetSubPaymentsReport'; - } + } } else { switch ($action) { case self::URL_GATEWAY: - { + return $this->bankTestBaseUrl.'/pasargad/pep.shaparak.ir/gateway.aspx'; - } + case self::URL_TOKEN: - { + return $this->bankTestBaseUrl.'/pasargad/pep.shaparak.ir/Api/v1/Payment/GetToken'; - } + case self::URL_CHECK: - { + return $this->bankTestBaseUrl.'/pasargad/pep.shaparak.ir/Api/v1/Payment/CheckTransactionResult'; - } + case self::URL_VERIFY: - { + return $this->bankTestBaseUrl.'/pasargad/pep.shaparak.ir/Api/v1/Payment/VerifyPayment'; - } + case self::URL_REFUND: - { + return $this->bankTestBaseUrl.'/pasargad/pep.shaparak.ir/Api/v1/Payment/RefundPayment'; - } + case self::UPDATE_SUBPAYMENT: - { + return $this->bankTestBaseUrl.'/pasargad/pep.shaparak.ir/Api/v1/Payment/UpdateInvoiceSubPayment'; - } + case self::GET_SUBPAYMENT: - { + return $this->bankTestBaseUrl.'/pasargad/pep.shaparak.ir/Api/v1/Payment/GetSubPaymentsReport'; - } + } } throw new Exception("could not find url for {$action} action"); diff --git a/src/Provider/SaderatProvider.php b/src/Provider/SaderatProvider.php index 11a3e75..ee68447 100644 --- a/src/Provider/SaderatProvider.php +++ b/src/Provider/SaderatProvider.php @@ -9,7 +9,7 @@ class SaderatProvider extends AbstractProvider protected bool $refundSupport = true; /** - * @inheritDoc + * {@inheritDoc} */ public function getFormParameters(): array { @@ -25,54 +25,55 @@ public function getFormParameters(): array } /** - * @inheritDoc + * {@inheritDoc} */ public function getUrlFor(string $action = null): string { if ($this->environment == 'production') { switch ($action) { case self::URL_GATEWAY: - { + return 'https://sepehr.shaparak.ir:8080/Pay'; - } - case self::URL_TOKEN : - { + + case self::URL_TOKEN: + return 'https://sepehr.shaparak.ir:8081/V1/PeymentApi/GetToken'; - } + case self::URL_VERIFY: - { + return 'https://sepehr.shaparak.ir:8081/V1/PeymentApi/Advice'; - } + case self::URL_REFUND: - { + return 'https://sepehr.shaparak.ir:8081/V1/PeymentApi/Rollback'; - } + } } else { switch ($action) { case self::URL_GATEWAY: - { + return $this->bankTestBaseUrl.'/saderat/sepehr.shaparak.ir/Pay'; - } + case self::URL_TOKEN: - { + return $this->bankTestBaseUrl.'/saderat/sepehr.shaparak.ir/V1/PeymentApi/GetToken'; - } + case self::URL_VERIFY: - { + return $this->bankTestBaseUrl.'/saderat/sepehr.shaparak.ir/V1/PeymentApi/Advice'; - } + case self::URL_REFUND: - { + return $this->bankTestBaseUrl.'/saderat/sepehr.shaparak.ir/V1/PeymentApi/Rollback'; - } + } } throw new Exception("could not find url for {$action} action"); } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception * @throws \JsonException */ @@ -111,7 +112,7 @@ protected function requestToken(): string } /** - * @inheritDoc + * {@inheritDoc} */ public function verifyTransaction(): bool { @@ -152,7 +153,7 @@ public function verifyTransaction(): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function refundTransaction(): bool { @@ -193,7 +194,7 @@ public function refundTransaction(): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function canContinueWithCallbackParameters(): bool { @@ -206,11 +207,12 @@ public function canContinueWithCallbackParameters(): bool } $respCode = $this->getParameters('RespCode'); - return (is_numeric($respCode) && (int) $respCode === 0) ; + + return is_numeric($respCode) && (int) $respCode === 0; } /** - * @inheritDoc + * {@inheritDoc} */ public function getGatewayReferenceId(): string { diff --git a/src/Provider/SamanProvider.php b/src/Provider/SamanProvider.php index d49bbb6..164f150 100644 --- a/src/Provider/SamanProvider.php +++ b/src/Provider/SamanProvider.php @@ -9,7 +9,8 @@ class SamanProvider extends AbstractProvider protected bool $refundSupport = true; /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ protected function requestToken(): string @@ -25,8 +26,8 @@ protected function requestToken(): string ]); $sendParams = [ - 'TermID' => $this->getParameters('terminal_id'), - 'ResNum' => $this->getGatewayOrderId(), + 'TermID' => $this->getParameters('terminal_id'), + 'ResNum' => $this->getGatewayOrderId(), 'TotalAmount' => $this->getAmount(), ]; @@ -35,7 +36,7 @@ protected function requestToken(): string $response = $soapClient->__soapCall('RequestToken', $sendParams); - if (!empty($response)) { + if (! empty($response)) { $token = trim($response); if (strlen($token) >= 20) { // got string token $this->log("fetched token from gateway: {$token}"); @@ -49,12 +50,13 @@ protected function requestToken(): string throw new Exception('shaparak::shaparak.token_failed'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function getFormParameters(): array @@ -62,19 +64,20 @@ public function getFormParameters(): array $token = $this->requestToken(); return [ - 'gateway' => 'saman', - 'method' => 'POST', - 'action' => $this->getUrlFor(self::URL_GATEWAY), + 'gateway' => 'saman', + 'method' => 'POST', + 'action' => $this->getUrlFor(self::URL_GATEWAY), 'parameters' => [ - 'Token' => $token, + 'Token' => $token, 'RedirectURL' => $this->getCallbackUrl(), - 'getmethod' => (bool) $this->getParameters('get_method', true) + 'getmethod' => (bool) $this->getParameters('get_method', true), ], ]; } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function verifyTransaction(): bool @@ -95,7 +98,7 @@ public function verifyTransaction(): bool ]); if ($this->getParameters('State') !== 'OK') { - throw new Exception('could not verify transaction with callback state: ' . $this->getParameters('State')); + throw new Exception('could not verify transaction with callback state: '.$this->getParameters('State')); } try { @@ -115,17 +118,18 @@ public function verifyTransaction(): bool return true; } - throw new Exception('shaparak::saman.error_' . (string)$response); + throw new Exception('shaparak::saman.error_'.(string) $response); } throw new Exception('shaparak::shaparak.could_not_verify_transaction'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function refundTransaction(): bool @@ -159,17 +163,17 @@ public function refundTransaction(): bool return true; } - throw new Exception('shaparak::saman.error_' . strval($response)); + throw new Exception('shaparak::saman.error_'.strval($response)); } throw new Exception('shaparak::shaparak.could_not_refund_payment'); } catch (SoapFault $e) { - throw new Exception('SoapFault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode()); + throw new Exception('SoapFault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode()); } } /** - * @inheritDoc + * {@inheritDoc} */ public function canContinueWithCallbackParameters(): bool { @@ -186,7 +190,8 @@ public function canContinueWithCallbackParameters(): bool } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function getGatewayReferenceId(): string @@ -199,39 +204,39 @@ public function getGatewayReferenceId(): string } /** - * @inheritDoc + * {@inheritDoc} */ public function getUrlFor(string $action = null): string { if ($this->environment === 'production') { switch ($action) { case self::URL_GATEWAY: - { + return 'https://sep.shaparak.ir/Payment.aspx'; - } + case self::URL_TOKEN : - { + return 'https://sep.shaparak.ir/Payments/InitPayment.asmx?WSDL'; - } + default: - { + return 'https://sep.shaparak.ir/payments/referencepayment.asmx?WSDL'; - } + } } else { switch ($action) { case self::URL_GATEWAY: - { - return $this->bankTestBaseUrl . '/saman/sep.shaparak.ir/payment.aspx'; - } + + return $this->bankTestBaseUrl.'/saman/sep.shaparak.ir/payment.aspx'; + case self::URL_TOKEN : - { - return $this->bankTestBaseUrl . '/saman/sep.shaparak.ir/payments/initpayment.asmx?wsdl'; - } + + return $this->bankTestBaseUrl.'/saman/sep.shaparak.ir/payments/initpayment.asmx?wsdl'; + default: - { - return $this->bankTestBaseUrl . '/saman/sep.shaparak.ir/payments/referencepayment.asmx?wsdl'; - } + + return $this->bankTestBaseUrl.'/saman/sep.shaparak.ir/payments/referencepayment.asmx?wsdl'; + } } } diff --git a/src/Provider/ZarinpalProvider.php b/src/Provider/ZarinpalProvider.php index b13a08c..45b9e95 100644 --- a/src/Provider/ZarinpalProvider.php +++ b/src/Provider/ZarinpalProvider.php @@ -9,7 +9,8 @@ class ZarinpalProvider extends AbstractProvider protected bool $refundSupport = true; /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function getFormParameters(): array @@ -19,13 +20,14 @@ public function getFormParameters(): array return [ 'gateway' => 'zarinpal', 'method' => 'GET', - 'action' => $this->getUrlFor(self::URL_GATEWAY) . '/' . $token, + 'action' => $this->getUrlFor(self::URL_GATEWAY).'/'.$token, 'parameters' => [], ]; } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ protected function requestToken(): string @@ -46,13 +48,13 @@ protected function requestToken(): string ]); if ($response->successful()) { - if ((int)$response->json('data.code') === 100) { + if ((int) $response->json('data.code') === 100) { return $response->json('data.authority'); } $this->log($response->json('errors.message'), $response->json('errors'), 'error'); throw new Exception( - $response->json('errors.code') . ' ' . $response->json('errors.message') + $response->json('errors.code').' '.$response->json('errors.message') ); } else { $this->log($response->body()); @@ -62,46 +64,46 @@ protected function requestToken(): string } /** - * @inheritDoc + * {@inheritDoc} */ public function getUrlFor(string $action = null): string { if ($this->environment === 'production') { switch ($action) { case self::URL_GATEWAY: - { + return 'https://www.zarinpal.com/pg/StartPay'; - } - case self::URL_TOKEN : - { + + case self::URL_TOKEN: + return 'https://api.zarinpal.com/pg/v4/payment/request.json'; - } - case self::URL_VERIFY : - { + + case self::URL_VERIFY: + return 'https://api.zarinpal.com/pg/v4/payment/verify.json'; - } + } } else { switch ($action) { case self::URL_GATEWAY: - { - return $this->bankTestBaseUrl . '/zarinpal/www.zarinpal.com/pg/StartPay'; - } - case self::URL_TOKEN : - { - return $this->bankTestBaseUrl . '/zarinpal/api.zarinpal.com/pg/v4/payment/request.json'; - } - case self::URL_VERIFY : - { - return $this->bankTestBaseUrl . '/zarinpal/api.zarinpal.com/pg/v4/payment/verify.json'; - } + + return $this->bankTestBaseUrl.'/zarinpal/www.zarinpal.com/pg/StartPay'; + + case self::URL_TOKEN: + + return $this->bankTestBaseUrl.'/zarinpal/api.zarinpal.com/pg/v4/payment/request.json'; + + case self::URL_VERIFY: + + return $this->bankTestBaseUrl.'/zarinpal/api.zarinpal.com/pg/v4/payment/verify.json'; + } } throw new Exception('url destination is not valid!'); } /** - * @inheritDoc + * {@inheritDoc} */ public function canContinueWithCallbackParameters(): bool { @@ -118,7 +120,8 @@ public function canContinueWithCallbackParameters(): bool } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function getGatewayReferenceId(): string @@ -131,7 +134,8 @@ public function getGatewayReferenceId(): string } /** - * @inheritDoc + * {@inheritDoc} + * * @throws Exception */ public function verifyTransaction(): bool @@ -146,7 +150,7 @@ public function verifyTransaction(): bool ]); if ($this->getParameters('Status') !== 'OK') { - throw new Exception('could not verify transaction with callback status: ' . $this->getParameters('Status')); + throw new Exception('could not verify transaction with callback status: '.$this->getParameters('Status')); } $response = Http::acceptJson()->post($this->getUrlFor(self::URL_VERIFY), [ @@ -156,23 +160,21 @@ public function verifyTransaction(): bool ]); if ($response->successful()) { - if ((int)$response->json('data.code') === 100 || (int)$response->json('data.code') === 101) { + if ((int) $response->json('data.code') === 100 || (int) $response->json('data.code') === 101) { $this->getTransaction()->setVerified(true); // save() + return true; } $this->log($response->json('errors.message'), $response->json('errors'), 'error'); throw new Exception( - $response->json('errors.code') . ' ' . $response->json('errors.message') + $response->json('errors.code').' '.$response->json('errors.message') ); } throw new Exception('shaparak::shaparak.could_not_verify_transaction'); } - /** - * @return bool - */ public function refundTransaction(): bool { return false; @@ -182,8 +184,9 @@ private function getDescription(): string { $description = $this->getTransaction()->description; if (empty($description)) { - $description = sprintf("Payment for Order ID: %s", $this->getTransaction()->id); + $description = sprintf('Payment for Order ID: %s', $this->getTransaction()->id); } + return $description; } } diff --git a/src/ShaparakManager.php b/src/ShaparakManager.php index db00160..3f95537 100755 --- a/src/ShaparakManager.php +++ b/src/ShaparakManager.php @@ -20,26 +20,17 @@ class ShaparakManager extends Manager implements Contracts\Factory { /** * runtime driver configuration - * - * @var array */ protected array $runtimeConfig; /** * transaction which should paid on the gateway - * - * @var Transaction $transaction */ protected Transaction $transaction; - /** - * @param string $message - * @param array $params - * @param string $level - */ public static function log(string $message, array $params = [], string $level = 'debug'): void { - $message = "SHAPARAK -> ".$message; + $message = 'SHAPARAK -> '.$message; forward_static_call(['PhpMonsters\Log\Facades\XLog', $level], $message, $params); } @@ -48,18 +39,17 @@ public static function log(string $message, array $params = [], string $level = * Get a driver instance. * * @param string $driver driver name - * @param Transaction $transaction * @param array $config runtime configuration for the driver instead of reading from config file - * * @return mixed */ public function with(string $driver, Transaction $transaction, array $config = []) { $this->transaction = $transaction; - if (!empty($config)) { + if (! empty($config)) { $this->runtimeConfig = $config; } + return $this->driver($driver); } @@ -92,10 +82,6 @@ protected function createSamanDriver() /** * get provider configuration runtime array or config based configuration - * - * @param string $driver - * - * @return array */ protected function getConfig(string $driver): array { @@ -108,12 +94,6 @@ protected function getConfig(string $driver): array /** * Build a Shaparak provider instance. - * - * @param string $provider - * - * @param array $config - * - * @return Provider */ public function buildProvider(string $provider, array $config): Provider { diff --git a/src/ShaparakServiceProvider.php b/src/ShaparakServiceProvider.php index 16e4920..9a18566 100644 --- a/src/ShaparakServiceProvider.php +++ b/src/ShaparakServiceProvider.php @@ -52,23 +52,23 @@ public function isDeferred() protected function registerResources() { - $this->loadViewsFrom(__DIR__ . '/../views/', 'shaparak'); + $this->loadViewsFrom(__DIR__.'/../views/', 'shaparak'); $this->publishes([ - __DIR__ . '/../translations/' => base_path('/lang/vendor/shaparak'), + __DIR__.'/../translations/' => base_path('/lang/vendor/shaparak'), ], 'translations'); - $this->loadTranslationsFrom(__DIR__ . '/../translations', 'shaparak'); + $this->loadTranslationsFrom(__DIR__.'/../translations', 'shaparak'); } protected function registerPublishing() { $this->publishes([ - __DIR__ . '/../views/' => resource_path('/views/vendor/shaparak'), + __DIR__.'/../views/' => resource_path('/views/vendor/shaparak'), ], 'views'); $this->publishes([ - __DIR__ . '/../config/shaparak.php' => config_path('shaparak.php') + __DIR__.'/../config/shaparak.php' => config_path('shaparak.php'), ], 'config'); } } diff --git a/translations/en/shaparak.php b/translations/en/shaparak.php index 83474f7..5fd94ea 100644 --- a/translations/en/shaparak.php +++ b/translations/en/shaparak.php @@ -1,18 +1,18 @@ 'canceled_by_user', - 'could_not_request_token' => 'could_not_request_token', + 'canceled_by_user' => 'canceled_by_user', + 'could_not_request_token' => 'could_not_request_token', 'could_not_verify_transaction' => 'could_not_verify_transaction', - 'could_not_inquiry_payment' => 'could_not_inquiry_payment', - 'could_not_settle_payment' => 'could_not_settle_payment', - 'could_not_refund_payment' => 'could_not_refund_payment', - 'gate_not_ready' => 'gate_not_ready', - 'goto_gate' => 'goto_gate', - 'invalid_response' => 'invalid_response', - 'token_failed' => 'token_failed', - 'verify_failed' => 'verify_failed', - 'inquiry_failed' => 'inquiry_failed', - 'settle_failed' => 'settle_failed', - 'refund_failed' => 'refund_failed', + 'could_not_inquiry_payment' => 'could_not_inquiry_payment', + 'could_not_settle_payment' => 'could_not_settle_payment', + 'could_not_refund_payment' => 'could_not_refund_payment', + 'gate_not_ready' => 'gate_not_ready', + 'goto_gate' => 'goto_gate', + 'invalid_response' => 'invalid_response', + 'token_failed' => 'token_failed', + 'verify_failed' => 'verify_failed', + 'inquiry_failed' => 'inquiry_failed', + 'settle_failed' => 'settle_failed', + 'refund_failed' => 'refund_failed', ];