當前位置: 首頁>>代碼示例>>PHP>>正文


PHP COM::signC方法代碼示例

本文整理匯總了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;
 }
開發者ID:noikiy,項目名稱:cxe,代碼行數:99,代碼來源:pay_icbc.php

示例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
開發者ID:dalinhuang,項目名稱:shopexts,代碼行數:31,代碼來源:index.php


注:本文中的COM::signC方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。