2017 © Pedro Peláez
 

yii2-extension zarinpal

Online Zarinpal Payment Extension For Yii2

image

amirasaran/zarinpal

Online Zarinpal Payment Extension For Yii2

  • Friday, September 1, 2017
  • by amirasaran
  • Repository
  • 1 Watchers
  • 7 Stars
  • 162 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 8 Versions
  • 13 % Grown

The README.md

ZarinPal Payment

Online Zarinpal Payment Extension For Yii2, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require amirasaran/zarinpal:"*"

or add, (*4)

"amirasaran/zarinpal": "*"

to the require section of your composer.json file., (*5)

How to config payment component

Add the following code to your common/config/main.php components, (*6)

    '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

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., (*7)

you need to use an storage to save your payments and payments status., (*8)

PaymentController.php, (*9)

..... 

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

.....

The Versions

01/09 2017

dev-master

9999999-dev

Online Zarinpal Payment Extension For Yii2

  Sources   Download

GPL-3.0+

The Requires

 

payment online persian iran zarinpal

01/09 2017

2.0.1

2.0.1.0

Online Zarinpal Payment Extension For Yii2

  Sources   Download

GPL-3.0+

The Requires

 

payment online persian iran zarinpal

16/09 2016

dev-analysis-zDDPwl

dev-analysis-zDDPwl

Online Zarinpal Payment Extension For Yii2

  Sources   Download

GPL-3.0+

The Requires

 

payment online persian iran zarinpal

16/09 2016

2.0.0

2.0.0.0

Online Zarinpal Payment Extension For Yii2

  Sources   Download

GPL-3.0+

The Requires

 

payment online persian iran zarinpal

09/08 2015

1.0.1

1.0.1.0

Online Payment Extension For Zarinpal

  Sources   Download

GPL-3.0+

The Requires

 

payment online persian iran zarinpal

29/07 2015

v0.1.0

0.1.0.0

Online Payment Extension For Zarinpal

  Sources   Download

GPL-3.0+

The Requires

 

payment online persian iran zarinpal

29/07 2015

v1.0.0

1.0.0.0

Online Payment Extension For Zarinpal

  Sources   Download

GPL-3.0+

The Requires

 

payment online persian iran zarinpal

29/07 2015

dev-AmirMohsen

dev-AmirMohsen

Online Payment Extension For Zarinpal

  Sources   Download

GPL-3.0+

The Requires

 

payment online persian iran zarinpal