成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

wemall app商城源碼Android之Native(原生)支付模式一demo

source / 3443人閱讀

摘要:本文分享原生支付模式一,供技術(shù)員參考學(xué)習(xí)。官網(wǎng)地址模式一商戶按固定格式生成鏈接二維碼,用戶掃碼后調(diào)微信會將和用戶發(fā)送到商戶設(shè)置的鏈接上,商戶收到請求生成訂單,調(diào)用統(tǒng)一支付接口下單提交到微信,微信會返回給商戶。

wemall-mobile是基于WeMall的Android app商城,只需要在原商城目錄下上傳接口文件即可完成服務(wù)端的配置,客戶端可定制修改。本文分享Native(原生)支付模式一demo,供技術(shù)員參考學(xué)習(xí)。

wemall官網(wǎng)地址:http://www.wemallshop.com

模式一:商戶按固定格式生成鏈接二維碼,用戶掃碼后調(diào)微信

會將productid和用戶openid發(fā)送到商戶設(shè)置的鏈接上,商戶收到

請求生成訂單,調(diào)用統(tǒng)一支付接口下單提交到微信,微信會返回

給商戶prepayid。

本例程對應(yīng)的二維碼由native_call_qrcode.php生成;

本例程對應(yīng)的響應(yīng)服務(wù)為native_call.php;

需要兩者配合使用。

native_call.php

log_result($log_name,"【接收到的native通知】:
".$xml."
");
    $nativeCall->saveData($xml);
    
    if($nativeCall->checkSign() == FALSE){
        $nativeCall->setReturnParameter("return_code","FAIL");//返回狀態(tài)碼
        $nativeCall->setReturnParameter("return_msg","簽名失敗");//返回信息
    }else{
        //提取product_id
        $product_id = $nativeCall->getProductId();
        
        //使用統(tǒng)一支付接口
        $unifiedOrder = new UnifiedOrder_pub();
        
        //根據(jù)不同的$product_id設(shè)定對應(yīng)的下單參數(shù),此處只舉例一種
        switch ($product_id) 
        {
            case WxPayConf_pub::APPID."static"://與native_call_qrcode.php中的靜態(tài)鏈接二維碼對應(yīng)
                //設(shè)置統(tǒng)一支付接口參數(shù)
                //設(shè)置必填參數(shù)
                //appid已填,商戶無需重復(fù)填寫
                //mch_id已填,商戶無需重復(fù)填寫
                //noncestr已填,商戶無需重復(fù)填寫
                //spbill_create_ip已填,商戶無需重復(fù)填寫
                //sign已填,商戶無需重復(fù)填寫
                $unifiedOrder->setParameter("body","貢獻(xiàn)一分錢");//商品描述
                //自定義訂單號,此處僅作舉例
                $timeStamp = time();
                $out_trade_no = WxPayConf_pub::APPID."$timeStamp";
                $unifiedOrder->setParameter("out_trade_no","$out_trade_no");//商戶訂單號             $unifiedOrder->setParameter("product_id","$product_id");//商品ID
                $unifiedOrder->setParameter("total_fee","1");//總金額
                $unifiedOrder->setParameter("notify_url",WxPayConf_pub::NOTIFY_URL);//通知地址 
                $unifiedOrder->setParameter("trade_type","NATIVE");//交易類型
                $unifiedOrder->setParameter("product_id","$product_id");//用戶標(biāo)識
                //非必填參數(shù),商戶可根據(jù)實際情況選填
                //$unifiedOrder->setParameter("sub_mch_id","XXXX");//子商戶號  
                //$unifiedOrder->setParameter("device_info","XXXX");//設(shè)備號 
                //$unifiedOrder->setParameter("attach","XXXX");//附加數(shù)據(jù) 
                //$unifiedOrder->setParameter("time_start","XXXX");//交易起始時間
                //$unifiedOrder->setParameter("time_expire","XXXX");//交易結(jié)束時間 
                //$unifiedOrder->setParameter("goods_tag","XXXX");//商品標(biāo)記 
                //$unifiedOrder->setParameter("openid","XXXX");//用戶標(biāo)識
                
                //獲取prepay_id
                $prepay_id = $unifiedOrder->getPrepayId();
                //設(shè)置返回碼
                //設(shè)置必填參數(shù)
                //appid已填,商戶無需重復(fù)填寫
                //mch_id已填,商戶無需重復(fù)填寫
                //noncestr已填,商戶無需重復(fù)填寫
                //sign已填,商戶無需重復(fù)填寫
                $nativeCall->setReturnParameter("return_code","SUCCESS");//返回狀態(tài)碼
                $nativeCall->setReturnParameter("result_code","SUCCESS");//業(yè)務(wù)結(jié)果
                $nativeCall->setReturnParameter("prepay_id","$prepay_id");//預(yù)支付ID
                
                break;
            default:
                //設(shè)置返回碼
                //設(shè)置必填參數(shù)
                //appid已填,商戶無需重復(fù)填寫
                //mch_id已填,商戶無需重復(fù)填寫
                //noncestr已填,商戶無需重復(fù)填寫
                //sign已填,商戶無需重復(fù)填寫
                $nativeCall->setReturnParameter("return_code","SUCCESS");//返回狀態(tài)碼
                $nativeCall->setReturnParameter("result_code","FAIL");//業(yè)務(wù)結(jié)果
                $nativeCall->setReturnParameter("err_code_des","此商品無效");//業(yè)務(wù)結(jié)果
                break;
        }

    }
    
    //將結(jié)果返回微信
    $returnXml = $nativeCall->returnXml();
    $log_->log_result($log_name,"【返回微信的native響應(yīng)】:
".$returnXml."
");

    echo $returnXml;
    
    //交易完成

?>

log_.php


WxPayPubHelper.php

 $v)
        {
            if($urlencode)
            {
               $v = urlencode($v);
            }
            //$buff .= strtolower($k) . "=" . $v . "&";
            $buff .= $k . "=" . $v . "&";
        }
        $reqPar;
        if (strlen($buff) > 0) 
        {
            $reqPar = substr($buff, 0, strlen($buff)-1);
        }
        return $reqPar;
    }
    
    /**
     *     作用:生成簽名
     */
    public function getSign($Obj)
    {
        foreach ($Obj as $k => $v)
        {
            $Parameters[$k] = $v;
        }
        //簽名步驟一:按字典序排序參數(shù)
        ksort($Parameters);
        $String = $this->formatBizQueryParaMap($Parameters, false);
        //echo "【string1】".$String."
"; //簽名步驟二:在string后加入KEY $String = $String."&key=".WxPayConf_pub::KEY; //echo "【string2】".$String."
"; //簽名步驟三:MD5加密 $String = md5($String); //echo "【string3】 ".$String."
"; //簽名步驟四:所有字符轉(zhuǎn)為大寫 $result_ = strtoupper($String); //echo "【result】 ".$result_."
"; return $result_; } /** * 作用:array轉(zhuǎn)xml */ function arrayToXml($arr) { $xml = ""; foreach ($arr as $key=>$val) { if (is_numeric($val)) { $xml.="<".$key.">".$val.""; } else $xml.="<".$key.">"; } $xml.=""; return $xml; } /** * 作用:將xml轉(zhuǎn)為array */ public function xmlToArray($xml) { //將XML轉(zhuǎn)為array $array_data = json_decode(json_encode(simplexml_load_string($xml, "SimpleXMLElement", LIBXML_NOCDATA)), true); return $array_data; } /** * 作用:以post方式提交xml到對應(yīng)的接口url */ public function postXmlCurl($xml,$url,$second=30) { //初始化curl $ch = curl_init(); //設(shè)置超時 curl_setopt($ch, CURLOP_TIMEOUT, $second); //這里設(shè)置代理,如果有的話 //curl_setopt($ch,CURLOPT_PROXY, "8.8.8.8"); //curl_setopt($ch,CURLOPT_PROXYPORT, 8080); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); //設(shè)置header curl_setopt($ch, CURLOPT_HEADER, FALSE); //要求結(jié)果為字符串且輸出到屏幕上 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //post提交方式 curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); //運(yùn)行curl $data = curl_exec($ch); curl_close($ch); //返回結(jié)果 if($data) { curl_close($ch); return $data; } else { $error = curl_errno($ch); echo "curl出錯,錯誤碼:$error"."
"; echo ""; echo ""); echo $wording."
"; var_dump($err); print_r("
"); } } /** * 請求型接口的基類 */ class Wxpay_client_pub extends Common_util_pub { var $parameters;//請求參數(shù),類型為關(guān)聯(lián)數(shù)組 public $response;//微信返回的響應(yīng) public $result;//返回參數(shù),類型為關(guān)聯(lián)數(shù)組 var $url;//接口鏈接 var $curl_timeout;//curl超時時間 /** * 作用:設(shè)置請求參數(shù) */ function setParameter($parameter, $parameterValue) { $this->parameters[$this->trimString($parameter)] = $this->trimString($parameterValue); } /** * 作用:設(shè)置標(biāo)配的請求參數(shù),生成簽名,生成接口參數(shù)xml */ function createXml() { $this->parameters["appid"] = WxPayConf_pub::APPID;//公眾賬號ID $this->parameters["mch_id"] = WxPayConf_pub::MCHID;//商戶號 $this->parameters["nonce_str"] = $this->createNoncestr();//隨機(jī)字符串 $this->parameters["sign"] = $this->getSign($this->parameters);//簽名 return $this->arrayToXml($this->parameters); } /** * 作用:post請求xml */ function postXml() { $xml = $this->createXml(); $this->response = $this->postXmlCurl($xml,$this->url,$this->curl_timeout); return $this->response; } /** * 作用:使用證書post請求xml */ function postXmlSSL() { $xml = $this->createXml(); $this->response = $this->postXmlSSLCurl($xml,$this->url,$this->curl_timeout); return $this->response; } /** * 作用:獲取結(jié)果,默認(rèn)不使用證書 */ function getResult() { $this->postXml(); $this->result = $this->xmlToArray($this->response); return $this->result; } } /** * 統(tǒng)一支付接口類 */ class UnifiedOrder_pub extends Wxpay_client_pub { function __construct() { //設(shè)置接口鏈接 $this->url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; //設(shè)置curl超時時間 $this->curl_timeout = WxPayConf_pub::CURL_TIMEOUT; } /** * 生成接口參數(shù)xml */ function createXml() { try { //檢測必填參數(shù) if($this->parameters["out_trade_no"] == null) { throw new SDKRuntimeException("缺少統(tǒng)一支付接口必填參數(shù)out_trade_no!"."
"); }elseif($this->parameters["body"] == null){ throw new SDKRuntimeException("缺少統(tǒng)一支付接口必填參數(shù)body!"."
"); }elseif ($this->parameters["total_fee"] == null ) { throw new SDKRuntimeException("缺少統(tǒng)一支付接口必填參數(shù)total_fee!"."
"); }elseif ($this->parameters["notify_url"] == null) { throw new SDKRuntimeException("缺少統(tǒng)一支付接口必填參數(shù)notify_url!"."
"); }elseif ($this->parameters["trade_type"] == null) { throw new SDKRuntimeException("缺少統(tǒng)一支付接口必填參數(shù)trade_type!"."
"); }elseif ($this->parameters["trade_type"] == "JSAPI" && $this->parameters["openid"] == NULL){ throw new SDKRuntimeException("統(tǒng)一支付接口中,缺少必填參數(shù)openid!trade_type為JSAPI時,openid為必填參數(shù)!"."
"); } $this->parameters["appid"] = WxPayConf_pub::APPID;//公眾賬號ID $this->parameters["mch_id"] = WxPayConf_pub::MCHID;//商戶號 $this->parameters["spbill_create_ip"] = $_SERVER["REMOTE_ADDR"];//終端ip $this->parameters["nonce_str"] = $this->createNoncestr();//隨機(jī)字符串 $this->parameters["sign"] = $this->getSign($this->parameters);//簽名 return $this->arrayToXml($this->parameters); }catch (SDKRuntimeException $e) { die($e->errorMessage()); } } /** * 獲取prepay_id */ function getPrepayId() { $this->postXml(); $this->result = $this->xmlToArray($this->response); $prepay_id = $this->result["prepay_id"]; return $prepay_id; } } /** * 訂單查詢接口 */ class OrderQuery_pub extends Wxpay_client_pub { function __construct() { //設(shè)置接口鏈接 $this->url = "https://api.mch.weixin.qq.com/pay/orderquery"; //設(shè)置curl超時時間 $this->curl_timeout = WxPayConf_pub::CURL_TIMEOUT; } /** * 生成接口參數(shù)xml */ function createXml() { try { //檢測必填參數(shù) if($this->parameters["out_trade_no"] == null && $this->parameters["transaction_id"] == null) { throw new SDKRuntimeException("訂單查詢接口中,out_trade_no、transaction_id至少填一個!"."
"); } $this->parameters["appid"] = WxPayConf_pub::APPID;//公眾賬號ID $this->parameters["mch_id"] = WxPayConf_pub::MCHID;//商戶號 $this->parameters["nonce_str"] = $this->createNoncestr();//隨機(jī)字符串 $this->parameters["sign"] = $this->getSign($this->parameters);//簽名 return $this->arrayToXml($this->parameters); }catch (SDKRuntimeException $e) { die($e->errorMessage()); } } } /** * 退款申請接口 */ class Refund_pub extends Wxpay_client_pub { function __construct() { //設(shè)置接口鏈接 $this->url = "https://api.mch.weixin.qq.com/secapi/pay/refund"; //設(shè)置curl超時時間 $this->curl_timeout = WxPayConf_pub::CURL_TIMEOUT; } /** * 生成接口參數(shù)xml */ function createXml() { try { //檢測必填參數(shù) if($this->parameters["out_trade_no"] == null && $this->parameters["transaction_id"] == null) { throw new SDKRuntimeException("退款申請接口中,out_trade_no、transaction_id至少填一個!"."
"); }elseif($this->parameters["out_refund_no"] == null){ throw new SDKRuntimeException("退款申請接口中,缺少必填參數(shù)out_refund_no!"."
"); }elseif($this->parameters["total_fee"] == null){ throw new SDKRuntimeException("退款申請接口中,缺少必填參數(shù)total_fee!"."
"); }elseif($this->parameters["refund_fee"] == null){ throw new SDKRuntimeException("退款申請接口中,缺少必填參數(shù)refund_fee!"."
"); }elseif($this->parameters["op_user_id"] == null){ throw new SDKRuntimeException("退款申請接口中,缺少必填參數(shù)op_user_id!"."
"); } $this->parameters["appid"] = WxPayConf_pub::APPID;//公眾賬號ID $this->parameters["mch_id"] = WxPayConf_pub::MCHID;//商戶號 $this->parameters["nonce_str"] = $this->createNoncestr();//隨機(jī)字符串 $this->parameters["sign"] = $this->getSign($this->parameters);//簽名 return $this->arrayToXml($this->parameters); }catch (SDKRuntimeException $e) { die($e->errorMessage()); } } /** * 作用:獲取結(jié)果,使用證書通信 */ function getResult() { $this->postXmlSSL(); $this->result = $this->xmlToArray($this->response); return $this->result; } } /** * 退款查詢接口 */ class RefundQuery_pub extends Wxpay_client_pub { function __construct() { //設(shè)置接口鏈接 $this->url = "https://api.mch.weixin.qq.com/pay/refundquery"; //設(shè)置curl超時時間 $this->curl_timeout = WxPayConf_pub::CURL_TIMEOUT; } /** * 生成接口參數(shù)xml */ function createXml() { try { if($this->parameters["out_refund_no"] == null && $this->parameters["out_trade_no"] == null && $this->parameters["transaction_id"] == null && $this->parameters["refund_id "] == null) { throw new SDKRuntimeException("退款查詢接口中,out_refund_no、out_trade_no、transaction_id、refund_id四個參數(shù)必填一個!"."
"); } $this->parameters["appid"] = WxPayConf_pub::APPID;//公眾賬號ID $this->parameters["mch_id"] = WxPayConf_pub::MCHID;//商戶號 $this->parameters["nonce_str"] = $this->createNoncestr();//隨機(jī)字符串 $this->parameters["sign"] = $this->getSign($this->parameters);//簽名 return $this->arrayToXml($this->parameters); }catch (SDKRuntimeException $e) { die($e->errorMessage()); } } /** * 作用:獲取結(jié)果,使用證書通信 */ function getResult() { $this->postXmlSSL(); $this->result = $this->xmlToArray($this->response); return $this->result; } } /** * 對賬單接口 */ class DownloadBill_pub extends Wxpay_client_pub { function __construct() { //設(shè)置接口鏈接 $this->url = "https://api.mch.weixin.qq.com/pay/downloadbill"; //設(shè)置curl超時時間 $this->curl_timeout = WxPayConf_pub::CURL_TIMEOUT; } /** * 生成接口參數(shù)xml */ function createXml() { try { if($this->parameters["bill_date"] == null ) { throw new SDKRuntimeException("對賬單接口中,缺少必填參數(shù)bill_date!"."
"); } $this->parameters["appid"] = WxPayConf_pub::APPID;//公眾賬號ID $this->parameters["mch_id"] = WxPayConf_pub::MCHID;//商戶號 $this->parameters["nonce_str"] = $this->createNoncestr();//隨機(jī)字符串 $this->parameters["sign"] = $this->getSign($this->parameters);//簽名 return $this->arrayToXml($this->parameters); }catch (SDKRuntimeException $e) { die($e->errorMessage()); } } /** * 作用:獲取結(jié)果,默認(rèn)不使用證書 */ function getResult() { $this->postXml(); $this->result = $this->xmlToArray($this->result_xml); return $this->result; } } /** * 短鏈接轉(zhuǎn)換接口 */ class ShortUrl_pub extends Wxpay_client_pub { function __construct() { //設(shè)置接口鏈接 $this->url = "https://api.mch.weixin.qq.com/tools/shorturl"; //設(shè)置curl超時時間 $this->curl_timeout = WxPayConf_pub::CURL_TIMEOUT; } /** * 生成接口參數(shù)xml */ function createXml() { try { if($this->parameters["long_url"] == null ) { throw new SDKRuntimeException("短鏈接轉(zhuǎn)換接口中,缺少必填參數(shù)long_url!"."
"); } $this->parameters["appid"] = WxPayConf_pub::APPID;//公眾賬號ID $this->parameters["mch_id"] = WxPayConf_pub::MCHID;//商戶號 $this->parameters["nonce_str"] = $this->createNoncestr();//隨機(jī)字符串 $this->parameters["sign"] = $this->getSign($this->parameters);//簽名 return $this->arrayToXml($this->parameters); }catch (SDKRuntimeException $e) { die($e->errorMessage()); } } /** * 獲取prepay_id */ function getShortUrl() { $this->postXml(); $prepay_id = $this->result["short_url"]; return $prepay_id; } } /** * 響應(yīng)型接口基類 */ class Wxpay_server_pub extends Common_util_pub { public $data;//接收到的數(shù)據(jù),類型為關(guān)聯(lián)數(shù)組 var $returnParameters;//返回參數(shù),類型為關(guān)聯(lián)數(shù)組 /** * 將微信的請求xml轉(zhuǎn)換成關(guān)聯(lián)數(shù)組,以方便數(shù)據(jù)處理 */ function saveData($xml) { $this->data = $this->xmlToArray($xml); } function checkSign() { $tmpData = $this->data; unset($tmpData["sign"]); $sign = $this->getSign($tmpData);//本地簽名 if ($this->data["sign"] == $sign) { return TRUE; } return FALSE; } /** * 獲取微信的請求數(shù)據(jù) */ function getData() { return $this->data; } /** * 設(shè)置返回微信的xml數(shù)據(jù) */ function setReturnParameter($parameter, $parameterValue) { $this->returnParameters[$this->trimString($parameter)] = $this->trimString($parameterValue); } /** * 生成接口參數(shù)xml */ function createXml() { return $this->arrayToXml($this->returnParameters); } /** * 將xml數(shù)據(jù)返回微信 */ function returnXml() { $returnXml = $this->createXml(); return $returnXml; } } /** * 通用通知接口 */ class Notify_pub extends Wxpay_server_pub { } /** * 請求商家獲取商品信息接口 */ class NativeCall_pub extends Wxpay_server_pub { /** * 生成接口參數(shù)xml */ function createXml() { if($this->returnParameters["return_code"] == "SUCCESS"){ $this->returnParameters["appid"] = WxPayConf_pub::APPID;//公眾賬號ID $this->returnParameters["mch_id"] = WxPayConf_pub::MCHID;//商戶號 $this->returnParameters["nonce_str"] = $this->createNoncestr();//隨機(jī)字符串 $this->returnParameters["sign"] = $this->getSign($this->returnParameters);//簽名 } return $this->arrayToXml($this->returnParameters); } /** * 獲取product_id */ function getProductId() { $product_id = $this->data["product_id"]; return $product_id; } } /** * 靜態(tài)鏈接二維碼 */ class NativeLink_pub extends Common_util_pub { var $parameters;//靜態(tài)鏈接參數(shù) var $url;//靜態(tài)鏈接 function __construct() { } /** * 設(shè)置參數(shù) */ function setParameter($parameter, $parameterValue) { $this->parameters[$this->trimString($parameter)] = $this->trimString($parameterValue); } /** * 生成Native支付鏈接二維碼 */ function createLink() { try { if($this->parameters["product_id"] == null) { throw new SDKRuntimeException("缺少Native支付二維碼鏈接必填參數(shù)product_id!"."
"); } $this->parameters["appid"] = WxPayConf_pub::APPID;//公眾賬號ID $this->parameters["mch_id"] = WxPayConf_pub::MCHID;//商戶號 $time_stamp = time(); $this->parameters["time_stamp"] = "$time_stamp";//時間戳 $this->parameters["nonce_str"] = $this->createNoncestr();//隨機(jī)字符串 $this->parameters["sign"] = $this->getSign($this->parameters);//簽名 $bizString = $this->formatBizQueryParaMap($this->parameters, false); $this->url = "weixin://wxpay/bizpayurl?".$bizString; }catch (SDKRuntimeException $e) { die($e->errorMessage()); } } /** * 返回鏈接 */ function getUrl() { $this->createLink(); return $this->url; } } /** * JSAPI支付——H5網(wǎng)頁端調(diào)起支付接口 */ class JsApi_pub extends Common_util_pub { var $code;//code碼,用以獲取openid var $openid;//用戶的openid var $parameters;//jsapi參數(shù),格式為json var $prepay_id;//使用統(tǒng)一支付接口得到的預(yù)支付id var $curl_timeout;//curl超時時間 function __construct() { //設(shè)置curl超時時間 $this->curl_timeout = WxPayConf_pub::CURL_TIMEOUT; } /** * 作用:生成可以獲得code的url */ function createOauthUrlForCode($redirectUrl) { $urlObj["appid"] = WxPayConf_pub::APPID; $urlObj["redirect_uri"] = "$redirectUrl"; $urlObj["response_type"] = "code"; $urlObj["scope"] = "snsapi_base"; $urlObj["state"] = "STATE"."#wechat_redirect"; $bizString = $this->formatBizQueryParaMap($urlObj, false); return "https://open.weixin.qq.com/connect/oauth2/authorize?".$bizString; } /** * 作用:生成可以獲得openid的url */ function createOauthUrlForOpenid() { $urlObj["appid"] = WxPayConf_pub::APPID; $urlObj["secret"] = WxPayConf_pub::APPSECRET; $urlObj["code"] = $this->code; $urlObj["grant_type"] = "authorization_code"; $bizString = $this->formatBizQueryParaMap($urlObj, false); return "https://api.weixin.qq.com/sns/oauth2/access_token?".$bizString; } /** * 作用:通過curl向微信提交code,以獲取openid */ function getOpenid() { $url = $this->createOauthUrlForOpenid(); //初始化curl $ch = curl_init(); //設(shè)置超時 curl_setopt($ch, CURLOP_TIMEOUT, $this->curl_timeout); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //運(yùn)行curl,結(jié)果以jason形式返回 $res = curl_exec($ch); curl_close($ch); //取出openid $data = json_decode($res,true); $this->openid = $data["openid"]; return $this->openid; } /** * 作用:設(shè)置prepay_id */ function setPrepayId($prepayId) { $this->prepay_id = $prepayId; } /** * 作用:設(shè)置code */ function setCode($code_) { $this->code = $code_; } /** * 作用:設(shè)置jsapi的參數(shù) */ public function getParameters() { $jsApiObj["appId"] = WxPayConf_pub::APPID; $timeStamp = time(); $jsApiObj["timeStamp"] = "$timeStamp"; $jsApiObj["nonceStr"] = $this->createNoncestr(); $jsApiObj["package"] = "prepay_id=$this->prepay_id"; $jsApiObj["signType"] = "MD5"; $jsApiObj["paySign"] = $this->getSign($jsApiObj); $this->parameters = json_encode($jsApiObj); return $this->parameters; } } ?>

WeMall - 開源微商城 微信商城 商城源碼 分銷商城 b2b2c商城系統(tǒng)

wemall官網(wǎng)地址:http://www.wemallshop.com

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/22121.html

相關(guān)文章

  • wemall app商城源碼Android支付寶接口公用函數(shù)

    摘要:本文分享商城源碼之支付寶接口公用函數(shù),該類是請求通知返回兩個文件所調(diào)用的公用函數(shù)核心處理文件,供技術(shù)員參考學(xué)習(xí)。 wemall-mobile是基于WeMall的Android app商城,只需要在原商城目錄下上傳接口文件即可完成服務(wù)端的配置,客戶端可定制修改。本文分享wemall app商城源碼Android之 支付寶接口公用函數(shù),該類是請求、通知返回兩個文件所調(diào)用的公用函數(shù)核心處理文...

    Lemon_95 評論0 收藏0
  • wemall app商城源碼Android支付寶通知處理類

    摘要:是基于的商城,只需要在原商城目錄下上傳接口文件即可完成服務(wù)端的配置,客戶端可定制修改。本文分享商城源碼之處理支付寶各接口通知返回,供技術(shù)員參考學(xué)習(xí)。 wemall-mobile是基于WeMall的Android app商城,只需要在原商城目錄下上傳接口文件即可完成服務(wù)端的配置,客戶端可定制修改。本文分享wemall app商城源碼Android之處理支付寶各接口通知返回,供技術(shù)員...

    Crazy_Coder 評論0 收藏0
  • wemall app商城系統(tǒng)Android支付寶接口RSA函數(shù)

    摘要:本文分享支付寶接口函數(shù)簽名驗簽解密等,供技術(shù)員參考學(xué)習(xí)。以下代碼只是為了方便商戶測試而提供的樣例代碼,商戶可以根據(jù)自己網(wǎng)站的需要,按照技術(shù)文檔編寫并非一定要使用該代碼,該代碼僅供學(xué)習(xí)和研究支付寶接口使用,只是提供一個參考。 wemall-mobile是基于WeMall的Android app商城,只需要在原商城目錄下上傳接口文件即可完成服務(wù)端的配置,客戶端可定制修改。本文分享支付寶接口...

    NusterCache 評論0 收藏0
  • wemall app商城系統(tǒng)Android支付寶接口RSA函數(shù)

    摘要:本文分享支付寶接口函數(shù)簽名驗簽解密等,供技術(shù)員參考學(xué)習(xí)。以下代碼只是為了方便商戶測試而提供的樣例代碼,商戶可以根據(jù)自己網(wǎng)站的需要,按照技術(shù)文檔編寫并非一定要使用該代碼,該代碼僅供學(xué)習(xí)和研究支付寶接口使用,只是提供一個參考。 wemall-mobile是基于WeMall的Android app商城,只需要在原商城目錄下上傳接口文件即可完成服務(wù)端的配置,客戶端可定制修改。本文分享支付寶接口...

    hiyang 評論0 收藏0
  • wemall app商城源碼AndroidListView異步加載網(wǎng)絡(luò)圖片(優(yōu)化緩存機(jī)制)

    摘要:本文分享商城源碼之異步加載網(wǎng)絡(luò)圖片優(yōu)化緩存機(jī)制代碼信息,供技術(shù)員參考學(xué)習(xí)。采用線程池內(nèi)存緩存文件緩存內(nèi)存緩存中網(wǎng)上很多是采用來防止堆溢出,這兒嚴(yán)格限制只能使用最大內(nèi)存的對下載的圖片進(jìn)行按比例縮放,以減少內(nèi)存的消耗具體的代碼里面說明。 wemall-mobile是基于WeMall的android app商城,只需要在原商城目錄下上傳接口文件即可完成服務(wù)端的配置,客戶端可定制修改。...

    luqiuwen 評論0 收藏0

發(fā)表評論

0條評論

閱讀需要支付1元查看
<