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

thinkPHP和onethink微信支付插件分享

 更新時(shí)間:2019年08月11日 09:38:07   投稿:hebedich  
這篇文章主要是給大家分享了thinkPHP和onethink微信支付插件,小編覺(jué)得挺不錯(cuò)的,也給大家做個(gè)參考。

thinkPHP和微支付實(shí)現(xiàn)的微信支付插件,在微信中調(diào)用微信jssdk實(shí)現(xiàn)支付,分享給大家參考下

 //實(shí)現(xiàn)的Wxpay鉤子方法
    public function Wxpay($param){
      require './Addons/Wxpay/WxPayPubHelper/WxPayPubHelper.php';
      $jsApi = new \JsApi_pub(); 
      
      //=========步驟1:網(wǎng)頁(yè)授權(quán)獲取用戶(hù)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","在線(xiàn)預(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ù)訂單號(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");//交易類(lèi)型
       
      $prepay_id = $unifiedOrder->getPrepayId();
      //=========步驟3:使用jsapi調(diào)起支付============
      $jsApi->setPrepayId($prepay_id);
      $jsApiParameters = $jsApi->getParameters();
      $this->assign('jsApiParameters',$jsApiParameters);
 
      $this->display('pay');
    }

總結(jié)

以上是腳本之家為你收集整理的thinkPHP和onethink微支付插件全部?jī)?nèi)容,希望文章能夠幫你解決thinkPHP和onethink微支付插件所遇到的程序開(kāi)發(fā)問(wèn)題。

相關(guān)文章

最新評(píng)論