Jack李
Jack李
  • 发布:2016-01-06 15:18
  • 更新:2018-08-10 17:06
  • 阅读:9731

微信支付 -100 第一次弹出支付页面,点击取消 之后再点击支付 不显示支付页面 并返回error.code -100

分类:HTML5+

document.getElementById('charge_true01').addEventListener('tap',function(){
var cType = charge_type.getAttribute('data-type');
if(cType == 'wxpay' || cType == 'alipay')
{
mui.plusReady(function(){
plus.payment.getChannels(function(channels){
for(var i in channels)
{
channel = channels[i];
if(channel.id == cType)
{
pays[channel.id]=channel;
var check = checkServices(channel);
if(check)
{
pay(channel.id);
}
}
};
});
});
}else{
if(confirm('暂不支持银联支付,请选择其他支付方式!'))
{
$.back();
}
}
});
// 检测服务状态是否支持
function checkServices(pc){
if(!pc.serviceReady){
var txt=null;
switch(pc.id){
case "alipay":
txt="检测到系统未安装“支付宝快捷支付服务”,无法完成支付操作,是否立即安装?";
break;
default:
txt="系统未安装“"+pc.description+"”服务,无法完成支付,是否立即安装?";
break;
}
plus.nativeUI.confirm(txt,function(e){
if(e.index==0){
pc.installService();
}
},pc.description);
}else{
return true;
}
}
var w=null;
var aliPayUrl= "http://test11.test11.cn/index.php/Api/Alipay/dopay/";//从服务器端获取预支付信息接口
var wxPayUrl = "http://test11.test11.cn/index.php/Api/Wxpay/dopay/";//从服务器端获取预支付信息接口
// 支付
function pay(id){
if(w){return;}
if(id=='alipay'||id=='wxpay')
{
if(id == 'alipay')
{
url = aliPayUrl;
}else{
url = wxPayUrl;
}
}else{
plus.nativeUI.toast('暂不支持当前支付方式!');
return;
}
// 支付金额;
amount = 0.01;
// 调用支付窗口前的等待状态
w=plus.nativeUI.showWaiting();
// 请求订单
var xhr=new XMLHttpRequest();
xhr.onreadystatechange=function(){
switch(xhr.readyState){
case 4:
w.close();w=null;
if(xhr.status==200)
{
mui.toast(" 请求订单成功 ");
var order=xhr.responseText;
console.log(order);
plus.payment.request(pays[id],order,function(result)
{
//支付成功处理区域

                        },function(e){  
                            //支付失败,或取消支付 等操作执行区域  
                                                            console.log("["+e.code+"]:"+e.message);  
                            if(e.code == '-100')  
                            {  
                                mui.toast("您取消了当前支付");  
                            }else{  
                                mui.toast(" 支付失败,请稍后再试 ");  
                            }  

// mui.toast("["+e.innerCode+"]:"+e.message);
});
}else{
mui.toast(" 支付异常,请稍后再试 ");
// mui.toast( xhr.status );
}
break;
default:
break;
}
}
xhr.open('POST',url);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.send('amount='+amount);
}

2016-01-06 15:18 负责人:无 分享
已邀请:
Float

Float - 专注

请问这个问题怎么解决的?同样遇到了!多谢

1***@qq.com

1***@qq.com

这个问题解决了没有啊

1***@qq.com

1***@qq.com - fighting

是不是你用的是公众号的支付方式?

该问题目前已经被锁定, 无法添加新回复