Eazypay icici bank payment gateway

people

Aneh Thakur

. 3 min read

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.

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

Before encryption:-

https://eazypay.icicibank.com/EazyPG?merchantid=100011&mandatory fields=8001|1234|80| 9000000001&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:-

https://eazypay.icicibank.com/EazyPG?merchantid=100011&mandatory fields=u65A+ywICIypfrJVQp9ED2VlkBzkIimiHhLXPyo2P14=&optional fields=faJ6BJUlOqjoV/AEbw5X4g==&returnurl=6WvzNalyXvqOX+aY9ee5oKm8FT+YUF5sz940o6QZvx0=&Reference No=X7VX+1ZnKq+o6K2QWCTERQ==&submerchantid=QVZkBomDLSbitS4C9lGaUA==&transaction amount=aTRTaIdS0sLyzGCxL3Y5dQ==&paymode=nFRjDWSCg0m80aUYivDlqw==

You can use below function to encrypt your data and set that encrypted data in your URL.

plaintext
private function aes128Encrypt($str, $key){
	$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, $key, $str, MCRYPT_MODE_ECB));
}

You use the below code to generate a link.

plaintext
<?php 
   $default_url = "https://eazypay.icicibank.com/EazyPG?"; 
   $merchant_id = KEY_IN_MAIL; 
   $encryption_key = KEY_IN_MAIL; 
   $sub_merchant_id = 15; 
   $merchant_reference_no = KEY_IN_MAIL; 
   $paymode = 9; 
   $return_url = $return; 
   $amount = 10; 
   $reference_no = rand(); 
   $optionalField = null; 
   $encrypt_value = $reference_no.'|'.$sub_merchant_id.'|'.$amount;

   $mandatoryField = $this->aes128Encrypt($encrypt_value, $encryption_key);
   $optionalField    =   $this->aes128Encrypt($optionalField, $encryption_key);
   $amount           =	  $this->aes128Encrypt($amount, $encryption_key);
   $reference_no     =   $this->aes128Encrypt($reference_no, $encryption_key);
   $return_url       =   $this->aes128Encrypt($return_url, $encryption_key);
   $sub_merchant_id  =   $this->aes128Encrypt($sub_merchant_id, $encryption_key);
   $paymode          =   $this->aes128Encrypt($paymode, $encryption_key);

   $url = $default_url."merchantid=".$merchant_id."&mandatory fields=".$mandatoryField."&optional fields=".$optionalField."&returnurl=".$return_url."&Reference No=".$reference_no."&submerchantid=".$sub_merchant_id."&transaction amount=".$amount."&paymode=".$paymode;   

Or if you like OOPS you can use this class.

Eazypay ICICI

plaintext
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              =    'KEY_MAIL';
        $this->encryption_key           =    'KEY_MAIL';
        $this->sub_merchant_id          =    'KEY_MAIL';
        $this->merchant_reference_no    =    'KEY_MAIL';
        $this->paymode                  =    '9';
        $this->return_url               =    'YOUR_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));
    }
    
}

And after adding this class you can call this

plaintext
  $amount = 11;
  $reference_no = rand();
  // call The method
  $base=new Eazypay();
  $url=$base->getPaymentUrl($amount, $reference_no, $optionalField=null);

Once you have URL now you can perform click action on your URL and redirect it to Eazypay ICICI website using the below code.

plaintext
<h4>Redirecting</h4>
<a id="redirect" href="&lt;?=$url?&gt;">If not redirect click here.</a>

<script>
document.getElementById("redirect").click();
</script>
Image

Hope you like this post please don’t forget to subscribe my youtube channel link on top of the page.

More Stories from

Aneh Thakur
Aneh Thakur.4 min read

React Native 0.78 Unveiled: New Features, Changes, and Benefits You’ll Love 🚀

Discover React Native 0.78! From React 19 support to Android vector drawables and better iOS integration, explore the latest features, changes, and benefits with examples to make app development faster and smoother. 🌟

.
Aneh Thakur
Aneh Thakur.4 min read

🚀 Encore.ts: Blazing Fast Backend Powerhouse – 9x Faster Than Express.js & 3x Faster Than Bun + Zod

Discover why Encore.ts outshines Express.js and Bun + Zod with 9x and 3x faster performance, respectively. Explore sample code, speed benchmarks, and see how this TypeScript framework redefines backend efficiency! ⚡

Aneh Thakur
Aneh Thakur.4 min read

Trump Unveils U.S. Crypto Strategic Reserve: Bitcoin and Altcoins Surge

Donald Trump announces a U.S. Crypto Strategic Reserve featuring Bitcoin, Ethereum, XRP, Solana, and Cardano, sparking a $300B market rally. Explore the implications and trends as of March 3, 2025.

.
Aneh Thakur
Aneh Thakur.4 min read

Prototype Your Idea in Under an Hour Using AI

Learn to create working prototypes in under an hour using AI tools like Claude and Bolt. Ideal for designers and entrepreneurs with minimal coding skills.

Aneh Thakur
Aneh Thakur.3 min read

How X’s New Grok AI Tools Make Ad Creation and Analysis a Breeze

Discover X’s latest AI-powered features—Prefill with Grok and Analyze Campaign with Grok. Learn how these tools simplify ad creation, boost campaign performance, and help advertisers save time in 2025.

Built on Koows