Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 39 additions & 37 deletions config/payment.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Shetabit\Multipay\Constants\Currency;

return [
/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -38,7 +40,7 @@
'apiPaymentUrl' => 'https://gooyapay.ir/startPay/',
'merchantId' => 'XXXX-XXXX-XXXX-XXXXXXXXXXXXXXXXXXXXX',
'callbackUrl' => 'http://yoursite.com/path/to',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'fanavacard' => [
'baseUri' => 'https://fcp.shaparak.ir',
Expand All @@ -49,14 +51,14 @@
'username' => 'xxxxxxx',
'password' => 'xxxxxxx',
'callbackUrl' => 'http://yoursite.com/path/to',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'atipay' => [
'atipayTokenUrl' => 'https://mipg.atipay.net/v1/get-token',
'atipayRedirectGatewayUrl' => 'https://mipg.atipay.net/v1/redirect-to-gateway',
'atipayVerifyUrl' => 'https://mipg.atipay.net/v1/verify-payment',
'apikey' => '',
'currency' => 'R', //Can be R, T (Rial, Toman)
'currency' => Currency::RIAL,
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using Atipay',
],
Expand All @@ -66,7 +68,7 @@
'username' => '',
'password' => '',
'merchantConfigID' => '',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using asanpardakht',
],
Expand All @@ -79,7 +81,7 @@
'password' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using behpardakht',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
'cumulativeDynamicPayStatus' => false,
],
'digipay' => [
Expand All @@ -89,7 +91,7 @@
'client_id' => '',
'client_secret' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'currency' => 'R', //Can be R, T (Rial, Toman)
'currency' => Currency::RIAL,
],
'etebarino' => [
'apiPurchaseUrl' => 'https://api.etebarino.com/public/merchant/request-payment',
Expand All @@ -116,7 +118,7 @@
'sandbox' => false, // Set it to true for test environments
'merchantId' => '', // Set `TEST` for test environments (sandbox)
'callbackUrl' => '',
'currency' => 'R', //Can be R, T (Rial, Toman)
'currency' => Currency::RIAL,
],
'irankish' => [
'apiPurchaseUrl' => 'https://ikc.shaparak.ir/api/v3/tokenization/make',
Expand All @@ -128,7 +130,7 @@
'password' => '',
'acceptorId' => '',
'pubKey' => '',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'jibit' => [
'apiPaymentUrl' => 'https://napi.jibit.ir/ppg/v3',
Expand All @@ -139,7 +141,7 @@
'tokenStoragePath' => 'jibit/',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using jibit',
'currency' => 'T', // Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN, // Can be R, T (Rial, Toman)
],
'nextpay' => [
'apiPurchaseUrl' => 'https://nextpay.org/nx/gateway/token',
Expand All @@ -148,7 +150,7 @@
'merchantId' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using nextpay',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'omidpay' => [
'apiGenerateTokenUrl' => 'https://ref.sayancard.ir/ref-payment/RestServices/mts/generateTokenWithNoSign/',
Expand All @@ -159,7 +161,7 @@
'password' => '',
'callbackUrl' => '',
'description' => 'payment using omidpay',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'parsian' => [
'apiPurchaseUrl' => 'https://pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx?wsdl',
Expand All @@ -168,7 +170,7 @@
'merchantId' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using parsian',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'parspal' => [
/* Normal api */
Expand All @@ -187,7 +189,7 @@
'sandbox' => false, // Set it to true for test environments
'merchantId' => '', // Set `00000000aaaabbbbcccc000000000000` for test environments (sandbox)
'callbackUrl' => '',
'currency' => 'T', // Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN, // Can be R, T (Rial, Toman)
],
'pasargad' => [
'baseUrl' => 'https://pep.shaparak.ir/dorsa1',
Expand All @@ -196,15 +198,15 @@
'merchantId' => '',
'terminalCode' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'panapal' => [
'apiPurchaseUrl' => 'https://paanapardakht.com/webservice/rest/PaymentRequest',
'apiVerificationUrl' => 'https://paanapardakht.com/webservice/rest/PaymentVerification',
'apiPaymentUrl' => 'https://paanapardakht.com/startPay/',
'merchantId' => 'XXXX-XXXX-XXXX-XXXXXXXXXXXXXXXXXXXXX',
'callbackUrl' => 'http://yoursite.com/path/to',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'paypal' => [
/* normal api */
Expand Down Expand Up @@ -232,7 +234,7 @@
'merchantId' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using payping',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'paystar' => [
'apiPurchaseUrl' => 'https://core.paystar.ir/api/pardakht/create/',
Expand All @@ -242,7 +244,7 @@
'signKey' => '', // sign key of your gateway
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using paystar',
'currency' => 'R', //Can be R, T (Rial, Toman)
'currency' => Currency::RIAL,
],
'poolam' => [
'apiPurchaseUrl' => 'https://poolam.ir/invoice/request/',
Expand All @@ -251,14 +253,14 @@
'merchantId' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using poolam',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'pna' => [
'apiNormalSale' => 'https://pna.shaparak.ir/mhipg/api/Payment/NormalSale',
'apiPaymentUrl' => 'https://pna.shaparak.ir/mhui/home/index/',
'apiConfirmationUrl' => 'https://pna.shaparak.ir/mhipg/api/Payment/confirm',
'CorporationPin' => '',
'currency' => 'R',//Can be R, T (Rial, Toman)
'currency' => Currency::RIAL,
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using pna',
],
Expand All @@ -272,7 +274,7 @@
'merchantId' => '',
'terminalId' => '',
'callbackUrl' => '',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
'mode' => 'normal', // can be normal, PaymentByIdentity, PaymentByMultiIdentity,
'PaymentIdentity' => '',
'MultiIdentityRows' => [
Expand All @@ -292,7 +294,7 @@
'password' => '',
'callbackUrl' => '',
'description' => 'payment using saman',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'sep' => [
'apiGetToken' => 'https://sep.shaparak.ir/onlinepg/onlinepg',
Expand All @@ -301,7 +303,7 @@
'terminalId' => '',
'callbackUrl' => '',
'description' => 'Saman Electronic Payment for Saderat & Keshavarzi',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'sepehr' => [
'apiGetToken' => 'https://sepehr.shaparak.ir:8081/V1/PeymentApi/GetToken',
Expand All @@ -310,7 +312,7 @@
'terminalId' => '',
'callbackUrl' => '',
'description' => 'payment using sepehr(saderat)',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'yekpay' => [
'apiPurchaseUrl' => 'https://gate.yekpay.com/api/payment/server?wsdl',
Expand Down Expand Up @@ -342,7 +344,7 @@
'merchantId' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using zarinpal',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'zibal' => [
/* normal api */
Expand All @@ -355,7 +357,7 @@
'merchantId' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using zibal',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'sepordeh' => [
'apiPurchaseUrl' => 'https://sepordeh.com/merchant/invoices/add',
Expand All @@ -366,7 +368,7 @@
'merchantId' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using sepordeh',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'rayanpay' => [
'apiPurchaseUrl' => 'https://bpm.shaparak.ir/pgwchannel/startpay.mellat',
Expand All @@ -377,7 +379,7 @@
'client_id' => '',
'password' => '',
'callbackUrl' => '',
'currency' => 'R', //Can be R, T (Rial, Toman)
'currency' => Currency::RIAL,
],
'shepa' => [
/* Normal api */
Expand All @@ -393,7 +395,7 @@
'sandbox' => false, // Set it to true for test environments
'merchantId' => '', // Set `sandbox` for test environments (sandbox)
'callbackUrl' => '',
'currency' => 'R', //Can be R, T (Rial, Toman)
'currency' => Currency::RIAL,
],
'sizpay' => [
'apiPurchaseUrl' => 'https://rt.sizpay.ir/KimiaIPGRouteService.asmx?WSDL',
Expand All @@ -405,7 +407,7 @@
'password' => '',
'SignData' => '',
'callbackUrl' => '',
'currency' => 'R', //Can be R, T (Rial, Toman)
'currency' => Currency::RIAL,
],
'vandar' => [
'apiPurchaseUrl' => 'https://ipg.vandar.io/api/v3/send',
Expand All @@ -414,7 +416,7 @@
'callbackUrl' => '',
'merchantId' => '',
'description' => 'payment using Vandar',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'aqayepardakht' => [
'apiPurchaseUrl' => 'https://panel.aqayepardakht.ir/api/v2/create',
Expand All @@ -428,15 +430,15 @@
'mobile' => '',
'email' => '',
'description' => 'payment using Aqayepardakht',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'azki' => [
'apiPaymentUrl' => 'https://api.azkivam.com',
'callbackUrl' => 'http://yoursite.com/path/to',
'fallbackUrl' => 'http://yoursite.com/path/to',
'merchantId' => '',
'key' => '',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
'description' => 'payment using azki',
],
'payfa' => [
Expand All @@ -445,7 +447,7 @@
'apiVerificationUrl' => 'https://payment.payfa.com/v2/api/Transaction/Verify/',
'callbackUrl' => '',
'apiKey' => '',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'toman' => [
'base_url' => 'https://escrow-api.toman.ir/api/v1',
Expand All @@ -460,7 +462,7 @@
'callbackUrl' => '',
'api_token' => '',
'description' => 'payment using Bitpay',
'currency' => 'R', //Can be R, T (Rial, Toman)
'currency' => Currency::RIAL,
],
'minipay' => [
'apiPurchaseUrl' => 'https://v1.minipay.me/api/pg/request/',
Expand All @@ -469,7 +471,7 @@
'merchantId' => '',
'callbackUrl' => 'http://yoursite.com/path/to',
'description' => 'payment using Minipay.',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'snapppay' => [
'apiPaymentUrl' => 'https://fms-gateway-staging.apps.public.teh-1.snappcloud.io',
Expand All @@ -479,7 +481,7 @@
'client_id' => '',
'client_secret' => '',
'description' => 'payment using Snapp Pay.',
'currency' => 'T', //Can be R, T (Rial, Toman)
'currency' => Currency::TOMAN,
],
'daracard' => [
'apiPurchaseUrl' => 'https://ipg.daracard.co/api/v0/Request/PaymentRequest/',
Expand All @@ -506,7 +508,7 @@
'client_secret' => '',
'username' =>'',
'password' => '',
'currency' => 'T', // یا 'R'
'currency' => Currency::TOMAN, // یا Currency::RIAL
'callbackUrl' => 'http://yoursite.com/path/to',
],
'xendit' => [
Expand Down
12 changes: 12 additions & 0 deletions src/Abstracts/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Shetabit\Multipay\Abstracts;

use Shetabit\Multipay\Constants\Currency;
use Shetabit\Multipay\Contracts\DriverInterface;
use Shetabit\Multipay\Contracts\ReceiptInterface;
use Shetabit\Multipay\Invoice;
Expand Down Expand Up @@ -100,6 +101,17 @@ public function redirectWithForm($action, array $inputs = [], $method = 'POST')
return new RedirectionForm($action, $inputs, $method);
}

/**
* Normalize the price based on the selected currency ratio on config.
*
* @param int|float $price
* @return int|float
*/
protected function normalizeByCurrency(int|float $price): int|float
{
return $price * Currency::RATIO[$this->settings->currency];
}

/**
* Purchase the invoice
*
Expand Down
15 changes: 15 additions & 0 deletions src/Constants/Currency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Shetabit\Multipay\Constants;

class Currency
{
public const TOMAN = 'T';

public const RIAL = 'R';

public const RATIO = [
self::TOMAN => 10,
self::RIAL => 1
];
}
2 changes: 1 addition & 1 deletion src/Drivers/Asanpardakht/Asanpardakht.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function token(): array
'serviceTypeId' => 1,
'merchantConfigurationId' => $this->settings->merchantConfigID,
'localInvoiceId' => $this->invoice->getUuid(),
'amountInRials' => $this->invoice->getAmount() * ($this->settings->currency == 'T' ? 10 : 1), // convert to rial
'amountInRials' => $this->normalizeByCurrency($this->invoice->getAmount()), // convert to rial
'localDate' => $this->getTime()['content'],
'callbackURL' => $this->settings->callbackUrl . $query,
'paymentId' => "0",
Expand Down
Loading