在做苹果IAP支付沙箱环境测试的时候,苹果提示已支付成功,但没有走回调函数,成功的、失败的、完成的回调函数都不走,回调函数中的日志一个都没打印,试了好多次了。
HBuilderX 2.6.1
plus.payment.getChannels(function(channels) {
console.log("channels: ", JSON.stringify(channels))
for (var i in channels) {
console.log(i)
if (channels[i].id == 'appleiap') {
let iapChannel = channels[i];
console.log('iap channel: ' + iapChannel)
iapChannel.requestOrder(['ORDINARY_SHOP_TASK_RECOMMEND_1_HOUR'], function(event) {
console.log("orders", JSON.stringify(event))
for (var index in event) {
var OrderItem = event[index];
console.log("Title:" + OrderItem.title + "Price:" + OrderItem.price + "Description:" + OrderItem.description + "ProductID:" + OrderItem.productid);
}
// console.log("start restoreComplateRequest")
// iapChannel.restoreComplateRequest({
// "username": "username1"
// },function(trancs){
// uni.hideLoading()
// console.log("获取已经购买项目成功:" + JSON.stringify(trancs));
// }, function(errormsg){
// console.log("获取支付通道失败:" + errormsg.message);
// });
uni.requestPayment({
provider: 'appleiap',
orderInfo: {
productid: 'ORDINARY_SHOP_TASK_RECOMMEND_1_HOUR',
username: "username1",
quantity: 2
},
success: (e) => {
console.log(e)
uni.showModal({
content: "感谢您的赞助",
showCancel: false
})
},
fail: (e) => {
uni.showModal({
content: "支付失败,原因为: " + e.errMsg,
showCancel: false
})
},
complete: () => {
console.log("payment结束")
uni.hideLoading()
}
})
// plus.payment.request(iapChannel, {
// "productid": 'ORDINARY_SHOP_TASK_RECOMMEND_1_HOUR',
// "username": "username1",
// "quantity": 2
// }, function(result) {
// uni.hideLoading()
// console.log(result);
// }, function(e) {
// uni.hideLoading()
// console.log("更多错误信息请参考支付(Payment)规范文档:http://www.html5plus.org/#specification#/specification/Payment.html", null, "支付失败:" + e.code);
// });
}, function(errormsg) {
console.log("获取支付通道失败:" + errormsg.message);
});
}
}
}, function(e) {
console.log("获取支付通道失败:" + e.message);
});
6***@qq.com
过会大概是多长时间,,据上次支付已经过了30分钟了,还是没有调用包括成功、失败、完成再内的任何一个回调方法;
2020-05-11 17:00
5***@qq.com
你好,我的正式环境下,有时候支付成功也不走成功回调,这是什么问题
2022-03-15 15:49