PHPackages                             parsisolution/gateway - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. parsisolution/gateway

ActiveLibrary[Payment Processing](/categories/payments)

parsisolution/gateway
=====================

A Laravel package for connecting to all Iraninan payment gateways

v2.2.1(2y ago)231.7k7[1 issues](https://github.com/parsisolution/gateway/issues)MITPHPPHP &gt;=7.1CI failing

Since Nov 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/parsisolution/gateway)[ Packagist](https://packagist.org/packages/parsisolution/gateway)[ Docs](https://github.com/parsisolution/gateway)[ RSS](/packages/parsisolution-gateway/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (8)Versions (36)Used By (0)

Parsisolution Gateway
=====================

[](#parsisolution-gateway)

Iranian Payment Gateways

This library is inspired by laravel [Socialite](https://github.com/laravel/socialite) and [PoolPort](https://github.com/PoolPort/PoolPort) and [larabook/gateway](https://github.com/larabook/gateway)

Available PSPs (Bank):

1. [Beh Pardakht](https://behpardakht.com) (`MELLAT`)
2. [SEP](https://sep.ir) (`SAMAN`)
3. [SADAD](https://sadadpsp.ir) (`MELLI`)
4. [PEC](https://pec.ir) (`PARSIAN`)
5. [PEP](https://pep.co.ir) (`PASARGAD`)
6. [Novin Pardakht](https://pna.co.ir) (`EN Bank`, also known as `Eghtesad Novin Bank`)
7. [IranKish](https://irankish.com)
8. [Sepehr](https://sepehrpay.com)
9. [Asan Pardakht](https://asanpardakht.ir)
10. [Fanava Card](https://fanavacard.ir)

Available 3rd-parties:

1. [Vandar](https://vandar.io)
2. [Pay.ir](https://pay.ir)
3. [ZarinPal](https://zarinpal.com)
4. [Zibal](https://zibal.ir)
5. [JibIt](https://jibit.ir)
6. [PayPing](https://payping.ir)
7. [IDPay](https://idpay.ir)
8. [Jibimo](https://jibimo.com)
9. [NextPay](https://nextpay.org)
10. [DigiPay](https://mydigipay.com)
11. [SizPay](https://sizpay.ir)
12. [Shepa](https://shepa.com)
13. [AqayePardakht](https://aqayepardakht.ir)
14. [IranDargah](https://irandargah.com)
15. [Bahamta](https://bahamta.com)
16. [ParsPal](https://parspal.com)
17. [BitPay](https://bitpay.ir)
18. [Milyoona](https://milyoona.com)
19. [Sepal](https://sepal.ir)
20. [TiPoul](https://tipoul.com)
21. [SabaPay](https://sabanovin.com)
22. [YekPay](https://yekpay.com)

Install
-------

[](#install)

### Step 1:

[](#step-1)

```
composer require parsisolution/gateway
```

### Step 2:

[](#step-2)

```
php artisan vendor:publish --provider="Parsisolution\Gateway\GatewayServiceProvider"
```

### Step 3:

[](#step-3)

```
php artisan migrate
```

### Step 4:

[](#step-4)

Change `.env` values or `config/gateways.php` fields to your specifications.

Usage
-----

[](#usage)

### Step 1:

[](#step-1-1)

Get instance of Gateway from Gateway Facade `Gateway::of('mellat')`Or create one yourself: `new Mellat(app(), config('gateways.mellat'));` Or

```
$gateway = Gateway::of('mellat');

$gateway = new Mellat(app(), config('gateways.mellat'));

$gateway = new Mellat(app(), [
    'username'    => '',
    'password'    => '',
    'terminal-id' => '',
]);
```

### Step2:

[](#step2)

Then to create new payment transaction you can do like this:

```
try {
    $gateway = Gateway::of('PayIR'); // $gateway = new Payir(app(), config('gateways.payir'));
    $gateway->callbackUrl(route('callback')); // You can change the callback

    // You can make it stateless.
    // in default mode it uses session to store and retrieve transaction id
    // (and other gateway specific or user provided (using $gateway->with) required parameters)
    // but in stateless mode it gets transaction id and other required parameters from callback url
    // Caution: you should use same stateless value in callback too
    $gateway->stateless();

    // You can get supported extra fields sample for each gateway and then set these fields with your desired values
    // (most gateways support `mobile` field)
    $supportedExtraFieldsSample = $gateway->getSupportedExtraFieldsSample();

    return compact('supportedExtraFieldsSample');

    // Then you should create a transaction to be processed by the gateway
    // Amount is in `Toman` by default, but you can set the currency in second argument as well. IRR (for `Riyal`)
    $transaction = new RequestTransaction(new Amount(12000)); // 12000 Toman
    $transaction->setExtra([
        'mobile' => '09124441122',
        'email'  => 'ali@gmail.com',
        'person' => 12345,
    ]);
    $transaction->setExtraField('description', 'توضیحات من');

    // if you added additional fields in your migration you can assign a value to it in the beginning like this
    $transaction['person_id'] = auth()->user()->id;

    $authorizedTransaction = $gateway->authorize($transaction);

    $transactionId = $authorizedTransaction->getId(); // شماره‌ی تراکنش در جدول پایگاه‌داده
    $orderId = $authorizedTransaction->getOrderId(); // شماره‌ی تراکنش اعلامی به درگاه
    $referenceId = $authorizedTransaction->getReferenceId(); // شناسه‌ی تراکنش در درگاه (در صورت وجود)
    $token = $authorizedTransaction->getToken(); // توکن درگاه (در صورت وجود)

    // در اینجا
    // شماره تراکنش(ها) را با توجه به نوع ساختار پایگاه‌داده‌ی خود
    // در جداول مورد نیاز و بسته به نیاز سیستم‌تان ذخیره کنید.

    // this object tells us how to redirect to gateway
    $redirectResponse = $authorizedTransaction->getRedirect();

    // if you're developing an Api just return it and handle redirect in your frontend
    // (this gives you redirect method [get or post], url and fields)
    // (you can use a code like `redirector.blade.php`)
    return $redirectResponse;

    // otherwise use this solution to redirect user to gateway with proper response
    return $redirectResponse->redirect(app());

} catch (\Exception $e) {

    echo $e->getMessage();
}
```

### Step3:

[](#step3)

And in callback

```
$all = $request->all();

try {

    // first argument defines stateless/stateful state (true for stateless / default is false (stateful))
    // if you want to update fields that you added in migration on successful transaction
    // you can pass them in second argument as associative array
    $settledTransaction = Gateway::settle(true, ['person_id' => 333, 'invoice_id' => 5233]);

    $id = $settledTransaction->getId();
    $orderId = $settledTransaction->getOrderId();
    $amount = strval($settledTransaction->getAmount());
    $extra = $settledTransaction->getExtra();
    $person = $settledTransaction->getExtraField('person');
    $referenceId = $settledTransaction->getReferenceId();
    $traceNumber = $settledTransaction->getTraceNumber();
    $cardNumber = $settledTransaction->getCardNumber();
    $RRN = $settledTransaction->getRRN();
    $person_id = $settledTransaction['person_id'];
    $attributes = $settledTransaction->getAttributes();

    // تراکنش با موفقیت سمت درگاه تایید گردید
    // در این مرحله عملیات خرید کاربر را تکمیل میکنیم

    return compact('all', 'id', 'orderId', 'amount', 'extra', 'person', 'referenceId',
        'traceNumber', 'cardNumber', 'RRN', 'person_id', 'attributes');

} catch (\Parsisolution\Gateway\Exceptions\GeneralTransactionException $e) {
    $code = $e->getCode();
    $message = $e->getMessage();
    /** @var AuthorizedTransaction $transaction */
    $transaction = $e->getTransaction();
    $attributes = $transaction->getAttributes();
    $throwable = $e->getPrevious();
    $previous_class = get_class($throwable);
    $previous_trace = $throwable->getTrace();

    // تراکنش با خطا مواجه شده است

    return compact('previous_class', 'code', 'message', 'attributes', 'previous_trace');

} catch (\Parsisolution\Gateway\Exceptions\RetryException $e) {
    $class = get_class($e);
    $code = $e->getCode();
    $message = $e->getMessage();
    /** @var AuthorizedTransaction $transaction */
    $transaction = $e->getTransaction();
    $attributes = $transaction->getAttributes();
    $trace = $e->getTrace();

    // تراکنش قبلا سمت درگاه تاییده شده است و
    // کاربر احتمالا صفحه را مجددا رفرش کرده است
    // لذا تنها فاکتور خرید قبل را مجدد به کاربر نمایش میدهیم

    return compact('class', 'code', 'message', 'attributes', 'trace');

} catch (\Parsisolution\Gateway\Exceptions\TransactionException|\Parsisolution\Gateway\Exceptions\InvalidRequestException $e) {
    $class = get_class($e);
    $code = $e->getCode();
    $message = $e->getMessage();
    /** @var AuthorizedTransaction $transaction */
    $transaction = $e->getTransaction();
    $attributes = $transaction->getAttributes();
    $trace = $e->getTrace();

    // تراکنش با خطا مواجه شده است

    return compact('class', 'code', 'message', 'attributes', 'trace');

} catch (\Exception $e) {
    $class = get_class($e);
    $code = $e->getCode();
    $message = $e->getMessage();
    $trace = $e->getTrace();

    // تراکنش با خطا مواجه شده است

    return compact('class', 'code', 'message', 'trace');
}
```

### Appendix 1:

[](#appendix-1)

You can easily add your own gateway with no effort in your own code base by extending `\Parsisolution\Gateway\AbstractProvider` class and then add snippet code below to your controller's constructor

```
public function __construct()
{
    $createIDPay = function () {
        return new IDPay(app(), config('gateways.idpay2'));
    };
    Gateway::extend('idpay2', $createIDPay);
    // below number (60) should match the return value of gateway's `getProviderId` method
    Gateway::extend(60, $createIDPay);
}
```

after that you can use added gateway in controller's methods like other gateways:

```
$gateway = Gateway::of('idpay2');
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 71.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~58 days

Recently: every ~158 days

Total

34

Last Release

802d ago

Major Versions

v1.3.7 → v2.0.0-alpha12018-12-18

v1.6.2 → v2.0.0-alpha22022-06-12

PHP version history (2 changes)v1.0.0PHP &gt;=5.6.4

v2.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/8321d85dc7878122fe527ff0a12c6ae513ccd5ad0b7d9f84e6c363dda4a8bc1c?d=identicon)[H4M3D3](/maintainers/H4M3D3)

---

Top Contributors

[![hamed-ehtesham](https://avatars.githubusercontent.com/u/14082075?v=4)](https://github.com/hamed-ehtesham "hamed-ehtesham (61 commits)")[![H4M3D3](https://avatars.githubusercontent.com/u/208514942?v=4)](https://github.com/H4M3D3 "H4M3D3 (15 commits)")[![alighasemzadeh-archived](https://avatars.githubusercontent.com/u/85446576?v=4)](https://github.com/alighasemzadeh-archived "alighasemzadeh-archived (6 commits)")[![mostafaznv](https://avatars.githubusercontent.com/u/7619687?v=4)](https://github.com/mostafaznv "mostafaznv (2 commits)")[![SaeedNikmehr](https://avatars.githubusercontent.com/u/21986853?v=4)](https://github.com/SaeedNikmehr "SaeedNikmehr (1 commits)")

---

Tags

laravelportpaymentgatewayBankpayiranzarinpalzibalPaylineshaparaksamanmellatpasargadparsiansadadmellisaderatirankishjibitasan pardakhtbitpaypepidpaypardakhtdargahiranian-bankspersian-bankspoolportipaypay-irnextpayeghtesad novinmabnaPayPingsabapayvandaryekpayShepabahamtamilyoonasizpayirandargahnovinnovin-pardakhtfanavafanava-cardsepehrjibimoaqayepardakhtparspalsepaltipouldigipay

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/parsisolution-gateway/health.svg)

```
[![Health](https://phpackages.com/badges/parsisolution-gateway/health.svg)](https://phpackages.com/packages/parsisolution-gateway)
```

###  Alternatives

[larabook/gateway

A Laravel package for connecting to all Iraninan payment gateways

24553.7k](/packages/larabook-gateway)[shetabit/multipay

PHP Payment Gateway Integration Package

291348.2k3](/packages/shetabit-multipay)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
