Skip to content

Commit

Permalink
Run code standard fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
omalizadeh committed May 5, 2023
1 parent 28a2947 commit 249f046
Show file tree
Hide file tree
Showing 29 changed files with 182 additions and 165 deletions.
6 changes: 3 additions & 3 deletions config/gateway_idpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
return [

/**
* driver class namespace
* driver class namespace.
*/
'driver' => Omalizadeh\MultiPayment\Drivers\IDPay\IDPay::class,

/**
* gateway configurations
* gateway configurations.
*/
'main' => [
'api_key' => '',
Expand All @@ -21,5 +21,5 @@
'sandbox' => true,
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using idpay',
]
],
];
8 changes: 4 additions & 4 deletions config/gateway_mellat.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
return [

/**
* driver class namespace
* driver class namespace.
*/
'driver' => Omalizadeh\MultiPayment\Drivers\Mellat\Mellat::class,

/**
* soap client options
* soap client options.
*/
'soap_options' => [
'encoding' => 'UTF-8',
],

/**
* gateway configurations
* gateway configurations.
*/
'main' => [
'terminal_id' => '',
Expand All @@ -30,5 +30,5 @@
'password' => '',
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using mellat gateway',
]
],
];
8 changes: 4 additions & 4 deletions config/gateway_novin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
return [

/**
* driver class namespace
* driver class namespace.
*/
'driver' => Omalizadeh\MultiPayment\Drivers\Novin\Novin::class,

/**
* gateway payment page language
* supported values: fa, en
* supported values: fa, en.
*/
'language' => 'fa',

/**
* gateway configurations
* gateway configurations.
*/
'main' => [
'username' => '',
Expand All @@ -33,5 +33,5 @@
'temp_files_dir' => '',
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using eghtesade novin',
]
],
];
6 changes: 3 additions & 3 deletions config/gateway_parsian.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
return [

/**
* driver class namespace
* driver class namespace.
*/
'driver' => Omalizadeh\MultiPayment\Drivers\Parsian\Parsian::class,

/**
* soap client options
* soap client options.
*/
'soap_options' => [
'encoding' => 'UTF-8',
],

/**
* gateway configurations
* gateway configurations.
*/
'main' => [
'pin_code' => '',
Expand Down
10 changes: 5 additions & 5 deletions config/gateway_pasargad.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
return [

/**
* driver class namespace
* driver class namespace.
*/
'driver' => Omalizadeh\MultiPayment\Drivers\Pasargad\Pasargad::class,

/**
* gateway configurations
* gateway configurations.
*/
'main' => [
'merchant_code' => '',
'merchant_code' => '',
'terminal_code' => '',
'certificate_type' => 'xml_file', // supported values: xml_file, xml_string
'certificate' => '', // certificate as a string or certificate.xml file path
'callback_url' => 'https://yoursite.com/path/to',
],
'other' => [
'merchant_code' => '',
'merchant_code' => '',
'terminal_code' => '',
'certificate_type' => 'xml_file',
'certificate' => '',
'callback_url' => 'https://yoursite.com/path/to',
]
],
];
6 changes: 3 additions & 3 deletions config/gateway_payir.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
return [

/**
* driver class namespace
* driver class namespace.
*/
'driver' => Omalizadeh\MultiPayment\Drivers\PayIr\PayIr::class,

/**
* gateway configurations
* gateway configurations.
*/
'main' => [
'api_key' => '', // use 'test' as api_key for sandbox mode
Expand All @@ -19,5 +19,5 @@
'api_key' => '',
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using payir',
]
],
];
10 changes: 5 additions & 5 deletions config/gateway_saman.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
return [

/**
* driver class namespace
* driver class namespace.
*/
'driver' => Omalizadeh\MultiPayment\Drivers\Saman\Saman::class,

/**
* soap client options
* soap client options.
*/
'soap_options' => [
'encoding' => 'UTF-8'
'encoding' => 'UTF-8',
],

/**
* gateway configurations
* merchant_id is the same as terminal_id
* merchant_id is the same as terminal_id.
*/
'main' => [
'terminal_id' => '',
Expand All @@ -29,5 +29,5 @@
'callback_url' => 'https://yoursite.com/path/to',
'callback_method' => 'POST',
'description' => 'payment using saman',
]
],
];
6 changes: 3 additions & 3 deletions config/gateway_zarinpal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
return [

/**
* driver class namespace
* driver class namespace.
*/
'driver' => Omalizadeh\MultiPayment\Drivers\Zarinpal\Zarinpal::class,

/**
* gateway configurations
* gateway configurations.
*/
'main' => [
'authorization_token' => '', // optional, used only to refund payments (can be created from zarinpal panel)
Expand All @@ -23,5 +23,5 @@
'callback_url' => 'https://yoursite.com/path/to',
'mode' => 'normal',
'description' => 'payment using zarinpal',
]
],
];
10 changes: 5 additions & 5 deletions config/gateway_zibal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
return [

/**
* driver class namespace
* driver class namespace.
*/
'driver' => Omalizadeh\MultiPayment\Drivers\Zibal\Zibal::class,

/**
* gateway configurations
* gateway configurations.
*/
'main' => [
'merchant' => '', // use 'zibal' for sandbox (testing) mode
'merchant' => '', // use 'zibal' for sandbox (testing) mode
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using zarinpal',
],
'other' => [
'merchant' => '',
'merchant' => '',
'callback_url' => 'https://yoursite.com/path/to',
'description' => 'payment using zarinpal',
]
],
];
6 changes: 3 additions & 3 deletions config/multipayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
return [

/**
* set default gateway
* set default gateway.
*
* valid pattern --> GATEWAY_NAME.GATEWAY_CONFIG_KEY
* valid GATEWAY_NAME --> zarinpal, saman, mellat, novin, parsian, pasargad, zibal, payir, idpay
*/
'default_gateway' => env('DEFAULT_GATEWAY', 'zarinpal.main'),

/**
* set to false if your in-app currency is IRR
* set to false if your in-app currency is IRR.
*/
'convert_to_rials' => true
'convert_to_rials' => true,
];
12 changes: 7 additions & 5 deletions src/Drivers/IDPay/IDPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function purchase(): string

if (isset($response['error_code'])) {
$message = $response['error_message'] ?? $this->getStatusMessage($response['error_code']);

throw new PurchaseFailedException($message, $response['error_code']);
}

Expand All @@ -41,10 +42,10 @@ public function verify(): Receipt
{
$status = (int) request('status');

if (!in_array($status, [
if (! in_array($status, [
$this->getPendingVerificationStatusCode(),
$this->getPaymentAlreadyVerifiedStatusCode(),
$this->getSuccessResponseStatusCode()
$this->getSuccessResponseStatusCode(),
], true)
) {
throw new PaymentFailedException($this->getStatusMessage($status), $status);
Expand All @@ -54,6 +55,7 @@ public function verify(): Receipt

if (isset($response['error_code'])) {
$message = $response['error_message'] ?? $this->getStatusMessage($response['error_code']);

throw new PaymentFailedException($message, $response['error_code']);
}

Expand All @@ -71,7 +73,7 @@ public function verify(): Receipt
$this->getInvoice(),
$response['track_id'],
$response['payment']['track_id'],
$response['payment']['card_no']
$response['payment']['card_no'],
);
}

Expand All @@ -90,7 +92,7 @@ protected function getPurchaseData(): array
$mobile = $this->getInvoice()->getPhoneNumber();
$email = $this->getInvoice()->getEmail();

if (!empty($mobile)) {
if (! empty($mobile)) {
$mobile = $this->checkPhoneNumberFormat($mobile);
}

Expand All @@ -101,7 +103,7 @@ protected function getPurchaseData(): array
'phone' => $mobile,
'mail' => $email,
'desc' => $description,
'callback' => $this->getInvoice()->getCallbackUrl() ?: $this->settings['callback_url']
'callback' => $this->getInvoice()->getCallbackUrl() ?: $this->settings['callback_url'],
];
}

Expand Down
21 changes: 11 additions & 10 deletions src/Drivers/Mellat/Mellat.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function pay(): RedirectionForm
{
$mobileNo = $this->getInvoice()->getPhoneNumber();

if (!empty($mobileNo)) {
if (! empty($mobileNo)) {
$mobileNo = $this->checkPhoneNumberFormat($mobileNo);
}

Expand Down Expand Up @@ -64,6 +64,7 @@ public function verify(): Receipt
if ($responseCode != $this->getSuccessResponseStatusCode()) {
if ($responseCode != $this->getPaymentAlreadyVerifiedStatusCode()) {
$soap->bpReversalRequest($data);

throw new PaymentFailedException($this->getStatusMessage($responseCode), $responseCode);
}

Expand Down Expand Up @@ -97,13 +98,13 @@ protected function getPurchaseData(): array
throw new InvalidConfigurationException('Username or password has not been set.');
}

if (!empty($this->getInvoice()->getDescription())) {
if (! empty($this->getInvoice()->getDescription())) {
$description = $this->getInvoice()->getDescription();
} else {
$description = $this->settings['description'];
}

return array(
return [
'terminalId' => $this->settings['terminal_id'],
'userName' => $this->settings['username'],
'userPassword' => $this->settings['password'],
Expand All @@ -113,8 +114,8 @@ protected function getPurchaseData(): array
'localTime' => now()->format('Gis'),
'orderId' => (int) $this->getInvoice()->getInvoiceId(),
'additionalData' => $description,
'payerId' => $this->getInvoice()->getUserId()
);
'payerId' => $this->getInvoice()->getUserId(),
];
}

protected function getVerificationData(): array
Expand Down Expand Up @@ -181,7 +182,7 @@ protected function getStatusMessage($statusCode): string
'55' => 'تراکنش نامعتبر است',
'61' => 'خطا در واریز',
'62' => 'مسیر بازگشت به سایت در دامنه ثبت شده برای پذیرنده قرار ندارد',
'98' => 'سقف استفاده از رمز ایستا به پایان رسیده است'
'98' => 'سقف استفاده از رمز ایستا به پایان رسیده است',
];
$unknownError = 'خطای ناشناخته رخ داده است.';

Expand All @@ -190,22 +191,22 @@ protected function getStatusMessage($statusCode): string

protected function getSuccessResponseStatusCode(): string
{
return "0";
return '0';
}

private function getPaymentAlreadyVerifiedStatusCode(): string
{
return "43";
return '43';
}

private function getPaymentAlreadySettledStatusCode(): string
{
return "45";
return '45';
}

private function getPaymentAlreadyReversedStatusCode(): string
{
return "48";
return '48';
}

protected function getPurchaseUrl(): string
Expand Down

0 comments on commit 249f046

Please sign in to comment.