您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程
ecshop农行支付接口对接开发demo示例
访琴2024-12-19Ecshop商城教程已有人查阅
导读对于ECSHOP来说,支付是以接口的形式存在的。于是:1:首先添加接口文件includes\modules\payment下,增加abcbank.php,代码如下:
对于ECSHOP来说,支付是以接口的形式存在的。于是:
1:首先添加接口文件
includes\modules\payment下,增加abcbank.php,代码如下:
二:发送和接收
MerchantPayment/MerchantPayment.php,如下:
接下来,我们就需要安装了,
1:首先将文件夹和文件进行覆盖;
2:进入系统后台,点击安装
3:修改证书地址、商户号、密码等,
首先,找到文件:\ebusclient\TrustMerchant.ini,然后把2和4两个证书的路径,改为cert文件夹对应文件的绝对路径。上图3处指需要给接口指定一个日志路径(备注:一定要创建路径)。
至此,我们的ecshop的pc端已经支持农行支付了。
四:关于手机端
echshop的支付只要按照上面进行安装,数据库中就有了记录,如下:
所以,手机端类似,接口文件不需要动了。只不过,需要在mobile目录下一样添加MerchantPayment文件夹,加入发送和接收的文件就可以了。
1:首先添加接口文件
includes\modules\payment下,增加abcbank.php,代码如下:
<?php
/**
* ECSHOP 农行在线插件
*/
if (!defined('IN_ECS'))
{
die('Hacking attempt');
}
$payment_lang = ROOT_PATH . 'languages/' .$GLOBALS['_CFG']['lang']. '/payment/abcbank.php';
if (file_exists($payment_lang))
{
global $_LANG;
include_once($payment_lang);
}
/* 模块的基本信息 */
if (isset($set_modules) && $set_modules == TRUE)
{
$i = isset($modules) ? count($modules) : 0;
/* 代码 */
$modules[$i]['code'] = basename(__FILE__, '.php');
/* 描述对应的语言项 */
$modules[$i]['desc'] = '农行接口';
/* 是否支持*/
$modules[$i]['is_cod'] = '0';
/* 是否支持在线支付 */
$modules[$i]['is_online'] = '1';
/* 支付费用 */
$modules[$i]['pay_fee'] = '0';
/* 作者 */
$modules[$i]['author'] = '嘉兴科蓝软件有限公司';
/* 网址 */
$modules[$i]['website'] = 'http:// .kelasoft.com/';
/* 版本号 */
$modules[$i]['version'] = 'kelasoft.com V1.0';
/* 配置信息 */
$modules[$i]['config'] = array(
);
return;
}
/**
* 类
*/
class abcbank
{
/**
* 构造函数
*
* @access public
* @param
*
* @return void
*/
function abcbank()
{
}
function __construct()
{
$this->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 = '<br /><form style="text-align:center;" method=post action="MerchantPayment/MerchantPayment.php">';
$def_url .= "<input type=HIDDEN name='OrderNo' value='". $tOrderNo."'>";
$def_url .= "<input type=HIDDEN name='OrderDesc' value='". $tOrderDesc."'>";
$def_url .= "<input type=HIDDEN name='OrderDate' value='".$tOrderDate."'>";
$def_url .= "<input type=HIDDEN name='OrderTime' value='".$tOrderTime."'>";
$def_url .= "<input type=HIDDEN name='OrderAmount' value='".$tOrderAmountStr."'>";
$def_url .= "<input type=HIDDEN name='OrderURL' value='".$tOrderURL."'>";
$def_url .= "<input type=HIDDEN name='ProductType' value='".$tProductType."'>";
$def_url .= "<input type=HIDDEN name='PaymentType' value='".$tPaymentType."'>";
$def_url .= "<input type=HIDDEN name='PaymentLinkType' value='".$tpaymentlinktype."'>";
$def_url .= "<input type=HIDDEN name='NotifyType' value='".$tnotifytype."'>";
$def_url .= "<input type=HIDDEN name='ResultNotifyURL' value='".$tresultnotifyurl."'>";
$def_url .= "<input type=HIDDEN name='MerchantRemarks' value='".$tMerchantRemarks."'>";
$def_url .= "<input type=HIDDEN name='TotalCount' value='".$tTotalCount."'>";
$def_url .= "<input type=HIDDEN name='productid[]' value='".$tproductid."'>";
$def_url .= "<input type=HIDDEN name='productname[]' value='".$tproductname."'>";
$def_url .= "<input type=HIDDEN name='uniteprice[]' value='".$tuniteprice."'>";
$def_url .= "<input type=HIDDEN name='qty[]' value='".$tqty."'>";
$def_url .= "<input type=submit value='" .$GLOBALS['_LANG']['pay_button']. "'>";
$def_url .= "</form>";
return $def_url;
}
/**
* 响应操作
*/
function respond()
{
}
}
?>
那么,注意了,respond在这里是不需要写任何代码的,农行数据会直接跳转到tresultnotifyurl 所定义的地址上。二:发送和接收
MerchantPayment/MerchantPayment.php,如下:
<?php
require_once ('../ebusclient/PaymentRequest.php');
$tRequest = new PaymentRequest();
$tRequest->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 ("<br>Success!!!" . "</br>");
// print ("ReturnCode = [" . $tResponse->getReturnCode() . "]</br>");
// print ("ReturnMsg = [" . $tResponse->getErrorMessage() . "]</br>");
$PaymentURL = $tResponse->GetValue("PaymentURL");
// print ("<br>PaymentURL=$PaymentURL" . "</br>");
echo "<script language='javascript'>";
echo "window.location.href='$PaymentURL'";
echo "</script>";
} else {
print ("<br>对不起,不能重复发起支付, 请重新下单!!!" . "</br>");
//print ("<br>Failed!!!" . "</br>");
//print ("ReturnCode = [" . $tResponse->getReturnCode() . "]</br>");
//print ("ReturnMsg = [" . $tResponse->getErrorMessage() . "]</br>");
}
?>
MerchantPayment/MerchantResult.php,如下:
<?php
define('IN_ECS', true);
require('../includes/init.php');
require_once ('../includes/lib_payment.php');
require_once ('../ebusclient/Result.php');
$tResult = new Result();
$tResponse = $tResult->init($_POST['MSG']);
if ($tResponse->isSuccess()) {
//2、、支付成功
// print ("TrxType = [" . $tResponse->getValue("TrxType") . "]<br/>");
// print ("OrderNo = [" . $tResponse->getValue("OrderNo") . "]<br/>");
// print ("Amount = [" . $tResponse->getValue("Amount") . "]<br/>");
// print ("BatchNo = [" . $tResponse->getValue("BatchNo") . "]<br/>");
// print ("VoucherNo = [" . $tResponse->getValue("VoucherNo") . "]<br/>");
// print ("HostDate = [" . $tResponse->getValue("HostDate") . "]<br/>");
// print ("HostTime = [" . $tResponse->getValue("HostTime") . "]<br/>");
// print ("MerchantRemarks = [" . $tResponse->getValue("MerchantRemarks") . "]<br/>");
// print ("PayType = [" . $tResponse->getValue("PayType") . "]<br/>");
// print ("NotifyType = [" . $tResponse->getValue("NotifyType") . "]<br/>");
new_order_paid($tResponse->getValue("OrderNo"), PS_PAYED, '', '农行支付');
// print ("xxx");
$url = "";
echo "<script language='javascript' type='text/javascript'>";
echo "window.location.href='$url'";
echo "</script>";
} else {
//3、失败
print ("<br>ReturnCode = [" . $tResponse->getReturnCode() . "]<br>");
print ("ErrorMessage = [" . $tResponse->getErrorMessage() . "]<br>");
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文件夹,加入发送和接收的文件就可以了。
本文标签:
很赞哦! ()
上一篇:ecshop广告怎么调用
相关教程
- discuz的ecshop的伪静态规则apache+nginx
- ecshop整合discuz的方法
- discuz和ecshop截取字符串函数介绍
- ECShop2.7.2整合Discuz 6.0论坛的步骤方法
- Ecshop和Discuz开源产品有哪些局限性
- ecshop怎么和discuz整合
- phpcmsv9和ecshop2.3.7以及discuzx3.0整合方法
- Nginx常用Rewrite(伪静态规则)WordPress/PHPCMS/ECSHOP/ShopEX/S
- ecshop收货地址199/198号段提示手机号格式不正确!
- ecshop调用商品属性的方法实例
- ecshop支付插件开发教程
- ecshop商品怎么增加新字段
图文教程
ecshop用户中心收藏列表商品显示商品缩略图
ECSHOP用户中心收藏列表商品显示商品缩略图修改教程代码号ECSHOP视频教程也再不断的完善与跟进,期待大家的关注!希望在ECSHOP的道路上,代码号与您一路同行!
ecshop微信登录微信商城接口配置教程图解
很多人在使用ECSHOP商城时候对于微信登录,微商城接口,微信回调url域名配置流程一知半解,今天代码号就为大家详细图解ecshop微信登录,微商城接口和微信回调url域名设置流程步骤。
ecshop商品列表不显示出现产品为空的修复方法
我们在运用ECSHOP模板时,能够规矩写的不标准 在列表页的最终一个商品的方位上经常会多出一个空商品,在换成默许模版今后空商品不见。
ecshop安装报错date_default_timezone_get()的解决方法
很明显是由于PHP默认的时间区域设置问题导致的警告date_default_timezone_get - 取得一个脚本中所有日期时间函数所使用的默认时区默认时区,使用如下“假定”的顺序:
相关源码
-
(自适应响应式)宠物经验资讯咨询博客pbootcms网站源码下载除宠物资讯领域外,通过内容替换可快速适配宠物用品商城、宠物医疗咨询平台、宠物训练教程网站、动物保护组织官网、水族爱好者社区等垂直领域。查看源码 -
(响应式)轴承机械五金零件产品pbootcms落地推广单页源码下载为轴承、机械零件等工业产品打造的响应式单页模板,基于PbootCMS内核开发,助力企业快速构建专业级产品展示页面。模板采用工业风设计语言,突出产品参数与性能优势,适用于设备制造商、零部件供应商等B2B场景推广。查看源码 -
(自适应)调节阀门气动球阀控制阀网站模板源码下载为调节阀门、气动球阀等工业设备企业打造的响应式网站模板,基于PbootCMS系统开发。突出产品参数展示与技术文档管理功能,通过专业化的布局设计有效呈现工业设备特性,适配各类终端访问需求。查看源码 -
帝国cms7.5模板生活常识美食女性时尚综合资讯门户源码本模板为帝国cms7.5生活资讯类网站设计,以天奇生活网为参考原型,涵盖生活常识、美食烹饪、女性时尚等多元化内容板块。采用响应式布局设计,适配各种终端设备,为访客提供优质的阅读体验。模板结构清晰合理,内容展示层次分明,符合生活类网站的用户需求。查看源码 -
(PC+WAP)红色驾校培训学车在线预约源码下载基于PbootCMS内核开发的驾校培训专用网站模板,深度适配驾驶培训行业展示需求。采用PC与移动端同步响应设计,单一后台统一管理内容数据,更换图文素材后可快速转变为其他行业网站。查看源码 -
自适应黑色简繁双语轴承齿轮机械设备制造网站模板该模板为轴承齿轮机械制造企业提供一体化网站建设方案,着重解决行业特有的多语言展示、移动端适配和高效率内容管理需求,帮助企业精准展示产品特性与工艺流程查看源码
| 分享笔记 (共有 篇笔记) |
