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

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

amirasaran/zarinpal
===================

Online Zarinpal Payment Extension For Yii2

2.0.2(7y ago)131.9k3GPL-3.0+PHP

Since Jul 29Pushed 7y ago1 watchersCompare

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

READMEChangelog (6)Dependencies (1)Versions (9)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 amirasaran/zarinpal:"*"

```

or add

```
"amirasaran/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 `common/config/main.php` `components`

```
    'components' => [
         ....
        'zarinpal' => [
            'class' => 'amirasaran\zarinpal\Zarinpal',
            'merchant_id' => 'XXXXXXX-XXX-XXXX-XXXXXXXXXXXX',
            'callback_url' => 'http://site.com/payment/verify',
            'testing' => true, // if you are testing zarinpal set it true, else set to false
        ],
        ....
    ]

```

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 ;
    /*
    * if you whant, you can pass $callbackParams as array to request method for additional params send to your callback url
    */
    if($zarinpal->request(100,'Test Payment description',null,null,['parameter'=>'value','parameter2'=>'value2'])->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 !";
}

/*
* $parameter and $parameter2 are optional parameter that set in request method $callbackParams
*/
public function actionVerify($Authority, $Status , $parameter , $parameter2){

    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";
    }
    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

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 57.7% 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 ~251 days

Recently: every ~314 days

Total

6

Last Release

2687d ago

Major Versions

v0.1.0 → v1.0.02015-07-29

1.0.1 → 2.0.02016-09-16

### Community

Maintainers

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

---

Top Contributors

[![amirasaran](https://avatars.githubusercontent.com/u/6253691?v=4)](https://github.com/amirasaran "amirasaran (15 commits)")[![hooman-mirghasemi](https://avatars.githubusercontent.com/u/11981070?v=4)](https://github.com/hooman-mirghasemi "hooman-mirghasemi (4 commits)")[![amiri27](https://avatars.githubusercontent.com/u/1594140?v=4)](https://github.com/amiri27 "amiri27 (3 commits)")[![itsmh](https://avatars.githubusercontent.com/u/927688?v=4)](https://github.com/itsmh "itsmh (2 commits)")[![MA7](https://avatars.githubusercontent.com/u/4957870?v=4)](https://github.com/MA7 "MA7 (2 commits)")

---

Tags

paymentiranpersianzarinpalonline

### Embed Badge

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

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

###  Alternatives

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