- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我是支付网关的新手。我想使用 PHP 将 CCAvenue 集成到我的网站。我已经下载了他们的集成工具包,包括我的商家 ID 和工作 key ,将帐户设置为事件状态并尝试对他们在我的本地主机中提供的索引文件进行虚拟交易。
但是,当我点击表单上的提交时,它会将我带到没有任何错误代码和错误描述的 CCAvenue 交易错误页面。
请让我知道我在哪里犯了错误以及我还需要做什么。
如果有人向我指出 CCAvenue 集成手册以外的教程,我会很棒。
代码: 结帐.php
<html>
<head>
<title> Checkout</title>
</head>
<body>
<?php include('adler32.php')?>
<?php include('Aes.php')?>
<?php
error_reporting(0);
$merchant_id=$_POST['Merchant_Id']; // Merchant id(also User_Id)
$amount=$_POST['Amount']; // your script should substitute the amount here in the quotes provided here
$order_id=$_POST['Order_Id']; //your script should substitute the order description here in the quotes provided here
$url=$_POST['Redirect_Url']; //your redirect URL where your customer will be redirected after authorisation from CCAvenue
$billing_cust_name=$_POST['billing_cust_name'];
$billing_cust_address=$_POST['billing_cust_address'];
$billing_cust_country=$_POST['billing_cust_country'];
$billing_cust_state=$_POST['billing_cust_state'];
$billing_city=$_POST['billing_city'];
$billing_zip=$_POST['billing_zip'];
$billing_cust_tel=$_POST['billing_cust_tel'];
$billing_cust_email=$_POST['billing_cust_email'];
$delivery_cust_name=$_POST['delivery_cust_name'];
$delivery_cust_address=$_POST['delivery_cust_address'];
$delivery_cust_country=$_POST['delivery_cust_country'];
$delivery_cust_state=$_POST['delivery_cust_state'];
$delivery_city=$_POST['delivery_city'];
$delivery_zip=$_POST['delivery_zip'];
$delivery_cust_tel=$_POST['delivery_cust_tel'];
$delivery_cust_notes=$_POST['delivery_cust_notes'];
$working_key=/*MY working Key*/; //Put in the 32 bit alphanumeric key in the quotes provided here.
$checksum=getchecksum($merchant_id,$amount,$order_id,$url,$working_key); // Method to generate checksum
$merchant_data= 'Merchant_Id='.$merchant_id.'&Amount='.$amount.'&Order_Id='.$order_id.'&Redirect_Url='.$url '&billing_cust_name='.$billing_cust_name.'&billing_cust_address='.$billing_cust_address.'&billing_cust_country='.$billing_cust_country.'&billing_cust_state='.$billing_cust_state.'&billing_cust_city='.$billing_city.'&billing_zip_code='.$billing_zip.'&billing_cust_tel='.$billing_cust_tel.'&billing_cust_email='.$billing_cust_email.'&delivery_cust_name='.$delivery_cust_name.'&delivery_cust_address='.$delivery_cust_address.'&delivery_cust_country='.$delivery_cust_country.'&delivery_cust_state='.$delivery_cust_state.'&delivery_cust_city='.$delivery_city.'&delivery_zip_code='.$delivery_zip.'&delivery_cust_tel='.$delivery_cust_tel.'&billing_cust_notes='.$delivery_cust_notes.'&Checksum='.$checksum ;
$encrypted_data=encrypt($merchant_data,$working_key); // Method for encrypting the data.
?>
<form method="post" name="redirect" action="http://www.ccavenue.com/shopzone/cc_details.jsp">
<?php
echo "<input type=hidden name=encRequest value=$encrypted_data>";
echo "<input type=hidden name=Merchant_Id value=$merchant_id>";
?>
</form>
<script type='text/javascript'>document.redirect.submit();</script>
</body>
</html>
还有我的 Redirecturl.php
<?php include('Aes.php')?>
<?php include('adler32.php')?>
<?php
error_reporting(0);
$workingKey=/*My Working Key*/; //Working Key should be provided here.
$encResponse=$_POST["encResponse"]; //This is the response sent by the CCAvenue Server
$rcvdString=decrypt($encResponse,$workingKey); //AES Decryption used as per the specified working key.
$AuthDesc="";
$MerchantId="";
$OrderId="";
$Amount=0;
$Checksum=0;
$veriChecksum=false;
$decryptValues=explode('&', $rcvdString);
$dataSize=sizeof($decryptValues);
//****************************** Messages based on Checksum & AuthDesc **********************************//
echo "<center>";
for($i = 0; $i < $dataSize; $i++)
{
$information=explode('=',$decryptValues[$i]);
if($i==0) $MerchantId=$information[1];
if($i==1) $OrderId=$information[1];
if($i==2) $Amount=$information[1];
if($i==3) $AuthDesc=$information[1];
if($i==4) $Checksum=$information[1];
}
$rcvdString=$MerchantId.'|'.$OrderId.'|'.$Amount.'|'.$AuthDesc.'|'.$workingKey;
$veriChecksum=verifyChecksum(genchecksum($rcvdString), $Checksum);
if($veriChecksum==TRUE && $AuthDesc==="Y")
{
echo "<br>Thank you for shopping with us. Your credit card has been charged and your transaction is successful. We will be shipping your order to you soon.";
//Here you need to put in the routines for a successful
//transaction such as sending an email to customer,
//setting database status, informing logistics etc etc
}
else if($veriChecksum==TRUE && $AuthDesc==="B")
{
echo "<br>Thank you for shopping with us.We will keep you posted regarding the status of your order through e-mail";
//Here you need to put in the routines/e-mail for a "Batch Processing" order
//This is only if payment for this transaction has been made by an American Express Card
//since American Express authorisation status is available only after 5-6 hours by mail from ccavenue and at the "View Pending Orders"
}
else if($veriChecksum==TRUE && $AuthDesc==="N")
{
echo "<br>Thank you for shopping with us.However,the transaction has been declined.";
//Here you need to put in the routines for a failed
//transaction such as sending an email to customer
//setting database status etc etc
}
else
{
echo "<br>Security Error. Illegal access detected";
//Here you need to simply ignore this and dont need
//to perform any operation in this condition
}
echo "<br><br>";
//************************************ DISPLAYING DATA RCVD ******************************************//
echo "<table cellspacing=4 cellpadding=4>";
for($i = 0; $i < $dataSize; $i++)
{
$information=explode('=',$decryptValues[$i]);
echo '<tr><td>'.$information[0].'</td><td>'.$information[1].'</td></tr>';
}
echo "</table><br>";
echo "</center>";
?>
我还包含了集成工具包中附带的 Adler.php 和 Aes.php
最佳答案
ccavenue 支付网关集成非常简单易行,请复制下面用于 ccavenue 支付网关集成的 php 代码或 php 脚本,并根据您的账户设置变量值。
<?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>
关于php - 将 CCAvenue 与 php 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21301125/
我在 JavaScript 文件中运行 PHP,例如...... var = '';). 我需要使用 JavaScript 来扫描字符串中的 PHP 定界符(打开和关闭 PHP 的 )。 我已经知道使
我希望能够做这样的事情: php --determine-oldest-supported-php-version test.php 并得到这个输出: 7.2 也就是说,php 二进制检查 test.
我正在开发一个目前不使用任何框架的大型 php 站点。我的大问题是,随着时间的推移慢慢尝试将框架融入应用程序是否可取,例如在创建的新部件和更新的旧部件中? 比如所有的页面都是直接通过url服务的,有几
下面是我的源代码,我想在同一页面顶部的另一个 php 脚本中使用位于底部 php 脚本的变量 $r1。我需要一个简单的解决方案来解决这个问题。我想在代码中存在的更新查询中使用该变量。 $name)
我正在制作一个网站,根据不同的情况进行大量 PHP 重定向。就像这样...... header("Location: somesite.com/redirectedpage.php"); 为了安全起见
我有一个旧网站,我的 php 标签从 因为短标签已经显示出安全问题,并且在未来的版本中将不被支持。 关于php - 如何避免在 php 文件中写入
我有一个用 PHP 编写的配置文件,如下所示, 所以我想用PHP开发一个接口(interface),它可以编辑文件值,如$WEBPATH , $ACCOUNTPATH和 const值(value)观
我试图制作一个登录页面来学习基本的PHP,首先我希望我的独立PHP文件存储HTML文件的输入(带有表单),但是当我按下按钮时(触发POST到PHP脚本) )我一直收到令人不愉快的错误。 我已经搜索了S
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: What is the max key size for an array in PHP? 正如标题所说,我想知道
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我在 MySQL 数据库中有一个表,其中存储餐厅在每个工作日和时段提供的菜单。 表结构如下: i_type i_name i_cost i_day i_start i_
我有两页。 test1.php 和 test2.php。 我想做的就是在 test1.php 上点击提交,并将 test2.php 显示在 div 中。这实际上工作正常,但我需要向 test2.php
我得到了这个代码。我想通过textarea更新mysql。我在textarea中回显我的MySQL,但我不知道如何更新它,我应该把所有东西都放进去吗,因为_GET模式没有给我任何东西,我也尝试_GET
首先,我是 php 的新手,所以我仍在努力学习。我在 Wordpress 上创建了一个表单,我想将值插入一个表(data_test 表,我已经管理了),然后从 data_test 表中获取所有列(id
我有以下函数可以清理用户或网址的输入: function SanitizeString($var) { $var=stripslashes($var); $va
我有一个 html 页面,它使用 php 文件查询数据库,然后让用户登录,否则拒绝访问。我遇到的问题是它只是重定向到 php 文件的 url,并且从不对发生的事情提供反馈。这是我第一次使用 html、
我有一个页面充满了指向 pdf 的链接,我想跟踪哪些链接被单击。我以为我可以做如下的事情,但遇到了问题: query($sql); if($result){
我正在使用 从外部文本文件加载 HTML/PHP 代码 $f = fopen($filename, "r"); while ($line = fgets($f, 4096)) { print $l
我是一名优秀的程序员,十分优秀!