在使用插件之前,请配置好交通银行在线支付的环境(具体安装方法,交行提供的demo会有,也不是很难,注意好细节就行)。安装好之后,请将includes文件夹和languages文件夹拷贝到ecshop站点的根目录覆盖(最下面有源码下载),最后进入后台的支付模块安装即可。
以下是调用的范例:
代码如下 | 复制代码 |
$order_['orderid'] = $order['order_sn']; $order_['amount'] = $order['yd_price']; $order_['orderMono'] = '测试'; //商家备注 $order_['goodsURL'] = "http://".$_SERVER['HTTP_HOST'].'/respond.php?code=bankcomm'; //取货URL $pay_code = new bankcomm; $pay_button = $pay_code->get_code($order_); $order['pay_button'] = $pay_button; //即此时已经生成了一个支付按钮 |
源码(includes/modules/payment/bankcomm.php):
代码如下 | 复制代码 |
* 交通银行在线支付插件 For Ecshop * Author: Reson * Date: 2014/03/31 */
{ die('Hacking attempt'); }
{ 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'] = 'bankcomm_desc';
$modules[$i]['is_cod'] = '0';
$modules[$i]['is_online'] = '1';
$modules[$i]['pay_fee'] = '0';
$modules[$i]['author'] = 'Reson';
$modules[$i]['website'] = 'http://www.daixiaorui.com';
$modules[$i]['version'] = '1.0.0.0';
$modules[$i]['config'] = array(); return; }
* 类 */ class bankcomm { /** * 构造函数 * * @return void */ function bankcomm() { }
{ $this->bankcomm(); }
* 提交函数 */ function get_code($order) { //获得表单传过来的数据 $param['interfaceVersion'] = '1.0.0.0'; //消息版本号* $param['merID'] = '301310063009501'; //商户号 (测试号,后期可自行更改) $param['orderid'] = $order['orderid']; //订单号* $param['orderDate'] = local_date("Ymd",gmtime()); //商户订单日期* yyyyMMdd $param['orderTime'] = local_date("His",gmtime()); //商户订单时间* HHmmss $param['tranType'] = 0; //交易类别* 0:B2C $param['amount'] = $order['amount']; //订单金额* $param['curType'] = 'CNY'; //交易币种* 默认CNY $param['orderContent'] = ''; $param['orderMono'] = $order['orderMono']; //商家备注 $param['phdFlag'] = ''; //物流配送标志 $param['notifyType'] = 1; //通知方式* 1 通知 $param['merURL'] = ''; $param['goodsURL'] = $order['goodsURL']; //取货URL $param['jumpSeconds'] = ''; $param['payBatchNo'] = ''; $param['proxyMerName'] = ''; $param['proxyMerType'] = ''; $param['proxyMerCredentials'] = ''; $param['netType'] = 0; //渠道编号* 0:html渠道 $param['issBankNo'] = ''; $tranCode = "cb2200_sign";
//连接字符串 $source = ''; foreach($param as $key=>$val){ if($key != 'issBankNo') $source .= $val.'|'; } $source = substr($source,0,strlen($source)-1);
$socketUrl = "tcp://127.0.0.1:8080"; //这里的端口根据自己配置的情况 $fp = stream_socket_client($socketUrl, $errno, $errstr, 30); $retMsg=""; // if (!$fp) { echo "$errstr ($errno) } else { $in = ""; $in .= " $in .= " $in .= " $in .= ""; fwrite($fp, $in); while (!feof($fp)) { $retMsg =$retMsg.fgets($fp, 1024); } fclose($fp); } //解析返回xml $dom = new DOMDocument; $dom->loadXML($retMsg); $retCode = $dom->getElementsByTagName('retCode'); $retCode_value = $retCode->item(0)->nodeValue; $errMsg = $dom->getElementsByTagName('errMsg'); $errMsg_value = $errMsg->item(0)->nodeValue; $signMsg = $dom->getElementsByTagName('signMsg'); $signMsg_value = $signMsg->item(0)->nodeValue; $orderUrl = $dom->getElementsByTagName('orderUrl'); $orderUrl_value = $orderUrl->item(0)->nodeValue; $MerchID = $dom->getElementsByTagName('MerchID'); $merID = $MerchID->item(0)->nodeValue; //echo "retMsg=".$retMsg; //echo $retCode_value." ".$errMsg_value." ".$signMsg_value." ".$orderUrl_value; if($retCode_value != "0"){ //echo "交易返回码:".$retCode_value." //echo "交易错误信息:" .$errMsg_value." return "交易错误信息:" .$errMsg_value." }else{ $param['signMsg_value'] = $signMsg_value; $param['orderUrl_value'] = $orderUrl_value; $form_code = $this->create_html($param); //创建提交表单 return $form_code; } } /** * 创建提交表单 */ function create_html($param){ $pay_html =' ';return $pay_html; }
* 处理函数 */ function respond() { $tranCode = "cb2200_verify"; $notifyMsg = $_REQUEST["notifyMsg"]; $lastIndex = strripos($notifyMsg,"|"); $signMsg = substr($notifyMsg,$lastIndex+1); //签名信息 $srcMsg = substr($notifyMsg,0,$lastIndex+1);//原文 //连接地址 $socketUrl = "tcp://127.0.0.1:8080"; $fp = stream_socket_client($socketUrl, $errno, $errstr, 30); $retMsg=""; if (!$fp) { //echo "$errstr ($errno) return false; }else{ $in = ""; $in .= " $in .= " $in .= " $in .= ""; fwrite($fp, $in); while (!feof($fp)) { $retMsg =$retMsg.fgets($fp, 1024); } fclose($fp); } //解析返回xml $dom = new DOMDocument; $dom->loadXML($retMsg); $retCode = $dom->getElementsByTagName('retCode'); $retCode_value = $retCode->item(0)->nodeValue; $errMsg = $dom->getElementsByTagName('errMsg'); $errMsg_value = $errMsg->item(0)->nodeValue; $signMsg = $dom->getElementsByTagName('signMsg'); $signMsg_value = $signMsg->item(0)->nodeValue; if($retCode_value != ''){ //echo "交易返回码:".$retCode_value." //echo "交易错误信息:" .$errMsg_value." return false; }else{ $arr = preg_split("/|{1,}/",$srcMsg); $pay_id = $arr[1]; $action_note = base64_decode($arr[16]); // 完成订单。 order_paid($pay_id, PS_PAYED, $action_note); //告诉用户交易完成 return true; } ///////////////// respond END /////////////// } }
* 交通银行语言文件 * by: Reson www.111com.net * 2014/03/31 */
$_LANG['bankcomm_desc'] = '交通银行在线支付'; $_LANG['pay_button'] = '交通银行支付';
|
原文件址:http://www.daixiaorui.com/read/80.html
原文下载:http://file.111com.net/upload/2014/4/13962827995368.zip
创造与魔法 安卓版v1.0.0750
创造与魔法是一款开放世界手游,在游戏中玩家可探索这个奇妙的世
创造与魔法修改版 最新版v1.0.0750
创造与魔法无限点券版是款探索冒险游戏,该款游戏的操作还是蛮自
战争与文明官方版本 安卓版v1.7.16
战争与文明是一款由上海邮通科技有限公司开发的战争策略游戏,这
迷你世界0元领皮肤无限迷你币版 最新安卓版v1.43.0
迷你世界0元购买皮肤版是这款开放沙盒冒险建造游戏的特殊破解版
创造与魔法无限经验版 安卓版v1.0.0750
创造与魔法无限经验版是款可以改造环境,整个游戏的自由度还是蛮