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

ActiveYii2-extension[Payment Processing](/categories/payments)

mjm/zarinpal
============

Online Zarinpal Payment Extension For Yii2

0.0.0(9y ago)254GPL-3.0+PHP

Since Oct 2Pushed 9y ago1 watchersCompare

[ Source](https://github.com/2012mjm/yii2-zarinpal)[ Packagist](https://packagist.org/packages/mjm/zarinpal)[ RSS](/packages/mjm-zarinpal/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

ZarinPal Payment
================

[](#zarinpal-payment)

Online Zarinpal Payment Extension For Yii2

Installation
============

[](#installation)

The preferred way to install this extension is through composer.

Either run

```
php composer.phar require mjm/zarinpal:"*"

```

or add

```
"mjm/zarinpal": "*"

```

to the require section of your `composer.json` file.

How to config payment component
===============================

[](#how-to-config-payment-component)

Add the following code to your `config/web.php` `components`

```
    'components' => [
         ....
        'zarinpal' => [
            'class' => 'mjm\zarinpal\Zarinpal',
            'merchant_id' => 'XXXXXXX-XXX-XXXX-XXXXXXXXXXXX',
            'callback_url' => 'http://site.com/payment/verify'
        ],
        ....
    ]

```

How to use this component
=========================

[](#how-to-use-this-component)

For example, imagine that you have a controller called this PaymentController at first you need 2 actions, one of them is for request payment and another is verify payment.

you need to use an storage to save your payments and payments status.

`PaymentController.php`

```
.....

public function actionRequest()
{
    /** @var Zarinpal $zarinpal */
    $zarinpal = Yii::$app->zarinpal ;

    // Change callback url (optional)
    $zarinpal->callback_url = Url::to(['verify', 'id'=>123], true);

    if($zarinpal->request(100,'Test Payment description')->getStatus() == '100'){
        /*
        * You can save your payment request data to the database in here before rediract user
        * to get authority code you can use $zarinpal->getAuthority()
        */
        return $this->redirect($zarinpal->getRedirectUrl());
    }
    echo "Error !";
}

public function actionVerify($Authority, $Status){

    if($Status != "OK")
        return ; //Payment canceled by user

    /** @var Zarinpal $zarinpal */
    $zarinpal = Yii::$app->zarinpal ;

    if($zarinpal->verify($Authority, 100)->getStatus() == '100'){
        //User payment successfully verified!
        echo "payment successfully with referrer code: ".$zarinpal->getRefID();
    }
    elseif($zarinpal->getStatus() == '101') {
        //User payment successfuly verified but user try to verified more than one
        echo  "duplicated verify payment";
    }
    else
        echo "payment error !";
}

.....

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3506d ago

### Community

Maintainers

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

---

Top Contributors

[![2012mjm](https://avatars.githubusercontent.com/u/3141834?v=4)](https://github.com/2012mjm "2012mjm (1 commits)")

---

Tags

paymentiranpersianzarinpalonline

### Embed Badge

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

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

###  Alternatives

[amirasaran/zarinpal

Online Zarinpal Payment Extension For Yii2

131.9k](/packages/amirasaran-zarinpal)[larabook/gateway

A Laravel package for connecting to all Iraninan payment gateways

24553.7k](/packages/larabook-gateway)[parsisolution/gateway

A Laravel package for connecting to all Iraninan payment gateways

231.7k](/packages/parsisolution-gateway)

PHPackages © 2026

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