博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ECSHOP农行支付接口开发(含手机端)
阅读量:5966 次
发布时间:2019-06-19

本文共 8208 字,大约阅读时间需要 27 分钟。

对于ECSHOP来说,支付是以接口的形式存在的。于是:

1:首先添加接口文件

includes\modules\payment下,增加abcbank.php,代码如下:

abcbank(); } /** * 生成支付代码 * @param array $order 订单信息 * @param array $payment 支付方式信息 */ function get_code($order, $payment) { if (!defined('EC_CHARSET')) { $charset = 'utf-8'; } else { $charset = EC_CHARSET; } $tOrderNo = $order['order_id'];//$order['order_sn']; /*订单编号*/ $tOrderDesc = 'Game Card Order'; /*订单说明*/ $tOrderDate = date("Y/m/d", $order['add_time']); /*订单日期*/ $tOrderTime = date("h:i:s", $order['add_time']); /*订单时间*/ $tOrderAmountStr = $order['order_amount'];//sprintf("%012d",$order['order_amount']); /*订单金额*/ $tOrderURL ='http://localhost:8080/huahui/MerchantPayment/MerchantQueryOrder.php?OrderNo=ON200306300001&QueryType=1'; /*订单查询网址*/ $tProductType = '0202'; /*商品种类*/ $tPaymentType ='A'; /*支付类型*/ $tpaymentlinktype ='1'; /*接入类型*/ $tnotifytype = '0'; /*通知方式*/ $tresultnotifyurl ='http://localhost:8080/huahui/MerchantPayment/MerchantResult.php'; /*支付结果地址*/ $tMerchantRemarks = 'Hi!'; /*商家备注*/ $tTotalCount = '1'; /*订单数量*/ $tproductid = "160605"; /*商品ID*/ $tproductname= "HTC s710e"; /*商品名称*/ $tuniteprice ="0.01"; /*商品单价*/ $tqty ="1"; /*购买数量*/ $def_url = '
'; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; $def_url .= "
"; return $def_url; } /** * 响应操作 */ function respond() { }} ?>

那么,注意了,respond在这里是不需要写任何代码的,农行数据会直接跳转到tresultnotifyurl 所定义的地址上。

 

二:发送和接收

MerchantPayment/MerchantPayment.php,如下:

order["PayTypeID"] = "ImmediatePay";//($_POST['PayTypeID']); //设定交易类型$tRequest->order["OrderNo"] = ($_POST['OrderNo']); //设定订单编号$tRequest->order["ExpiredDate"] = "30";//($_POST['ExpiredDate']); //设定订单保存时间$tRequest->order["OrderAmount"] = ($_POST['OrderAmount']);//($_POST['PaymentRequestAmount']); //设定交易金额$tRequest->order["Fee"] = "";//($_POST['Fee']); //设定手续费金额$tRequest->order["CurrencyCode"] = "156";//($_POST['CurrencyCode']); //设定交易币种$tRequest->order["ReceiverAddress"] = "xx";//($_POST['ReceiverAddress']); //收货地址$tRequest->order["InstallmentMark"] = "0";//($_POST['InstallmentMark']); //分期标识$installmentMerk = "0";//$_POST['InstallmentMark'];$paytypeID = "ImmediatePay";//$_POST['PayTypeID'];if (strcmp($installmentMerk, "1") == 0 && strcmp($paytypeID, "DividedPay") == 0) { $tRequest->order["InstallmentCode"] = ($_POST['InstallmentCode']); //设定分期代码 $tRequest->order["InstallmentNum"] = ($_POST['InstallmentNum']); //设定分期期数}$tRequest->order["BuyIP"] = "";//($_POST['BuyIP']); //IP$tRequest->order["OrderDesc"] = ($_POST['OrderDesc']); //设定订单说明$tRequest->order["OrderURL"] = ($_POST['OrderURL']); //设定订单地址$tRequest->order["OrderDate"] = ($_POST['OrderDate']); //设定订单日期 (必要信息 - YYYY/MM/DD)date_default_timezone_set('PRC');$hh = date("H:i:s",time());$tRequest->order["OrderTime"] = $hh;//($_POST['OrderTime']); //设定订单时间 (必要信息 - HH:MM:SS)$tRequest->order["orderTimeoutDate"] = "20240619104901";//($_POST['orderTimeoutDate']); //设定订单有效期$tRequest->order["CommodityType"] = "0202";//($_POST['CommodityType']); //设置商品种类$orderitem = array ();$orderitem["SubMerName"] = "HongYue HuaHui"; //设定二级商户名称$orderitem["SubMerId"] = "12345"; //设定二级商户代码$orderitem["SubMerMCC"] = "0000"; //设定二级商户MCC码 $orderitem["SubMerchantRemarks"] = "xx"; //二级商户备注项$orderitem["ProductID"] = "IP000001"; //商品代码,预留字段$orderitem["ProductName"] = ($_POST['OrderDesc']); //商品名称$orderitem["UnitPrice"] = "1.00"; //商品总价$orderitem["Qty"] = "1"; //商品数量$orderitem["ProductRemarks"] = ($_POST['OrderDesc']); //商品备注项$orderitem["ProductType"] = "0202"; //商品类型$orderitem["ProductDiscount"] = "0.9"; //商品折扣$orderitem["ProductExpiredDate"] = "10"; //商品有效期$tRequest->orderitems[0] = $orderitem;//3、生成支付请求对象$tRequest->request["PaymentType"] = ($_POST['PaymentType']); //设定支付类型$tRequest->request["PaymentLinkType"] = ($_POST['PaymentLinkType']); //设定支付接入方式if ($_POST['PaymentType'] === "6" && $_POST['PaymentLinkType'] === "2") { $tRequest->request["UnionPayLinkType"] = ($_POST['UnionPayLinkType']); //当支付类型为6,支付接入方式为2的条件满足时,需要设置银联跨行移动支付接入方式}$tRequest->request["ReceiveAccount"] = "";//($_POST['ReceiveAccount']); //设定收款方账号$tRequest->request["ReceiveAccName"] = "";//($_POST['ReceiveAccName']); //设定收款方户名$tRequest->request["NotifyType"] = ($_POST['NotifyType']); //设定通知方式$tRequest->request["ResultNotifyURL"] = ($_POST['ResultNotifyURL']); //设定通知URL地址$tRequest->request["MerchantRemarks"] = ($_POST['MerchantRemarks']); //设定附言$tRequest->request["IsBreakAccount"] = "0"; //($_POST['IsBreakAccount']); //设定交易是否分账$tRequest->request["SplitAccTemplate"] = "";//($_POST['SplitAccTemplate']); //分账模版编号 $tResponse = $tRequest->postRequest();//支持多商户配置//$tResponse = $tRequest->extendPostRequest(2);if ($tResponse->isSuccess()) {// print ("
Success!!!" . "
");// print ("ReturnCode = [" . $tResponse->getReturnCode() . "]
");// print ("ReturnMsg = [" . $tResponse->getErrorMessage() . "]
"); $PaymentURL = $tResponse->GetValue("PaymentURL");// print ("
PaymentURL=$PaymentURL" . "
"); echo "";} else { print ("
对不起,不能重复发起支付, 请重新下单!!!" . "
"); //print ("
Failed!!!" . "
"); //print ("ReturnCode = [" . $tResponse->getReturnCode() . "]
"); //print ("ReturnMsg = [" . $tResponse->getErrorMessage() . "]
");}?>

MerchantPayment/MerchantResult.php,如下:

init($_POST['MSG']);if ($tResponse->isSuccess()) { //2、、支付成功// print ("TrxType = [" . $tResponse->getValue("TrxType") . "]
");// print ("OrderNo = [" . $tResponse->getValue("OrderNo") . "]
");// print ("Amount = [" . $tResponse->getValue("Amount") . "]
");// print ("BatchNo = [" . $tResponse->getValue("BatchNo") . "]
");// print ("VoucherNo = [" . $tResponse->getValue("VoucherNo") . "]
");// print ("HostDate = [" . $tResponse->getValue("HostDate") . "]
");// print ("HostTime = [" . $tResponse->getValue("HostTime") . "]
");// print ("MerchantRemarks = [" . $tResponse->getValue("MerchantRemarks") . "]
");// print ("PayType = [" . $tResponse->getValue("PayType") . "]
");// print ("NotifyType = [" . $tResponse->getValue("NotifyType") . "]
"); new_order_paid($tResponse->getValue("OrderNo"), PS_PAYED, '', '农行支付');// print ("xxx"); $url = "http://localhost:8080/huahui/user.php?act=order_list"; echo ""; } else { //3、失败 print ("
ReturnCode = [" . $tResponse->getReturnCode() . "]
"); print ("ErrorMessage = [" . $tResponse->getErrorMessage() . "]
"); set_pay_error($tResponse->getValue("OrderNo"), "", $tResponse->getValue("Amount"), '农行支付', $tResponse->getReturnCode()); }?>

 

三:安装

接下来,我们就需要安装了,

1:首先将文件夹和文件进行覆盖;

2:进入系统后台,点击安装

3:修改证书地址、商户号、密码等,

首先,找到文件:\ebusclient\TrustMerchant.ini,然后把2和4两个证书的路径,改为cert文件夹对应文件的绝对路径。上图3处指需要给接口指定一个日志路径(备注:一定要创建路径)。

至此,我们的ecshop的pc端已经支持农行支付了。

 

四:关于手机端

echshop的支付只要按照上面进行安装,数据库中就有了记录,如下:

所以,手机端类似,接口文件不需要动了。只不过,需要在mobile目录下一样添加MerchantPayment文件夹,加入发送和接收的文件就可以了。

本文基于 发布,欢迎转载,演绎或用于商业目的,但是必须保留本文的署名 (包含链接)。如您有任何疑问或者授权方面的协商,请给我留言。
你可能感兴趣的文章
记一次数据中心云平台系统项目实施
查看>>
SQL Server 黑盒跟踪 -- 如何启用黑盒跟踪?
查看>>
递归转非递归的思路和例子
查看>>
Eclipse使用总结
查看>>
【Cocos2d-X(2.x) 游戏开发系列之二】cocos2dx最新2.0.1版本跨平台整合NDK+Xcode编译到Android...
查看>>
TBK打牌游戏信誉网站
查看>>
Ioc的作用
查看>>
小猿圈Java循环嵌套语法的使用介绍
查看>>
解锁缓存新姿势——更灵活的 Cache
查看>>
如何利用小程序更有效的触达用户,引爆社交电商
查看>>
《大话数据结构》读后总结(三)
查看>>
阿里云图数据库GraphDB上线,助力图数据处理
查看>>
分布式环境下实现分布式锁的关键技术
查看>>
前端的请求拦截
查看>>
重点用能单位能耗能源管理系统集成平台技术
查看>>
首次公开!单日600PB的计算力--阿里巴巴EB级大数据平台的进击
查看>>
怎么用云服务器搭建个人网站
查看>>
iOS 崩溃异常捕获
查看>>
python动态装饰器
查看>>
android动画
查看>>