Codeigniter library for Iranian getway, Zarinpal
Codeigniter library for Iranian gateway, Zarinpal
Copy Zarinpal.php
and nusoap
directory to application/libraries
of your own project.
First, load library:
$this->load->library('zarinpal');
For sending user to gateway:
$this->zarinpal->webgate($merchant_id , $amount, $desc, $call_back, $mobile, $email);
$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
}
For test for script, you can turn on sandbox mode:
$this->zarinpal->sandbox();