對於ECSHOP來講,支付是以接口的形式存在的。因而:javascript
1:首先添加接口文件php
includes\modules\payment下,增長abcbank.php,代碼以下:java
<?php /** * ECSHOP 農行在線插件 * $Author: 嘉興科藍軟件有限公司 * QQ 32974283 */ 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://www.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 所定義的地址上。web
二:發送和接收數據庫
MerchantPayment/MerchantPayment.php,以下:ide
<?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; //三、生成支付請求對象 $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()) { //二、、支付成功 // 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 = "http://localhost:8080/huahui/user.php?act=order_list"; echo "<script language='javascript' type='text/javascript'>"; echo "window.location.href='$url'"; echo "</script>"; } else { //三、失敗 print ("<br>ReturnCode = [" . $tResponse->getReturnCode() . "]<br>"); print ("ErrorMessage = [" . $tResponse->getErrorMessage() . "]<br>"); set_pay_error($tResponse->getValue("OrderNo"), "", $tResponse->getValue("Amount"), '農行支付', $tResponse->getReturnCode()); } ?>
三:安裝post
接下來,咱們就須要安裝了,ui
1:首先將文件夾和文件進行覆蓋;this
2:進入系統後臺,點擊安裝
3:修改證書地址、商戶號、密碼等,
首先,找到文件:\ebusclient\TrustMerchant.ini,而後把2和4兩個證書的路徑,改成cert文件夾對應文件的絕對路徑。上圖3處指須要給接口指定一個日誌路徑(備註:必定要建立路徑)。
至此,咱們的ecshop的pc端已經支持農行支付了。
四:關於手機端
echshop的支付只要按照上面進行安裝,數據庫中就有了記錄,以下:
因此,手機端相似,接口文件不須要動了。只不過,須要在mobile目錄下同樣添加MerchantPayment文件夾,加入發送和接收的文件就能夠了。