/**
* 处理函数
*/
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)<br />\n";
return false;
}else{
$in = "<?xml version='1.0' encoding='UTF-8'?>";
$in .= "<Message>";
$in .= "<TranCode>".$tranCode."</TranCode>";
$in .= "<MsgContent>".$notifyMsg."</MsgContent>";
$in .= "</Message>";
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."<br>";
//echo "交易错误信息:" .$errMsg_value."<br>";
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 ///////////////
}
}
?>
语言包源码(languages/zh_cn/payment/bankcomm.php):
复制代码 代码如下:
<?php
/**
* 交通银行语言文件
* by: Reson
* 2014/03/31
*/
global $_LANG;
$_LANG['bankcomm'] = '交通银行在线支付';
$_LANG['bankcomm_desc'] = '交通银行在线支付';
$_LANG['pay_button'] = '交通银行支付';
?>
以下是调用的范例:
复制代码 代码如下: