PHPackages                             larapardakht/larapardakht - 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. larapardakht/larapardakht

ActiveLibrary[Payment Processing](/categories/payments)

larapardakht/larapardakht
=========================

A modern, extensible payment gateway integration package for Laravel supporting Iranian payment providers.

V1.1.2(1mo ago)014MITPHPPHP ^8.3|^8.4

Since Feb 16Pushed 1mo agoCompare

[ Source](https://github.com/TheXERC/LaraPardakht)[ Packagist](https://packagist.org/packages/larapardakht/larapardakht)[ RSS](/packages/larapardakht-larapardakht/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (10)Versions (6)Used By (0)

LaraPardakht
============

[](#larapardakht)

A modern, extensible payment gateway integration package for Laravel 11, 12, and 13, supporting Iranian payment providers.

Features
--------

[](#features)

- **Driver-based architecture** — easily add new gateways without modifying core code
- **Fluent API** — clean, chainable interface for purchases, payments and verifications
- **Sandbox/test support** — every driver supports sandbox mode out of the box
- **Events** — fires events after purchase and verification for easy integration
- **Runtime configuration** — switch drivers and override settings on the fly
- **Typed exceptions** — distinct exception classes for different failure scenarios
- **Security first** — SSL/TLS verification, URL validation, input sanitization included

Supported Gateways
------------------

[](#supported-gateways)

GatewayNormal ModeSandbox Mode[Zarinpal](https://www.zarinpal.com/)✅✅[Zibal](https://zibal.ir/)✅✅More gateways coming soon! You can also [create custom drivers](#creating-custom-drivers).

Requirements
------------

[](#requirements)

- PHP 8.3 or 8.4
- Laravel 11, 12, or 13

Installation
------------

[](#installation)

```
composer require larapardakht/larapardakht
```

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --tag=larapardakht-config
```

This will create `config/larapardakht.php` in your application.

Configuration
-------------

[](#configuration)

Set your gateway credentials in `.env`:

```
PAYMENT_GATEWAY=zarinpal

# Zarinpal
ZARINPAL_MERCHANT_ID=your-merchant-id-here
ZARINPAL_SANDBOX=false

# Zibal
ZIBAL_MERCHANT=your-zibal-merchant
ZIBAL_SANDBOX=false

# Shared
PAYMENT_CALLBACK_URL=https://yoursite.com/payment/callback

# Optional: global max amount in Rials (leave empty to disable cap)
PAYMENT_MAX_AMOUNT=
```

Usage
-----

[](#usage)

### Purchase &amp; Redirect

[](#purchase--redirect)

```
use LaraPardakht\Facades\Payment;
use LaraPardakht\DTOs\Invoice;

$invoice = new Invoice();
$invoice->amount(50000)
    ->description('Order #123')
    ->detail('mobile', '09121234567')
    ->detail('email', 'customer@example.com');

return Payment::purchase($invoice, function ($driver, $transactionId) {
    // Store $transactionId in your database
    Order::find($orderId)->update(['transaction_id' => $transactionId]);
})->pay()->render();
```

### Verify Payment

[](#verify-payment)

```
use LaraPardakht\Facades\Payment;
use LaraPardakht\Exceptions\InvalidPaymentException;

try {
    $receipt = Payment::amount(50000)
        ->transactionId($transactionId)
        ->verify();

    // Payment was successful
    echo $receipt->getReferenceId();
    echo $receipt->getDriver();

} catch (InvalidPaymentException $e) {
    // Payment verification failed
    echo $e->getMessage();
}
```

### Switch Driver at Runtime

[](#switch-driver-at-runtime)

```
Payment::via('zibal')->purchase($invoice, function ($driver, $transactionId) {
    // ...
});
```

### Override Config at Runtime

[](#override-config-at-runtime)

```
Payment::config('merchant_id', 'another-merchant-id')->purchase($invoice);

// Or multiple values:
Payment::config([
    'merchant_id' => 'another-merchant-id',
    'sandbox' => true,
])->purchase($invoice);
```

### Override Callback URL

[](#override-callback-url)

```
Payment::callbackUrl('https://yoursite.com/custom-callback')
    ->purchase($invoice);
```

### Get JSON Redirect Data

[](#get-json-redirect-data)

```
$redirect = Payment::purchase($invoice)->pay();
return $redirect->toJson();
```

Creating Custom Drivers
-----------------------

[](#creating-custom-drivers)

### 1. Create a Gateway Class

[](#1-create-a-gateway-class)

Create a new directory under `src/Drivers/YourGateway/` and implement `GatewayInterface`:

```
