本文整理汇总了PHP中COM::signC方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::signC方法的具体用法?PHP COM::signC怎么用?PHP COM::signC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COM
的用法示例。
在下文中一共展示了COM::signC方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toSubmit
function toSubmit($payment)
{
$merId = $this->getConf($payment["M_OrderId"], 'member_id');
$keyPass = $this->getConf($payment["M_OrderId"], 'keyPass');
$icbcno = $this->getConf($payment["M_OrderId"], 'icbcno');
$icbcFile = $this->getConf($payment["M_OrderId"], 'icbcFile');
$keyFile = $this->getConf($payment["M_OrderId"], 'keyFile');
$certFile = $this->getConf($payment["M_OrderId"], 'certFile');
$charset = $this->system->loadModel('utility/charset');
if (is_dir(dirname(__FILE__) . "/../../../home/upload/icbc/")) {
$realpath = dirname(__FILE__) . "/../../../home/upload/icbc/";
} elseif (is_dir(dirname(__FILE__) . "/../../../cert/icbc/")) {
$realpath = dirname(__FILE__) . "/../../../cert/icbc/";
}
$key = $realpath . $keyFile;
//私钥文件
$cert = $realpath . $certFile;
//公钥文件
$icbc = $realpath . $icbcFile;
if (!file_exists($key)) {
die("ICBC key file not found!");
}
if (!file_exists($cert)) {
die("ICBC Cert file not found!");
}
//接口名称固定为“ICBC_PERBANK_B2C”
$aREQ["interfaceName"] = "ICBC_PERBANK_B2C";
//接口版本目前为“1.0.0.0”
$aREQ["interfaceVersion"] = "1.0.0.11";
//商城代码,ICBC提供
$aREQ["merID"] = $merId;
//商户帐号,ICBC提供
$aREQ["merAcct"] = $icbcno;
//接收银行通知地址,目前只支持http协议80端口
$aREQ["merURL"] = $this->callbackUrl;
//HS方式实时发送通知;AG方式不发送通知;
$aREQ["notifyType"] = "HS";
//订单号商户端产生,一天内不能重复,拼接上订单号和支付号。
$aREQ["orderid"] = $payment['M_OrderId'] . "-" . $payment['M_Time'];
//$payment['M_OrderNO']."-".substr(trim($payment['M_OrderId']),0,10);
//金额以分为单位
$aREQ["amount"] = $payment['M_Amount'] * 100;
//币种目前只支持人民币,代码为“001”
$aREQ["curType"] = "001";
//对于HS方式“0”:发送成功或者失败信息;“1”,只发送交易成功信息。
$aREQ["resultType"] = 0;
//商户reference
//$aREQ["merReference"] = 0;
//客户端IP
$aREQ["merCustomIp"] = remote_addr();
//14位时间戳
$aREQ["orderDate"] = date("YmdHis", empty($payment['M_Time']) ? time() : $payment['M_Time']);
//$aREQ["orderDate"] = "20080620".date("His",time());
$aREQ["verifyJoinFlag"] = "0";
//以上五个字段用于客户支付页面显示
$aREQ["goodsID"] = "";
//网关只认GB2312
$aREQ["goodsName"] = $payment['M_OrderNO'];
//$aREQ["goodsName"] = "中文";
//$convert = new iconvex();
//$aREQ["goodsName"] = $convert->utf82gb($aREQ["goodsName"]);
$aREQ["goodsNum"] = 1;
//运费金额以分为单位
$aREQ["carriageAmt"] = 0;
$aREQ["merHint"] = "";
//备注
$aREQ["remark1"] = $charset->utf2local($payment['rnote'], "zh");
//备注2
$aREQ["remark2"] = "";
//“1”判断该客户是否与商户联名;取值“0”不检验客户是否与商户联名。
$aREQ["verifyJoinFlag"] = 0;
//构造V3版的xml
$tranData = "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\"?><B2CReq><interfaceName>" . $aREQ["interfaceName"] . "</interfaceName><interfaceVersion>" . $aREQ["interfaceVersion"] . "</interfaceVersion><orderInfo><orderDate>" . $aREQ["orderDate"] . "</orderDate><orderid>" . $aREQ["orderid"] . "</orderid><amount>" . $aREQ["amount"] . "</amount><curType>" . $aREQ["curType"] . "</curType><merID>" . $aREQ["merID"] . "</merID><merAcct>" . $aREQ["merAcct"] . "</merAcct></orderInfo><custom><verifyJoinFlag>" . $aREQ["verifyJoinFlag"] . "</verifyJoinFlag><Language>ZH_CN</Language></custom><message><goodsID>" . $aREQ["goodsID"] . "</goodsID><goodsName>" . $aREQ["goodsName"] . "</goodsName><goodsNum>" . $aREQ["goodsNum"] . "</goodsNum><carriageAmt>" . $aREQ["carriageAmt"] . "</carriageAmt><merHint>" . $aREQ["merHint"] . "</merHint><remark1>" . $aREQ["remark1"] . "</remark1><remark2>" . $aREQ["remark2"] . "</remark2><merURL>" . $aREQ["merURL"] . "</merURL><merVAR>" . $payment['M_OrderId'] . "</merVAR></message></B2CReq>";
if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
$bb = new COM('ICBCEBANKUTIL.B2CUtil');
$rc = $bb->init($icbc, $cert, $key, $keyPass);
$merSignMsg = $bb->signC($tranData, strlen($tranData));
} else {
//商户签名数据BASE64编码
$cmd = "/bin/icbc_sign '{$key}' '{$keyPass}' '{$tranData}'";
//error_log($cmd,3,__FILE__.".log");
$handle = popen($cmd, 'r');
$merSignMsg = fread($handle, 2096);
pclose($handle);
}
$fp = fopen($cert, "rb");
$merCert = fread($fp, filesize($cert));
$merCert = base64_encode($merCert);
fclose($fp);
$aFinalReq['interfaceName'] = $aREQ["interfaceName"];
$aFinalReq['interfaceVersion'] = $aREQ["interfaceVersion"];
$aFinalReq['tranData'] = base64_encode($tranData);
$aFinalReq['merSignMsg'] = $merSignMsg;
$aFinalReq['merCert'] = $merCert;
foreach ($aFinalReq as $key => $val) {
$return[$key] = $val;
}
return $return;
}
示例2: foreach
echo "<form action=?action=go method=post target='go'><table>";
foreach ($aREQ as $k => $v) {
echo "<tr><td>{$k}</td><td><input name=\"{$k}\" type=\"text\" value=\"{$v}\" size='100'/></td></tr>";
}
echo "<tr><td clospan=2><input type=submit value=submit></td></tr><table>";
echo "</form>";
}
if ($action == 'go') {
//xml
$tranData = "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\"?><B2CReq><interfaceName>" . $_REQUEST["interfaceName"] . "</interfaceName><interfaceVersion>" . $_REQUEST["interfaceVersion"] . "</interfaceVersion><orderInfo><orderDate>" . $_REQUEST["orderDate"] . "</orderDate><curType>" . $_REQUEST["curType"] . "</curType><merID>" . $_REQUEST["merID"] . "</merID><subOrderInfoList><subOrderInfo><orderid>" . $_REQUEST["orderid"] . "</orderid><amount>" . $_REQUEST["amount"] . "</amount><installmentTimes>" . $_REQUEST["installmentTimes"] . "</installmentTimes><merAcct>" . $_REQUEST["merAcct"] . "</merAcct><goodsID>" . $_REQUEST["goodsID"] . "</goodsID><goodsName>" . $_REQUEST["goodsName"] . "</goodsName><goodsNum>" . $_REQUEST["goodsNum"] . "</goodsNum><carriageAmt>" . $_REQUEST["carriageAmt"] . "</carriageAmt></subOrderInfo></subOrderInfoList></orderInfo><custom><verifyJoinFlag>" . $_REQUEST["verifyJoinFlag"] . "</verifyJoinFlag><Language>" . $_REQUEST["Language"] . "</Language></custom><message><merHint>" . $_REQUEST["merHint"] . "</merHint><remark1>" . $_REQUEST["remark1"] . "</remark1><remark2>" . $_REQUEST["remark2"] . "</remark2><merURL>" . $_REQUEST["merURL"] . "</merURL><merVAR>" . $_REQUEST["merVAR"] . "</merVAR></message></B2CReq>";
//商户签名数据BASE64编码
if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
//windows系统,请先注册ICBCEBankUtil.dll,这个文件在文档包中的asp文件夹中
$icbcutil = new COM("ICBCEBANKUTIL.B2CUtil");
$rc = $icbcutil->init(MERCCERTFILE, MERCCERTFILE, MERCRRVIFILE, MERCPASSWORD);
$merSignMsg = $icbcutil->signC($tranData, strlen($tranData));
} else {
$cmd = "/bin/icbc_sign '" . MERCRRVIFILE . "' '" . MERCPASSWORD . "' '{$tranData}'";
$handle = popen($cmd, 'r');
$merSignMsg = fread($handle, 2096);
pclose($handle);
}
//
$fp = fopen(MERCCERTFILE, "rb");
$merCert = fread($fp, filesize(MERCCERTFILE));
$merCert = base64_encode($merCert);
fclose($fp);
//
$tranData = base64_encode($tranData);
//
echo <<<EOF