ccavenue payment gateway integration in php demo

in ccavenue payment gateway integration in php, CCAvenue is a most simple payment gateway integration that supports e-merchants a single stop platform for easy processing step by step e-transaction ranging from your any types of the credit card transaction to direct debit from their online netbanking, net banking, credit / debit card payments or any your bank accounts. It is designed to integrate quickly without any hassle. To integrate CCAvenue payment gateway in your website, you should have CCAvenue account and they will give you a merchant id and a unique key for your website to perform transaction. therefor here in this best Article, I have explained easy steps to manage CCAvenue Payment Gateway with PHP.

CCAvenue is the most easy payment gateway in country of the India. As the eCommerce platform is picking A to z momentum as well as some additional at exponential data rate, this is high time you think about more advance level setting up a shopping cart. If you are based out of India then CCAvenue is one among the best selection.

You will also like related best Article to Integrate Payment Gateways

As We have explained step by step earlier that this is very simply to integration, you just required to pass argumend based required input filed to CCAvenue to fully transaction. The CCAvenue gret system expects all the data certain form hiddin input data with each form tag names to be sent to the CCAvenue website. For this reason, this is essential that the names of the form input fields on the merchant website as well as the CCAvenue website should match exactly. as well as there are some form input filed values are compulsory shch as a Merchant_Id, Amount as well as Order_Id. The Merchant_Id as well as working key will be fully assigned to you by CCAvenue. following is form with more action URL to CCAvenue as well as user form input field with required values.

Also Read This πŸ‘‰   Create Video Background Website using Bootstrap HTML5

CCAvenue payment gateway integration methods

  • CCAvenue billing page
  • CCAvenue iFrame checkout
  • Custom checkout form
  • CCAvenue shopping cart

Steps to integrate CCAvenue Payment Gateway

These are the steps required for the CCAvenue payment gateway integration in PHP.

  1. step 1: Make Merchant Account.
  2. Step 2: and then you can Login to Merchant Dashboard as well a100% free download CCAvenue payment integration packages.
  3. Step 3: get here your Security keys (like as a Merchant id, Access full source Code, Working key).
  4. Step 4: after that simply Settings CCAvenue security keys and mode of the (like as a test/live) endpoint in your PHP web app.
  5. Step 5: Make Payment form and deploy Http request / response handlers and with the details of the integration packages.
  6. Step 6: here last step to Make return pages for handling payment confirm notification on success web page url or cancel web page url.


$Merchant_Id = "1234566";
$Amount = "100";
$Order_Id = "006789";
$WorkingKey= "";
$Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey);
<form id="ccavenue" method="post" action="">
<input type="hidden" name="delivery_cust_tel" value="telphone no">
<input type="hidden" name="delivery_cust_notes" value="this is a test">
<input type="hidden" name="Checksum" value="<?php echo $Checksum; ?>">
<input type="hidden" name="billing_cust_name" value="name of user">
<input type="hidden" name="billing_cust_address" value="address of user">
<input type="hidden" name="billing_cust_country" value="user country">
<input type="hidden" name="billing_cust_state" value="state of user">
<input type="hidden" name="billing_cust_city" value="city">
<input type="hidden" name="billing_zip" value="zip/pin code">
<input type="hidden" name="billing_cust_tel" value="telphone no">
<input type="hidden" name="billing_cust_email" value="emailid">
<input type="hidden" name="delivery_cust_name" value="user name">
<input type="hidden" name="delivery_cust_address" value="delivering address">
<input type="hidden" name="delivery_cust_country" value="delivering country">
<input type="hidden" name="delivery_cust_state" value="delivering state">
<input type="hidden" name="Merchant_Param" value="">
<input type="hidden" name="Merchant_Id" value="Merchant_Id">
<input type="hidden" name="Amount" value="Amount">
<input type="hidden" name="Order_Id" value="Order_Id">
<input type="hidden" name="Redirect_Url" value="<?php echo $Redirect_Url; ?>">
<input type="hidden" name="TxnType" value="A">
<input type="hidden" name="ActionID" value="TXN">
<input type="hidden" name="billing_zip_code" value="zip/pin">
<input type="hidden" name="delivery_cust_city" value="city">
<input type="submit" value="Buy Now" />

CCAvenue payment flow diagram

In this flow diagram, it displays the payment flow between CCAvenue and the PHP web application in which this payment gateway is integrated.

CCAvenue,pay,payment,ccavenue payment gateway integration in php demo,ccavenue payment gateway integration in php source code download
CCAvenue,pay,payment,ccavenue payment gateway integration in php demo,ccavenue payment gateway integration in php source code download

In this flow diagram, it displays the possible methods of payments supported by CCAvenue. As we have already seen, it supports net banking, credit / debit card payments as shown in the figure.

Also Read This πŸ‘‰   How to Import and Export CSV Files Using Codeigniter and MySQL

And then the successful payment, the CCavenue will redirect to your provided success URL with the some transaction information with $_GET means ($_REQUEST) get all the variable having auth_status. If it is β€œYES” then it is successfully user authorized by gateway. If it is β€œNO” then it is unsuccessful web page transaction. If it is β€œUSER” then it is not authenticated at this point of time.

We also requied to verify the payment gateway information send by CCavenue is tampered or not for that we have to use the verify checksum method verifychecksum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey). We requied to pass the transaction information to this method. If it data returns true than the information are ok and payment page was successfully redirect to success web page. If it data returns boolean data false then the information are tampered while sending to our web application as well as something wrong has occurred and requied to redirect to unsuccessful web page .

Use below PHP methods to get check all the data sum using methods getchecksum() and verify returned checksum using method verifychecksum().

Also Read This πŸ‘‰   paypal payment gateway integration in php source code download

// Get the checksum
function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
$CCAvenueString ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
$bridge = 1;
$bridge = Caclutate32data($bridge,$CCAvenueString);
return $bridge;

Verify the the checksum

function verifychecksum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey)
$CCAvenueString = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey";
$bridge = 1;
$bridge = Caclutate32data($bridge,$CCAvenueString);
if($bridge == $CheckSum)
return "true";
return "false" ;

function leftshift($CCAvenueString , $num) {
	$CCAvenueString = DecBin($CCAvenueString);
	for( $i = 0 ; $i < (64 – strlen($CCAvenueString)) ; $i++)
	$CCAvenueString = "0".$CCAvenueString ;
	for($i = 0 ; $i < $num ; $i++) {
		$CCAvenueString = $CCAvenueString."0";
		$CCAvenueString = substr($CCAvenueString , 1 ) ;
	return cdec($CCAvenueString) ;

function cdec($num) {
for ($n = 0 ; $n < strlen($num) ; $n++) {
$temp = $num[$n] ;
$dec = $dec + $temp*pow(2 , strlen($num) – $n – 1);
return $dec;

function Caclutate32data($bridge , $CCAvenueString) {
	$DEFAULT = 65521 ;
	$s1 = $bridge & 0xffff ;
	$s2 = ($bridge >> 16) & 0xffff;
	for($i = 0 ; $i < strlen($CCAvenueString) ; $i++) {
	$s1 = ($s1 + Ord($CCAvenueString[$i])) % $DEFAULT ;
	$s2 = ($s2 + $s1) % $DEFAULT ;
	return leftshift($s2 , 16) + $s1;

I hope you get an idea about ccavenue payment gateway integration in php source code download.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.