From 6bfd731aada856ef20cf4a3fd40633f35da25132 Mon Sep 17 00:00:00 2001 From: Hamed Date: Fri, 1 Nov 2019 20:26:05 +0330 Subject: [PATCH 01/27] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d019108..0f5d2da0 100644 --- a/README.md +++ b/README.md @@ -72,10 +72,10 @@ php artisan vendor:publish + + // then chose : GatewayServiceProviderLaravel6 - -
-سپس این گزینه را انتخاب کنید : "Larabookir\Gateway\GatewayServiceProviderLaravel6" +
From b24608af26d681b38191d973659906991175c566 Mon Sep 17 00:00:00 2001 From: Hamed Date: Fri, 1 Nov 2019 20:26:33 +0330 Subject: [PATCH 02/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f5d2da0..39421ea0 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ php artisan vendor:publish - // then chose : GatewayServiceProviderLaravel6 + // then choose : GatewayServiceProviderLaravel6
From 0deeb54cbbcc4bf83e13e896abae3a5e90d7a3de Mon Sep 17 00:00:00 2001 From: Hamed Date: Fri, 1 Nov 2019 20:27:42 +0330 Subject: [PATCH 03/27] Update README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 39421ea0..dccb00fc 100644 --- a/README.md +++ b/README.md @@ -63,18 +63,22 @@ برای لاراول ۵ :
+```php - php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProviderLaravel5 +php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProviderLaravel5 +```
برای لاراول ۶ به بعد :
+```php + php artisan vendor:publish // then choose : GatewayServiceProviderLaravel6 - +```
From 50c489d090bafffbbe17bbd08c0c9e795e37860c Mon Sep 17 00:00:00 2001 From: Hamed Date: Fri, 1 Nov 2019 20:28:54 +0330 Subject: [PATCH 04/27] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dccb00fc..97042fbc 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ برای لاراول ۵ :
+ ```php php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProviderLaravel5 @@ -75,10 +76,11 @@ php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProviderL ```php - php artisan vendor:publish - - // then choose : GatewayServiceProviderLaravel6 +php artisan vendor:publish +// then choose : GatewayServiceProviderLaravel6 + ``` +
From 8037b25fe67c5b06456394b02e8c343ded5e113a Mon Sep 17 00:00:00 2001 From: Hamed Date: Fri, 1 Nov 2019 20:29:48 +0330 Subject: [PATCH 05/27] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 97042fbc..3bf3688c 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProviderL ```php php artisan vendor:publish + // then choose : GatewayServiceProviderLaravel6 ``` @@ -87,7 +88,11 @@ php artisan vendor:publish **مرحله ۴) - ایجاد جداول** - php artisan migrate +```php + +php artisan migrate + +``` From fe057e4e98da986aad35c196c947168b868a2a07 Mon Sep 17 00:00:00 2001 From: Hamed Date: Fri, 1 Nov 2019 20:30:40 +0330 Subject: [PATCH 06/27] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3bf3688c..90f02da2 100644 --- a/README.md +++ b/README.md @@ -84,10 +84,10 @@ php artisan vendor:publish
- - **مرحله ۴) - ایجاد جداول** +
+ ```php php artisan migrate @@ -95,7 +95,8 @@ php artisan migrate ``` - +
+ **مرحله ۵)** عملیات نصب پایان یافته است حال فایل gateway.php را در مسیر app/ را باز نموده و تنظیمات مربوط به درگاه بانکی مورد نظر خود را در آن وارد نمایید . From 909e2fede0d207848ccfed5e12227b75dc06f0a5 Mon Sep 17 00:00:00 2001 From: Hamed Date: Fri, 1 Nov 2019 20:31:50 +0330 Subject: [PATCH 07/27] Update README.md --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 90f02da2..4f9696df 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,17 @@ **مرحله ۱)** - composer require larabook/gateway - +
+ + +```php +composer require larabook/gateway + +``` + +
+ **مرحله ۲)** تغییرات زیر را در فایل config/app.php اعمال نمایید: From b8c5946628f05b1334423395e84da98d7edb3d98 Mon Sep 17 00:00:00 2001 From: Hamed Date: Fri, 1 Nov 2019 20:33:32 +0330 Subject: [PATCH 08/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f9696df..aba279a4 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ php artisan migrate **مرحله ۵)** -عملیات نصب پایان یافته است حال فایل gateway.php را در مسیر app/ را باز نموده و تنظیمات مربوط به درگاه بانکی مورد نظر خود را در آن وارد نمایید . +عملیات نصب پایان یافته است حال فایل gateway.php را در مسیر app/ باز نموده و تنظیمات مربوط به درگاه بانکی مورد نظر خود را در آن وارد نمایید . حال میتوایند برای اتصال به api بانک از یکی از روش های زیر به انتخاب خودتان استفاده نمایید . (Facade , Service container):
From 248d6bf3524c31f4a53f3da056c4a45f7d6d6378 Mon Sep 17 00:00:00 2001 From: hosein abedi Date: Tue, 5 Nov 2019 10:26:06 +0330 Subject: [PATCH 09/27] Fix stupid realese bug --- src/Saman/Saman.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Saman/Saman.php b/src/Saman/Saman.php index 5fa9ccdf..af4e8d97 100644 --- a/src/Saman/Saman.php +++ b/src/Saman/Saman.php @@ -24,11 +24,9 @@ class Saman extends PortAbstract implements PortInterface * @var string */ -// protected $serverVerifyUrl = "https://sep.shaparak.ir/payments/referencepayment.asmx?WSDL"; - protected $serverVerifyUrl = "http://banktest.ir/gateway/saman/payments/referencepayment?wsdl"; + protected $serverVerifyUrl = "https://sep.shaparak.ir/payments/referencepayment.asmx?WSDL"; -// protected $gateUrl = "https://sep.shaparak.ir/Payment.aspx"; - protected $gateUrl = "http://banktest.ir/gateway/saman/gate"; + protected $gateUrl = "https://sep.shaparak.ir/Payment.aspx"; /** * {@inheritdoc} From ee552d2c3be3c15be0d10f720e46df87ae4ec863 Mon Sep 17 00:00:00 2001 From: Hamed Date: Thu, 7 Nov 2019 18:46:02 +0330 Subject: [PATCH 10/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aba279a4..f8caa5b6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ پکیج اتصال به تمامی IPG ها و بانک های ایرانی. این پکیج با ورژن های -( ۴ و ۵ و ۶ لاراول ) +( ۴ و ۵ و ۶ ) لاراول سازگار می باشد From b5865a00a022b23a4e9f6486165ff14ff1d74eff Mon Sep 17 00:00:00 2001 From: Hamed Date: Mon, 2 Mar 2020 17:41:53 +0330 Subject: [PATCH 11/27] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f8caa5b6..8a5040c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@
-سایت مرجع پکیج: [larabook.ir](http://larabook.ir/اتصال-درگاه-بانک-لاراول/) + +``` +متاسفانه این پکیج دیگر پشتیبانی نمی شود +``` پکیج اتصال به تمامی IPG ها و بانک های ایرانی. From 0b0121437e99dd4eac28b60e40d997bc2f7cf3d2 Mon Sep 17 00:00:00 2001 From: masih Date: Mon, 4 May 2020 11:27:09 +0430 Subject: [PATCH 12/27] fix bug in redirect to bank page --- config/gateway.php | 9 + src/Saderat/Saderat.php | 257 +++++++++++++++++++++++++++++ src/Saderat/SaderatException.php | 47 ++++++ views/saderat-redirector.blade.php | 32 ++++ 4 files changed, 345 insertions(+) create mode 100644 src/Saderat/Saderat.php create mode 100644 src/Saderat/SaderatException.php create mode 100644 views/saderat-redirector.blade.php diff --git a/config/gateway.php b/config/gateway.php index fffe3d7e..da0be24e 100644 --- a/config/gateway.php +++ b/config/gateway.php @@ -40,6 +40,15 @@ 'callback-url' => '/', ], + //-------------------------------- + // Saderat gateway + //-------------------------------- + 'saderat' => [ + 'terminalID' => '', + 'password' => '', + 'callback-url' => '/', + ], + //-------------------------------- // PayIr gateway //-------------------------------- diff --git a/src/Saderat/Saderat.php b/src/Saderat/Saderat.php new file mode 100644 index 00000000..41ceb1ba --- /dev/null +++ b/src/Saderat/Saderat.php @@ -0,0 +1,257 @@ +amount = $amount; + return $this; + } + + /** + * {@inheritdoc} + */ + public function ready() + { + $this->newTransaction(); + $this->getRedirectToken(); + return $this; + } + + /** + * + * Add optional data to the request + * + * @param Array $data an array of data + * + */ + function setOptionalData(Array $data) + { + $this->optional_data = $data; + } + + function makeHttpChargeRequest( $_Data, $_Address) + { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $_Address); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $_Data); + $result = curl_exec($curl); + curl_close($curl); + return $result; + + } + function test_input($data) { + $data = trim($data); + $data = stripslashes($data); + $data = htmlspecialchars($data); + return $data; + } + public function getRedirectToken() + { + $dataQuery ='Amount='.$this->test_input($this->amount).'&callbackURL='.$this->test_input($this->getCallback()).'&InvoiceID='.$this->test_input($this->transactionId()).'&TerminalID='.$this->test_input($this->config->get('gateway.saderat.terminalID')); + try { + $response = $this->makeHttpChargeRequest($dataQuery, $this->getTokenUrl); + + } catch (\Exception $e) { + $this->transactionFailed(); + $this->newLog('http', $e->getMessage()); + throw $e; + } + + $response = json_decode($response); + $Status = $response->Status; + $AccessToken = $response->Accesstoken; + + if (!empty($AccessToken) && $Status == 0) { + $this->refId = $AccessToken; + $this->transactionSetRefId(); + return; + } + $this->transactionFailed(); + $this->newLog($Status, $AccessToken); + throw new SaderatException($Status); + } + + + /** + * {@inheritdoc} + */ + public function redirect() + { + $main_data = [ + 'token' => $this->refId, + 'terminalID' => $this->config->get('gateway.saderat.terminalID'), + ]; + + $data = array_merge($main_data, $this->optional_data); + + return \View::make('gateway::saderat-redirector')->with($data)->with('gateUrl', $this->redirectUrl); + } + + /** + * {@inheritdoc} + */ + public function verify($transaction) + { + parent::verify($transaction); + + $this->userPayment(); + $this->verifyPayment(); + + return $this; + } + + /** + * Sets callback url + * @param $url + */ + function setCallback($url) + { + $this->callbackUrl = $url; + return $this; + } + + /** + * Gets callback url + * @return string + */ + function getCallback() + { + if (!$this->callbackUrl) + $this->callbackUrl = $this->config->get('gateway.saderat.callback-url'); + + return $this->callbackUrl = $this->config->get('gateway.saderat.callback-url'); + + $url = $this->makeCallback($this->callbackUrl, ['transaction_id' => $this->transactionId()]); + + return $url; + } + + + /** + * Check user payment + * + * @return bool + * + * @throws SaderatException + */ + protected function userPayment() + { + $this->trackingCode = Request::input('TRACENO'); + // $this->cardNumber = Request::input('SecurePan'); , will cause mysql error : Data too long for column 'card_number' ! + $payRequestRes = Request::input('State'); + $payRequestResCode = Request::input('Status'); + + $this->refId = Request::input('RefNum'); + $this->getTable()->whereId($this->transactionId)->update([ + 'ref_id' => $this->refId, + 'tracking_code' => $this->trackingCode, + // 'card_number' => $this->cardNumber, will cause mysql error : Data too long for column 'card_number' ! + 'updated_at' => Carbon::now(), + ]); + + if ($payRequestRes == 'OK') { + return true; + } + + $this->transactionFailed(); + $this->newLog($payRequestResCode, @SaderatException::$errors[$payRequestRes]); + throw new SaderatException($payRequestRes); + } + + + /** + * Verify user payment from bank server + * + * @return bool + * + * @throws SaderatException + * @throws SoapFault + */ + protected function verifyPayment() + { + $fields = array( + "merchantID" => $this->config->get('gateway.saderat.merchant'), + "RefNum" => $this->refId, + "password" => $this->config->get('gateway.saderat.password'), + ); + + try { + $soap = new SoapClient($this->serverVerifyUrl); + $response = $soap->VerifyTransaction($fields["RefNum"], $fields["merchantID"]); + + } catch (\SoapFault $e) { + $this->transactionFailed(); + $this->newLog('SoapFault', $e->getMessage()); + throw $e; + } + + $response = intval($response); + + if ($response == $this->amount) { + $this->transactionSucceed(); + return true; + } + + //Reverse Transaction + if ($response > 0) { + try { + $soap = new SoapClient($this->serverVerifyUrl); + $response = $soap->ReverseTransaction($fields["RefNum"], $fields["merchantID"], $fields["password"], $response); + + } catch (\SoapFault $e) { + $this->transactionFailed(); + $this->newLog('SoapFault', $e->getMessage()); + throw $e; + } + } + + // + $this->transactionSetRefId(); + $this->transactionFailed(); + $this->newLog($response, SaderatException::$errors[$response]); + throw new SaderatException($response); + + + } + + +} diff --git a/src/Saderat/SaderatException.php b/src/Saderat/SaderatException.php new file mode 100644 index 00000000..66dd9099 --- /dev/null +++ b/src/Saderat/SaderatException.php @@ -0,0 +1,47 @@ + "پرداخت با موفقیت انجام شد", + 'Canceled By User' => 'تراکنش توسط خریدار کنسل شد', + 'Invalid Amount' => 'مبلغ سند برگشتی از مبلغ تراکنش اصلی بیشتر است', + 'Merchant Invalid' => 'پذیرنده فروشگاهی نامعتبر است', + 'Do Not Honour' => 'از انجام تراکنش صرف نظر شد', + 'Honour With Identification' => 'با تشخیص هویت دارنده کارت،تراکنش موفق می باشد', + 'Invalid Transaction' => 'درخواست برگشت تراکنش رسیده است در حالی که تراکنش اصلی پیدا نمی شود', + 'Invalid Card Number' => 'شماره کارت اشتباه است', + 'No Such Issuer' => 'چنین صادر کننده کارتی وجود ندارد', + 'Expired Card Pick Up' => 'از تاریخ انقضای کارت گذشته است و کارت دیگر معتبر نیست', + 'Incorrect PIN' => 'رمز کارت (PIN) اشتباه وارد شده است', + 'No Sufficient Funds' => 'موجودی به اندازه کافی در حساب شما نیست', + 'Issuer Down Slm' => 'سیستم کارت بانک صادر کننده فعال نیست', + 'TME Error' => 'خطا در شبکه بانکی', + 'Exceeds Withdrawal Amount Limit' => 'مبلغ بیش از سقف برداشت است', + 'Transaction Cannot Be Completed' => 'امکان سند خوردن وجود ندارد', + 'Allowable PIN Tries Exceeded Pick Up' => 'رمز کارت (PIN) 3 مرتبه اشتباه وارد شده است در نتیجه کارت شما غیر فعال خواهد شد', + 'Response Received Too Late' => 'تراکنش در شبکه بانکی Timeout خورده است', + 'Suspected Fraud Pick Up' => 'فیلد CV2V و یا فیلد ExpDate اشتباه وارد شده و یا اصلا وارد نشده است', + + + + -1 => "تراکنش پیدا نشد.", + -2 => "تراکنش قبال Reverse شده است.", + -3 => "r Total خطای عمومی – خطای Exception ها", + -4 => "امکان انجام درخواست برای این تراکنش وجود ندارد.", + -5 => "IP Address فروشنده نا معتبر است", + -6 => "عدم فعال بودن سرویس برگشت تراکنش برای پذیرنده" + ); + + public function __construct($errorRef) + { + $this->errorRef = $errorRef; + + parent::__construct(@self::$errors[$this->errorRef].' ('.$this->errorRef.')', intval($this->errorRef)); + } +} diff --git a/views/saderat-redirector.blade.php b/views/saderat-redirector.blade.php new file mode 100644 index 00000000..e59dddda --- /dev/null +++ b/views/saderat-redirector.blade.php @@ -0,0 +1,32 @@ + + + + + + + From 0fb677ed95422226d36916422d9acf658a96b54c Mon Sep 17 00:00:00 2001 From: masih Date: Mon, 4 May 2020 13:58:40 +0430 Subject: [PATCH 13/27] change namespaces --- src/Asanpardakht/Asanpardakht.php | 6 ++-- src/Asanpardakht/AsanpardakhtException.php | 4 +-- src/Enum.php | 2 +- src/Exceptions/BankException.php | 2 +- .../ConfigFileNotFoundException.php | 2 +- src/Exceptions/GatewayException.php | 2 +- src/Exceptions/InvalidRequestException.php | 2 +- .../NotFoundTransactionException.php | 2 +- src/Exceptions/PortNotFoundException.php | 2 +- src/Exceptions/RetryException.php | 2 +- src/Gateway.php | 4 +-- src/GatewayResolver.php | 32 +++++++++---------- src/GatewayServiceProvider.php | 8 ++--- src/GatewayServiceProviderLaravel4.php | 4 +-- src/GatewayServiceProviderLaravel5.php | 8 ++--- src/GatewayServiceProviderLaravel6.php | 8 ++--- src/Irankish/Irankish.php | 8 ++--- src/Irankish/IrankishException.php | 4 +-- src/JahanPay/JahanPay.php | 8 ++--- src/JahanPay/JahanPayException.php | 4 +-- src/Maskan/Maskan.php | 8 ++--- src/Maskan/MaskanException.php | 4 +-- src/Mellat/Mellat.php | 8 ++--- src/Mellat/MellatException.php | 4 +-- src/Parsian/Parsian.php | 6 ++-- src/Parsian/ParsianErrorException.php | 4 +-- src/Parsian/ParsianResult.php | 2 +- src/Pasargad/Parser.php | 2 +- src/Pasargad/Pasargad.php | 10 +++--- src/Pasargad/PasargadErrorException.php | 4 +-- src/Pasargad/PasargadResult.php | 2 +- src/Pasargad/RSA.php | 2 +- src/Pasargad/RSAProcessor.php | 2 +- src/Payir/Payir.php | 8 ++--- src/Payir/PayirReceiveException.php | 4 +-- src/Payir/PayirSendException.php | 4 +-- src/Payline/Payline.php | 8 ++--- src/Payline/PaylineReceiveException.php | 4 +-- src/Payline/PaylineSendException.php | 4 +-- src/PortAbstract.php | 2 +- src/PortInterface.php | 2 +- src/Sadad/Sadad.php | 6 ++-- src/Sadad/SadadException.php | 4 +-- src/Sadad/SadadResult.php | 2 +- src/Saderat/Saderat.php | 6 ++-- src/Saderat/SaderatException.php | 4 +-- src/Saman/Saman.php | 6 ++-- src/Saman/SamanException.php | 4 +-- src/Zarinpal/Zarinpal.php | 8 ++--- src/Zarinpal/ZarinpalException.php | 4 +-- 50 files changed, 126 insertions(+), 126 deletions(-) diff --git a/src/Asanpardakht/Asanpardakht.php b/src/Asanpardakht/Asanpardakht.php index 89363b0b..88d0624e 100644 --- a/src/Asanpardakht/Asanpardakht.php +++ b/src/Asanpardakht/Asanpardakht.php @@ -1,11 +1,11 @@ =') && version_compare(\Illuminate\Foundation\Application::VERSION, '6.0', '<')) { - $provider = 'Larabookir\Gateway\GatewayServiceProviderLaravel5'; + $provider = 'Masihjazayeri\Gateway\GatewayServiceProviderLaravel5'; }else { - $provider = 'Larabookir\Gateway\GatewayServiceProviderLaravel6'; + $provider = 'Masihjazayeri\Gateway\GatewayServiceProviderLaravel6'; } return new $provider($this->app); diff --git a/src/GatewayServiceProviderLaravel4.php b/src/GatewayServiceProviderLaravel4.php index 7194ab93..7f5a736e 100644 --- a/src/GatewayServiceProviderLaravel4.php +++ b/src/GatewayServiceProviderLaravel4.php @@ -1,6 +1,6 @@ package('larabook/gateway',null,__DIR__.'/../'); + $this->package('masihjazayeri/gateway',null,__DIR__.'/../'); if ( diff --git a/src/GatewayServiceProviderLaravel5.php b/src/GatewayServiceProviderLaravel5.php index a075b3f1..25eef69f 100644 --- a/src/GatewayServiceProviderLaravel5.php +++ b/src/GatewayServiceProviderLaravel5.php @@ -1,6 +1,6 @@ publishes([ $config => config_path('gateway.php'), ], 'config'); - // php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=migrations + // php artisan vendor:publish --provider=Masihjazayeri\Gateway\GatewayServiceProvider --tag=migrations $this->publishes([ $migrations => base_path('database/migrations') ], 'migrations'); @@ -38,7 +38,7 @@ public function boot() $this->loadViewsFrom($views, 'gateway'); - // php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=views + // php artisan vendor:publish --provider=Masihjazayeri\Gateway\GatewayServiceProvider --tag=views $this->publishes([ $views => base_path('resources/views/vendor/gateway'), ], 'views'); diff --git a/src/GatewayServiceProviderLaravel6.php b/src/GatewayServiceProviderLaravel6.php index b3df8082..993cc6c1 100644 --- a/src/GatewayServiceProviderLaravel6.php +++ b/src/GatewayServiceProviderLaravel6.php @@ -1,6 +1,6 @@ publishes([ $config => config_path('gateway.php'), ], 'config') ; - // php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=migrations + // php artisan vendor:publish --provider=Masihjazayeri\Gateway\GatewayServiceProvider --tag=migrations $this->publishes([ $migrations => base_path('database/migrations') ], 'migrations'); @@ -39,7 +39,7 @@ public function boot() $this->loadViewsFrom($views, 'gateway'); - // php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=views + // php artisan vendor:publish --provider=Masihjazayeri\Gateway\GatewayServiceProvider --tag=views $this->publishes([ $views => base_path('resources/views/vendor/gateway'), ], 'views'); diff --git a/src/Irankish/Irankish.php b/src/Irankish/Irankish.php index e6a61be6..78bae778 100644 --- a/src/Irankish/Irankish.php +++ b/src/Irankish/Irankish.php @@ -1,13 +1,13 @@ Date: Mon, 4 May 2020 13:58:57 +0430 Subject: [PATCH 14/27] composer update --- composer.json | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 686f19f9..318aac6a 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "larabook/gateway", - "homepage": "https://github.com/larabook/gateway", + "homepage": "https://github.com/masihjazy-z/gateway", "description": "A Laravel package for connecting to all Iraninan payment gateways", "keywords": [ "laravel", @@ -33,16 +33,8 @@ "license": "MIT", "authors": [ { - "name": "Hamed Pakdaman", - "email": "pakdaman.it@gmail.com" - }, - { - "name": "MohammadReza Honarkhah", - "email": "m.honar@gmail.com" - }, - { - "name": "Amir Khorsandi", - "email": "Khorsandi@me.com" + "name": "Masih Jazayeri", + "email": "masih1376@gmail.com" } ], "require": { @@ -59,10 +51,10 @@ "extra": { "laravel": { "providers": [ - "Larabookir\\Gateway\\GatewayServiceProvider" + "Masihjazayeri\\Gateway\\GatewayServiceProvider" ], "aliases": { - "Gateway": "Larabookir\\Gateway\\Gateway" + "Gateway": "Masihjazayeri\\Gateway\\Gateway" } } } From 05db336a6272ab5e0c2903ea6e27caacb287cc3c Mon Sep 17 00:00:00 2001 From: masihjay-z <49074709+masihjay-z@users.noreply.github.com> Date: Mon, 4 May 2020 14:00:34 +0430 Subject: [PATCH 15/27] Update composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 318aac6a..c4129a60 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "larabook/gateway", + "name": "masihjazayeri/gateway", "homepage": "https://github.com/masihjazy-z/gateway", "description": "A Laravel package for connecting to all Iraninan payment gateways", "keywords": [ @@ -43,8 +43,8 @@ }, "autoload": { "psr-4": { - "Larabookir\\Gateway\\": "src/", - "Larabookir\\Gateway\\Tests\\": "tests/" + "Masihjzayeri\\Gateway\\": "src/", + "Masihjazayeri\\Gateway\\Tests\\": "tests/" } }, "minimum-stability": "dev", From b1a27f06a97ab758b68f85d2d42e4d5653d302f4 Mon Sep 17 00:00:00 2001 From: masih Date: Mon, 4 May 2020 14:12:57 +0430 Subject: [PATCH 16/27] change namespace --- LICENSE | 2 +- README.md | 12 ++++++------ ...5_02_193213_create_gateway_transactions_table.php | 6 +++--- src/Paypal/Paypal.php | 12 ++++++------ src/Paypal/PaypalException.php | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/LICENSE b/LICENSE index d48c581e..49278a1f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Larabook +Copyright (c) 2016 Masihjazayeri Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 8a5040c2..32e001f1 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ ```php -composer require larabook/gateway +composer require masihjazayeri/gateway ``` @@ -55,13 +55,13 @@ composer require larabook/gateway 'providers' => [ ... - Larabookir\Gateway\GatewayServiceProvider::class, // <-- add this line at the end of provider array + Masihjazayeri\Gateway\GatewayServiceProvider::class, // <-- add this line at the end of provider array ], 'aliases' => [ ... - 'Gateway' => Larabookir\Gateway\Gateway::class, // <-- add this line at the end of aliases array + 'Gateway' => Masihjazayeri\Gateway\Gateway::class, // <-- add this line at the end of aliases array ] ``` @@ -77,7 +77,7 @@ composer require larabook/gateway ```php -php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProviderLaravel5 +php artisan vendor:publish --provider=Masihjazayeri\Gateway\GatewayServiceProviderLaravel5 ``` @@ -179,7 +179,7 @@ try { // تراکنش با موفقیت سمت بانک تایید گردید // در این مرحله عملیات خرید کاربر را تکمیل میکنیم -} catch (\Larabookir\Gateway\Exceptions\RetryException $e) { +} catch (\Masihjazayeri\Gateway\Exceptions\RetryException $e) { // تراکنش قبلا سمت بانک تاییده شده است و // کاربر احتمالا صفحه را مجددا رفرش کرده است @@ -205,7 +205,7 @@ try { درصورت بروز هر گونه - [باگ](https://github.com/larabook/gateway/issues) یا [خطا](https://github.com/larabook/gateway/issues) . + [باگ](https://github.com/masihjay-z/gateway/issues) یا [خطا](https://github.com/masihjay-z/gateway/issues) . ما را آگاه سازید . این پکیج از پکیج دیگری بنام poolport مشتق شده است اما برخی از عملیات آن متناسب با فریموورک لارول تغییر کرده است diff --git a/migrations/2016_05_02_193213_create_gateway_transactions_table.php b/migrations/2016_05_02_193213_create_gateway_transactions_table.php index f87a50d6..99a1accb 100644 --- a/migrations/2016_05_02_193213_create_gateway_transactions_table.php +++ b/migrations/2016_05_02_193213_create_gateway_transactions_table.php @@ -2,9 +2,9 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -use Larabookir\Gateway\PortAbstract; -use Larabookir\Gateway\GatewayResolver; -use Larabookir\Gateway\Enum; +use Masihjazayeri\Gateway\PortAbstract; +use Masihjazayeri\Gateway\GatewayResolver; +use Masihjazayeri\Gateway\Enum; class CreateGatewayTransactionsTable extends Migration { diff --git a/src/Paypal/Paypal.php b/src/Paypal/Paypal.php index fbf3bc5f..b267193c 100644 --- a/src/Paypal/Paypal.php +++ b/src/Paypal/Paypal.php @@ -1,13 +1,13 @@ Date: Mon, 4 May 2020 14:20:40 +0430 Subject: [PATCH 17/27] change namespace --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c4129a60..9645c5a7 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "masihjazayeri/gateway", - "homepage": "https://github.com/masihjazy-z/gateway", + "homepage": "https://github.com/masihjay-z/gateway", "description": "A Laravel package for connecting to all Iraninan payment gateways", "keywords": [ "laravel", @@ -43,7 +43,7 @@ }, "autoload": { "psr-4": { - "Masihjzayeri\\Gateway\\": "src/", + "Masihjazayeri\\Gateway\\": "src/", "Masihjazayeri\\Gateway\\Tests\\": "tests/" } }, From e84311fc048dbf21ff947071f0510ef80358fd23 Mon Sep 17 00:00:00 2001 From: masih Date: Mon, 4 May 2020 15:40:28 +0430 Subject: [PATCH 18/27] fix bug in callback --- src/Saderat/Saderat.php | 52 +++++++++++------------------------------ 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/src/Saderat/Saderat.php b/src/Saderat/Saderat.php index 3c7f4b7e..c24b7f95 100644 --- a/src/Saderat/Saderat.php +++ b/src/Saderat/Saderat.php @@ -26,9 +26,8 @@ class Saderat extends PortAbstract implements PortInterface * @var string */ - protected $serverVerifyUrl = "https://sep.shaparak.ir/payments/referencepayment.asmx?WSDL"; - protected $token_service_wsdl = 'https://mabna.shaparak.ir:8082/Token.svc?wsdl'; + protected $advice_url = 'https://mabna.shaparak.ir:8081/V1/PeymentApi/Advice'; protected $getTokenUrl = "https://mabna.shaparak.ir:8081/V1/PeymentApi/GetToken"; @@ -175,20 +174,20 @@ function getCallback() */ protected function userPayment() { - $this->trackingCode = Request::input('TRACENO'); + $this->trackingCode = Request::input('tracenumber'); // $this->cardNumber = Request::input('SecurePan'); , will cause mysql error : Data too long for column 'card_number' ! - $payRequestRes = Request::input('State'); - $payRequestResCode = Request::input('Status'); + $payRequestRes = Request::input('respmsg'); + $payRequestResCode = Request::input('respcode'); - $this->refId = Request::input('RefNum'); + $this->refId = Request::input('rrn'); $this->getTable()->whereId($this->transactionId)->update([ 'ref_id' => $this->refId, 'tracking_code' => $this->trackingCode, - // 'card_number' => $this->cardNumber, will cause mysql error : Data too long for column 'card_number' ! + 'card_number' => $this->cardNumber, 'updated_at' => Carbon::now(), ]); - if ($payRequestRes == 'OK') { + if ($$payRequestResCode == '0') { return true; } @@ -208,42 +207,19 @@ protected function userPayment() */ protected function verifyPayment() { - $fields = array( - "merchantID" => $this->config->get('gateway.saderat.merchant'), - "RefNum" => $this->refId, - "password" => $this->config->get('gateway.saderat.password'), - ); + + $dataQuery ='digitalreceipt='.$this->test_input(Request::input('digitalreceipt')).'&Tid='.$this->config->get('gateway.saderat.terminalID'); - try { - $soap = new SoapClient($this->serverVerifyUrl); - $response = $soap->VerifyTransaction($fields["RefNum"], $fields["merchantID"]); - - } catch (\SoapFault $e) { - $this->transactionFailed(); - $this->newLog('SoapFault', $e->getMessage()); - throw $e; - } + $response =json_decode( makeHttpChargeRequest('POST',$dataQuery,$AdviceAddress)); - $response = intval($response); + $Status =$response->Status; + $ReturnId=$response->ReturnId; + $Message=$response->Message; - if ($response == $this->amount) { + if ( $respcode == 0 && $Status== "Ok" && $ReturnId==$this->amount) { $this->transactionSucceed(); return true; } - - //Reverse Transaction - if ($response > 0) { - try { - $soap = new SoapClient($this->serverVerifyUrl); - $response = $soap->ReverseTransaction($fields["RefNum"], $fields["merchantID"], $fields["password"], $response); - - } catch (\SoapFault $e) { - $this->transactionFailed(); - $this->newLog('SoapFault', $e->getMessage()); - throw $e; - } - } - // $this->transactionSetRefId(); $this->transactionFailed(); From 829299df0b917386b504408da48a32c4044871be Mon Sep 17 00:00:00 2001 From: masih Date: Mon, 4 May 2020 15:52:20 +0430 Subject: [PATCH 19/27] fix bug in save card number --- src/Saderat/Saderat.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Saderat/Saderat.php b/src/Saderat/Saderat.php index c24b7f95..150a1e7f 100644 --- a/src/Saderat/Saderat.php +++ b/src/Saderat/Saderat.php @@ -175,7 +175,7 @@ function getCallback() protected function userPayment() { $this->trackingCode = Request::input('tracenumber'); - // $this->cardNumber = Request::input('SecurePan'); , will cause mysql error : Data too long for column 'card_number' ! + $this->cardNumber = Request::input('cardnumber'); $payRequestRes = Request::input('respmsg'); $payRequestResCode = Request::input('respcode'); @@ -183,7 +183,7 @@ protected function userPayment() $this->getTable()->whereId($this->transactionId)->update([ 'ref_id' => $this->refId, 'tracking_code' => $this->trackingCode, - 'card_number' => $this->cardNumber, + 'card_number' => $this->cardNumber, 'updated_at' => Carbon::now(), ]); From fb04df3eb632d7aae5fb8d2e3e0d4d4bbc69bd9a Mon Sep 17 00:00:00 2001 From: masih Date: Mon, 4 May 2020 15:57:14 +0430 Subject: [PATCH 20/27] fix bug --- src/Saderat/Saderat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Saderat/Saderat.php b/src/Saderat/Saderat.php index 150a1e7f..da5f0a8b 100644 --- a/src/Saderat/Saderat.php +++ b/src/Saderat/Saderat.php @@ -223,7 +223,7 @@ protected function verifyPayment() // $this->transactionSetRefId(); $this->transactionFailed(); - $this->newLog($response, SaderatException::$errors[$response]); + $this->newLog($response, SaderatException::$errors[$respcode]); throw new SaderatException($response); From 14f83895b9c29e7cb42e81897f14c136a3f8bbe4 Mon Sep 17 00:00:00 2001 From: masih Date: Mon, 4 May 2020 16:27:15 +0430 Subject: [PATCH 21/27] add saderat enum --- src/Enum.php | 4 +++- src/GatewayResolver.php | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Enum.php b/src/Enum.php index 992f272c..c488bd29 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -15,7 +15,9 @@ class Enum const ASANPARDAKHT = 'ASANPARDAKHT'; const PAYPAL = 'PAYPAL'; const PAYIR = 'PAYIR'; - const IRANKISH = 'IRANKISH'; + const IRANKISH = 'IRANKISH'; + const SADERAT = 'SADERAT'; + const MASKAN = self::IRANKISH; static function getIPGs(){ diff --git a/src/GatewayResolver.php b/src/GatewayResolver.php index 8c787737..d8ba5cc5 100644 --- a/src/GatewayResolver.php +++ b/src/GatewayResolver.php @@ -148,6 +148,8 @@ function make($port) $name = Enum::PASARGAD; } elseif ($port InstanceOf Irankish) { $name = Enum::IRANKISH; + }elseif ($port InstanceOf Saderat) { + $name = Enum::SADERAT; } elseif (in_array(strtoupper($port), $this->getSupportedPorts())) { $port = ucfirst(strtolower($port)); $name = strtoupper($port); From 31bf5cae2bcb915bb55146d52a805738f3a81104 Mon Sep 17 00:00:00 2001 From: masih Date: Mon, 4 May 2020 16:36:38 +0430 Subject: [PATCH 22/27] add enum for saderat --- src/GatewayResolver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/GatewayResolver.php b/src/GatewayResolver.php index d8ba5cc5..da977034 100644 --- a/src/GatewayResolver.php +++ b/src/GatewayResolver.php @@ -6,6 +6,7 @@ use Masihjazayeri\Gateway\Parsian\Parsian; use Masihjazayeri\Gateway\Paypal\Paypal; use Masihjazayeri\Gateway\Sadad\Sadad; +use Masihjazayeri\Gateway\Saderat\Saderat; use Masihjazayeri\Gateway\Mellat\Mellat; use Masihjazayeri\Gateway\Pasargad\Pasargad; use Masihjazayeri\Gateway\Saman\Saman; From 52832f7fbb5b1662ead9da55ffa6b4072f96a1a2 Mon Sep 17 00:00:00 2001 From: masih Date: Tue, 5 May 2020 10:05:40 +0430 Subject: [PATCH 23/27] fix bug in generate callback url --- src/PortAbstract.php | 2 +- src/Saderat/Saderat.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PortAbstract.php b/src/PortAbstract.php index f3ac25c9..df95469b 100644 --- a/src/PortAbstract.php +++ b/src/PortAbstract.php @@ -2,7 +2,7 @@ namespace Masihjazayeri\Gateway; use Illuminate\Support\Facades\Request; -use Larabookir\Gateway\Enum; +use Masihjazayeri\Gateway\Enum; use Carbon\Carbon; abstract class PortAbstract diff --git a/src/Saderat/Saderat.php b/src/Saderat/Saderat.php index da5f0a8b..80e00618 100644 --- a/src/Saderat/Saderat.php +++ b/src/Saderat/Saderat.php @@ -157,7 +157,6 @@ function getCallback() if (!$this->callbackUrl) $this->callbackUrl = $this->config->get('gateway.saderat.callback-url'); - return $this->callbackUrl = $this->config->get('gateway.saderat.callback-url'); $url = $this->makeCallback($this->callbackUrl, ['transaction_id' => $this->transactionId()]); From c3e2e3571475131baf970029c6df2820914ec5a1 Mon Sep 17 00:00:00 2001 From: masih Date: Tue, 5 May 2020 10:56:00 +0430 Subject: [PATCH 24/27] fix bug in saderat gatewat --- src/Saderat/Saderat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Saderat/Saderat.php b/src/Saderat/Saderat.php index 80e00618..1d836843 100644 --- a/src/Saderat/Saderat.php +++ b/src/Saderat/Saderat.php @@ -186,7 +186,7 @@ protected function userPayment() 'updated_at' => Carbon::now(), ]); - if ($$payRequestResCode == '0') { + if ($payRequestResCode == '0') { return true; } From f328d9e4c4642ac6dd08e7cc4a08f6a3cecc1e3f Mon Sep 17 00:00:00 2001 From: masih Date: Tue, 5 May 2020 11:08:48 +0430 Subject: [PATCH 25/27] fix bug in saderat gatewat --- src/Saderat/Saderat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Saderat/Saderat.php b/src/Saderat/Saderat.php index 1d836843..7d649226 100644 --- a/src/Saderat/Saderat.php +++ b/src/Saderat/Saderat.php @@ -209,7 +209,7 @@ protected function verifyPayment() $dataQuery ='digitalreceipt='.$this->test_input(Request::input('digitalreceipt')).'&Tid='.$this->config->get('gateway.saderat.terminalID'); - $response =json_decode( makeHttpChargeRequest('POST',$dataQuery,$AdviceAddress)); + $response =json_decode( $this.makeHttpChargeRequest('POST',$dataQuery,$AdviceAddress)); $Status =$response->Status; $ReturnId=$response->ReturnId; From 480c6f3ff0fd8e7b2f4d83d0aee6b73b0ae67458 Mon Sep 17 00:00:00 2001 From: masih Date: Tue, 5 May 2020 11:32:53 +0430 Subject: [PATCH 26/27] fix bug in saderat gatewat --- src/Saderat/Saderat.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Saderat/Saderat.php b/src/Saderat/Saderat.php index 7d649226..2b34e824 100644 --- a/src/Saderat/Saderat.php +++ b/src/Saderat/Saderat.php @@ -209,13 +209,13 @@ protected function verifyPayment() $dataQuery ='digitalreceipt='.$this->test_input(Request::input('digitalreceipt')).'&Tid='.$this->config->get('gateway.saderat.terminalID'); - $response =json_decode( $this.makeHttpChargeRequest('POST',$dataQuery,$AdviceAddress)); + $response =json_decode($this->makeHttpChargeRequest($dataQuery,$this->advice_url)); $Status =$response->Status; $ReturnId=$response->ReturnId; $Message=$response->Message; - if ( $respcode == 0 && $Status== "Ok" && $ReturnId==$this->amount) { + if ( $Status== "Ok" && $ReturnId==$this->amount) { $this->transactionSucceed(); return true; } From 8f050df280127c612bf53b1844d9cb31f14227fe Mon Sep 17 00:00:00 2001 From: masih Date: Tue, 5 May 2020 11:40:33 +0430 Subject: [PATCH 27/27] fix bug in saderat gatewat --- src/Saderat/Saderat.php | 6 +++--- src/Saderat/SaderatException.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Saderat/Saderat.php b/src/Saderat/Saderat.php index 2b34e824..67b78b26 100644 --- a/src/Saderat/Saderat.php +++ b/src/Saderat/Saderat.php @@ -215,15 +215,15 @@ protected function verifyPayment() $ReturnId=$response->ReturnId; $Message=$response->Message; - if ( $Status== "Ok" && $ReturnId==$this->amount) { + if ($Status== "Ok" && $ReturnId==$this->amount) { $this->transactionSucceed(); return true; } // $this->transactionSetRefId(); $this->transactionFailed(); - $this->newLog($response, SaderatException::$errors[$respcode]); - throw new SaderatException($response); + $this->newLog(intval($Status), SaderatException::$errors[$Status]); + throw new SaderatException($Status); } diff --git a/src/Saderat/SaderatException.php b/src/Saderat/SaderatException.php index 4d31412a..2e518c36 100644 --- a/src/Saderat/SaderatException.php +++ b/src/Saderat/SaderatException.php @@ -27,7 +27,7 @@ class SaderatException extends BankException 'Allowable PIN Tries Exceeded Pick Up' => 'رمز کارت (PIN) 3 مرتبه اشتباه وارد شده است در نتیجه کارت شما غیر فعال خواهد شد', 'Response Received Too Late' => 'تراکنش در شبکه بانکی Timeout خورده است', 'Suspected Fraud Pick Up' => 'فیلد CV2V و یا فیلد ExpDate اشتباه وارد شده و یا اصلا وارد نشده است', - + 'Duplicate'=> 'این تراکنش قبلا انجام شده است.', -1 => "تراکنش پیدا نشد.",