调用支付宝
程序员文章站
2022-05-27 22:01:25
...
var pays = {};
var w = null;
mui.plusReady(function() {
// $.init({});
plus.payment.getChannels(function(channels) { //获取支付通道
for(var i in channels) {
var channel = channels[i];
// 过滤掉不支持的支付通道:暂不支持360相关支付
if(channel.id == 'qhpay' || channel.id == 'qihoo'||channel.id=='wxpay') {
continue;
}
pays[channel.id] = channel;
//checkServices(channel); //检查服务是否安装
}
}, function(e) {
alert("获取支付通道失败", "系统提示");
});
document.getElementById("ensure").addEventListener("tap", function() {
w = plus.nativeUI.showWaiting();
var xhr = new XMLHttpRequest();
xhr.open("GET","url");
xhr.send();
xhr.onreadystatechange = function() {
if (xhr.readyState==4 && xhr.status ==200) {
console.log(xhr.responseText);
var My = JSON.parse(xhr.responseText);
console.log(My);
var order = My.data;
console.log(order);
plus.payment.request(pays['alipay'],order,function(result) {
console.log(result);
})
}
};
});
});
下一篇: mysql安装演示