abolfazlahmadiweb/laravel-zarinpal

Simple Laravel package for Zarinpal payment gateway.

Maintainers

Package info

github.com/abolfazlahmadiweb/laravel-zarinpal

pkg:composer/abolfazlahmadiweb/laravel-zarinpal

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-07-09 12:50 UTC

This package is auto-updated.

Last update: 2026-07-09 13:01:24 UTC


README

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).