在做微信公众号支付的时候,参数中有带微信支付回调
protected function createWxPay($order_id)
{
$orders = M('Orders')->find($order_id);
$tools = new JsApiPay;
$openId = M('Users')->where('id='.$orders['user_id'])->getField('openid');
$input = new WxPayUnifiedOrder();
$input->SetBody('订单支付'.$orders['order_sn']);
$input->SetAttach("测试订单");
$input->SetOut_trade_no($orders['order_sn']);
$input->SetTotal_fee($orders['order_amount']*100);
$input->SetNotify_url('http://'.$_SERVER['HTTP_HOST'].'/Home/Wxpay/notify.html');
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
$jsApiParameters = $tools->GetJsApiParameters($order);
$urls = U('Myorders/index');
if (IS_AJAX) {
$this->ajaxReturn(['jsparams'=>json_decode($jsApiParameters),'urls'=>$urls,'code'=>1]);
} else {
$this->assign('jsparams',$jsApiParameters);
$this->assign('urls',$urls);
}
}
订单支付成功,但是微信并没有回调通知。
最后发现是url模式的问题,书写的回调地址不合法。
微信支付回调地址不接受带参数的url地址
我默认的url模式地址为:http://www.test.com/index.php?s=/Home/Test/test.html
解决方法:服务器支持url重写
例如:http://www.test.com/Home/Test/test.html