PHPackages                             rfmhb2/zarinpal - 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. rfmhb2/zarinpal

ActiveLibrary[Payment Processing](/categories/payments)

rfmhb2/zarinpal
===============

Official Zarinpal payment gateway library for PHP

v1.4.7(1mo ago)07↓75%MITPHPPHP ^8.2

Since Jul 1Pushed 1mo agoCompare

[ Source](https://github.com/rfmhb2/zarinpal-composer-library)[ Packagist](https://packagist.org/packages/rfmhb2/zarinpal)[ RSS](/packages/rfmhb2-zarinpal/feed)WikiDiscussions master Synced 1w ago

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

zarinpal-composer-library
=========================

[](#zarinpal-composer-library)

[![Build Status](https://camo.githubusercontent.com/a117bacdc3fd36c77eec1d6942cc79adc79e70da482aa4e397d9e7d990e6171f/68747470733a2f2f7472617669732d63692e6f72672f52544c65722f7a6172696e70616c2d636f6d706f7365722d6c6962726172792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/RTLer/zarinpal-composer-library)[![StyleCI](https://camo.githubusercontent.com/cfca5f09ce414eca9858a00513d7806e5e41c8307b334c002e346be2131b8cc7/68747470733a2f2f7374796c6563692e696f2f7265706f732f33373933373238302f736869656c64)](https://styleci.io/repos/37937280)[![Coverage Status](https://camo.githubusercontent.com/ae733632fd460a35786edf065a2ef388f8a30f5619fd5f83a6c97aa86dccc555/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f52544c65722f7a6172696e70616c2d636f6d706f7365722d6c6962726172792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/RTLer/zarinpal-composer-library?branch=master)

transaction request library for zarinpal

usage
-----

[](#usage)

### installation

[](#installation)

`composer require zarinpal/zarinpal`

### request

[](#request)

```
use Zarinpal\Zarinpal;

$zarinpal = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');
$zarinpal->enableSandbox(); // active sandbox mod for test env
// $zarinpal->isZarinGate(); // active zarinGate mode
$results = $zarinpal->request(
    "example.com/testVerify.php",          //required
    1000,                                  //required
    'testing',                             //required
    'me@example.com',                      //optional
    '09000000000',                         //optional
    [                          //optional
        "Wages" => [
            "zp.1.1"'=> [
                "Amount"'=> 120,
                "Description"'=> "part 1"
            ],
            "zp.2.5"'=> [
                "Amount"'=> 60,
                "Description"'=> "part 2"
            ]
        ]
    ]
);
echo json_encode($results);
if (isset($results['Authority'])) {
    file_put_contents('Authority', $results['Authority']);
    $zarinpal->redirect();
}
//it will redirect to zarinpal to do the transaction or fail and just echo the errors.
//$results['Authority'] must save somewhere to do the verification
```

### verify

[](#verify)

```
use Zarinpal\Zarinpal;

$zarinpal = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');
$authority = file_get_contents('Authority');
echo json_encode($zarinpal->verify('OK', 1000, $authority));
//'Status'(index) going to be 'success', 'error' or 'canceled'
```

laravel ready
-------------

[](#laravel-ready)

this package is going to work with all kinds of projects, but for laravel i add provider to make it as easy as possible. just add **(if you are using laravel 5.5 or higher skip this one)**:

```
'providers' => [
    ...
    Zarinpal\Laravel\ZarinpalServiceProvider::class
    ...
]
```

to providers list in "config/app.php". then add this to `config/services.php`

```
'zarinpal' => [
    'merchantID' => 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
    'zarinGate' => false,
    'sandbox' => false,
],
```

and you are good to go (legacy config still works) now you can access the zarinpal lib like this:

```
use Zarinpal\Laravel\Facade\Zarinpal;

$results = Zarinpal::request(
    "example.com/testVerify.php",          //required
    1000,                                  //required
    'testing',                             //required
    'me@example.com',                      //optional
    '09000000000',                         //optional
    [                          //optional
        "Wages" => [
            "zp.1.1" => [
                "Amount" => 120,
                "Description" => "part 1"
            ],
            "zp.2.5" => [
                "Amount" => 60,
                "Description" => "part 2"
            ]
        ]
    ]
);
// save $results['Authority'] for verifying step
Zarinpal::redirect(); // redirect user to zarinpal

// after that verify transaction by that $results['Authority']
Zarinpal::verify('OK',1000,$results['Authority']);
```

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance91

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 81.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 ~192 days

Recently: every ~2 days

Total

22

Last Release

41d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e3ff18b53b9cae8fe02f2d3b66a47c35cb4d025cda1b8bffcc9601651a743db5?d=identicon)[rfmhb2](/maintainers/rfmhb2)

---

Top Contributors

[![hoomanna](https://avatars.githubusercontent.com/u/5413073?v=4)](https://github.com/hoomanna "hoomanna (63 commits)")[![rfmhb2](https://avatars.githubusercontent.com/u/16733920?v=4)](https://github.com/rfmhb2 "rfmhb2 (9 commits)")[![amiri27](https://avatars.githubusercontent.com/u/1594140?v=4)](https://github.com/amiri27 "amiri27 (2 commits)")[![majidgolshadi](https://avatars.githubusercontent.com/u/5164297?v=4)](https://github.com/majidgolshadi "majidgolshadi (1 commits)")[![thisismzm](https://avatars.githubusercontent.com/u/12869372?v=4)](https://github.com/thisismzm "thisismzm (1 commits)")[![zartosht](https://avatars.githubusercontent.com/u/6488633?v=4)](https://github.com/zartosht "zartosht (1 commits)")

---

Tags

phplaravelpaymentgatewayiranzarinpal

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rfmhb2-zarinpal/health.svg)

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

###  Alternatives

[shetabit/multipay

PHP Payment Gateway Integration Package

299382.6k4](/packages/shetabit-multipay)[larabook/gateway

A Laravel package for connecting to all Iraninan payment gateways

24454.5k](/packages/larabook-gateway)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4954.1k](/packages/sebdesign-laravel-viva-payments)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.3k](/packages/omalizadeh-laravel-multi-payment)[dena-a/iran-payment

a Laravel package to handle Internet Payment Gateways for Iran Banking System

312.4k1](/packages/dena-a-iran-payment)

PHPackages © 2026

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