PHPackages                             farayaz/larapay - 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. farayaz/larapay

ActiveLibrary[Payment Processing](/categories/payments)

farayaz/larapay
===============

iranian online payment gateways

v2.0.0(1mo ago)206534MITPHPPHP ^8.2

Since Oct 25Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/farayaz/larapay)[ Packagist](https://packagist.org/packages/farayaz/larapay)[ Docs](https://github.com/farayaz/larapay)[ RSS](/packages/farayaz-larapay/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (12)Versions (80)Used By (0)

Larapay | لاراپِی
=================

[](#larapay--لاراپِی)

 [![GitHub Repo stars](https://camo.githubusercontent.com/ccafc5bfa6146cce37346da91915e727cf14c54aad2d017cc2cd55bfb9466638/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6661726179617a2f6c617261706179)](https://github.com/farayaz/larapay) [![Total Downloads](https://camo.githubusercontent.com/1f0cc70f780123de64afabf90d39740d502927b896f8520e7c046f06001b10e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6661726179617a2f6c617261706179)](https://packagist.org/packages/farayaz/larapay) [![Latest Stable Version](https://camo.githubusercontent.com/aa559ace28342785face2f2e2d92247fa0d80ac706677700bbbb7a45bc52a4cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6661726179617a2f6c617261706179)](https://packagist.org/packages/farayaz/larapay) [![License](https://camo.githubusercontent.com/a6033dacf55eaa3481c9c0f6ff6b93b869eaa2fe765e164645a286850fb7b011/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6661726179617a2f6c617261706179)](https://packagist.org/packages/farayaz/larapay) [![PHP Version](https://camo.githubusercontent.com/dcb0c7affb24560e3dd0b6a191c3ebea9ee5e7e97f0443265495781ae6a33d8f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6661726179617a2f6c617261706179)](https://packagist.org/packages/farayaz/larapay)

Larapay is a Laravel package for integrating Iranian payment gateways.

لاراپی یک پکیج لاراول برای اتصال به درگاه‌های پرداختی ایرانی است.

---

Requirements | نیازمندی‌ها
--------------------------

[](#requirements--نیازمندی‌ها)

- **PHP**: `^8.2`
- **Laravel**: `^12.0` | `^13.0`

---

Installation | نصب
------------------

[](#installation--نصب)

```
composer require farayaz/larapay
```

---

Configuration | تنظیمات
-----------------------

[](#configuration--تنظیمات)

No configuration file is required. Just pass the gateway config directly when calling the gateway.

نیازی به فایل کانفیگ جداگانه نیست. تنظیمات درگاه را مستقیماً هنگام فراخوانی ارسال کنید.

Each gateway has its own required parameters. See the [Gateways table](#gateways--%D8%AF%D8%B1%DA%AF%D8%A7%D9%87%E2%80%8C%D9%87%D8%A7) below.

هر درگاه پارامترهای مورد نیاز خود را دارد. به جدول درگاه‌ها مراجعه کنید.

---

Gateways | درگاه‌ها
-------------------

[](#gateways--درگاه‌ها)

ClassName (en)Name (fa)RequirementsFeatures**AsanPardakht**[AsanPardakht](https://asanpardakht.ir)آسان پرداخت (آپ)`username`, `password`, `merchant_configuration_id`—**Azkivam**[Azkivam](https://azkivam.com/)ازکی وام`merchant_id`, `api_key`—**BehPardakht**[Beh Pardakht Mellat](https://behpardakht.com)به‌پرداخت ملت`terminal_id`, `username`, `password`, `is_credit`—**Bitpay**[Bitpay](https://bitpay.ir/)بیت پی`api`, `sandbox`—**Digipay**[Digipay](https://www.mydigipay.com)دیجی‌پی`username`, `password`, `client_id`, `client_secret`—**ECD**[Electronic Card Damavand](https://ecd-co.ir)پرداخت الکترونیک دماوند`terminal_number`, `hash_key`—**FanavaCard**[FanavaCard](https://fanavacard.ir)فن‌آوا کارت`user_id`, `password`—**IdPay**[IdPay](https://idpay.ir)آیدی‌پی`apiKey`, `sandbox`—**IranDargah**[IranDargah](https://irandargah.com)ایران درگاه`merchant_id`, `sandbox`—**IranKish**[Iran Kish](https://www.irankish.com)ایران کیش`terminalId`, `password`, `acceptorId`, `pubKey`—**IsipaymentSamin**[Isipayment Samin](https://isipayment.ir)ایزایران ثمین`merchant_code`, `merchant_password`, `terminal_code`, `type`, `number_of_installment`—**Keepa**[Keepa - Kipaa](https://keepa.ir)کیپا`token`—**MehrIran**[MehrIran](https://qmb.ir)بانک مهر ایران`terminal_id`, `merchant_nid`, `encrypt_key`—**NextPay**[NextPay](https://nextpay.org)نکست پی`api_key`—**Omidpay**[Omidpay - Sayan Card](https://omidpayment.ir)امید پی (سایان کارت)`user_id`, `password`—**PardakhtNovin**[Pardakht Novin](https://pna.co.ir)پرداخت نوین`userId`, `password`, `terminalId`—**Payir**[Pay.ir](https://www.pay.ir)پی.آی‌آر`api`—**PayPing**[PayPing](https://payping.ir)پی پینگ`token`—**PEC**[PEC](https://pec.ir)تجارت الکترونیک پارسیان`login_account`—**PEP**[PEP](https://pep.co.ir)پرداخت الکترونیک پاسارگاد`username`, `password`, `terminal_number`—**Polam**[Polam (Poolam)](https://polam.io)پولام`api_key`—**RefahBeta**[Refah Beta](https://beta.refah-bank.ir)بانک رفاه بتا`client_id`, `client_secret`, `api_key`, `number_of_installments`Bulk Check**Sadad**[Sadad](https://sadadpsp.ir)پرداخت الکترونیک سداد (ملی)`terminal_id`, `merchant_id`, `key`—**SadadBNPL**[SadadBNPL](https://sadadpsp.ir)سداد BNPL`terminal_id`, `merchant_id`, `key`—**Sep**[Saman Electronic Payment](https://www.sep.ir)پرداخت الکترونیک سامان (سپ)`terminalId`—**Sepal**[Sepal](https://sepal.ir)سپال`api_key`—**SepehrPay**[Sepehr Pay](https://www.sepehrpay.com)پرداخت الکترونیک سپهر (مبنا)`terminalId`—**Shepa**[Shepa](https://shepa.com)شپا`api`—**SnappPay**[SnappPay](https://snapppay.ir)اسنپ‌پی`username`, `password`, `client_id`, `client_secret`—**TabaPay**[TabaPay](https://tabapay.ir)تاباپی`token`—**TejaratBajet**[Tejarat Bajet](https://mybajet.ir)بانک تجارت - باجت`client_id`, `client_secret`, `sandbox`Bulk Check🧪 **Test****Test****تست**——**Vandar**[Vandar](https://vandar.io)وندار`api_key`—**ZarinPal**[Zarin Pal](https://www.zarinpal.com)زرین پال`merchant_id`—**Zibal**[Zibal](https://zibal.ir)زیبال`merchant`—> **Features**: `Bulk Check` = supports bulk transaction status checking.

اگر درگاه مورد نظر خود را پیدا نکردید، به ما اطلاع دهید یا در اضافه کردن آن مشارکت کنید.

---

Usage | نحوه استفاده
--------------------

[](#usage--نحوه-استفاده)

The payment flow consists of 3 steps: **Request** (get token), **Redirect** (send user to gateway), and **Verify** (confirm payment).

فرایند پرداخت شامل ۳ مرحله است: **دریافت توکن**، **هدایت کاربر به درگاه**، و **تأیید پرداخت**.

### 1. Request Token | دریافت توکن

[](#1-request-token--دریافت-توکن)

```
use Farayaz\Larapay\Exceptions\LarapayException;
use Larapay;

$gateway = 'ZarinPal';
$config = [
    'merchant_id' => 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
];

$amount = 10000; // Rial | ریال
$id = 1230; // Transaction ID | شماره تراکنش
$callbackUrl = route('payment.callback', $id);
$nationalId = '1234567890';
$mobile = '09131234567';

try {
    $result = Larapay::gateway($gateway, $config)
        ->request(
            id: $id,
            amount: $amount,
            callbackUrl: $callbackUrl,
            nationalId: $nationalId,
            mobile: $mobile,
        );
} catch (LarapayException $e) {
    // handle error
}

// Save token for later verification
$token = $result['token'];
$fee = $result['fee'];
```

**Response:**

KeyTypeDescription`token`stringGateway token to use in redirect/verify`fee`intTransaction fee in Rials### 2. Redirect to Gateway | هدایت به درگاه

[](#2-redirect-to-gateway--هدایت-به-درگاه)

```
try {
    return Larapay::gateway($gateway, $config)
        ->redirect(id: $id, token: $token, callbackUrl: $callbackUrl);
} catch (LarapayException $e) {
    // handle error
}
```

This returns a redirect response (either a `RedirectResponse` to the gateway or a form view).

### 3. Verify Payment | تأیید پرداخت

[](#3-verify-payment--تأیید-پرداخت)

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

try {
    $result = Larapay::gateway($gateway, $config)
        ->verify(
            id: $id,
            amount: $amount,
            nationalId: $nationalId,
            mobile: $mobile,
            token: $token,
            params: $params,
        );
} catch (LarapayException $e) {
    // Transaction failed
}

// Transaction successful
$result['result'];       // Status message
$result['reference_id']; // Gateway reference ID
$result['tracking_code'];// Tracking code
$result['card'];         // Masked card number
$result['fee'];          // Transaction fee
```

**Response:**

KeyTypeDescription`result`stringStatus message from gateway`reference_id`string|nullGateway reference number (شناسه پیگیری)`tracking_code`string|nullTransaction tracking code (شماره تراکنش)`card`string|nullMasked card number (شماره کارت)`fee`intTransaction fee in Rials---

### Complete Controller Example | مثال کامل کنترلر

[](#complete-controller-example--مثال-کامل-کنترلر)

```
