Integrate ICICI EazyPay payment gateway to your website

In this tutorial I would like to explain how to integrate Eazypay into your website.I am using Codeigniter to integrate eazypay.
Register and get you Merchant details through registration in ICICI Eazypay
To encrypt all parameter you can use eazypay inbuilt function of encryption.Please find below the code
function eazypayu_aes128Encrypt($plaintext,$key){ $cipher = "AES-128-ECB"; if (in_array($cipher, openssl_get_cipher_methods())){ $ivlen = openssl_cipher_iv_length($cipher); $iv = openssl_random_pseudo_bytes($ivlen); $ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options=0, $iv); return $ciphertext; } }
To process your payment you have to take input from user and after thet serialize all data and set as parameter value.Below code is for reference.
public function fees_pay() { $amount = $this->input->post('amount'); $merchant_id = "YOUR MERCHANT ID"; $key = "YOUR MERCHANT KEY"; $reference_no = 2; $sub_merchant_id = "YOUR SUBMERCHANT ID"; $return_url = "YOUR REGISTERED RETURN URL"; $paymode = "9"; $mandatory_fields = $reference_no ."|".$sub_merchant_id ."|".$amount; $opt_fields = ""; $e_sub_merchant_id = $this->eazypayu_aes128Encrypt($sub_merchant_id, $key); $e_reference_no = $this->eazypayu_aes128Encrypt($reference_no, $key); $e_amount = $this->eazypayu_aes128Encrypt($amount, $key); $e_return_url = $this->eazypayu_aes128Encrypt($return_url, $key); $e_paymode = $this->eazypayu_aes128Encrypt($paymode, $key); $e_mandatory_fields = $this->eazypayu_aes128Encrypt($mandatory_fields, $key); $button_code = 'https://eazypay.icicibank.com/EazyPG?merchantid='.$merchant_id.'&mandatory fields='.$e_mandatory_fields.'&optional fields='.$opt_fields.'&returnurl='.$e_return_url.'&Reference No='.$e_reference_no.'&submerchantid='.$e_sub_merchant_id.'&transaction amount='.$e_amt.'&paymode='.$e_paymode.'"'; redirect($button_code); }
After payment done you have to capture response getting from return URL. Here is the sample code to capture the response.
public function index(){ $res = $_REQUEST; $data_transaction = array( 'Response_Code'=> $res['Response_Code'], 'Unique_Ref_Number'=> $res['Unique_Ref_Number'], 'Service_Tax_Amount'=> $res['Service_Tax_Amount'], 'Processing_Fee_Amount'=> $res['Processing_Fee_Amount'], 'Total_Amount'=> $res['Total_Amount'], 'Transaction_Amount'=> $res['Transaction_Amount'], 'Transaction_Date'=> date('Y-m-d',strtotime($res['Transaction_Date'])), 'Interchange_Value'=> $res['Interchange_Value'], 'TDR'=> $res['TDR'], 'Payment_Mode'=> $res['Payment_Mode'], 'SubMerchantId'=> $res['SubMerchantId'], 'ReferenceNo'=> $res['ReferenceNo'], 'ID'=> $res['ID'], 'RS'=> $res['RS'], 'TPS'=> $res['TPS'], 'mandatory_fields'=> $res['mandatory_fields'], 'optional_fields'=> $res['optional_fields'], 'RSV'=> $res['Response_Code'], '_policy'=> $res['_policy'], 'visitor'=> $res['visitor'] ); $this->db->insert('tbl_all_payments', $data_transaction); $this->load->view('schools/login-register/reg_hedder'); $this->load->view('schools/login-register/payment-message'); $this->load->view('schools/login-register/reg_footer'); }
Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help! Stay tuned!