Skip to content

Commit

Permalink
Merge pull request #249 from larabook/dev
Browse files Browse the repository at this point in the history
merge to master
  • Loading branch information
hpakdaman committed Nov 21, 2021
2 parents 30272bc + 4cd84d8 commit 42d0977
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 32 deletions.
43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<div dir="rtl">

سایت مرجع پکیج: [larabook.ir](http://larabook.ir/اتصال-درگاه-بانک-لاراول/)

```
متاسفانه این پکیج دیگر پشتیبانی نمی شود
```

پکیج اتصال به تمامی IPG ها و بانک های ایرانی.

این پکیج با ورژن های
( ۴ و ۵ و ۶ لاراول )
( ۴ و ۵ و ۶ )
لاراول سازگار می باشد


Expand All @@ -29,9 +32,17 @@

**مرحله ۱)**

composer require larabook/gateway

</div>


```php

composer require larabook/gateway

```

<div dir="rtl">

**مرحله ۲)**

تغییرات زیر را در فایل config/app.php اعمال نمایید:
Expand Down Expand Up @@ -64,30 +75,42 @@
برای لاراول ۵ :
</div>

php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProviderLaravel5
```php

php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProviderLaravel5

```

<div dir="rtl">
برای لاراول ۶ به بعد :
</div>

php artisan vendor:publish
```php

php artisan vendor:publish

<div dir="rtl">
سپس این گزینه را انتخاب کنید : "Larabookir\Gateway\GatewayServiceProviderLaravel6"
// then choose : GatewayServiceProviderLaravel6

```

<div dir="rtl">

**مرحله ۴) - ایجاد جداول**

php artisan migrate
</div>

```php

php artisan migrate

```


<div dir="rtl">

**مرحله ۵)**

عملیات نصب پایان یافته است حال فایل gateway.php را در مسیر app/ را باز نموده و تنظیمات مربوط به درگاه بانکی مورد نظر خود را در آن وارد نمایید .
عملیات نصب پایان یافته است حال فایل gateway.php را در مسیر app/ باز نموده و تنظیمات مربوط به درگاه بانکی مورد نظر خود را در آن وارد نمایید .

حال میتوایند برای اتصال به api بانک از یکی از روش های زیر به انتخاب خودتان استفاده نمایید . (Facade , Service container):
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddDescriptionToGatewayTransactions extends Migration
{
public function getTable()
{
return config('gateway.table', 'gateway_transactions');
}

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('gateway_transactions', function (Blueprint $table) {
//
Schema::table($this->getTable(), function (Blueprint $table) {
$table->text('description')->after('ip')->nullable();
});
}
Expand All @@ -26,10 +30,8 @@ public function up()
*/
public function down()
{
Schema::table('gateway_transactions', function (Blueprint $table) {
//
Schema::table($this->getTable(), function (Blueprint $table) {
$table->dropColumn('description');

});
}
}
4 changes: 3 additions & 1 deletion src/Mellat/MellatException.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class MellatException extends BankException
51 => 'تراکنش تکراری است',
54 => 'تراکنش مرجع موجود نیست',
55 => 'تراکنش نامعتبر است',
61 => 'خطا در واریز'
61 => 'خطا در واریز',
62 => 'مسیر بازگشت به سایت در دامنه ثبت شده برای پدیرنده قرار ندارد',
98 => 'سقف استفاده از رمز ایستا به پایان رسیده است'
);

public function __construct($errorId)
Expand Down
19 changes: 9 additions & 10 deletions src/Payir/Payir.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ class Payir extends PortAbstract implements PortInterface
*
* @var string
*/
protected $serverUrl = 'https://pay.ir/payment/send';
protected $serverUrl = 'https://pay.ir/pg/send';

/**
* Address of CURL server for verify payment
*
* @var string
*/
protected $serverVerifyUrl = 'https://pay.ir/payment/verify';
protected $serverVerifyUrl = 'https://pay.ir/pg/verify';

/**
* Address of gate for redirect
*
* @var string
*/
protected $gateUrl = 'https://pay.ir/payment/gateway/';
protected $gateUrl = 'https://pay.ir/pg/';


protected $factorNumber;
Expand Down Expand Up @@ -131,7 +132,7 @@ protected function sendPayRequest()
$response = json_decode($response, true);
curl_close($ch);
if (is_numeric($response['status']) && $response['status'] > 0) {
$this->refId = $response['transId'];
$this->refId = $response['token'];
$this->transactionSetRefId();
return true;
}
Expand All @@ -150,15 +151,11 @@ protected function sendPayRequest()
protected function userPayment()
{
$status = Request::input('status');
$transId = Request::input('transId');
$this->cardNumber = Request::input('cardNumber');
$message = Request::input('message');
if (is_numeric($status) && $status > 0) {
$this->trackingCode = $transId;
return true;
}
$this->transactionFailed();
$this->newLog(-5, $message);
$this->newLog(-5, Enum::TRANSACTION_FAILED_TEXT);
throw new PayirReceiveException(-5);
}

Expand All @@ -173,7 +170,7 @@ protected function verifyPayment()
{
$fields = [
'api' => $this->config->get('gateway.payir.api'),
'transId' => $this->refId(),
'token' => $this->refId(),
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->serverVerifyUrl);
Expand All @@ -184,6 +181,8 @@ protected function verifyPayment()
$response = json_decode($response, true);
curl_close($ch);
if ($response['status'] == 1) {
$this->trackingCode = $response['transId'];
$this->cardNumber = $response['cardNumber'];
$this->transactionSucceed();
$this->newLog(1, Enum::TRANSACTION_SUCCEED_TEXT);
return true;
Expand Down
6 changes: 2 additions & 4 deletions src/Saman/Saman.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 42d0977

Please sign in to comment.