<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 微信支付 ### 說明 在開發網頁、微信公眾號H5頁面的過程中,微信支付是常用的使用場景。使用wxpay微信支付插件,可以快速的對項目集成微信支付功能。 當然可以在不使用插件的情況下,自己開發微信支付功能。微信支付基于EasyWechat,參考開發地址:https://www.easywechat.com/docs/master/zh-CN/payment/index >[info] 微信支付插件地址:http://www.eacoophp.com/appstore_plugin/wxpay ### 插件使用要求 ~~~ 1. 依賴于composer安裝easywechat,命令行composer require overtrue/wechat:~4.0 -vvv 2. EacooPHP系統版本1.1.0+ 3. 微信商戶號配置信息 ~~~ ### 應用場景 1.微信公眾號H5支付 2.微信掃碼支付,常用于PC端 3.APP接口調起微信支付 ### 實現過程 **1.后臺配置支付信息** ![微信支付后臺配置](https://box.kancloud.cn/7797d8110857b7f28db63ac74afdc7f3_2740x1578.jpg) **2.在微信商戶平臺配置支付授權目錄** ![](https://box.kancloud.cn/fef61c432b30684ddb2908680e505dff_2752x1520.jpg) **3.在控制器中需要處理微信支付的地方添加代碼,例如** ~~~ $total_fee=0.01; $out_trade_no=訂單號; $body='測試支付'; $notify_url = 支付異步通知地址; $openid = 微信OPENID; $params = [ 'money' => $total_fee, 'order_number' => $out_trade_no, 'body' => $body, 'notify_url' => $notify_url, 'openid' => $openid, 'trade_type' => 'JSAPI' ]; $result = hook('wxpay',$params,true); return $result; ~~~ 返回結果根據trade_type的參數而定,目前支持JSAPI,NATIVE,APP... 比如:trade_type參數為JSAPI,默認返回json字符串。用于WeixinJSBridge發起的支付方式。 **4.要確認主題或模版中啟用了頁面尾部鉤子PageFooter。** ~~~ html代碼: {:hook('PageFooter')} ~~~ 因為微信支付插件封裝的js代碼會在這個鉤子中加載。 **5.在自己開發的js代碼中調用封裝的支付方法。** ~~~[js] $.post(請求URL, data, function(result) { jsWxpay(result); }) ~~~ **6.完成上面的工作就能調起微信支付框了。** 微信支付成功后,支付結果會異步發送到通知地址,就是第3步中設置的notify_url。通知接收方法接收到結果數據后就進行處理。 **7.異步通知處理** 直接上代碼例子: ~~~ public function Notify() { $wxpay_class = get_plugin_class('wxpay'); if (!class_exists($wxpay_class)) { //wxpay插件類不存在 echo 'fail'; exit; } $wxpay = new $wxpay_class; $wxpay_app = $wxpay->initPayment(); $response = $wxpay_app->handlePaidNotify(function($message, $fail){ // 使用通知里的 "微信支付訂單號" 或者 "商戶訂單號" 去自己的數據庫找到訂單 $order = 查詢訂單($message['out_trade_no']); if (!$order) { // 如果訂單不存在 $fail('Order not exist.'); // 告訴微信,我已經處理完了,訂單沒找到,別再通知我了 } // 如果訂單存在 // 檢查訂單是否已經更新過支付狀態 if ($order->paid_at) { // 假設訂單字段“支付時間”不為空代表已經支付 return true; // 已經支付成功了就不再更新了 } // 用戶是否支付成功 if ($message['result_code'] === 'SUCCESS') { // 不是已經支付狀態則修改為已經支付狀態 $order->paid_at = time(); // 更新支付時間為當前時間 $order->status = 'paid'; } else { // 用戶支付失敗 $order->status = 'paid_fail'; } $order->save(); // 保存訂單 return true; // 返回處理完成 }); return $response->send(); // return $response; } ~~~ ## 最后 插件中包含Demo,不過要自己改寫,主要提供思路
                  <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>

                              哎呀哎呀视频在线观看