PHP 微信扫码支付
生活随笔
收集整理的這篇文章主要介紹了
PHP 微信扫码支付
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
$count = $count*100;vendor('WeixinPC.WxPayApi');//引入vendor('WeixinPC.Notify');//引入vendor('WeixinPC.WxPayNativePay');//引入$notify = new \NativePay();$input = new \WxPayUnifiedOrder(); //調用統一下單類$input->SetBody($data['title']);$input->SetAttach($data['title']);$input->SetOut_trade_no($_POST['number']);$input->SetTotal_fee($count);//$input->SetTotal_fee($count);//$input->SetTotal_fee("$count");$input->SetTime_start(date("YmdHis"));$input->SetTime_expire(date("YmdHis", time() + 7200));//$input->SetGoods_tag("test");$ss=S('config');$input->SetNotify_url("http://".$_SERVER['SERVER_NAME']."/Wxpay/WxHui");$input->SetTrade_type("NATIVE");$input->SetProduct_id($_POST['number']);$result = $notify->GetPayUrl($input);$url2 = $result["code_url"];
//二維碼地址 調用方式<img alt="模式一掃碼支付" src="http://paysdk.weixin.qq.com/example/qrcode.php?data='$url2" style="width:200px;height:200px;"/>
//前臺可做一個js定時 每兩秒執行 查詢是否支付成功 成功后跳轉頁面等操作'" style="width:200px;height:200px;"/>///微信支付掃碼支付 回調地址public function WxHui(){vendor('WeixinPC.Notify'); $notify = new \PayNotifyCallBack(); $notify->Handle(false); $is_success = $notify->IsSuccess(); $bdata = $is_success['data']; //獲取微信回調數據if($is_success['code'] == 1){ $total_fee=$bdata['total_fee']/100;//支付金額$trade_no=$bdata['transaction_id'];//微信訂單號$out_trade_no=$bdata['out_trade_no'];//系統訂單號$openid=$bdata['openid'];//用戶在商戶appid下的唯一標識$number = explode('-',$out_trade_no);$type = substr($out_trade_no,0,1);echo 'success';}}//
總結
以上是生活随笔為你收集整理的PHP 微信扫码支付的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 宏定义宏函数 if else语句报错:e
- 下一篇: 解释型语言和编译型语言的优缺点