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';
}
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章