laravel-zarinpal maintained by abolfazlahmadiweb
Laravel Zarinpal
A simple, lightweight and clean Laravel package for integrating the Zarinpal Payment Gateway.
Features
- 🚀 Simple API
- ⚡ Laravel Auto Discovery
- 📦 Publishable configuration
- 🎯 Facade support
- 💉 Dependency Injection support
- 🧩 Laravel 12 & 13 compatible
- 🛠️ Minimal and easy to maintain
Installation
Install the package via Composer:
composer require abolfazlahmadiweb/laravel-zarinpal
Publish Configuration
Publish the configuration file:
php artisan vendor:publish --tag=zarinpal-config
Environment Variables
Add the following variables to your .env file:
ZARINPAL_MERCHANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ZARINPAL_SANDBOX=true
ZARINPAL_CURRENCY=IRT
ZARINPAL_MAX_AMOUNT=200000000
ZARINPAL_BASE_URL=https://sandbox.zarinpal.com/pg/v4/payment
Create Payment
use AbolfazlAhmadi\LaravelZarinpal\Facades\Zarinpal;
$payment = Zarinpal::request(
amount: 100000,
description: 'Order #1001',
callback: route('payment.callback'),
mobile: '09123456789',
email: 'user@example.com'
);
return redirect()->away($payment['url']);
Response:
[
"authority" => "...",
"url" => "...",
"fee" => "...",
"fee_amount" => ...
]
Verify Payment
use AbolfazlAhmadi\LaravelZarinpal\Facades\Zarinpal;
$result = Zarinpal::verify(
authority: request('Authority'),
amount: 100000
);
Response:
[
"ref_id" => "...",
"card_pan" => "...",
"fee" => "...",
"fee_type" => "..."
]
Using Dependency Injection
use AbolfazlAhmadi\LaravelZarinpal\Services\ZarinpalService;
public function __construct(
protected ZarinpalService $zarinpal
) {
}
$payment = $this->zarinpal->request(...);
Configuration
| Key | Description |
|---|---|
| merchant_id | Zarinpal Merchant ID |
| sandbox | Enable Sandbox mode |
| currency | IRT or IRR |
| max_amount | Maximum payment amount |
| base_url | Zarinpal API URL |
Requirements
- PHP 8.2+
- Laravel 12+
- Laravel 13+
License
The MIT License (MIT).