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

猜你喜欢

转载自blog.csdn.net/qq_18105691/article/details/79542547