项目作者: MahdiMajidzadeh

项目描述 :
Codeigniter library for Iranian getway, Zarinpal
高级语言: PHP
项目地址: git://github.com/MahdiMajidzadeh/CodeIgniter-Zarinpal-gateway.git


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:

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

For sending user to gateway:

  • webgate (first show zarinpal page):
    1. $this->zarinpal->webgate($merchant_id , $amount, $desc, $call_back, $mobile, $email);
  • zaringate (direct to bank page):
    1. $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:

  1. if($this->zarinpal->webgate($merchant_id , $amount, $desc, $call_back, $mobile, $email)){
  2. $authority = $this->zarinpal->getAuthority();
  3. // do database
  4. $this->zarinpal->redirect();
  5. }
  6. else{
  7. $error = $this->zarinpal->getError();
  8. }

For verify user payment:

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

Full code is:

  1. if($_GET['Status'] == 'OK'){
  2. if($this->zarinpal->verify($merchant_id , $amount, $authority)){
  3. $refid = $this->zarinpal->getRefId();
  4. // do database
  5. }
  6. else{
  7. $error = $this->zarinpal->getError();
  8. }
  9. }
  10. else{
  11. //use cancel payment
  12. }

Sandbox

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

  1. $this->zarinpal->sandbox();

Contributor