<? Php /** * Bank of Communications online payment plug-in For Ecshop * Author: Reson * Date: 2014/03/31 */ If (! Defined ('in _ ECS ')) { Die ('hacking attempt '); } $ Payment_lang = ROOT_PATH. 'Ages/'. $ GLOBALS [' _ CFG '] ['Lang']. '/payment/bankcomm. Php '; If (file_exists ($ payment_lang )) { Global $ _ LANG; Include_once ($ payment_lang ); } /* Basic information of the module */ If (isset ($ set_modules) & $ set_modules = TRUE) { $ I = isset ($ modules )? Count ($ modules): 0; /* Code */ $ Modules [$ I] ['code'] = basename (_ FILE __, '. Php '); /* Description of the corresponding language item */ $ Modules [$ I] ['desc'] = 'bankcomm _ desc '; /* Supported Cash on Delivery */ $ Modules [$ I] ['is _ cod '] = '0 '; /* Whether online payment is supported */ $ Modules [$ I] ['is _ online'] = '1 '; /* Payment, determined by delivery */ $ Modules [$ I] ['pay _ period'] = '0 '; /* Author */ $ Modules [$ I] ['autor'] = 'reson '; /* Url */ $ Modules [$ I] ['Website'] = 'http: // www.daixiaorui.com '; /* Version */ $ Modules [$ I] ['version'] = '1. 0.0.0 '; /* Configuration information */ $ Modules [$ I] ['config'] = array (); Return; } /** * Class */ Class bankcomm { /** * Constructor * * @ Return void */ Function bankcomm () { } Function _ construct () { $ This-> bankcomm (); } /** * Submit a function */ Function get_code ($ order) { // Obtain the data transmitted from the form $ Param ['interfaceversion'] = '1. 0.0.0 '; // message version * $ Param ['merid'] = '000000'; // merchant ID (Test ID, which can be changed later) $ Param ['orderid'] = $ order ['orderid']; // order number * $ Param ['orderdate'] = local_date ("Ymd", gmtime (); // merchant Order Date * yyyyMMdd $ Param ['ordertime'] = local_date ("His", gmtime (); // merchant order time * HHmmss $ Param ['trantype'] = 0; // transaction type * 0: B2C $ Param ['amount'] = $ order ['amount']; // order amount * $ Param ['curtype'] = 'cny '; // transaction currency * default CNY $ Param ['ordercontent'] = ''; $ Param ['ordermono'] = $ order ['ordermono']; // merchant remarks $ Param ['phdflag'] = ''; // logistics delivery mark $ Param ['policytype'] = 1; // notification method * 1 notification $ Param ['merurl'] = ''; $ Param ['goodsurl'] = $ order ['goodsurl']; // pick up URL $ Param ['jumyun conds '] = ''; $ Param ['paybatchno'] = ''; $ Param ['proxymername'] = ''; $ Param ['proxymertype'] = ''; $ Param ['proxymercredentials '] = ''; $ Param ['nettype'] = 0; // channel number * 0: html Channel $ Param ['issbankno'] = ''; $ TranCode = "cb2200_sign "; Htmlentities ($ param ['ordermono'], "ENT_QUOTES", "UTF-8 "); // Connection string $ Source = ''; Foreach ($ param as $ key => $ val ){ If ($ key! = 'Issbankno ') $ Source. = $ val. '| '; } $ Source = substr ($ source, 0, strlen ($ source)-1 ); // Connection address: www.111cn.net $ SocketUrl = "tcp: // 127.0.0.1: 8080"; // the port here depends on your configuration. $ Fp = stream_socket_client ($ socketUrl, $ errno, $ errstr, 30 ); $ RetMsg = ""; // If (! $ Fp ){ Echo "$ errstr ($ errno) <br/> "; } Else { $ In = "<? Xml version = '1. 0' encoding = 'utf-8'?> "; $ In. = "<Message> "; $ In. = "<TranCode>". $ tranCode. "</TranCode> "; $ In. = "<MsgContent>". $ source. "</MsgContent> "; $ In. = "</Message> "; Fwrite ($ fp, $ in ); While (! Feof ($ fp )){ $ RetMsg = $ retMsg. fgets ($ fp, 1024 ); } Fclose ($ fp ); } // Parse and return 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 "transaction return code:". $ retCode_value. "<br> "; // Echo "transaction error message:". $ errMsg_value. "<br> "; Return "transaction error message:". $ errMsg_value. "<br> "; } Else { $ Param ['signmsg _ value'] = $ signMsg_value; $ Param ['orderurl _ value'] = $ orderUrl_value; $ Form_code = $ this-> create_html ($ param); // Create a submission form Return $ form_code; } } /** * Create a submission form */ Function create_html ($ param ){ $ Pay_html = '<form name = "form1" method = "post" action = "'. $ param ['orderurl _ value']. '"> <Input type = "hidden" name = "interfaceVersion" value = "'. $ param ['interfaceversion'].'"> <Input type = "hidden" name = "merID" value = "'. $ param ['merid'].'"> <Input type = "hidden" name = "orderid" value = "'. $ param ['orderid'].'"> <Input type = "hidden" name = "orderDate" value = "'. $ param ['orderdate'].'"> <Input type = "hidden" name = "orderTime" value = "'. $ param ['ordertime'].'"> <Input type = "hidden" name = "tranType" value = "'. $ param ['trantype'].'"> <Input type = "hidden" name = "amount" value = "'. $ param ['amount'].'"> <Input type = "hidden" name = "curType" value = "'. $ param ['curtype'].'"> <Input type = "hidden" name = "orderContent" value = "'. $ param ['ordercontent'].'"> <Input type = "hidden" name = "orderMono" value = "'. $ param ['ordermono'].'"> <Input type = "hidden" name = "phdFlag" value = "'. $ param ['phdflag'].'"> <Input type = "hidden" name = "yytype" value = "'. $ param ['policytype'].'"> <Input type = "hidden" name = "merURL" value = "'. $ param ['merurl'].'"> <Input type = "hidden" name = "goodsURL" value = "'. $ param ['goodsurl'].'"> <Input type = "hidden" name = "jumyun conds" value = "'. $ param ['jumyun conds']. '"> <Input type = "hidden" name = "payBatchNo" value = "'. $ param ['paybatchno'].'"> <Input type = "hidden" name = "proxyMerName" value = "'. $ param ['proxymername'].'"> <Input type = "hidden" name = "proxyMerType" value = "'. $ param ['proxymertype'].'"> <Input type = "hidden" name = "proxyMerCredentials" value = "'. $ param ['proxymercredentials']. '"> <Input type = "hidden" name = "netType" value = "'. $ param ['nettype'].'"> <Input type = "hidden" name = "merSignMsg" value = "'. $ param ['signmsg _ value'].'"> <Input type = "hidden" name = "issBankNo" value = "'. $ param ['issbankno'].'"> <Input type = "submit" value = "" class = "pay_button"/> </Form> '; Return $ pay_html; } /** * Processing functions */ Function respond () { $ TranCode = "cb2200_verify "; $ Policymsg = $ _ REQUEST ["policymsg"]; $ LastIndex = strripos ($ policymsg, "| "); $ SignMsg = substr ($ policymsg, $ lastIndex + 1); // signature information $ SrcMsg = substr ($ policymsg, 0, $ lastIndex + 1); // original // Connection address $ SocketUrl = "tcp: // fig: 8080 "; $ Fp = stream_socket_client ($ socketUrl, $ errno, $ errstr, 30 ); $ RetMsg = ""; If (! $ Fp ){ // Echo "$ errstr ($ errno) <br/> "; Return false; } Else { $ In = "<? Xml version = '1. 0' encoding = 'utf-8'?> "; $ In. = "<Message> "; $ In. = "<TranCode>". $ tranCode. "</TranCode> "; $ In. = "<MsgContent>". $ policymsg. "</MsgContent> "; $ In. = "</Message> "; Fwrite ($ fp, $ in ); While (! Feof ($ fp )){ $ RetMsg = $ retMsg. fgets ($ fp, 1024 ); } Fclose ($ fp ); } // Parse and return 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 "transaction return code:". $ retCode_value. "<br> "; // Echo "transaction error message:". $ errMsg_value. "<br> "; Return false; } Else { $ Arr = preg_split ("/| {1,}/", $ srcMsg ); $ Pay_id = $ arr [1]; $ Action_note = base64_decode ($ arr [16]); // Complete the order. Order_paid ($ pay_id, PS_PAYED, $ action_note ); // Notify the user that the transaction is completed Return true; } /// // Respond END /////////////// } } ?> Source code (ages/zh_cn/payment/bankcomm. php ): <? Php /** * Bank of Communications language files * By: Reson www.111cn.net * */ Global $ _ LANG; $ _ LANG ['bankcomm '] = 'Bank of communications online payment '; $ _ LANG ['bankcomm _ desc'] = 'Bank of communications online payment '; $ _ LANG ['pay _ click'] = 'Bank of communications payby '; ?> |