Picture of Shubham Vijay

Shubham Vijay

Top Rated Upwork Developer

I’m a freelance Wordpress developer and web designer based in India. I started freelancing in 2012 and have worked for a wide range of personal clients and agencies. I design and build WordPress websites. My goal is to do great work, for great people and organisations.

Eazypay icici bank payment gateway – WordPress custom templates

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.


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

						<div class="payment-section">
  <div class="eazypay-payment">

    <form method="post" name="paymentform">
      <label for="payername"> Name: (Required)</label><br>
      <input type="text" id="payername" name="payername" required><br>
      <label for="payerphone"> Phone Number: (Optional)</label><br>
      <input type="text" id="payerphone" name="payerphone"/><br>
      <label for="payeremail"> Email ID: (Required)</label><br>
      <input type="email" id="payeremail" name="payeremail"/><br>
      <label for="payeramount"> Amount:</label><br>
      <input type="number" min="0" id="amount" name="payeramount" required/><br><br>
      <input id="paybutton" type="submit" value="Pay Amount">

Add in header.php (child theme)


    if(isset($_POST['payeramount'])) {
   $_SESSION['payer_name'] = $_REQUEST['payername'];
    $_SESSION['payer_phone'] = $_REQUEST['payerphone'];
   $_SESSION['payer-email'] = $_REQUEST['payeremail'];
	echo '</br>';	
     $amount = $_POST['payeramount'];
		//echo $amount.'xyx';

    include 'payment.php';
	//	echo '</br>';
     $reference_no = rand();
   // $reference_no = 123676456;
  //   echo $reference_no. ' xyx';
	//	echo '</br>';
    // 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 );


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.
Default URLhttps://eazypay.icicibank.com/EazyPG?Yes
Merchant ID100011Yes
Merchant Reference NoYes
Reference No8001Yes
Sub Merchant Id1234Yes
Transaction Amount80Yes
Encryption keyYes
Return URLYes
Optional FieldNo

Add in html.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?';
    const DEFAULT_BASE_URL = 'https://eazypayuat.icicibank.com/EazyPG?';

    public function __construct()
        $this->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=".

        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)

More to explorer

Ask me if you have any question ?

Leave a Comment

Your email address will not be published. Required fields are marked *