CCAvenue integration in PHP application with troubleshooting guide.

CCAvenue integration in PHP application with troubleshooting guide.

CCAvenue is a payment gateway provider which has numerous variety of features which suits everyone’s business requirements. It offers various features such as, 200+ Payment Options, Multiple Currency processing, Dynamic Routing, Payments page customization and much more!

In this guide, we are going to look how we can enrich our PHP application by integrating CCAvenue payment gateway system.

Prerequisites:

Before we roll our sleeves to begin with coding our application, let’s first gather all the required variables for the gateway’s API.

Open the API Keys page which is under the Settings item in the navigation menu. There you’ll find the API credentials and details.

Here are the variable which are required:

  • merchant_id – Unique merchant identification number provided by CCAvenue.
  • working_key  – This is the encryption key, which is provided by CCAvenue itself.
  • access_code  – Your unique API secret code. Provided by CCAvenue.

All these three variables are required. Please ensure that your working_key is always hidden from user’s access.

Let the keyboard action begin…

We’ll be creating five PHP files as follows:

  • index.php  –  Our application will be served through this file.
  • config.php  – We’ll store our API variable in here.
  • ccavRequestHandler.php  – This file is responsible for preparing our gateway request.
  • ccavResponseHandler.php  – Upon completion of transaction, we’ll be redirected here.
  • Crypto.php  – To encrypt our requested variable and to decrypt the encrypted response.

 

config.php

This file contains all the global variable which we’ll be using often in our application. It will contain variables such as API Credentials, User Settings, Redirect URLs etc.

Crypto.php

This file is used to encrypt the request parameters which we have to send to the CCAvenue Payment Gateway server. We also have a decrypt function in it which is used to decrypt the encrypted response which we receive upon callback from CCAvenue Payment page.

index.php

This file has the checkout page fields on which you can show the user his ordered items and their details. After details, we can add a payment button by which the user will be redirected to the gateway’s payment page.

ccavRequestHandler.php

This is the request page, which is displayed after the checkout page. With this PHP file we are securing and preparing our user’s defined payment parameters. We utilize the encrypt function of crypto.php file here to encrypt and secure the data of our users.

ccavResponseHandler.php

After a successful or failed or aborted payment action the payment gateway will redirect us the response data here. Upon receiving the user response data this file then decrypts it, processes the decrypted data for usage, performs conditional checks to determine the payment status, and serializes the data for further usage as values for database or for displaying it to user or for debugging purposes.

Now that we have successfully integrated the CCAvenue payment gateway processor in our PHP Application. Let’s take a look at the troubles and errors you might face.

Possible Error with fixes while integrating the payment gateway:

#1 After clicking the payment link, it shows “Merchant Authentication Failed” error.

Solution: Please double check  merchant_id , working_key , access_code , redirect_url . Your  redirect_url should be the same domain with which you have registered on CCAvenue MARS platform.

#2 I have double checked the credentials, but still the errors persist.

Solution: Please also check the currency for which you have registered on CCAvenue and the currency which you are sending the request parameters. For example, if you have registered for INR currency but in payment gateway request you are submitting USD as parameter then you may receive “Merchant Authentication Failed” error.

#3 There is no error, but it is still not accepting user’s payment.

Solution: Often this happen because you have registered for .in CCAvenue and you are submitting your request to .com or .ae or any other international CCAvenue service website. To solve this, replace .com with .in (if you are dealing in India)   https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction . If error still persist then contact CCAvenue to confirm if there’s no restriction placed on the account.

Leave a Comment

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