微信支付完成后不能跳转指定的页面,多半原因是前段js写错了,也就是微信支付调起H5插件的那部分,这个是微信支付调h5插件的开发文档https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&index=6
下面小编把自己的前段支付js送给大家参考
function 支付按钮(){
var appId = "${appid}";
var timeStamp = "${timeStamp}";
var nonceStr = "${nonce_str}";
var prepay_id = "${prepay_id}";
var paySign = "${sign}";
pay(appId,timeStamp,nonceStr,prepay_id,paySign);
}
function pay(appId,timeStamp,nonceStr,prepay_id,paySign){
if (typeof WeixinJSBridge == "undefined"){
if( document.addEventListener ){
document.addEventListener(‘WeixinJSBridgeReady‘, onBridgeReady, false);
}else if (document.attachEvent){
document.attachEvent(‘WeixinJSBridgeReady‘, onBridgeReady);
document.attachEvent(‘onWeixinJSBridgeReady‘, onBridgeReady);
}
}else{
onBridgeReady(appId,timeStamp,nonceStr,prepay_id,paySign);
}
}
function onBridgeReady(appId,timeStamp,nonceStr,prepay_id,paySign){
WeixinJSBridge.invoke(
‘getBrandWCPayRequest‘, {
"appId" : appId, //公众号名称,由商户传入
"timeStamp": timeStamp, //时间戳,自1970年以来的秒数
"nonceStr" : nonceStr, //随机串
"package" : prepay_id,
"signType" : "MD5", //微信签名方式:
"paySign" : paySign //微信签名
},
function(res){
if(res.err_msg == "get_brand_wcpay_request:ok" ) {
window.location.href="支付成功后要跳转页面的地址";
}else{
alert("充值失败")
}
}
);
}