赞
踩
对接农行网上支付平台
从银行那边获取到对应的接口包
将文件保存在网站的路径中
我是destoon网站系统对接,就放在了api/pay/新建一个文件夹abc/下
完成之后填写接口的配置文件
路径:ebusclient/TrustMerchant.ini
标出的内容 都是需要填写的 对应的证书,联系银行要
配置完成之后 访问测试文件确定是否安装正确
在接下来就是交易流程
首先仿照对应demo从自己的网站中获取接口需要的所有信息 例我在desoon中只需要对接支付充值 因为本身dt的第三方支付就是充值,所以我只需要按照农行接口需要的信息提供就可以了 如代码
defined('IN_DESTOON') or exit('Access Denied');
require DT_ROOT.'/api/pay/'.$bank.'/ebusclient/PaymentRequest.php';
$tRequest= newPaymentRequest();
$tRequest->order["PayTypeID"] = "ImmediatePay"; //设定交易类型
$tRequest->order["OrderNo"] = "$orderid"; //设定订单编号
$tRequest->order["ExpiredDate"] = ""; //设定订单保存时间
$tRequest->order["OrderAmount"] = "$charge"; //设定交易金额
$tRequest->order["Fee"] = "$fee"; //设定手续费金额
$tRequest->order["CurrencyCode"] = "156"; //设定交易币种
$tRequest->order["ReceiverAddress"] = ""; //收货地址
$tRequest->order["InstallmentMark"] = "0"; //分期标识
$tRequest->order["CommodityType"] = "0201"; //设置商品种类
$tRequest->order["BuyIP"] = ""; //IP
$tRequest->order["orderTimeoutDate"] = ""; //设定订单有效期
$tRequest->order["OrderDesc"] = "网站充值"; //设定订单说明
$tRequest->order["OrderURL"] = ""; //设定订单地址
$time1= str_replace('-', '/', timetodate($DT_TIME,3));
$time= explode(' ', timetodate($DT_TIME,6));
$time2= $time[1];
$tRequest->order["OrderDate"] = $time1; //设定订单日期 (必要信息 - YYYY/MM/DD)
$tRequest->order["OrderTime"] = $time2 ; //设定订单时间 (必要信息 - HH:MM:SS)//2、订单明细
$orderitem =array ();
$orderitem["ProductName"] = "网站充值"; //商品名称
$tRequest->orderitems[0] =$orderitem;//3、生成支付请求对象
$tRequest->request["PaymentType"] = "A"; //设定支付类型
if($DT_PC){
$tRequest->request["PaymentLinkType"] = "1"; //设定支付接入方式
}else{
$tRequest->request["PaymentLinkType"] = "2"; //设定支付接入方式
}/*if (isset($_POST['PaymentType']) && isset($_POST['PaymentLinkType']) && $_POST['PaymentType'] === "6" && $_POST['PaymentLinkType'] === "2") {
$tRequest->request["UnionPayLinkType"] = ($_POST['UnionPayLinkType']); //当支付类型为6,支付接入方式为2的条件满足时,需要设置银联跨行移动支付接入方式
}*/$tRequest->request["ReceiveAccount"] = ""; //设定收款方账号
$tRequest->request["ReceiveAccName"] = ""; //设定收款方户名
$tRequest->request["NotifyType"] = "1"; //设定通知方式
$tRequest->request["ResultNotifyURL"] = 'http://www.ceshi.cn/api/pay/abc/notify.php'; //设定通知URL地址
$tRequest->request["MerchantRemarks"] = ""; //设定附言
$tRequest->request["IsBreakAccount"] = "0"; //设定交易是否分账
$tRequest->request["SplitAccTemplate"] = ""; //分账模版编号
$tResponse= $tRequest->postRequest();/*print_r($tResponse);
exit('test11');
var_dump($tResponse);exit;*/
if ($tResponse->isSuccess()) {//print ("
Success!!!" . "");//print ("ReturnCode = [" . $tResponse->getReturnCode() . "]");//print ("ReturnMsg = [" . $tResponse->getErrorMessage() . "]");
$PaymentURL = $tResponse->GetValue("PaymentURL");//var_dump($PaymentURL);exit;//print ("
PaymentURL=$PaymentURL" . "");
echo "
echo"window.location.href='$PaymentURL'";
echo"";
}else{
print ("
Failed!!!" . "");
print ("ReturnCode = [" . $tResponse->getReturnCode() . "]");
print ("ReturnMsg = [" . $tResponse->getErrorMessage() . "]");
}?>
其中的有些参数直接写死
上面的代码就是把信息打包好发给农行 农行会返回一个支付链接 浏览器会自动跳转到链接
再完了之后就是接受返回的信息 接口文档中有说明
demo中有示例文件
获取到返回的信息之后 就可以自己处理了 修改本地的支付状态 等等
例我在destoon中的
require'../../../common.inc.php';
$bank= 'abc';
require DT_ROOT.'/api/pay/'.$bank.'/ebusclient/Result.php';
$PAY= cache_read('pay.php');//1、取得MSG参数,并利用此参数值生成验证结果对象
$tResult= newResult();
$tResponse= $tResult->init($_POST['MSG']);if ($tResponse->isSuccess()) {
$order= $tResponse->getValue("OrderNo");
$amount= $tResponse->getValue("Amount");
$r= $db->get_one("SELECT * FROM {$DT_PRE}finance_charge WHERE itemid='$order'");if($r){if($r['status'] == 0) {
$charge_orderid= $r['itemid'];
$charge_money= $r['amount'] + $r['fee'];
$charge_amount= $r['amount'];
$editor= 'L'.$bank;if($amount ==$charge_money){
require DT_ROOT.'/api/pay/success.inc.php';
$rtnUrl= $MODULE[2]['linkurl'].'charge.php';
echo"
echo"window.location.replace('$rtnUrl')";
echo"";
}else{
$note= '充值金额不匹配S:'.$charge_money.'R:'.$amount;
$db->query("UPDATE {$DT_PRE}finance_charge SET status=1,receivetime='$DT_TIME',editor='$editor',note='$note' WHERE itemid=$charge_orderid");//支付失败
log_write($note, 'labc');
exit('error');
}
}else if($r['status'] == 1) {
exit('error');
}else if($r['status'] == 2) {
exit('error');
}else{
$rtnUrl= $MODULE[2]['linkurl'].'charge.php';
echo"
echo"window.location.replace('$rtnUrl')";
echo"";
}
}
}else{
exit('error');
}?>
以上基本就完工了
友情提示 浏览器一定要用ie
踩过的坑 跳转到农行支付页面一直不成功 配置信息填写有问题
返回的信息一直抓不到,日志一步一步扒 总会找到错到哪儿了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。