In this tutorial, I will explain to you how we can integrate ICICI bank Eazypay payment gateway into our PHP web application. Eazypay payment gateway is created by ICICI bank which helps you to pay your bills conveniently, be it your education, housing society maintenance or any other bills. You can pay your bills using Cash Deposit, Cheque Deposit, RTGS, NEFT, Net Banking or Cards.
Prerequisites
You need to have EazyPay Account before integration in your web application.
Once you have successfully registered your account on Eazypay you will get your account detail via your registration email address. You need to encrypt your data with a key that they provide you in email and open that link in your browser. Now you need to pass some required parameter in URL to open eazypay payment gateway.
Add in custom templete or elementor html code
Add in header.php (child theme)
';
$amount = $_POST['payeramount'];
//echo $amount.'xyx';
include 'payment.php';
// echo '';
$reference_no = rand();
// $reference_no = 123676456;
// echo $reference_no. ' xyx';
// echo '';
// call The method
$eazypay_integration=new Eazypay();
$payment_url=$eazypay_integration->getPaymentUrl($amount, $reference_no , $optionalField=null);
// print_r($payment_url);
// header('Location: '.$payment_url);
wp_redirect( $payment_url );
exit;
}
?>
Make the payment.php file and add in root folder
Here is a list of the parameter which is required when we request for payment.
Parameter | Description | Mandatory |
Default URL | https://eazypay.icicibank.com/EazyPG? | Yes |
Merchant ID | 100011 | Yes |
Merchant Reference No | Yes | |
Reference No | 8001 | Yes |
Sub Merchant Id | 1234 | Yes |
Transaction Amount | 80 | Yes |
Encryption key | Yes | |
Paymode | 9 | Yes |
Return URL | Yes | |
Optional Field | No |
Add in html.php
merchant_id = xx;
$this->encryption_key = xx;
$this->sub_merchant_id = xx;
$this->paymode = xx;
$this->return_url = 'https://yourwebsitw.in/thank-you';
}
public function getPaymentUrl($amount, $reference_no, $optionalField=null)
{
$mandatoryField = $this->getMandatoryField($amount, $reference_no);
$optionalField = $this->getOptionalField($optionalField);
$amount = $this->getAmount($amount);
$reference_no = $this->getReferenceNo($reference_no);
$paymentUrl = $this->generatePaymentUrl($mandatoryField, $optionalField, $amount, $reference_no);
// echo $paymentUrl;
return $paymentUrl;
}
protected function generatePaymentUrl($mandatoryField, $optionalField, $amount, $reference_no)
{
$encryptedUrl = self::DEFAULT_BASE_URL."merchantid=".$this->merchant_id.
"&mandatory fields=".$mandatoryField."&optional fields=".$optionalField.
"&returnurl=".$this->getReturnUrl()."&Reference No=".$reference_no.
"&submerchantid=".$this->getSubMerchantId()."&transaction amount=".
$amount."&paymode=".$this->getPaymode();
return $encryptedUrl;
}
protected function getMandatoryField($amount, $reference_no)
{
return $this->getEncryptValue($reference_no.'|'.$this->sub_merchant_id.'|'.$amount);
}
// optional field must be seperated with | eg. (20|20|20|20)
protected function getOptionalField($optionalField=null)
{
if (!is_null($optionalField)) {
return $this->getEncryptValue($optionalField);
}
return null;
}
protected function getAmount($amount)
{
return $this->getEncryptValue($amount);
}
protected function getReturnUrl()
{
return $this->getEncryptValue($this->return_url);
}
protected function getReferenceNo($reference_no)
{
return $this->getEncryptValue($reference_no);
}
protected function getSubMerchantId()
{
return $this->getEncryptValue($this->sub_merchant_id);
}
protected function getPaymode()
{
return $this->getEncryptValue($this->paymode);
}
// use @ to avoid php warning php
protected function getEncryptValue($data)
{
// Generate an initialization vector
// $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
// Encrypt the data using AES 128 encryption in ecb mode using our encryption key and initialization vector.
$encrypted = openssl_encrypt($data, 'aes-128-ecb', $this->encryption_key, OPENSSL_RAW_DATA);
// The $iv is just as important as the key for decrypting, so save it with our encrypted data using a unique separator (::)
return base64_encode($encrypted);
}
}
Hope you like this post. Do you have any question so please contact us.
0/5
(0 Reviews)