© 2020-23 BizApprise. All rights reserved.

CCAvenue Payment Gateway Integration in PHP (2023)

PHP (Hypertext Pre-processor) is a very popular backend coding language that is especially used in Web Development. CCAvenue payment gateway integration in PHP is what you will get in this article.

CCAvenue is an important payment gateway provider. It provides a secure platform for making payments to customers. Many merchants have trusted the services of CCAvenue for years due to continued Customer Satisfaction.

This particular payment gateway lets merchants accept payments through Credit Cards, Debit Cards, and Net Banking. All the sensitive payment information is securely stored in a Card Storage Vault.

CCAvenue is also PCI DSS compliant and also abides by the rules and regulations that have been laid down by RBI. Therefore, CCAvenue is the safest option, especially for those merchants who are new to the online platform of selling.

Related: Top 10 Payment Gateways in India

CCAvenue Payment Gateway Integration in PHP involves a few simple steps. Follow the steps mentioned below and implement them.

CCAvenue Payment Gateway Integration in PHP

CCAvenue Payment Gateway Integration in PHP is easy with the below 8 easy steps.

Step 1: Create an account

Go to the homepage of CCAvenue and create your account. For creating an account, you would be asked to provide details like your email address, business type, contact information, and PAN details.

Step 2: Verification of account

After you have created your account, officials at CCAvenue would verify your details to make sure that no false information has been entered. This whole process may take 2-3 business days.

Step 3: Noting down important credentials

Once you receive confirmation that your account has been verified, then head over to CCAvenue and log in to your Dashboard. There you would find important credentials like Merchant ID, Working Key, and Access Code. These credentials will be used in the integration process.

Step 4: Understanding the contents of the Integration Kit

The Payment Gateway kit that you will receive from CCAvenue contains four files.

Index.php: This file is for accepting input from the user

ccavRequestHandler.php: This particular file is for handling the payment request

ccavResponseHandler.php: This file is meant for handling the response that is received from the payment gateway

Crypto.php: The Crypto file is meant for handling encryption and decryption of data.

Step 5: Creating a Payment form

Now, you will need to create a payment form to accept the input from the user. Create the form and name it index.php. Defining some configuration variables on index.php is also necessary.

Merchant ID: Replace the Merchant ID with the one that you have received from your CCAvenue credentials.

Redirect URL: Define the redirect URL where you want to redirect the customer after the transaction is complete.

Cancel URL: Define the cancel URL where you want to redirect the customer if the customer decides to cancel the transaction.

Step 6: Creating ccavRequestHandler.php file

This file is meant for handling all the requests that will be received from the payment form. In a ccavRequestHandler.php file, we will have to define the configuration variables working_key and access_code.

$working_key: Replace the given working key value with the one that you have received from CCAvenue credentials.

$access_code: Similarly, replace the access_code value with the one given in your CCAvenue credentials.

Set form action= https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction: Initially the integration process is being carried out in the sandbox environment. So, we will have to use the sandbox URL in the form of an action.

Step 7: Creating ccavResponseHandler.php file

This file is meant for handling the response that will be reverted by the payment gateway. It will show the status of the transaction (payment-failed, payment-success, etc.). In this file, we will have to set the $working_key variable value, so it will be able to identify that the source of the response is a valid one.

$working_key: Replace the working key value with the one that you have received from your CCAvenue credentials.

Step 8: Testing the Payment Gateway

  • To start the testing process, go to the payment form and fill in all the required details and click the checkout button.
  • On clicking the checkout button, you will be redirected to the CCAvenue payment gateway page.
  • On this page, you will be shown the different payment methods. Select ‘Internet Banking’ and select the bank as ‘Avenues Test’.
  • After these steps, you will get redirected to the transaction status page.
  • If you select the transaction status as ‘Y’, you will get a response that will show that the transaction was successful.
  • If you select the transaction status as ‘N’, you will get a response that will show that the transaction had been declined.

Note: After the successful testing of the payment gateway, make sure to change the Sandbox URL to the Production URL. This mode will allow you to receive payments from your customers. Just change the ccavRequestHandler.php form action with the production URL.

Set form action= https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction

Also, replace the working key value with the product key value (get this value from CCAvenue credentials) in both ccavRequestHandler.php and ccavResponseHandler.php. Also, change the access code value to the production access code value in the ccavRequestHandler.php file.

Conclusion

CCAvenue payment gateway integration in PHP is a very systematic process. Just make sure to fill in the correct keys at the correct time. Even if by mistake, you use the working key for your production mode, you will not be able to receive payments, and transactions will fail.

Follow the above steps and you will not go wrong anywhere. Get securely paid with CCAvenue.

Aditya Goyal
Aditya Goyal

Author, Researcher, and SEO Expert with over 6 years of experience in Writing Content on Money Making Ideas, Startup Resources, and Business Growth. With a background in Marketing and Operations, I love to help individuals/businesses to create their own success stories.

Articles: 137

2 Comments

Leave a Reply

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