CCavenue is most popular Payment gateway for online Shopping. It provide payment through using International credit card as well using your Bank (who have bond with CCavenue) online Account or using it's debit card(ATM card). It is one of the most secure place for given your money to online shop.
For Integrate it with your website you should have ccavenue account and they give you a merchant id and a unique key for your site that is most important for money transaction.
Creat a validCCAvenueparam.php for server side generate valid checksum param
----------------------------------------------------------------------------------------
<?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 ;
//echo "s1 : $s1 <BR> s2 : $s2 <BR>";
}
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 ) ;
//echo "str : $str <BR>";
}
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;
}
?>
-------------------------------------------------------------------------------------------------------------------------------
Step -2
create cat page form cart.php
<?php
$Merchant_Id = "M_apa18528_18528";//This id(also User Id) available at "Generate Working Key" of "Settings & Options"
$Amount = 900;;//your script should substitute the amount in the quotes provided here
$Order_Id = 689663;//your script should substitute the order description in the quotes provided here
$WorkingKey = "";//Note : if you empty the working value then CCavenue "return
because CCavenue security key providing to merchant .
"
$Redirect_Url ="http://www.englishleap.com/users/payment/";
$Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey); // Validate All value
?>
<form action="https://www.ccavenue.com/shopzone/cc_details.jsp" method="post">
<!--<br/>Merchant_Id:
--><input type="hidden" value="<?php echo $Merchant_Id; ?>" name="Merchant_Id">
<!--<br/>Amount:
--><input type="hidden" value="<?php echo $Amount; ?>" name="Amount">
<!--<br/>Order_Id:
--><input type="hidden" value="<?php echo $Order_Id; ?>" name="Order_Id">
<!--<br/>Redirect_Url:
--><input type="hidden" value="<?php echo $Redirect_Url; ?>" name="Redirect_Url">
<!--<br/>Checksum:
--><input type="hidden" value="<?php echo $Checksum; ?>" name="Checksum">
<!--<br/>billing_cust_name:
--><input type="hidden" value="bp.nayak20000" name="billing_cust_name">
<!--<br/>billing_cust_address:
--><input type="hidden" value="" name="billing_cust_address">
<!--<br/>billing_cust_country:
--><input type="hidden" value="" name="billing_cust_country">
<!--<br/>billing_cust_state:
--><input type="hidden" value="" name="billing_cust_state">
<!--<br/>billing_zip:
--><input type="hidden" value="" name="billing_zip">
<!--<br/>billing_cust_tel:
--><input type="hidden" value="" name="billing_cust_tel">
<!--<br/>billing_cust_email:
--><input type="hidden" value="bp.nayak20000@gmail.com" name="billing_cust_email">
<!--<br/>delivery_cust_name:
--><input type="hidden" value="bp.nayak20000" name="delivery_cust_name">
<!--<br/>delivery_cust_address:
--><input type="hidden" value="" name="delivery_cust_address">
<!--<br/>delivery_cust_country:
--><input type="hidden" value="" name="delivery_cust_country">
<!--<br/>delivery_cust_state:
--><input type="hidden" value="" name="delivery_cust_state">
<!--<br/>delivery_cust_tel:
--><input type="hidden" value="" name="delivery_cust_tel">
<!--<br/>delivery_cust_notes:
--><input type="hidden" value="" name="delivery_cust_notes">
<!--<br/>Merchant_Param:
--><input type="hidden" value="" name="Merchant_Param">
<!--<br/>billing_cust_city:
--><input type="hidden" value="" name="billing_cust_city">
<!--<br/>billing_zip_code:
--><input type="hidden" value="" name="billing_zip_code">
<!--<br/>delivery_cust_city:
--><input type="hidden" value="" name="delivery_cust_city">
<!--<br/>delivery_zip_code:
--><input type="hidden" value="" name="delivery_zip_code">
<input type="submit" class="button-placeorder" value="Pay by CCavenue ">
</form>
For Integrate it with your website you should have ccavenue account and they give you a merchant id and a unique key for your site that is most important for money transaction.
Creat a validCCAvenueparam.php for server side generate valid checksum param
----------------------------------------------------------------------------------------
<?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 ;
//echo "s1 : $s1 <BR> s2 : $s2 <BR>";
}
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 ) ;
//echo "str : $str <BR>";
}
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;
}
?>
-------------------------------------------------------------------------------------------------------------------------------
Step -2
create cat page form cart.php
<?php
$Merchant_Id = "M_apa18528_18528";//This id(also User Id) available at "Generate Working Key" of "Settings & Options"
$Amount = 900;;//your script should substitute the amount in the quotes provided here
$Order_Id = 689663;//your script should substitute the order description in the quotes provided here
$WorkingKey = "";//Note : if you empty the working value then CCavenue "return
Error Code: | 108 |
Error Description: | Checksum+mismatch |
"
$Redirect_Url ="http://www.englishleap.com/users/payment/";
$Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey); // Validate All value
?>
<form action="https://www.ccavenue.com/shopzone/cc_details.jsp" method="post">
<!--<br/>Merchant_Id:
--><input type="hidden" value="<?php echo $Merchant_Id; ?>" name="Merchant_Id">
<!--<br/>Amount:
--><input type="hidden" value="<?php echo $Amount; ?>" name="Amount">
<!--<br/>Order_Id:
--><input type="hidden" value="<?php echo $Order_Id; ?>" name="Order_Id">
<!--<br/>Redirect_Url:
--><input type="hidden" value="<?php echo $Redirect_Url; ?>" name="Redirect_Url">
<!--<br/>Checksum:
--><input type="hidden" value="<?php echo $Checksum; ?>" name="Checksum">
<!--<br/>billing_cust_name:
--><input type="hidden" value="bp.nayak20000" name="billing_cust_name">
<!--<br/>billing_cust_address:
--><input type="hidden" value="" name="billing_cust_address">
<!--<br/>billing_cust_country:
--><input type="hidden" value="" name="billing_cust_country">
<!--<br/>billing_cust_state:
--><input type="hidden" value="" name="billing_cust_state">
<!--<br/>billing_zip:
--><input type="hidden" value="" name="billing_zip">
<!--<br/>billing_cust_tel:
--><input type="hidden" value="" name="billing_cust_tel">
<!--<br/>billing_cust_email:
--><input type="hidden" value="bp.nayak20000@gmail.com" name="billing_cust_email">
<!--<br/>delivery_cust_name:
--><input type="hidden" value="bp.nayak20000" name="delivery_cust_name">
<!--<br/>delivery_cust_address:
--><input type="hidden" value="" name="delivery_cust_address">
<!--<br/>delivery_cust_country:
--><input type="hidden" value="" name="delivery_cust_country">
<!--<br/>delivery_cust_state:
--><input type="hidden" value="" name="delivery_cust_state">
<!--<br/>delivery_cust_tel:
--><input type="hidden" value="" name="delivery_cust_tel">
<!--<br/>delivery_cust_notes:
--><input type="hidden" value="" name="delivery_cust_notes">
<!--<br/>Merchant_Param:
--><input type="hidden" value="" name="Merchant_Param">
<!--<br/>billing_cust_city:
--><input type="hidden" value="" name="billing_cust_city">
<!--<br/>billing_zip_code:
--><input type="hidden" value="" name="billing_zip_code">
<!--<br/>delivery_cust_city:
--><input type="hidden" value="" name="delivery_cust_city">
<!--<br/>delivery_zip_code:
--><input type="hidden" value="" name="delivery_zip_code">
<input type="submit" class="button-placeorder" value="Pay by CCavenue ">
</form>