更换苹果支付模式
This commit is contained in:
@@ -11,28 +11,37 @@ const ComplateRequestArr = []
|
||||
|
||||
|
||||
var iap = {
|
||||
getProvider() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getProvider({
|
||||
service: 'payment',
|
||||
success: (res) => {
|
||||
const iapChannel = res.providers.find((channel) => {
|
||||
return (channel.id === 'appleiap')
|
||||
})
|
||||
resolve(iapChannel);
|
||||
// 如果 iapChannel 为 null,说明当前包没有包含iap支付模块。注意:HBuilder基座不包含 iap 通道
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
// 检测支付通道
|
||||
getChannels(){
|
||||
async getChannels(){
|
||||
const that = this;
|
||||
console.log('检测支付通道')
|
||||
plus.payment.getChannels(async (channels) => {
|
||||
for (var i in channels) {
|
||||
console.log("channels",channels, );
|
||||
// 判断是否苹果支付1
|
||||
if (channels[i].id === "appleiap") {
|
||||
console.log("存在苹果内购channels",channels, );
|
||||
that.iapChannel = channels[i];
|
||||
// 先检测有没有未完成的订单
|
||||
that.restoreComplateRequest()
|
||||
}
|
||||
}
|
||||
});
|
||||
this.iapChannel = await this.getProvider()
|
||||
if(this.iapChannel){
|
||||
// this.requestOrder();
|
||||
this.restoreComplateRequest()
|
||||
}else{
|
||||
console.log("不支持iap支付");
|
||||
}
|
||||
},
|
||||
// 检测是否有未关闭订单
|
||||
restoreComplateRequest() {
|
||||
let that = this
|
||||
console.log('检测未完成订单')
|
||||
this.iapChannel.restoreComplateRequest({
|
||||
this.iapChannel.restoreCompletedTransactions({
|
||||
manualFinishTransaction: true
|
||||
}, function(results) {
|
||||
if (!that.checking) {
|
||||
@@ -49,7 +58,7 @@ var iap = {
|
||||
// return false
|
||||
// 已经支付,但是没有走逻辑的内购订单 就发给后台做验证
|
||||
that.iapCheck(item, index)
|
||||
// that.finishTransaction(item)
|
||||
// that.finishTransaction(item)
|
||||
} else {
|
||||
// 其他状态的内购订单
|
||||
that.finishTransaction(item)
|
||||
@@ -110,7 +119,7 @@ var iap = {
|
||||
.catch((e) => {
|
||||
console.log('后台验证失败=>',e);
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
title: "提示",
|
||||
cancelColor:'#0081ff',
|
||||
content: `您的账户下存在验证异常的订单(订单编号为:${e.data.orderId}),可尝试稍后重启app,如不能解决您的问题,可联系官方客服`,
|
||||
cancelText:'已验证关闭订单',
|
||||
|
||||
Reference in New Issue
Block a user