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

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);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值