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 7d019108..32e001f1 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,14 @@
-سایت مرجع پکیج: [larabook.ir](http://larabook.ir/اتصال-درگاه-بانک-لاراول/)
+
+```
+متاسفانه این پکیج دیگر پشتیبانی نمی شود
+```
پکیج اتصال به تمامی IPG ها و بانک های ایرانی.
این پکیج با ورژن های
-( ۴ و ۵ و ۶ لاراول )
+( ۴ و ۵ و ۶ )
لاراول سازگار می باشد
@@ -29,9 +32,17 @@
**مرحله ۱)**
- composer require larabook/gateway
-
+
+
+
+```php
+
+composer require masihjazayeri/gateway
+
+```
+
+
**مرحله ۲)**
تغییرات زیر را در فایل config/app.php اعمال نمایید:
@@ -44,13 +55,13 @@
'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
]
```
@@ -64,30 +75,42 @@
برای لاراول ۵ :
- php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProviderLaravel5
+```php
+php artisan vendor:publish --provider=Masihjazayeri\Gateway\GatewayServiceProviderLaravel5
+
+```
-سپس این گزینه را انتخاب کنید : "Larabookir\Gateway\GatewayServiceProviderLaravel6"
+// then choose : GatewayServiceProviderLaravel6
+```
+
**مرحله ۴) - ایجاد جداول**
- php artisan migrate
+
+```php
+
+php artisan migrate
+```
+
+
+
**مرحله ۵)**
-عملیات نصب پایان یافته است حال فایل gateway.php را در مسیر app/ را باز نموده و تنظیمات مربوط به درگاه بانکی مورد نظر خود را در آن وارد نمایید .
+عملیات نصب پایان یافته است حال فایل gateway.php را در مسیر app/ باز نموده و تنظیمات مربوط به درگاه بانکی مورد نظر خود را در آن وارد نمایید .
حال میتوایند برای اتصال به api بانک از یکی از روش های زیر به انتخاب خودتان استفاده نمایید . (Facade , Service container):
@@ -156,7 +179,7 @@ try {
// تراکنش با موفقیت سمت بانک تایید گردید
// در این مرحله عملیات خرید کاربر را تکمیل میکنیم
-} catch (\Larabookir\Gateway\Exceptions\RetryException $e) {
+} catch (\Masihjazayeri\Gateway\Exceptions\RetryException $e) {
// تراکنش قبلا سمت بانک تاییده شده است و
// کاربر احتمالا صفحه را مجددا رفرش کرده است
@@ -182,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/composer.json b/composer.json
index 686f19f9..9645c5a7 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
- "name": "larabook/gateway",
- "homepage": "https://github.com/larabook/gateway",
+ "name": "masihjazayeri/gateway",
+ "homepage": "https://github.com/masihjay-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": {
@@ -51,18 +43,18 @@
},
"autoload": {
"psr-4": {
- "Larabookir\\Gateway\\": "src/",
- "Larabookir\\Gateway\\Tests\\": "tests/"
+ "Masihjazayeri\\Gateway\\": "src/",
+ "Masihjazayeri\\Gateway\\Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"extra": {
"laravel": {
"providers": [
- "Larabookir\\Gateway\\GatewayServiceProvider"
+ "Masihjazayeri\\Gateway\\GatewayServiceProvider"
],
"aliases": {
- "Gateway": "Larabookir\\Gateway\\Gateway"
+ "Gateway": "Masihjazayeri\\Gateway\\Gateway"
}
}
}
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/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/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 @@
getSupportedPorts())) {
$port = ucfirst(strtolower($port));
$name = strtoupper($port);
diff --git a/src/GatewayServiceProvider.php b/src/GatewayServiceProvider.php
index f51e4ae5..54a2a898 100644
--- a/src/GatewayServiceProvider.php
+++ b/src/GatewayServiceProvider.php
@@ -1,6 +1,6 @@
=') && 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 @@
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');
+
+
+ $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('tracenumber');
+ $this->cardNumber = Request::input('cardnumber');
+ $payRequestRes = Request::input('respmsg');
+ $payRequestResCode = Request::input('respcode');
+
+ $this->refId = Request::input('rrn');
+ $this->getTable()->whereId($this->transactionId)->update([
+ 'ref_id' => $this->refId,
+ 'tracking_code' => $this->trackingCode,
+ 'card_number' => $this->cardNumber,
+ 'updated_at' => Carbon::now(),
+ ]);
+
+ if ($payRequestResCode == '0') {
+ 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()
+ {
+
+ $dataQuery ='digitalreceipt='.$this->test_input(Request::input('digitalreceipt')).'&Tid='.$this->config->get('gateway.saderat.terminalID');
+
+ $response =json_decode($this->makeHttpChargeRequest($dataQuery,$this->advice_url));
+
+ $Status =$response->Status;
+ $ReturnId=$response->ReturnId;
+ $Message=$response->Message;
+
+ if ($Status== "Ok" && $ReturnId==$this->amount) {
+ $this->transactionSucceed();
+ return true;
+ }
+ //
+ $this->transactionSetRefId();
+ $this->transactionFailed();
+ $this->newLog(intval($Status), SaderatException::$errors[$Status]);
+ throw new SaderatException($Status);
+
+
+ }
+
+
+}
diff --git a/src/Saderat/SaderatException.php b/src/Saderat/SaderatException.php
new file mode 100644
index 00000000..2e518c36
--- /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 اشتباه وارد شده و یا اصلا وارد نشده است',
+ 'Duplicate'=> 'این تراکنش قبلا انجام شده است.',
+
+
+ -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/src/Saman/Saman.php b/src/Saman/Saman.php
index 5fa9ccdf..c9f70828 100644
--- a/src/Saman/Saman.php
+++ b/src/Saman/Saman.php
@@ -1,12 +1,12 @@
+
+
+
+