Skip to main content

CCavenue Payment Gateway Integration Using PHP

CCavenue is a most popular payment gateway that provides the perfect e-commerce solution. It will accept payment from all major payment methods like Debit card, Credit Card, Internet Banking. If you want to integrate complete payment solution for your website. So, In that case CCavenue payment gateway is the perfect choice for you.

Also, the integration of CCavenue payment gateway is very easy, it is designed in that manner so it doesn’t require so much configuration. Using PHP we can easily integrate CCavenue payment gateway in our website.

Some of benifits of using CCavenue payment gateway

  • Most important feature of CCavenue payment gateway is it accept all the major payment method like debit,credit card , netbanking
  • Accept online payment from 30+ banks
  • CCavenue payment gateway is very safe and secure
  • Easy and hassle free integration
  • Payment gateway kit available on multiple programming language

We follow step by step integration process, so we can easily integrate payment gateway

Procedure to integrate CCavenue payment gateway in PHP

Step 1: First you have to create the account on CCavenue by visiting this link https://www.ccavenue.com/ and provide all the details like website detail where you want to integrate payment gateway, business type, email, mobile number, pan card details etc

Step 2: After that CCavenue verifiy all of the your details email id ,mobile no etc

Step 3: After the verification CCavenue provide the details like Working Key ,
Access Code

So now we are ready for the integration so we can move to the coding parts:-
Payment gateway kit contains four file

Index.php :- For Accepting the input from the user
ccavRequestHandler.php:- For Handling the payment request
ccavResponseHandler.php:- For Handling the response that is received from payment gateway
Crypto.php:- Crypto file handle encryption and decryption

You can also download the source code ,download link is given below at the end of this tutorial

Step 4: Create payment form to accept the input from the user and give name index.php also we have to define some configuration variable on the index.php

Merchant ID: - Replace the Merchant ID with your Merchant ID that you have received from CCavenue

Redirect URL: - Define the redirect URL where you want to redirect the user after the transaction

Cancel URL: - Define the cancel URL where you want to redirect the user if user cancel the transaction

Index.php

Step 5: Create ccavRequestHandler.php file

ccavRequestHandler.php

Handle all the request that will received from the payment form ,In a ccavRequestHandler.php file we have to define the configuration variable like $working_key and $access_code

$working_key :- Replace with your working key value that you have received from the CCavenue

$access_code :- Change the access code value with your access_code that you have received from CCavenue

Set form action="https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction" :- Initially we are integrating payment gateway in sandbox environment so we have to use sandbox url in the form action

Step 6: Create ccavResponseHandler.php file

ccavResponseHandler.php

ccavResponseHandler handles the response that will return by the payment gateway. It will show payment status payment-failed, payment-success etc

Also in the ccavResponseHandler.php file, we have to set the working key variable value, so it can identify that the response comes from the valid source

$working_key :- Replace the working key value with your working key that you have received from CCavenue

For Testing the payment gateway working fine or not follow the below steps

First go the payment form and enter the all the necessary details and click on the checkout button

After that you will be redirected to the CCavenue payment gateway page

In this page select payment method is internet banking and select bank Avenues Test

After that you will be redirected to the transaction status page, similar to below-given image

If you select the transaction status Y, you will get a response like this

If you select the transaction status N, you will get a response like this

Note:- After successfully testing we have to change the sandbox URL So, instead of this we use production URL so, we can test the payment gateway in production mode. Basically we have to change ccavRequestHandler.php form action with the production URL

Also, we have to replace the working key value with the production working key value in both files ccavRequestHandler.php , ccavResponseHandler.php and also we have to replace the access code value with the production access code value in the ccavRequestHandler.php

See Also :

How To Integrate Payu Money Payment Gateway Using PHP

How To Integrate Paytm Payment Gateway In PHP With Demo & Download

Conclusion :-

Here we learn about how we can easily integrate CCavenue payment gateway using PHP. If you are facing any issue in the integration, please comment below in the comment box so we can help you in the integration.

 

Recomended Tutorial

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.