温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

PHP 微信扫码支付

发布时间:2020-06-26 18:44:50 来源:网络 阅读:24925 作者:pansw113 栏目:web开发
        $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" />

//前台可做一个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';
}
}

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI