I am getting error whenever I am trying to post data to CCAvenue on localhost for testing purpose. I am following this website http://www.phpzag.com/ccavenue-payment-gateway-integration-in-php/. I have every credential what we need.
index.php
<?php
include_once 'success.php';
// Merchant id provided by CCAvenue
// Item amount for which transaction perform
$Merchant_Id = 44071;
$Amount = 1000;
// Unique OrderId that should be passed to payment gateway
$Order_Id = "ORDER10203040";
// Unique Key provided by CCAvenue
$WorkingKey= "43E2EC833610E0295FCDEA09DB039382";
// Success page URL
$Redirect_Url="success.php";
//$Redirect_Url="http://watersportssimple.com/";
$Checksum = getCheckSum($Merchant_Id,$Amount,$Order_Id ,$Redirect_Url,$WorkingKey);
?>
<html>
<head>
<title>CCAvenue</title>
</head>
<body>
<!-- <form id="ccavenue" method="post" action="https://world.ccavenue.com/servlet/ccw.CCAvenueController">-->
<form id="ccavenu" method="post" action="https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction">
<input type="text" name="Merchant_Id" value="<?php echo $Merchant_Id; ?>">
<input type="text" name="Amount" value="<?php echo $Amount; ?>">
<input type="text" name="Order_Id" value="<?php echo $Order_Id; ?>">
<input type="text" name="Redirect_Url" value="<?php echo $Redirect_Url; ?>">
<input type="text" name="TxnType" value="A">
<input type="text" name="actionID" value="TXN">
<input type="text" name="Checksum" value="<?php echo $Checksum; ?>">
<?php
// Get the checksum
function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
{
$str ="$MerchantId|$OrderId|$Amount|$URL|$WorkingKey";
$adler = 1;
$adler = adler32($adler,$str);
return $adler;
}
//Verify the the checksum
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 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;
}
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;
}
?>
Error Code: 10001
PHP Mcrypt module has been used to encrypt customers and merchant data to the payment gateway so either it is disabled or you have some disabled functions which is blocking mcrypt. In your PHP Configurations set only disable_functions = show_source, system, passthru, popen, proc_open. If you are on a shared hosting then contact your hosting provider to enable and allow PHP mcrypt.
at server side install mcrypt module.
sudo apt-get install php7.0-mcrypt
Then try again.
This link may helpful. https://www.acewebworld.com/blog/whmcs-ccavenue-m-c-p-g-module/