Do you want to integrate CCAvenue payment gateway in your PHP website? You are in the right place! CCAvenue is one of the most popular payment gateways in India. With multi-currency support, fraud prevention measures, and plug and play checkout experience, it is perfect for startups, e-commerce websites, and service-based platforms.
In this blog, we will show you how to integrate CCAvenue payment gateway in PHP using source code.
Requirements for CCAvenue PHP Integration
Requirements To use CCAvenue with PHP, you should have:
- A CCAvenue Merchant Account
- Access to CCAvenue Sandbox (Test) enviroment.
- Your Irs Working Key and Access Code
- A PHP server with cURL support
- Downloaded CCAvenue PHP Integration Kit
You can access the PHP kit from your CCAvenue dashboard Integrate > API Kits. If you don’t have one already you can find it here.
Step-by-Step Integration Guide

Step 1: Create Payment Form (checkout.php)
First, create a simple form for order initiation.
<formmethod=”post”action=”ccavRequestHandler.php”>
<inputtype=”hidden”name=”merchant_id”value=”YOUR_MERCHANT_ID”>
<inputtype=”hidden”name=”order_id”value=”ORD123456″>
<inputtype=”hidden”name=”amount”value=”500.00″>
<inputtype=”hidden”name=”currency”value=”INR”>
<inputtype=”hidden”name=”redirect_url”value=”http://yourdomain.com/ccavResponseHandler.php”>
<inputtype=”hidden”name=”cancel_url”value=”http://yourdomain.com/ccavResponseHandler.php”>
<inputtype=”hidden”name=”language”value=”EN”>
<inputtype=”submit”value=”Pay Now”>
</form>
Step 2: Encrypt Request – ccavRequestHandler.php
Encrypt the form data using CCAvenue’s Crypto.php file.
<?php
include(‘Crypto.php’);
$workingKey = “YOUR_WORKING_KEY”;
$accessCode = “YOUR_ACCESS_CODE”;
$merchant_data = ”;
foreach ($_POSTas$key => $value) {
$merchant_data .= $key . ‘=’ . $value . ‘&’;
}
$encrypted_data = encrypt($merchant_data, $workingKey);
?>
<formmethod=”post”action=”https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction”>
<inputtype=”hidden”name=”encRequest”value=”<?phpecho$encrypted_data; ?>”>
<inputtype=”hidden”name=”access_code”value=”<?phpecho$accessCode; ?>”>
</form>
<script>document.forms[0].submit();</script>
Step 3: Handle Payment Response – ccavResponseHandler.php
<?php
include(‘Crypto.php’);
$workingKey = “YOUR_WORKING_KEY”;
$encResponse = $_POST[“encResp”];
$rcvdString = decrypt($encResponse, $workingKey);
parse_str($rcvdString, $response);
$order_status = $response[‘order_status’];
if ($order_status == “Success”) {
echo”✅ Payment Successful”;
} elseif ($order_status == “Failure”) {
echo”❌ Payment Failed”;
} else {
echo”⚠️ Payment Aborted”;
}
?>
Frequently Asked Questions
No, there will be a transaction fee from CCAvenue which is based on the payment gateway.
Yes. CCAvenue gives you sandbox to check out all capabilities.
Typing errors in encryption or incorrect value of working keys will in most cases result in transaction not being successful. Always verify credentials.
Final Thoughts:
Integrating CCAvenue payment gateway in PHP is simple and easy if you are using CCAvenue kit and following the documentation properly. It provides a secure and fast way of online transactions, which is the need of the hour for fast-growing online businesses in India.
Follow our blog for more tutorials on PHP payment integration like Paytm, Cashfree, Razorpay etc.
Read also:-