欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Thinkphp和onethink實(shí)現(xiàn)微信支付插件

 更新時(shí)間:2016年04月13日 15:19:39   作者:hilbp  
這篇文章主要為大家詳細(xì)介紹了Thinkphp和onethink實(shí)現(xiàn)微信支付插件,感興趣的小伙伴們可以參考一下

thinkPHP和微支付實(shí)現(xiàn)的微信支付插件,在微信中調(diào)用微信jssdk實(shí)現(xiàn)支付,這里有詳細(xì)的代碼和教程,具體看這里:

//實(shí)現(xiàn)的Wxpay鉤子方法
    public function Wxpay($param){
      require './Addons/Wxpay/WxPayPubHelper/WxPayPubHelper.php';
      $jsApi = new \JsApi_pub(); 
       
      //=========步驟1:網(wǎng)頁(yè)授權(quán)獲取用戶openid============
      if (!isset($_GET['code']))
      {
        //觸發(fā)微信返回code碼
        $url = $jsApi->createOauthUrlForCode(\WxPayConf_pub::JS_API_CALL_URL.'/order_id/'.$param['order_id']);
        Header("Location: $url");
      }else
      {
        $order_id = $param['order_id'];
        $info = M('Order')->where('id='.$order_id)->find();
        if(empty($info) || $info['is_pay'] == 1){
          dump('該訂單不存在或已支付'.$order_id);
          exit();
        }
        $this->assign('info', $info);
        $a = $info['money'];
        $b = 100;
        $c = $a * $b;
         
        //獲取code碼,以獲取openid
        $code = $_GET['code'];
        $jsApi->setCode($code);
        $openid = $jsApi->getOpenId();
      }
       
      //=========步驟2:使用統(tǒng)一支付接口,獲取prepay_id============
      //使用統(tǒng)一支付接口
      $unifiedOrder = new \UnifiedOrder_pub();
       
      $unifiedOrder->setParameter("openid","$openid");//商品描述
      $unifiedOrder->setParameter("body","在線預(yù)訂");//商品描述
      //自定義訂單號(hào),此處僅作舉例
      $timeStamp = time();
//       $out_trade_no = \WxPayConf_pub::APPID."$timeStamp";
      $out_trade_no = $info['ordersn'];
      $unifiedOrder->setParameter("out_trade_no", "$out_trade_no");//商戶訂單號(hào)
      $unifiedOrder->setParameter("total_fee", "$c");//總金額
      $unifiedOrder->setParameter("notify_url",\WxPayConf_pub::NOTIFY_URL.'/order_id/'.$param['order_id']);//通知地址
      $unifiedOrder->setParameter("trade_type","JSAPI");//交易類型
       
      $prepay_id = $unifiedOrder->getPrepayId();
      //=========步驟3:使用jsapi調(diào)起支付============
      $jsApi->setPrepayId($prepay_id);
      $jsApiParameters = $jsApi->getParameters();
      $this->assign('jsApiParameters', $jsApiParameters);
 
      $this->display('pay');
    }

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家學(xué)習(xí)PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論