Codeigniter library for Iranian getway, Zarinpal
Clone or download
Latest commit a3f9b19 Oct 13, 2018
Permalink
Failed to load latest commit information.
nusoap Apply fixes from StyleCI Oct 16, 2017
README.md Update README.md Oct 13, 2018
Zarinpal.php Apply fixes from StyleCI Oct 16, 2017

README.md

CodeIgniter-Zarinpal-gateway

StyleCI

This library not maintained eny more

Codeigniter library for Iranian gateway, Zarinpal

how to install

Copy Zarinpal.php and nusoap directory to application/libraries of your own project.

how to use

First, load library:

$this->load->library('zarinpal');

For sending user to gateway:

  • webgate (first show zarinpal page):
$this->zarinpal->webgate($merchant_id , $amount, $desc, $call_back, $mobile, $email);
  • zaringate (direct to bank page):
$this->zarinpal->zaringate($merchant_id , $amount, $desc, $gate, $call_back, $mobile, $email);

list of gate:

Name Bank
zaringate zarinpal choose bank
asan asan pardackt
saman saman
sadad melli
parsian parsian
fanava fanava tech

Full code is:

if($this->zarinpal->webgate($merchant_id , $amount, $desc, $call_back, $mobile, $email)){
    $authority = $this->zarinpal->getAuthority();
    // do database 
    $this->zarinpal->redirect();
}
else{
    $error = $this->zarinpal->getError();
}

For verify user payment:

$this->zarinpal->verify($merchant_id , $amount, $authority);

Full code is:

if($_GET['Status'] == 'OK'){
    if($this->zarinpal->verify($merchant_id , $amount, $authority)){
        $refid = $this->zarinpal->getRefId();
        // do database 
    }
    else{
        $error = $this->zarinpal->getError();
    }
}
else{
    //use cancel payment
}

Sandbox

For test for script, you can turn on sandbox mode:

$this->zarinpal->sandbox();

Contributor