This commit is contained in:
2024-10-16 09:37:54 +08:00
parent 0ba0738ef9
commit 4e4c60aa24
25 changed files with 12038 additions and 12255 deletions

View File

@@ -249,82 +249,82 @@
uni.requestPayment({
provider: 'appleiap',
orderInfo: orderInfo,
success: (res) => {
success: (res) => {
that.iapCheck(res);
resolve(res);
resolve(res);
},
fail: (err) => {
uni.hideLoading()
// console.log('其他支付错误', err);
that.restoreComplateRequest()
if (err.code == 2) {
uni.showToast({
that.restoreComplateRequest()
if (err.code == 2) {
uni.showToast({
title: '取消支付,内购订单即将关闭',
icon: 'none'
})
} else {
uni.showToast({
title: '支付失败,内购订单即将关闭',
icon: 'none'
})
icon: 'none'
})
} else {
uni.showToast({
title: '支付失败,内购订单即将关闭',
icon: 'none'
})
}
reject(err);
}
reject(err);
}
});
})
},
// 查询未关闭iap订单
async restoreComplateRequest() {
let that = this
console.log('检测未完成订单')
console.log('检测未完成订单')
// if (!that.checking) {
// that.checking = true
// that.checking = true
// console.log(this.iapChannel, 'this.iapChannel1')
await this.iapChannel.restoreCompletedTransactions({
manualFinishTransaction: true
}, function(results) {
// console.log(that.checking)
// results 格式为数组存放恢复的IAP商品交易信息对象 IAPTransaction通用需将返回的支付凭证传给后端进行二次认证
that.ComplateRequestArr = results
console.log('未完成订单数组共有:=》',that.ComplateRequestArr.length )
if (results && results.length > 0) {
results.map((item, index) => {
// "0"为正在支付;"1"为支付成功;"2"为支付失败;"3"为支付已恢复。
if (item.transactionState == '1') {
// 已经支付,但是没有走逻辑的内购订单 就发给后台做验证
that.iapCheck('未完成订单的验证',item, index)
// that.finishTransaction(item)
} else if(item.transactionState != '1' || item.transactionState != '0') {
// 不是正在支付订单,也不是已经支付订单就关闭掉
// 其他状态的内购订单
that.finishTransaction(item)
}
})
}
// console.log(that.checking)
// results 格式为数组存放恢复的IAP商品交易信息对象 IAPTransaction通用需将返回的支付凭证传给后端进行二次认证
that.ComplateRequestArr = results
console.log('未完成订单数组共有:=》', that.ComplateRequestArr.length)
if (results && results.length > 0) {
results.map((item, index) => {
// "0"为正在支付;"1"为支付成功;"2"为支付失败;"3"为支付已恢复。
if (item.transactionState == '1') {
// 已经支付,但是没有走逻辑的内购订单 就发给后台做验证
that.iapCheck('未完成订单的验证', item, index)
// that.finishTransaction(item)
} else if (item.transactionState != '1' || item.transactionState != '0') {
// 不是正在支付订单,也不是已经支付订单就关闭掉
// 其他状态的内购订单
that.finishTransaction(item)
}
})
}
});
// }
// }
},
async iphonepay() {
const that = this;
uni.showLoading({
title:"检测支付环境"
title: "检测支付环境"
})
console.log("检测支付环境...");
this.iapChannel = await this.getProvider()
console.log('that.iapChannel',this.iapChannel);
if(this.iapChannel){
console.log('that.iapChannel', this.iapChannel);
if (this.iapChannel) {
this.requestOrder();
}else{
} else {
uni.hideLoading()
uni.showToast({
title:'不支持内购支付',
icon:'none'
title: '不支持内购支付',
icon: 'none'
})
console.log("获取iap支付通道失败" + e.message, that.iapChannel);
}
console.log("获取iap支付通道失败" + e.message, that.iapChannel);
}
},
requestOrder() {
uni.showLoading({
@@ -367,15 +367,15 @@
uni.showLoading({
title: "正在支付",
mask: true,
});
});
let orderInfo = {
productid: id,
username: that.orderSn, // 用户标识/订单标识
quantity:1,
manualFinishTransaction: true, // 3.5.1+ 支持,设置此参数后需要开发者主动关闭订单,参见下面的关闭订单方法 finishTransaction()
}
productid: id,
username: that.orderSn, // 用户标识/订单标识
quantity: 1,
manualFinishTransaction: true, // 3.5.1+ 支持,设置此参数后需要开发者主动关闭订单,参见下面的关闭订单方法 finishTransaction()
}
this.transaction = await this.requestPayment(orderInfo)
console.log('支付后的that.transaction',this.transaction);
console.log('支付后的that.transaction', this.transaction);
},
iapCheck(result) {
let that = this;
@@ -639,7 +639,7 @@
});
} else {
uni.showToast({
title: "请勾选 已阅读会员服务协议",
title: "请勾选 已阅读增值服务协议",
icon: "none",
});
return false;