<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ~~~ class Pay2 extends Wechat { private $appid = 'wxa5ed04228937e0fc'; private $mch_id = '1524992931'; private $spbill_create_ip ='122.114.250.59'; private $notify_url = 'https://admin.nineopen.com/pay/notify_url'; private $body = '壹城好店平臺'; public function pay(){ $fee =input('post.fee');//舉例支付0.01 $openid =input('post.openid'); $appid = $this->appid; $body = $this->body; $mch_id =$this->mch_id;//商戶號 $nonce_str = $this->nonce_str();//隨機字符串 $notify_url = $this->notify_url; //回調的url【自己填寫】 $out_trade_no = $this->order_number($openid);//商戶訂單號 $spbill_create_ip =$this->spbill_create_ip;//服務器的ip【自己填寫】; $total_fee = $fee * 100;// 微信支付單位是分,所以這里需要*100 $trade_type = 'JSAPI';//交易類型 默認 //這里是按照順序的 因為下面的簽名是按照順序 排序錯誤 肯定出錯 $post['appid'] = $appid; $post['body'] = $body; $post['mch_id'] = $mch_id; $post['nonce_str'] = $nonce_str;//隨機字符串 $post['notify_url'] = $notify_url; $post['openid'] = $openid; $post['out_trade_no'] = $out_trade_no; $post['spbill_create_ip'] = $spbill_create_ip;//終端的ip $post['total_fee'] = $total_fee;//總金額? $post['trade_type'] = $trade_type; $sign = $this->sign($post);//簽名 $post_xml = '<xml> ? ? ? ? ? ?<appid>' . $appid . '</appid> <body>' . $body . '</body> <mch_id>' . $mch_id . '</mch_id> <nonce_str>' . $nonce_str . '</nonce_str> ? ? ? ? ? ?<notify_url>' . $notify_url . '</notify_url> ? ? ? ? ? ?<openid>' . $openid . '</openid> ? ? ? ? ? ?<out_trade_no>' . $out_trade_no . '</out_trade_no> ? ? ? ? ? ?<spbill_create_ip>' . $spbill_create_ip . '</spbill_create_ip> ? ? ? ? ? ?<total_fee>' . $total_fee . '</total_fee> ? ? ? ? ? ?<trade_type>' . $trade_type . '</trade_type> ? ? ? ? ? ?<sign>' . $sign . '</sign> ? ? ? ? </xml> '; $url = 'https://api.mch.weixin.qq.com/pay/unifiedorder'; $xml = $this->curl($url,$post_xml); $array = $this->xml($xml);//全要大寫 //print_r($array); if ($array['RETURN_CODE'] == 'SUCCESS' && $array['RESULT_CODE'] == 'SUCCESS') { $time = time(); $tmp =[];//臨時數組用于簽名 $tmp['appId'] = $appid; $tmp['nonceStr'] = $nonce_str; $tmp['package'] = 'prepay_id=' . $array['PREPAY_ID']; $tmp['signType'] = 'MD5'; $tmp['timeStamp'] = "$time"; $data['state'] = 200; $data['timeStamp'] = "$time";//時間戳 $data['nonceStr'] = $nonce_str;//隨機字符串 $data['signType'] = 'MD5';//簽名算法,暫支持 MD5 $data['package'] = 'prepay_id=' . $array['PREPAY_ID'];//統一下單接口返回的 prepay_id 參數值,提交格式如:prepay_id=* $data['paySign'] = $this->sign($tmp);//簽名,具體簽名方案參見微信公眾號支付幫助文檔; $data['out_trade_no'] = $out_trade_no; } else { $data['state'] = 0; $data['text'] = "錯誤"; $data['RETURN_CODE'] = $array['RETURN_CODE']; $data['RETURN_MSG'] = $array['RETURN_MSG']; } return show(0,'ok',$data); } /** * 隨機32位字符串 * @return string */ private function nonce_str() { $result = ''; $str = 'QWERTYUIOPASDFGHJKLZXVBNMqwertyuioplkjhgfdsamnbvcxz'; for ($i = 0; $i < 32; $i++) { $result .= $str[rand(0, 48)]; } return $result; } /** * 生成訂單號 * @param $openid * @return string */ private function order_number($openid) { return md5($openid.time().rand(10,99)); } /** * sign簽名 * @param $data * @return string */ private function sign($data) { $stringA = ''; foreach ($data as $key => $value) { if (!$value) continue; if ($stringA) $stringA .= '&' . $key . "=" . $value; else $stringA = $key . "=" . $value; } $wx_key = 'doubao140716wanghuade6072019zeng';//申請支付后有給予一個商戶賬號和密碼,登陸后自己設置的key $stringSignTemp = $stringA . '&key=' . $wx_key; return strtoupper(md5($stringSignTemp)); } public function http_request($url, $data = null, $headers = array()) { $curl = curl_init(); if (count($headers) >= 1) { curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); } curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($data)) { curl_setopt($curl, CURLOPT_POST, 1); ?curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output; } /** * xml轉數組 * @param $xml * @return array */ public function xml($xml){ $p = xml_parser_create(); xml_parse_into_struct($p, $xml, $vals, $index); xml_parser_free($p); $data =[]; foreach ($index as $key=>$value) { if($key == 'xml' || $key == 'XML') continue; $tag = $vals[$value[0]]['tag']; $value = $vals[$value[0]]['value']; $data[$tag] = $value; } return $data; } /** * 支付回調地址 */ public function notify_url(){ $postStr = file_get_contents('php://input'); libxml_disable_entity_loader(true); $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $data=json_decode(trim(json_encode($postObj)),true); if($data['return_code']=='SUCCESS' and $data['result_code']=='SUCCESS' ){ Cache::set('test111',$data, 7000); $xml='<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>'; echo $xml; } } public function notify(){ $data=Cache::get('test111'); return show(0,'ok',$data); } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看