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

eazypay-icicibank-EazyPG Itinfotech.in
eazypay-icicibank-EazyPG

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.

53 Comments

Add a Comment

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