How To Integrate ICICI EazyPay Payment Gateway In Website Using PHP
What Is ICICI EazyPay?
ICICI Bank EazyPay Provided secure payment in India. It enables to collect money from customers through multiple payment modes.
Before start to integration of ICICI EazyPay Payment Geteway You Need To Follow Bellow
Flow Structure For Merchant.
- Enterpriser have to registered in EazyPay as Category “PG”
- Enterpriser have to registered with Payment Modes opted by their Customers, on registered EazyPay generates the merchant unique KEY for transactions.
- Enterpriser have to share the URL on which the redirection will done for the transaction initiated from EazyPay .
- Enterpriser of required data fields beside Mandatory fields.
- Unique EazyPay Merchant ID will be generated after Checker Approval.
- Payments through EazyPay will be enabled only for Approved
Enterpriser. - Any Modification to Enterpriser in the registration after Approval, New Unique Key will be Generated
After completing this process you will get the EazyPay
Merchant ID and 16 digit Unique Key for Encryption and confirmation of the return URL and They also Provide Documentation PDF with JAVA/.NET/PHP Source code (functions) based on the technology for encrypting the request URL.
Copy the bellow code for
Encryption of data and create a
Encrypted production URL using PHP
<?php
class Eazypay
{
public $merchant_id;
public $encryption_key;
public $sub_merchant_id;
public $reference_no;
public $paymode;
public $return_url;
const DEFAULT_BASE_URL = 'https://eazypay.icicibank.com/EazyPG?';
public function __construct()
{
$this->merchant_id = 'Merchant Id';
$this->encryption_key = 'AES KEY';
$this->sub_merchant_id = 'Merchant Id';
$this->merchant_reference_no = 'Reference Number';
$this->paymode = '9';
$this->return_url = 'Return Url';
}
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);
return $paymentUrl;
// return redirect()->to($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($str)
{
$block = @mcrypt_get_block_size('rijndael_128', 'ecb');
$pad = $block - (strlen($str) % $block);
$str .= str_repeat(chr($pad), $pad);
return base64_encode(@mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->encryption_key, $str, MCRYPT_MODE_ECB));
}
}
// call The method
$base=new Eazypay();
$url=$base->getPaymentUrl($amount, $reference_no, $optionalField=null);
Save above code in single file and pass the required value, Like amount reference number etc.
Before Encryption EX.
https://eazypay.icicibank.com/EazyPG?merchantid=100011&mandatory fields=8001|1234|80| 90002450001&optional fields=20|20|20|20&returnurl= http://abc.com/cbc/action.aspx&Reference No=8001&submerchantid=1234&transaction amount=80&paymode=9
After Encryption EX.
https://eazypay.icicibank.com/EazyPG?merchantid=100011&mandatory fields=u65A+ywICIypfrJVQp9ED2VlkBzkIimiHhLXPyo2P14=&optional fields=faJ6BJUlOqjoV/AEbw5X4g==&returnurl=6WvzNalyXvqOX+aY9ee5oKm8FT+YUF5sz940o6QZvx0=&Refe rence No=X7VX+1ZnKq+o6K2QWCTERQ==&submerchantid=QVZkBomDLSbitS4C9lGaUA==&transaction amount=aTRTaIdS0sLyzGCxL3Y5dQ==&paymode=nFRjDWSCg0m80aUYivDlqw==
Payment Page

NOTE:
- Read the documentation provided by the ICICI EazyPay Payment gateway provider and follow the step accordingly.
- For the testing the URL you have to pass the value to the bank using live server.
If any help needed to with ICICI EazyPay Payment Getway integration contact us or comment bellow.
Very Good Information
I have integrate payment gateway.how can i get payer name and email id from my form to your actual payment page as parameter.
I dont know how to implement eazypay payment gateway for my website. I have merchant id, key, plain and encrypted URl
This code returns blank page whenever im running the script
Kindly guide
Any help really appreciated..
Use last $url parameter as your payment link
Use echo
Dear Tushar I need your help in implementing icici eazypay payment gateway for one of my work. Please help me contact me on my mobile 9900165069 or mail me please. regards Mahadev Prasad
please provide success page code
How the $return_url is going to catch the response? Whether POST or GET and how to implement the the code for getting the response parameters?
It’s Basically POST But you can use REQUEST as well
I dont know how to implement eazypay payment gateway for my website. I have merchant id, key,
please follow the step as mention in post
when we integrate the eazypay payment gateway then we have get some error as like “Your Session has expired”
Send us you code file if you can mail-id: itinfotech.in@gmail.com
same error shows me
Can I send you code
Please help me
hi, i need your help in integrating this icici payment gateway to my word press site. can u help i am a noob.
Let me know where you stuck.
i dont know how to integrate icici eazypay as payment gateway in E-Commerce site using nopcommerce 3.80 version
Do you want to integrate in word-press?
Hello admin and Tushar, what options do you have to integrate with the WordPress. Could you please let us know on our phone91- 9736010699
Doing custom coding you can integrate payment gateway in WordPress
I am using PHP Version 7.3.3 in XAMPP and as well as Live Server.
I am getting errors for mcrypt_get_block_size, mcrypt_encrypt. Can you help me in this?
Thanks in advance
yes you can use openssl_encrypt($msg, ‘aes-128-ecb’, $key, OPENSSL_RAW_DATA) if your using php>7.0.0
mail us if you find any difficulty
in my case it gives an error: Could not resolve host: eazypay.icicibank.com; Unknown error
I’m using PHP 7.2 so I cannot use mcrypt. Is there any other way? I need to integrate this in Woocommerce
It’s the best time to make some plans for the longer term and it is time to be happy.
I have learn this post and if I may I want to counsel you some interesting things or advice.
Maybe you can write next articles relating to this article.
I want to read more things about it!
very good code. can you please tell me for wordpress website integrate ICICI EazyPay.
I need to integrate ICICI eazypay on Woocommerce over WordPress. As I’m using PHP 7.2 I can no longer use mcrypt() for encryption. What do I have to do to implement something like OpenSSL? I’m already using CCAvenue on the site and I can’t lose that.
Yes you can use openssl_encrypt if your using php>7.0.0
I’ve integrated the PG URLs in my ERP web app. Can I use the same to create a payment option on the front end website (that is no way related to the ERP)? Or should I ask for another URL from ICICI?
What is Reference Number in icici eazypay payment gateway?
Reference number is a unique number which you can generate using php’s rand() function. Note: Number should be of following length (Min 1 and Max 30 as per eazypay documentation kit) .
I need to integrate ICICI eazypay in the android app.
why you not try web view in your android app for payment section
I need to get response ICICI eazypay in the codeigniter
Full api documentation needed
Hello ICICI Eazypay Team ,
I am intregrating ICICI Eazypay PG , Could you please suggest Why I am getting “Your Session has expired” Error again and again.
once we got the response how to decrypt and store into database
once we got the response how to dcrypt and store the fields data into database
What is sub merchant id in icici eazypay
Hi,
I have integrated the easy payment gateway as per your code. It’s showing a blank page and The URL is showing(echo $url). Can you help me out…8892840982
when I redirect to eazypay.icici.com for payment from my application is takes a lots of time. Is this the problem with eazypay or I am doing something wrong with my integration.
I need a simple form to enter name, amount etc and redirect to payment page, how can I send my form submitted data to this code and generate the url
Always showing session payout page even if we pass correct arguments with encryption
how ? where code are paste in woo-commerce plugin
This code is not for woocommerce. you need customize the woocommerce plugin as per above code
Hi Admin & Tushar,
A simple and straight forward question:
can i integrate EazyPay with above PHP code which is provided by you and with EazyPay
Merchant ID and 16 digit Unique Key for Encryption with my website. It is built in Wix platform?
If yes, How ?
Your help will be appreciated.
Not sure! Haven’t try yet. If you find code please share with other developer too. thanks
ICICI PG (Testing Page)
Hello Customer,
Please Transfer for Amount ₹ 1.00/-
<a href="https://eazypay.icicibank.com/EazyPG?merchantid=&mandatory fields=&optional fields=&returnurl=&Reference No=&submerchantid=&transaction amount=&paymode=”>Pay
Pay Link (Before Encryption):https://eazypay.icicibank.com/EazyPG?merchantid=&mandatory fields=&optional fields=&returnurl=&Reference No=&submerchantid=&transaction amount=&paymode=
Pay Link (After Encryption):https://eazypay.icicibank.com/EazyPG?merchantid=&mandatory fields=&optional fields=&returnurl=&Reference No=&submerchantid=&transaction amount=&paymode=
Sir in above code i uable to encrypt my url so kindly let me know how i can integrate it
Which php version your using
If you need help please mail us
Thanks for the great article.
How to get the response of the $return_url when they cancel a payment?
For now, even if I have done the payment successfully or if I click on the cancel button, I’m getting redirected to the same file and the file content is displayed.
I want to show a different message if a user clicks on Cancel. Can someone please help?
Thanks in advance.
Thanks for reaching out to me on mail.
I was getting a 301 response code after payment because of my domain settings.
I’m using Plesk for hosting and I had to change the domain settings from http://www.domainname.com to domainname.com.
Changing the domain settings solved the issue for me. Hope it helps someone as well.