How to Integrate icici eazypay payment gateway using PHP

How to Integrate ICICI EazyPay payment gateway using PHP

Hey everyone!
Today, I’m going to explain How to Integrate icici eazypay payment gateway in PHP. This is a great way for businesses and organizations looking for an easier payment solution that can be integrated quickly and easily.

First of all, you need to register with ICICI Eazypay in order to get your Merchant details. Next, you will use the eazypay built-in encryption function of all parameters – this ensures that all payments are securely processed through their system. Once everything is set up correctly on the backend side of things, customers will be able to make payments directly from your website without having any issues or worries about security risks associated with online transactions.

To integrate eazypay payment into your website, you will need to follow these steps

Step 1: Encrypt the required parameters

Encrypting all your parameters is an important step in ensuring the security of sensitive information. Fortunately, eazypay has a built-in encryption function that makes it easy to do just that! Simply copy and paste the code provided below into your project

 public function aes128Encrypt($plaintext,$key){
        $cipher = 'aes-128-ecb';
        in_array($cipher, openssl_get_cipher_methods(true));
        $ivlen = openssl_cipher_iv_length($cipher);
        //echo ""ivlen ["". $ivlen . ""]"";
        $iv = openssl_random_pseudo_bytes(1);
        // echo ""iv ["". $iv . ""]"";
        $ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options=0, "");
        return $ciphertext;

Step 2: Process your payment

To process the payment, you’ll need to take input from the user and then serialize all of that data so you can set it as a parameter value.

public function eazypay_process() {

        try {

            $params = $this->session->userdata('params');

            $data['merchant_id']       = "YOUR MERCHANT ID";
            $data['key']               = "YOUR MERCHANT KEY";
            $data['ref_no']            = rand(10,10000);
            $data['sub_mer_id']        = "YOUR SUBMERCHANT ID";
            $data['amount']            = $this->input->post('amount');;
            $data['return_url']        = "YOUR EAZYPAY REGISTERED RETURN URL"; 
            $data['paymode']           = "9";
            $data['mandatory_fields']  = $data['ref_no'] ."|". $data['sub_mer_id'] ."|". $data['amount'];
            $data['opt_fields']        = "";

            $e_sub_merchant_id  = $this->aes128Encrypt($data['sub_mer_id'], $data['key']);
            $e_reference_no     = $this->aes128Encrypt($data['ref_no'], $data['key']);
            $e_amount           = $this->aes128Encrypt($data['amount'], $data['key']);
            $e_return_url       = $this->aes128Encrypt($data['return_url'], $data['key']);
            $e_paymode          = $this->aes128Encrypt($data['paymode'], $data['key']);
            $e_mandatory_fields = $this->aes128Encrypt($data['mandatory_fields'], $data['key']);

            $redirect_url = ''.$data['merchant_id'].'&mandatory fields='.$e_mandatory_fields.'&optional fields='.$data['opt_fields'].'&returnurl='.$e_return_url.'&Reference No='.$e_reference_no.'&submerchantid='.$e_sub_merchant_id.'&transaction amount='.$e_amount.'&paymode='.$e_paymode;

        } catch (Exception $e) {
            exit('something error !!!'); 

Step 3: Capture the response from the return URL

It’s always nice to see the response you get from a return URL! It’s an indication that your request has been processed and completed successfully. This is especially helpful when you’re dealing with sensitive information, as it can provide peace of mind knowing that everything went through without any issues.

public function index(){
        $result = $_REQUEST;
        $data_transaction = array(
        'Response_Code'=> $result['Response_Code'],
        'Unique_Ref_Number'=> $result['Unique_Ref_Number'],
        'Service_Tax_Amount'=> $result['Service_Tax_Amount'],
        'Processing_Fee_Amount'=> $result['Processing_Fee_Amount'],
        'Total_Amount'=> $result['Total_Amount'],
        'Transaction_Amount'=> $result['Transaction_Amount'],
        'Transaction_Date'=> date('Y-m-d',strtotime($result['Transaction_Date'])),
        'Interchange_Value'=> $result['Interchange_Value'],
        'TDR'=> $result['TDR'],
        'Payment_Mode'=> $result['Payment_Mode'],
        'SubMerchantId'=> $result['SubMerchantId'],
        'ReferenceNo'=> $result['ReferenceNo'],
        'ID'=> $result['ID'],
        'RS'=> $result['RS'],
        'TPS'=> $result['TPS'],
        'mandatory_fields'=> $result['mandatory_fields'],
        'optional_fields'=> $result['optional_fields'],
        'RSV'=> $result['Response_Code'],
        '_policy'=> $result['_policy'],
        'visitor'=> $result['visitor']
        $this->db->insert('transactions', $data_transaction);
        // there will show payment success and fail it we be depend on your response.

Here is a set of response codes that can be a valuable resource for handling and managing responses.

//response code
'E000' =>'"Payment Successful.', 
'E001' =>'Unauthorized Payment Mode', 
'E002' =>'Unauthorized Key', 
'E003' =>'Unauthorized Packet', 
'E004' =>'Unauthorized Merchant', 
'E005' =>'Unauthorized Return URL', 
'E006' =>'"Transaction Already Paid, Received Confirmation from the Bank, Yet to Settle the transaction with the Bank', 
'E007' =>'Transaction Failed', 
'E008' =>'Failure from Third Party due to Technical Error', 
'E009' =>'Bill Already Expired', 
'E0031' =>'Mandatory fields coming from merchant are empty', 
'E0032' =>'Mandatory fields coming from database are empty', 
'E0033' =>'Payment mode coming from merchant is empty', 
'E0034' =>'PG Reference number coming from merchant is empty', 
'E0035' =>'Sub merchant id coming from merchant is empty', 
'E0036' =>'Transaction amount coming from merchant is empty', 
'E0037' =>'Payment mode coming from merchant is other than 0 to 9', 
'E0038' =>'Transaction amount coming from merchant is more than 9 digit length', 
'E0039' =>'Mandatory value Email in wrong format', 
'E00310' =>'Mandatory value mobile number in wrong format', 
'E00311' =>'Mandatory value amount in wrong format', 
'E00312' =>'Mandatory value Pan card in wrong format', 
'E00313' =>'Mandatory value Date in wrong format', 
'E00314' =>'Mandatory value String in wrong format', 
'E00315' =>'Optional value Email in wrong format', 
'E00316' =>'Optional value mobile number in wrong format', 
'E00317' =>'Optional value amount in wrong format', 
'E00318' =>'Optional value pan card number in wrong format', 
'E00319' =>'Optional value date in wrong format', 
'E00320' =>'Optional value string in wrong format', 
'E00321' =>'Request packet mandatory columns is not equal to mandatory columns set in enrolment or optional columns are not equal to optional columns length set in enrolment', 
'E00322' =>'Reference Number Blank', 
'E00323' =>'Mandatory Columns are Blank', 
'E00324' =>'Merchant Reference Number and Mandatory Columns are Blank', 
'E00325' =>'Merchant Reference Number Duplicate', 
'E00326' =>'Sub merchant id coming from merchant is non numeric', 
'E00327' =>'Cash Challan Generated', 
'E00328' =>'Cheque Challan Generated', 
'E00329' =>'NEFT Challan Generated', 
'E00330' =>'Transaction Amount and Mandatory Transaction Amount mismatch in Request URL', 
'E00331' =>'UPI Transaction Initiated Please Accept or Reject the Transaction', 
'E00332' =>'Challan Already Generated, Please re-initiate with unique reference number', 
'E00333' =>'Referer value is null / invalid Referer', 
'E00334' =>'Value of Mandatory parameter Reference No and Request Reference No are not matched', 
'E00335' =>'Payment has been cancelled',
'E0801' =>'FAIL', 
'E0802' =>'User Dropped', 
'E0803' =>'Canceled by user', 
'E0804' =>'User Request arrived but card brand not supported', 
'E0805' =>'Checkout page rendered Card function not supported', 
'E0806' =>'Forwarded / Exceeds withdrawal amount limit', 
'E0807' =>'PG Fwd Fail / Issuer Authentication Server failure', 
'E0808' =>'Session expiry / Failed Initiate Check, Card BIN not present', 
'E0809' =>'Reversed / Expired Card', 
'E0810' =>'Unable to Authorize', 
'E0811' =>'Invalid Response Code or Guide received from Issuer', 
'E0812' =>'Do not honor', 
'E0813' =>'Invalid transaction', 
'E0814' =>'Not Matched with the entered amount', 
'E0815' =>'Not sufficient funds', 
'E0816' =>'No Match with the card number', 
'E0817' =>'General Error', 
'E0818' =>'Suspected fraud', 
'E0819' =>'User Inactive', 
'E0820' =>'ECI 1 and ECI6 Error for Debit Cards and Credit Cards', 
'E0821' =>'ECI 7 for Debit Cards and Credit Cards', 
'E0822' =>'System error. Could not process transaction', 
'E0823' =>'Invalid 3D Secure values', 
'E0824' =>'Bad Track Data', 
'E0825' =>'Transaction not permitted to cardholder', 
'E0826' =>'Rupay timeout from issuing bank', 
'E0827' =>'OCEAN for Debit Cards and Credit Cards', 
'E0828' =>'E-commerce decline', 
'E0829' =>'This transaction is already in process or already processed', 
'E0830' =>'Issuer or switch is inoperative', 
'E0831' =>'Exceeds withdrawal frequency limit', 
'E0832' =>'Restricted card', 
'E0833' =>'Lost card', 
'E0834' =>'Communication Error with NPCI', 
'E0835' =>'The order already exists in the database', 
'E0836' =>'General Error Rejected by NPCI', 
'E0837' =>'Invalid credit card number', 
'E0838' =>'Invalid amount', 
'E0839' =>'Duplicate Data Posted', 
'E0840' =>'Format error', 
'E0841' =>'SYSTEM ERROR', 
'E0842' =>'Invalid expiration date', 
'E0843' =>'Session expired for this transaction', 
'E0844' =>'FRAUD - Purchase limit exceeded', 
'E0845' =>'Verification decline', 
'E0846' =>'Compliance error code for issuer', 
'E0847' =>'Caught ERROR of type:[ System.Xml.XmlException ] . strXML is not a valid XML string', 
'E0848' =>'Incorrect personal identification number', 
'E0849' =>'Stolen card', 
'E0850' =>'Transaction timed out, please retry', 
'E0851' =>'Failed in Authorize - PE', 
'E0852' =>'Cardholder did not return from Rupay', 
'E0853' =>'Missing Mandatory Field(s)The field card_number has exceeded the maximum length of', 
'E0854' =>'Exception in CheckEnrollmentStatus: Data at the root level is invalid. Line 1, position 1.', 
'E0855' =>'CAF status = 0 or 9', 
'E0856' =>'412', 
'E0857' =>'Allowable number of PIN tries exceeded', 
'E0858' =>'No such issuer', 
'E0859' =>'Invalid Data Posted', 
'E0861' =>'Cardholder did not return from ACS', 
'E0862' =>'Duplicate transmission', 
'E0863' =>'Wrong transaction state', 
'E0864' =>'Card acceptor contact acquirer'

Thank you for taking the time to read this post. We value your feedback, so please don’t hesitate to leave a comment with your suggestions. If you encounter any issues with the provided code, please reach out to us. We’re here to assist you! Keep following us for more updates and information.

Exit mobile version