I am a total newbie to payment gateways. I would like to integrate CCAvenue to my website using PHP. I have downloaded their Intergration kit, Included my merchant id and wo
ccavenue payment gateway integration is very simple and easy, please copy below php code or php script for ccavenue payment gateway integration and set the variable value as per you account.
<?php
function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
{
$str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
$adler = 1;
$adler = adler32($adler,$str);
return $adler;
}
function verifychecksum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey)
{
$str = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey";
$adler = 1;
$adler = adler32($adler,$str);
if($adler == $CheckSum)
return "true" ;
else
return "false" ;
}
function adler32($adler , $str)
{
$BASE = 65521 ;
$s1 = $adler & 0xffff ;
$s2 = ($adler >> 16) & 0xffff;
for($i = 0 ; $i < strlen($str) ; $i++)
{
$s1 = ($s1 + Ord($str[$i])) % $BASE ;
$s2 = ($s2 + $s1) % $BASE ;
}
return leftshift($s2 , 16) + $s1;
}
function leftshift($str , $num)
{
$str = DecBin($str);
for( $i = 0 ; $i < (64 - strlen($str)) ; $i++)
$str = "0".$str ;
for($i = 0 ; $i < $num ; $i++)
$str = $str."0"; $str = substr($str , 1 ) ;
return cdec($str) ;
}
function cdec($num)
{
for ($n = 0 ; $n < strlen($num) ; $n++)
{
$temp = $num[$n] ;
$dec = $dec + $temp*pow(2 , strlen($num) - $n - 1);
}
return $dec;
}
$Merchant_Id = "User ID" ;//This id(also User Id) available at "Generate Working Key" of "Settings & Options"
$Amount = 'Total Amount';//your script should substitute the amount in the quotes provided here
$Order_Id = "Order ID";//your script should substitute the order description in the quotes provided here
$Redirect_Url = "Your Return URL" ;//your redirect URL where your customer will be redirected after authorisation from CCAvenue
$WorkingKey = "Your Working Key" ;//put in the 32 bit alphanumeric key in the quotes provided here.Please note that get this key ,login to your CCAvenue merchant account and visit the "Generate Working Key" section at the "Settings & Options" page.
$Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey);
$billing_cust_name=$customer_name;
$billing_cust_address=$customer_address;
$billing_cust_state=$customer_statename;
$billing_cust_country=$customer_country;
$billing_cust_tel=$customer_contact_no;
$billing_cust_email=$customer_email;
$delivery_cust_name=$customer_name;
$delivery_cust_address=$customer_address;
$delivery_cust_state = $customer_statename;
$delivery_cust_country = $customer_country;
$delivery_cust_tel=$customer_contact_no;
$delivery_cust_notes=$customer_message;
$billing_city = $customer_city;
$billing_zip = $customer_zipcode;
$delivery_city = $customer_city;
$delivery_zip = $customer_zipcode;
?>
<form name="paymentform" method="post" action="https://www.ccavenue.com/shopzone/cc_details.jsp">
<input type="hidden" name="Merchant_Id" value="<?php echo $Merchant_Id; ?>">
<input type="hidden" name="Amount" value="<?php echo $Amount; ?>">
<input type="hidden" name="Order_Id" value="<?php echo $Order_Id; ?>">
<input type="hidden" name="Redirect_Url" value="<?php echo $Redirect_Url; ?>">
<input type="hidden" name="Checksum" value="<?php echo $Checksum; ?>">
<input type="hidden" name="billing_cust_name" value="<?php echo $billing_cust_name; ?>">
<input type="hidden" name="billing_cust_address" value="<?php echo $billing_cust_address; ?>">
<input type="hidden" name="billing_cust_country" value="<?php echo $billing_cust_country; ?>">
<input type="hidden" name="billing_cust_state" value="<?php echo $billing_cust_state; ?>">
<input type="hidden" name="billing_zip" value="<?php echo $billing_zip; ?>">
<input type="hidden" name="billing_cust_tel" value="<?php echo $billing_cust_tel; ?>">
<input type="hidden" name="billing_cust_email" value="<?php echo $billing_cust_email; ?>">
<input type="hidden" name="delivery_cust_name" value="<?php echo $delivery_cust_name; ?>">
<input type="hidden" name="delivery_cust_address" value="<?php echo $delivery_cust_address; ?>">
<input type="hidden" name="delivery_cust_country" value="<?php echo $delivery_cust_country; ?>">
<input type="hidden" name="delivery_cust_state" value="<?php echo $delivery_cust_state; ?>">
<input type="hidden" name="delivery_cust_tel" value="<?php echo $delivery_cust_tel; ?>">
<input type="hidden" name="delivery_cust_notes" value="<?php echo $delivery_cust_notes; ?>">
<input type="hidden" name="Merchant_Param" value="<?php echo $Merchant_Param; ?>">
<input type="hidden" name="billing_cust_city" value="<?php echo $billing_city; ?>">
<input type="hidden" name="billing_zip_code" value="<?php echo $billing_zip; ?>">
<input type="hidden" name="delivery_cust_city" value="<?php echo $delivery_city; ?>">
<input type="hidden" name="delivery_zip_code" value="<?php echo $delivery_zip; ?>">
<INPUT TYPE="submit" value="submit">
</form>
Steps to Integrate Payment Gateway :
At first create a merchant account on https://dashboard.ccavenue.com/web/registration.do?command=Preview.
After successful registration CCavenue team will verify your provided phone no. and email Id.
After account activation your website will be verified and the team will provided your the merchant Id and working key which will be needed while integrating the payment gateway.
Login to your account on https://dashboard.ccavenue.com/jsp/merchant/merchantLogin.jsp
Go to dashboard and click on setting tab then select API KEYS.
Copy all three keys Merchant ID, Access Code and Working Key.
Now follow the following code steps to integrate Ccavenue :
Create a file containing the form e.g. index.php and paste below code:
Follow below link for step by step execution :
https://www.lelocode.com/posts/integrate-ccavenue-payment-gateway-in-php-with-simple-step---lelocode