diff --git a/config/payment.php b/config/payment.php index 37ae7c1c..9a915cf0 100755 --- a/config/payment.php +++ b/config/payment.php @@ -23,16 +23,50 @@ | */ 'drivers' => [ + 'local' => [ + 'callbackUrl' => '/callback', + 'title' => 'درگاه پرداخت تست', + 'description' => 'این درگاه *صرفا* برای تست صحت روند پرداخت و لغو پرداخت میباشد', + 'orderLabel' => 'شماره سفارش', + 'amountLabel' => 'مبلغ قابل پرداخت', + 'payButton' => 'پرداخت موفق', + 'cancelButton' => 'پرداخت ناموفق', + ], + 'gooyapay' => [ + 'apiPurchaseUrl' => 'https://gooyapay.ir/webservice/rest/PaymentRequest', + 'apiVerificationUrl' => 'https://gooyapay.ir/webservice/rest/PaymentVerification', + 'apiPaymentUrl' => 'https://gooyapay.ir/startPay/', + 'merchantId' => 'XXXX-XXXX-XXXX-XXXXXXXXXXXXXXXXXXXXX', + 'callbackUrl' => 'http://yoursite.com/path/to', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'fanavacard' => [ + 'baseUri' => 'https://fcp.shaparak.ir', + 'apiPaymentUrl' => '_ipgw_//payment/', + 'apiPurchaseUrl' => 'ref-payment/RestServices/mts/generateTokenWithNoSign/', + 'apiVerificationUrl' => 'ref-payment/RestServices/mts/verifyMerchantTrans/', + 'apiReverseAmountUrl' => 'ref-payment/RestServices/mts/reverseMerchantTrans/', + 'username' => 'xxxxxxx', + 'password' => 'xxxxxxx', + 'callbackUrl' => 'http://yoursite.com/path/to', + 'currency' => 'T', //Can be R, T (Rial, 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) + 'callbackUrl' => 'http://yoursite.com/path/to', + 'description' => 'payment using Atipay', + ], 'asanpardakht' => [ - 'apiPurchaseUrl' => 'https://services.asanpardakht.net/paygate/merchantservices.asmx?wsdl', 'apiPaymentUrl' => 'https://asan.shaparak.ir', - 'apiVerificationUrl' => 'https://services.asanpardakht.net/paygate/merchantservices.asmx?wsdl', - 'apiUtilsUrl' => 'https://services.asanpardakht.net/paygate/internalutils.asmx?wsdl', - 'key' => '', - 'iv' => '', + 'apiRestPaymentUrl' => 'https://ipgrest.asanpardakht.ir/v1/', 'username' => '', 'password' => '', - 'merchantId' => '', + 'merchantConfigID' => '', + 'currency' => 'T', //Can be R, T (Rial, Toman) 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using asanpardakht', ], @@ -40,12 +74,33 @@ 'apiPurchaseUrl' => 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl', 'apiPaymentUrl' => 'https://bpm.shaparak.ir/pgwchannel/startpay.mellat', 'apiVerificationUrl' => 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl', - 'apiNamespaceUrl' => 'http://interfaces.core.sw.bps.com/', 'terminalId' => '', 'username' => '', 'password' => '', 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using behpardakht', + 'currency' => 'T', //Can be R, T (Rial, Toman) + 'cumulativeDynamicPayStatus' => false, + ], + 'digipay' => [ + 'apiPaymentUrl' => 'https://api.mydigipay.com', // with out '/' at the end + 'username' => 'username', + 'password' => 'password', + 'client_id' => '', + 'client_secret' => '', + 'callbackUrl' => 'http://yoursite.com/path/to', + 'currency' => 'R', //Can be R, T (Rial, Toman) + ], + 'etebarino' => [ + 'apiPurchaseUrl' => 'https://api.etebarino.com/public/merchant/request-payment', + 'apiPaymentUrl' => 'https://panel.etebarino.com/gateway/public/ipg', + 'apiVerificationUrl' => 'https://api.etebarino.com/public/merchant/verify-payment', + 'merchantId' => '', + 'terminalId' => '', + 'username' => '', + 'password' => '', + 'callbackUrl' => 'http://yoursite.com/path/to', + 'description' => 'payment using etebarino', ], 'idpay' => [ 'apiPurchaseUrl' => 'https://api.idpay.ir/v1.1/payment', @@ -56,23 +111,50 @@ 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using idpay', 'sandbox' => false, // set it to true for test environments + 'currency' => 'R', //Can be R, T (Rial, Toman) ], 'irankish' => [ - 'apiPurchaseUrl' => 'https://ikc.shaparak.ir/XToken/Tokens.xml', - 'apiPaymentUrl' => 'https://ikc.shaparak.ir/TPayment/Payment/index/', - 'apiVerificationUrl' => 'https://ikc.shaparak.ir/XVerify/Verify.xml', - 'merchantId' => '', - 'sha1Key' => '', + 'apiPurchaseUrl' => 'https://ikc.shaparak.ir/api/v3/tokenization/make', + 'apiPaymentUrl' => 'https://ikc.shaparak.ir/iuiv3/IPG/Index/', + 'apiVerificationUrl' => 'https://ikc.shaparak.ir/api/v3/confirmation/purchase', 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using irankish', + 'terminalId' => '', + 'password' => '', + 'acceptorId' => '', + 'pubKey' => '', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'jibit' => [ + 'apiPaymentUrl' => 'https://napi.jibit.ir/ppg/v3', + 'apiKey' => '', + 'apiSecret' => '', + // You can change the token storage path in Laravel like this + // 'tokenStoragePath' => function_exists('storage_path') ? storage_path('jibit/') : 'jibit/' + 'tokenStoragePath' => 'jibit/', + 'callbackUrl' => 'http://yoursite.com/path/to', + 'description' => 'payment using jibit', + 'currency' => 'T', // Can be R, T (Rial, Toman) ], 'nextpay' => [ - 'apiPurchaseUrl' => 'https://api.nextpay.org/gateway/token.http', - 'apiPaymentUrl' => 'https://api.nextpay.org/gateway/payment/', - 'apiVerificationUrl' => 'https://api.nextpay.org/gateway/verify.http', + 'apiPurchaseUrl' => 'https://nextpay.org/nx/gateway/token', + 'apiPaymentUrl' => 'https://nextpay.org/nx/gateway/payment/', + 'apiVerificationUrl' => 'https://nextpay.org/nx/gateway/verify', 'merchantId' => '', 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using nextpay', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'omidpay' => [ + 'apiGenerateTokenUrl' => 'https://ref.sayancard.ir/ref-payment/RestServices/mts/generateTokenWithNoSign/', + 'apiPaymentUrl' => 'https://say.shaparak.ir/_ipgw_/MainTemplate/payment/', + 'apiVerificationUrl' => 'https://ref.sayancard.ir/ref-payment/RestServices/mts/verifyMerchantTrans/', + 'username' => '', + 'merchantId' => '', + 'password' => '', + 'callbackUrl' => '', + 'description' => 'payment using omidpay', + 'currency' => 'T', //Can be R, T (Rial, Toman) ], 'parsian' => [ 'apiPurchaseUrl' => 'https://pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx?wsdl', @@ -81,25 +163,30 @@ 'merchantId' => '', 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using parsian', + 'currency' => 'T', //Can be R, T (Rial, Toman) ], 'pasargad' => [ - 'apiPaymentUrl' => 'https://pep.shaparak.ir/payment.aspx', - 'apiGetToken' => 'https://pep.shaparak.ir/Api/v1/Payment/GetToken', - 'apiCheckTransactionUrl' => 'https://pep.shaparak.ir/Api/v1/Payment/CheckTransactionResult', - 'apiVerificationUrl' => 'https://pep.shaparak.ir/Api/v1/Payment/VerifyPayment', + 'apiGetToken' => 'https://pep.shaparak.ir/dorsa1/token/getToken', + 'confirmTransactions' => 'https://pep.shaparak.ir/dorsa1/api/payment/confirm-transactions', + 'verifyPayment' => 'https://pep.shaparak.ir/dorsa1//api/payment/verify-payment', + 'apiPaymentUrl' => 'https://pep.shaparak.ir/dorsa1/api/payment/purchase', + 'paymentInquiry' => 'https://pep.shaparak.ir/dorsa1/api/payment/payment-inquiry', + 'apiBaseUrl' => 'https://pep.shaparak.ir/dorsa1/', 'merchantId' => '', 'terminalCode' => '', - 'certificate' => '', // can be string (and set certificateType to xml_string) or an xml file path (and set cetificateType to xml_file) - 'certificateType' => 'xml_file', // can be: xml_file, xml_string - 'callbackUrl' => 'http://yoursite.com/path/to', + 'username' => '', + 'password' => '', + 'callbackUrl' => '', + 'currency' => 'T' ////Can be R, T (Rial, Toman) ], 'payir' => [ - 'apiPurchaseUrl' => 'https://pay.ir/pg/send/', + 'apiPurchaseUrl' => 'https://pay.ir/pg/send', 'apiPaymentUrl' => 'https://pay.ir/pg/', - 'apiVerificationUrl' => 'https://pay.ir/pg/verify/', + 'apiVerificationUrl' => 'https://pay.ir/pg/verify', 'merchantId' => 'test', // set it to `test` for test environments 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using payir', + 'currency' => 'T', //Can be R, T (Rial, Toman) ], 'paypal' => [ /* normal api */ @@ -113,26 +200,29 @@ 'sandboxApiVerificationUrl' => 'https://sandbox.zarinpal.com/pg/services/WebGate/wsdl', 'mode' => 'normal', // can be normal, sandbox - 'currency' => '', 'id' => '', // Specify the email of the PayPal Business account 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using paypal', + 'currency' => 'T', //Can be R, T (Rial, Toman) ], 'payping' => [ - 'apiPurchaseUrl' => 'https://api.payping.ir/v1/pay/', - 'apiPaymentUrl' => 'https://api.payping.ir/v1/pay/gotoipg/', - 'apiVerificationUrl' => 'https://api.payping.ir/v1/pay/verify/', + 'apiPurchaseUrl' => 'https://api.payping.ir/v2/pay/', + 'apiPaymentUrl' => 'https://api.payping.ir/v2/pay/gotoipg/', + 'apiVerificationUrl' => 'https://api.payping.ir/v2/pay/verify/', 'merchantId' => '', 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using payping', + 'currency' => 'T', //Can be R, T (Rial, Toman) ], 'paystar' => [ - 'apiPurchaseUrl' => 'https://paystar.ir/api/create/', - 'apiPaymentUrl' => 'https://paystar.ir/paying/', - 'apiVerificationUrl' => 'https://paystar.ir/api/verify/', - 'merchantId' => '', + 'apiPurchaseUrl' => 'https://core.paystar.ir/api/pardakht/create/', + 'apiPaymentUrl' => 'https://core.paystar.ir/api/pardakht/payment/', + 'apiVerificationUrl' => 'https://core.paystar.ir/api/pardakht/verify/', + 'gatewayId' => '', // your gateway id + 'signKey' => '', // sign key of your gateway 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using paystar', + 'currency' => 'R', //Can be R, T (Rial, Toman) ], 'poolam' => [ 'apiPurchaseUrl' => 'https://poolam.ir/invoice/request/', @@ -141,15 +231,28 @@ 'merchantId' => '', 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using poolam', + 'currency' => 'T', //Can be R, T (Rial, Toman) ], 'sadad' => [ - 'apiPurchaseUrl' => 'https://sadad.shaparak.ir/vpg/api/v0/Request/PaymentRequest', - 'apiPaymentUrl' => 'https://sadad.shaparak.ir/VPG/Purchase', + 'apiPaymentByMultiIdentityUrl' => 'https://sadad.shaparak.ir/VPG/api/v0/PaymentByMultiIdentityRequest', + 'apiPaymentByIdentityUrl' => 'https://sadad.shaparak.ir/api/v0/PaymentByIdentity/PaymentRequest', + 'apiPaymentUrl' => 'https://sadad.shaparak.ir/api/v0/Request/PaymentRequest', + 'apiPurchaseUrl' => 'https://sadad.shaparak.ir/Purchase', 'apiVerificationUrl' => 'https://sadad.shaparak.ir/VPG/api/v0/Advice/Verify', 'key' => '', 'merchantId' => '', 'terminalId' => '', - 'callbackUrl' => 'http://yoursite.com/path/to', + 'callbackUrl' => '', + 'currency' => 'T', //Can be R, T (Rial, Toman) + 'mode' => 'normal', // can be normal, PaymentByIdentity, PaymentByMultiIdentity, + 'PaymentIdentity' => '', + 'MultiIdentityRows' => [ + [ + "IbanNumber" => '', // Sheba number (with IR) + "Amount" => 0, + "PaymentIdentity" => '', + ], + ], 'description' => 'payment using sadad', ], 'saman' => [ @@ -159,6 +262,34 @@ 'merchantId' => '', 'callbackUrl' => '', 'description' => 'payment using saman', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'sep' => [ + 'apiGetToken' => 'https://sep.shaparak.ir/onlinepg/onlinepg', + 'apiPaymentUrl' => 'https://sep.shaparak.ir/OnlinePG/OnlinePG', + 'apiVerificationUrl' => 'https://sep.shaparak.ir/verifyTxnRandomSessionkey/ipg/VerifyTransaction', + 'terminalId' => '', + 'callbackUrl' => '', + 'description' => 'Saman Electronic Payment for Saderat & Keshavarzi', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'sepehr' => [ + 'apiGetToken' => 'https://sepehr.shaparak.ir:8081/V1/PeymentApi/GetToken', + 'apiPaymentUrl' => 'https://sepehr.shaparak.ir:8080/Pay', + 'apiVerificationUrl' => 'https://sepehr.shaparak.ir:8081/V1/PeymentApi/Advice', + 'terminalId' => '', + 'callbackUrl' => '', + 'description' => 'payment using sepehr(saderat)', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'walleta' => [ + 'apiPurchaseUrl' => 'https://cpg.walleta.ir/payment/request.json', + 'apiPaymentUrl' => 'https://cpg.walleta.ir/ticket/', + 'apiVerificationUrl' => 'https://cpg.walleta.ir/payment/verify.json', + 'merchantId' => '', + 'callbackUrl' => 'http://yoursite.com/path/to', + 'description' => 'payment using walleta', + 'currency' => 'T', //Can be R, T (Rial, Toman) ], 'yekpay' => [ 'apiPurchaseUrl' => 'https://gate.yekpay.com/api/payment/server?wsdl', @@ -172,9 +303,9 @@ ], 'zarinpal' => [ /* normal api */ - 'apiPurchaseUrl' => 'https://ir.zarinpal.com/pg/services/WebGate/wsdl', + 'apiPurchaseUrl' => 'https://api.zarinpal.com/pg/v4/payment/request.json', 'apiPaymentUrl' => 'https://www.zarinpal.com/pg/StartPay/', - 'apiVerificationUrl' => 'https://ir.zarinpal.com/pg/services/WebGate/wsdl', + 'apiVerificationUrl' => 'https://api.zarinpal.com/pg/v4/payment/verify.json', /* sandbox api */ 'sandboxApiPurchaseUrl' => 'https://sandbox.zarinpal.com/pg/services/WebGate/wsdl', @@ -190,6 +321,7 @@ 'merchantId' => '', 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using zarinpal', + 'currency' => 'T', //Can be R, T (Rial, Toman) ], 'zibal' => [ /* normal api */ @@ -202,6 +334,115 @@ 'merchantId' => '', 'callbackUrl' => 'http://yoursite.com/path/to', 'description' => 'payment using zibal', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'sepordeh' => [ + 'apiPurchaseUrl' => 'https://sepordeh.com/merchant/invoices/add', + 'apiPaymentUrl' => 'https://sepordeh.com/merchant/invoices/pay/id:', + 'apiDirectPaymentUrl' => 'https://sepordeh.com/merchant/invoices/pay/automatic:true/id:', + 'apiVerificationUrl' => 'https://sepordeh.com/merchant/invoices/verify', + 'mode' => 'normal', // can be normal, direct + 'merchantId' => '', + 'callbackUrl' => 'http://yoursite.com/path/to', + 'description' => 'payment using sepordeh', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'rayanpay' => [ + 'apiPurchaseUrl' => 'https://bpm.shaparak.ir/pgwchannel/startpay.mellat', + 'apiTokenUrl' => 'https://pms.rayanpay.com/api/v1/auth/token/generate', + 'apiPayStart' => 'https://pms.rayanpay.com/api/v1/ipg/payment/start', + 'apiPayVerify' => 'https://pms.rayanpay.com/api/v1/ipg/payment/response/parse', + 'username' => '', + 'client_id' => '', + 'password' => '', + 'callbackUrl' => '', + 'currency' => 'R', //Can be R, T (Rial, Toman) + ], + 'sizpay' => [ + 'apiPurchaseUrl' => 'https://rt.sizpay.ir/KimiaIPGRouteService.asmx?WSDL', + 'apiPaymentUrl' => 'https://rt.sizpay.ir/Route/Payment', + 'apiVerificationUrl' => 'https://rt.sizpay.ir/KimiaIPGRouteService.asmx?WSDL', + 'merchantId' => '', + 'terminal' => '', + 'username' => '', + 'password' => '', + 'SignData' => '', + 'callbackUrl' => '', + 'currency' => 'R', //Can be R, T (Rial, Toman) + ], + 'vandar' => [ + 'apiPurchaseUrl' => 'https://ipg.vandar.io/api/v3/send', + 'apiPaymentUrl' => 'https://ipg.vandar.io/v3/', + 'apiVerificationUrl' => 'https://ipg.vandar.io/api/v3/verify', + 'callbackUrl' => '', + 'merchantId' => '', + 'description' => 'payment using Vandar', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'aqayepardakht' => [ + 'apiPurchaseUrl' => 'https://panel.aqayepardakht.ir/api/v2/create', + 'apiPaymentUrl' => 'https://panel.aqayepardakht.ir/startpay/', + 'apiPaymentUrlSandbox' => 'https://panel.aqayepardakht.ir/startpay/sandbox/', + 'apiVerificationUrl' => 'https://panel.aqayepardakht.ir/api/v2/verify', + 'mode' => 'normal', //normal | sandbox + 'callbackUrl' => '', + 'pin' => '', + 'invoice_id' => '', + 'mobile' => '', + 'email' => '', + 'description' => 'payment using Aqayepardakht', + 'currency' => 'T', //Can be R, T (Rial, 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) + 'description' => 'payment using azki', + ], + 'payfa' => [ + 'apiPurchaseUrl' => 'https://payment.payfa.com/v2/api/Transaction/Request', + 'apiPaymentUrl' => 'https://payment.payfa.ir/v2/api/Transaction/Pay/', + 'apiVerificationUrl' => 'https://payment.payfa.com/v2/api/Transaction/Verify/', + 'callbackUrl' => '', + 'apiKey' => '', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'toman' => [ + 'base_url' => 'https://escrow-api.toman.ir/api/v1', + 'shop_slug' => '', + 'auth_code' => '', + 'data' => '' + ], + 'bitpay' => [ + 'apiPurchaseUrl' => 'https://bitpay.ir/payment/gateway-send', + 'apiPaymentUrl' => 'https://bitpay.ir/payment/gateway-{id_get}-get', + 'apiVerificationUrl' => 'https://bitpay.ir/payment/gateway-result-second', + 'callbackUrl' => '', + 'api_token' => '', + 'description' => 'payment using Bitpay', + 'currency' => 'R', //Can be R, T (Rial, Toman) + ], + 'minipay' => [ + 'apiPurchaseUrl' => 'https://v1.minipay.me/api/pg/request/', + 'apiPaymentUrl' => 'https://ipg.minipay.me/', + 'apiVerificationUrl' => 'https://v1.minipay.me/api/pg/verify/', + 'merchantId' => '', + 'callbackUrl' => 'http://yoursite.com/path/to', + 'description' => 'payment using Minipay.', + 'currency' => 'T', //Can be R, T (Rial, Toman) + ], + 'snapppay' => [ + 'apiPaymentUrl' => 'https://fms-gateway-staging.apps.public.teh-1.snappcloud.io', + 'callbackUrl' => 'http://yoursite.com/path/to', + 'username' => 'username', + 'password' => 'password', + 'client_id' => '', + 'client_secret' => '', + 'description' => 'payment using Snapp Pay.', + 'currency' => 'T', //Can be R, T (Rial, Toman) ], ], @@ -218,11 +459,19 @@ | */ 'map' => [ + 'local' => \Shetabit\Multipay\Drivers\Local\Local::class, + 'gooyapay' => \Shetabit\Multipay\Drivers\Gooyapay\Gooyapay::class, + 'fanavacard' => \Shetabit\Multipay\Drivers\Fanavacard\Fanavacard::class, 'asanpardakht' => \Shetabit\Multipay\Drivers\Asanpardakht\Asanpardakht::class, + 'atipay' => \Shetabit\Multipay\Drivers\Atipay\Atipay::class, 'behpardakht' => \Shetabit\Multipay\Drivers\Behpardakht\Behpardakht::class, + 'digipay' => \Shetabit\Multipay\Drivers\Digipay\Digipay::class, + 'etebarino' => \Shetabit\Multipay\Drivers\Etebarino\Etebarino::class, 'idpay' => \Shetabit\Multipay\Drivers\Idpay\Idpay::class, 'irankish' => \Shetabit\Multipay\Drivers\Irankish\Irankish::class, + 'jibit' => \Shetabit\Multipay\Drivers\Jibit\Jibit::class, 'nextpay' => \Shetabit\Multipay\Drivers\Nextpay\Nextpay::class, + 'omidpay' => \Shetabit\Multipay\Drivers\Omidpay\Omidpay::class, 'parsian' => \Shetabit\Multipay\Drivers\Parsian\Parsian::class, 'pasargad' => \Shetabit\Multipay\Drivers\Pasargad\Pasargad::class, 'payir' => \Shetabit\Multipay\Drivers\Payir\Payir::class, @@ -232,8 +481,22 @@ 'poolam' => \Shetabit\Multipay\Drivers\Poolam\Poolam::class, 'sadad' => \Shetabit\Multipay\Drivers\Sadad\Sadad::class, 'saman' => \Shetabit\Multipay\Drivers\Saman\Saman::class, + 'sep' => \Shetabit\Multipay\Drivers\SEP\SEP::class, + 'sepehr' => \Shetabit\Multipay\Drivers\Sepehr\Sepehr::class, + 'walleta' => \Shetabit\Multipay\Drivers\Walleta\Walleta::class, 'yekpay' => \Shetabit\Multipay\Drivers\Yekpay\Yekpay::class, 'zarinpal' => \Shetabit\Multipay\Drivers\Zarinpal\Zarinpal::class, 'zibal' => \Shetabit\Multipay\Drivers\Zibal\Zibal::class, + 'sepordeh' => \Shetabit\Multipay\Drivers\Sepordeh\Sepordeh::class, + 'rayanpay' => \Shetabit\Multipay\Drivers\Rayanpay\Rayanpay::class, + 'sizpay' => \Shetabit\Multipay\Drivers\Sizpay\Sizpay::class, + 'vandar' => \Shetabit\Multipay\Drivers\Vandar\Vandar::class, + 'aqayepardakht' => \Shetabit\Multipay\Drivers\Aqayepardakht\Aqayepardakht::class, + 'azki' => \Shetabit\Multipay\Drivers\Azki\Azki::class, + 'payfa' => \Shetabit\Multipay\Drivers\Payfa\Payfa::class, + 'toman' => \Shetabit\Multipay\Drivers\Toman\Toman::class, + 'bitpay' => \Shetabit\Multipay\Drivers\Bitpay\Bitpay::class, + 'minipay' => \Shetabit\Multipay\Drivers\Minipay\Minipay::class, + 'snapppay'=> \Shetabit\Multipay\Drivers\SnappPay\SnappPay::class, ] ]; diff --git a/src/Drivers/Pasargad/Pasargad.php b/src/Drivers/Pasargad/Pasargad.php index 3c19fa6f..d7744f5f 100644 --- a/src/Drivers/Pasargad/Pasargad.php +++ b/src/Drivers/Pasargad/Pasargad.php @@ -3,14 +3,16 @@ namespace Shetabit\Multipay\Drivers\Pasargad; use GuzzleHttp\Client; +use GuzzleHttp\Exception\GuzzleException; +use Shetabit\Multipay\Drivers\Pasargad\PasargadHolder\PasargadHolder; use Shetabit\Multipay\Invoice; use Shetabit\Multipay\Receipt; use Shetabit\Multipay\Abstracts\Driver; use Shetabit\Multipay\Contracts\ReceiptInterface; use Shetabit\Multipay\Exceptions\InvalidPaymentException; -use Shetabit\Multipay\Drivers\Pasargad\Utils\RSAProcessor; use Shetabit\Multipay\RedirectionForm; -use Shetabit\Multipay\Request; +use DateTimeZone; +use DateTime; class Pasargad extends Driver { @@ -42,6 +44,12 @@ class Pasargad extends Driver */ protected $preparedData = array(); + /** + * Pasardad Holder + * @var string + */ + protected $holder; + /** * Pasargad(PEP) constructor. * Construct the class with the relevant settings. @@ -52,22 +60,38 @@ class Pasargad extends Driver public function __construct(Invoice $invoice, $settings) { $this->invoice($invoice); - $this->settings = (object) $settings; + $this->settings = (object)$settings; $this->client = new Client(); + $this->holder = new PasargadHolder(); } /** * Purchase Invoice. * * @return string + * @throws InvalidPaymentException + * @throws GuzzleException + * @throws \Exception */ - public function purchase() + public function purchase(): string { $invoiceData = $this->getPreparedInvoiceData(); - $this->invoice->transactionId($invoiceData['InvoiceNumber']); + $this->invoice->transactionId($invoiceData['invoice']); + + $response = $this->request( + $this->settings->apiPaymentUrl, + $invoiceData, + 'POST', + $this->createToken() + ); + + if ($response['data']['urlId']) { + $this->holder->urlId($response['data']['urlId']); + } else { + throw new InvalidPaymentException("urlId is not set."); + } - // return the transaction's id return $this->invoice->getTransactionId(); } @@ -76,14 +100,12 @@ public function purchase() * * @return RedirectionForm */ - public function pay() : RedirectionForm + public function pay(): RedirectionForm { - $paymentUrl = $this->settings->apiPaymentUrl; - $getTokenUrl = $this->settings->apiGetToken; - $tokenData = $this->request($getTokenUrl, $this->getPreparedInvoiceData()); + $paymentUrl = $this->settings->apiBaseUrl . $this->holder->getUrlId(); // redirect using HTML form - return $this->redirectWithForm($paymentUrl, $tokenData, 'POST'); + return $this->redirectWithForm($paymentUrl, ['Token' => $this->holder->getUrlId()]); } /** @@ -92,87 +114,79 @@ public function pay() : RedirectionForm * @return ReceiptInterface * * @throws InvalidPaymentException - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \Exception + * @throws GuzzleException */ - public function verify() : ReceiptInterface + public function verify(): ReceiptInterface { - $invoiceDetails = $this->request( - $this->settings->apiCheckTransactionUrl, - [ - 'TransactionReferenceID' => Request::input('tref') - ] - ); - $fields = [ - 'MerchantCode' => $invoiceDetails['MerchantCode'], - 'TerminalCode' => $invoiceDetails['TerminalCode'], - 'InvoiceNumber' => $invoiceDetails['InvoiceNumber'], - 'InvoiceDate' => $invoiceDetails['InvoiceDate'], - 'Amount' => $invoiceDetails['Amount'], - 'Timestamp' => date("Y/m/d H:i:s"), - ]; + $transactionId = $this->invoice->getTransactionId(); - $verifyResult = $this->request($this->settings->apiVerificationUrl, $fields); + $payment_inquiry = $this->request( + $this->settings->paymentInquiry, + ['invoiceId' => $transactionId], + 'POST', + $this->createToken() + ); - return $this->createReceipt($verifyResult, $invoiceDetails); - } + if ($payment_inquiry['resultCode'] != 0) { + throw new InvalidPaymentException("This transaction is fail."); + } - /** - * Generate the payment's receipt - * - * @param $referenceId - * - * @return Receipt - */ - protected function createReceipt($verifyResult, $invoiceDetails) - { - $referenceId = $invoiceDetails['TransactionReferenceID']; - $traceNumber = $invoiceDetails['TraceNumber']; - $referenceNumber = $invoiceDetails['ReferenceNumber']; + if($payment_inquiry['data']['transactionId'] !== $transactionId) { + throw new InvalidPaymentException("This transaction is fail."); + } - $reciept = new Receipt('Pasargad', $referenceId); + $verifyResult = $this->request( + $this->settings->verifyPayment, + [ + 'invoice' => $transactionId, + 'urlId' => $payment_inquiry['data']['url'] + ], + 'POST', + $this->createToken() + ); - $reciept->detail('TraceNumber', $traceNumber); - $reciept->detail('ReferenceNumber', $referenceNumber); - $reciept->detail('MaskedCardNumber', $verifyResult['MaskedCardNumber']); - $reciept->detail('ShaparakRefNumber', $verifyResult['ShaparakRefNumber']); + if (!$verifyResult['data']['referenceNumber']) { + throw new InvalidPaymentException("This transaction is fail."); + } - return $reciept; + $receipt = $this->createReceipt($$verifyResult['data']['referenceNumber']); + + $receipt->detail([ + 'resultCode' => $verifyResult['resultCode'], + 'resultMsg' => $verifyResult['resultMsg'] ?? null, + 'hashedCardNumber' => $verifyResult['data']['hashedCardNumber'] ?? null, + 'maskedCardNumber' => $verifyResult['data']['maskedCardNumber'] ?? null, + 'invoiceId' => $transactionId, + 'referenceNumber' => $verifyResult['data']['referenceNumber'] ?? null, + 'trackId' => $verifyResult['data']['trackId'] ?? null, + 'amount' => $verifyResult['data']['amount'] ?? null, + 'requestDate' => $verifyResult['data']['requestDate'] ?? null, + ]); + + return $receipt; } - /** - * A default message for exceptions - * - * @return string - */ - protected function getDefaultExceptionMessage() - { - return 'مشکلی در دریافت اطلاعات از بانک به وجود آمده است'; - } /** - * Sign given data. - * - * @param string $data + * Generate the payment's receipt * - * @return string + * @param $referenceId + * @return Receipt */ - public function sign($data) + protected function createReceipt($referenceId): Receipt { - $certificate = $this->settings->certificate; - $certificateType = $this->settings->certificateType; - - $processor = new RSAProcessor($certificate, $certificateType); - - return $processor->sign($data); + return new Receipt('pasargad', $referenceId); } /** * Retrieve prepared invoice's data * * @return array + * @throws \Exception */ - protected function getPreparedInvoiceData() + protected function getPreparedInvoiceData(): array { if (empty($this->preparedData)) { $this->preparedData = $this->prepareInvoiceData(); @@ -185,57 +199,51 @@ protected function getPreparedInvoiceData() * Prepare invoice data * * @return array + * @throws \Exception */ protected function prepareInvoiceData(): array { - $action = 1003; // 1003 : for buy request (bank standard) - $merchantCode = $this->settings->merchantId; + $action = 8; // 8 : for buy request (bank standard) $terminalCode = $this->settings->terminalCode; - $amount = $this->invoice->getAmount(); //rial + $amount = $this->invoice->getAmount() * ($this->settings->currency == 'T' ? 10 : 1); $redirectAddress = $this->settings->callbackUrl; $invoiceNumber = crc32($this->invoice->getUuid()) . rand(0, time()); - $timeStamp = date("Y/m/d H:i:s"); - $invoiceDate = date("Y/m/d H:i:s"); + + $iranTime = new DateTime('now', new DateTimeZone('Asia/Tehran')); + $invoiceDate = $iranTime->format("Y/m/d H:i:s"); if (!empty($this->invoice->getDetails()['date'])) { $invoiceDate = $this->invoice->getDetails()['date']; } return [ - 'InvoiceNumber' => $invoiceNumber, - 'InvoiceDate' => $invoiceDate, - 'Amount' => $amount, - 'TerminalCode' => $terminalCode, - 'MerchantCode' => $merchantCode, - 'RedirectAddress' => $redirectAddress, - 'Timestamp' => $timeStamp, - 'Action' => $action, + 'invoice' => $invoiceNumber, + 'invoiceDate' => $invoiceDate, + 'amount' => $amount, + 'terminalNumber' => $terminalCode, + 'callbackApi' => $redirectAddress, + 'serviceCode' => $action, + 'nationalCode' => "", + 'serviceType' => "PURCHASE", + 'mobileNumber' => "" ]; } - /** - * Prepare signature based on Pasargad document - * - * @param string $data - * @return string - */ - public function prepareSignature(string $data): string - { - return base64_encode($this->sign(sha1($data, true))); - } - /** * Make request to pasargad's Api * * @param string $url * @param array $body * @param string $method + * @param string|null $token * @return array + * @throws GuzzleException + * @throws InvalidPaymentException */ - protected function request(string $url, array $body, $method = 'POST'): array + protected function request(string $url, array $body, string $method = 'POST', string $token = null): array { $body = json_encode($body); - $sign = $this->prepareSignature($body); + $token = $token !== null ? 'Bearer '.$token : null; $response = $this->client->request( 'POST', @@ -244,7 +252,7 @@ protected function request(string $url, array $body, $method = 'POST'): array 'body' => $body, 'headers' => [ 'content-type' => 'application/json', - 'Sign' => $sign + 'Authorization' => $token ], "http_errors" => false, ] @@ -252,10 +260,31 @@ protected function request(string $url, array $body, $method = 'POST'): array $result = json_decode($response->getBody(), true); - if ($result['IsSuccess'] === false) { - throw new InvalidPaymentException($result['Message']); + if ($result['resultMsg'] !== 'Successful') { + throw new InvalidPaymentException($result['resultMsg']); } return $result; } + + /** + * * make token with username and password + * @return string + * @throws InvalidPaymentException + */ + protected function createToken(): string + { + $data = [ + "username" => $this->settings->username, + "password" => $this->settings->password + ]; + + $getTokenUrl = $this->settings->apiGetToken; + + try { + return $this->request($getTokenUrl, $data)['token']; + } catch (GuzzleException|InvalidPaymentException $e) { + throw new InvalidPaymentException($e->getMessage()); + } + } } diff --git a/src/Drivers/Pasargad/PasargadHolder/PasargadHolder.php b/src/Drivers/Pasargad/PasargadHolder/PasargadHolder.php new file mode 100644 index 00000000..36d7d529 --- /dev/null +++ b/src/Drivers/Pasargad/PasargadHolder/PasargadHolder.php @@ -0,0 +1,22 @@ +urlId = $id; + return $this; + } + + + public function getUrlId(): string + { + return $this->urlId; + } +} diff --git a/src/Drivers/Pasargad/Utils/RSA.php b/src/Drivers/Pasargad/Utils/RSA.php deleted file mode 100644 index b52672cb..00000000 --- a/src/Drivers/Pasargad/Utils/RSA.php +++ /dev/null @@ -1,143 +0,0 @@ -= 0; $i--) { - $digit = ord($data{$i}); - $part_res = bcmul($digit, $radix); - $result = bcadd($result, $part_res); - $radix = bcmul($radix, $base); - } - return $result; - } - - public static function numberToBinary($number, $blocksize) - { - $base = "256"; - $result = ""; - $div = $number; - while ($div > 0) { - $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/Drivers/Pasargad/Utils/RSAProcessor.php b/src/Drivers/Pasargad/Utils/RSAProcessor.php deleted file mode 100644 index 2824d0ef..00000000 --- a/src/Drivers/Pasargad/Utils/RSAProcessor.php +++ /dev/null @@ -1,121 +0,0 @@ -modulus = RSA::binaryToNumber(base64_decode($xmlObject->Modulus)); - $this->publicKey = RSA::binaryToNumber(base64_decode($xmlObject->Exponent)); - $this->privateKey = RSA::binaryToNumber(base64_decode($xmlObject->D)); - $this->keyLength = strlen(base64_decode($xmlObject->Modulus)) * 8; - } - - /** - * Retrieve public key - * - * @return string|null - */ - public function getPublicKey() - { - return $this->publicKey; - } - - /** - * Retrieve private key - * - * @return string|null - */ - public function getPrivateKey() - { - return $this->privateKey; - } - - /** - * Retrieve key length - * - * @return integer - */ - public function getKeyLength() - { - return $this->keyLength; - } - - /** - * Retrieve modulus - * - * @return string|null - */ - public function getModulus() - { - return $this->modulus; - } - - /** - * Encrypt given data - * - * @param string $data - * - * @return string - */ - public function encrypt($data) - { - return base64_encode(RSA::rsaEncrypt($data, $this->publicKey, $this->modulus, $this->keyLength)); - } - - /** - * Decrypt given data - * - * @param $data - * - * @return string - */ - public function decrypt($data) - { - return RSA::rsaDecrypt($data, $this->privateKey, $this->modulus, $this->keyLength); - } - - /** - * Sign given data - * - * @param string $data - * - * @return string - */ - public function sign($data) - { - return RSA::rsaSign($data, $this->privateKey, $this->modulus, $this->keyLength); - } - - /** - * Verify RSA data - * - * @param string $data - * - * @return boolean - */ - public function verify($data) - { - return RSA::rsaVerify($data, $this->publicKey, $this->modulus, $this->keyLength); - } -}