tzc
tzc
  • 发布:2022-10-12 12:12
  • 更新:2022-10-13 11:58
  • 阅读:272

苹果内购 plus.payment.request 的回调函数有概率不执行

分类:5+ SDK

苹果内购 plus.payment.request 的回调函数有概率不执行,是什么导致的呢?已经支付成功了,回调一直不触发,有概率出现这个,10次会出现1~2次。。。是代码有问题?还是其他原因呢?

2022-10-12 12:12 负责人:天生DR 分享
已邀请:
天生DR

天生DR - 天生我材必有用

贴一下你的代码

  • tzc (作者)

    您好,我用沙盒环境测试能够拉起支付并且走完流程,但是苹果官方审核时 好像拉不起支付,甚至会提示 your account is temporarily unavailable.try again later [Environment: Sandbox],我判断是苹果官方审核时没有获取到支付通道或产品,请问这个该怎么解决呢?

    2022-10-13 12:00

  • 天生DR

    回复 tzc: 听你这个描述怎么感觉像 证书的问题 你提交苹果官方审核时 是发布证书吗?

    2022-10-13 15:02

  • tzc (作者)

    回复 天生DR: 如果不是发布证书是不能上传到testflight的

    2022-10-13 16:56

  • 天生DR

    回复 tzc: getChannels 不联网 肯定能获取到 通道 后边的取决于网和你appid 如果是这种错误的话 建议你 重新登录你的appid 跟 appstore 里的appid 最好一致 现在是苹果审核给你打回来了是吗 有没有完整的信息?

    2022-10-13 17:44

  • tzc (作者)

    回复 天生DR: 这个可能解决了,问题是:必须要requestOrder方法执行成功后,再调用plus.payment.request方法不然就会拉不起支付,可能明天就过审了,等我的好消息。

    2022-10-13 19:19

  • 天生DR

    回复 tzc: 好的 过了吗?

    2022-10-17 13:00

  • tzc (作者)

    回复 天生DR: 过了

    2022-10-18 17:03

  • 天生DR

    回复 tzc: 好 关闭问题了

    2022-10-20 11:03

tzc

tzc (作者)

plus.payment.getChannels(function(channels) { // 获取支付通道
for (var i in channels) {
var channel = channels[i];
// 获取 id 为 'appleiap' 的 channel
if (channel.id === 'appleiap') {
_self.iap = channel;
var ids = [_self.product.apple_product_id + ''];
// iap 为刚刚获取的appleiap支付通道
_self.iap.requestOrder(ids, function(e) {
// 获取订单信息成功回调方法
console.log('requestOrder success: ' + JSON.stringify(e));
_self.iapId = e[0].productid;
}, function(e) {
// 获取订单信息失败回调方法
console.err('requestOrder failed: ' + JSON.stringify(e));
});
}
}
}, function(e) {
console.log("获取支付通道失败:" + e.message);
});

iosPay(order_id) { // 支付
let _self = this;
_self.restoreComplateRequest();
if (_self.iapId != -1) {
plus.payment.request(_self.iap, {
productid: _self.iapId,
username: order_id,
optimize: true, // 支付时设置 optimize: true
quantity: _self.product.purchaseNum
}, function(result) {
console.log(result, 'result')
_self.$api.post('pay.apple.notice', {
order_id: result.payment.username,
transaction_id: result.transactionIdentifier,
transaction_receipt: result.transactionReceipt,
}).then((res) => {
_self.loadingShow = false;
_self.inOperation2 = false;
console.log(res.status, res)
if (res.status == 0) {
uni.navigateTo({
url: '../../d_payment/d_payment/index?order_id=' +
order_id +
'&situation=complete'
});
}
});
}, function(e) {
_self.loadingShow = false;
_self.inOperation2 = false;
_self.restoreComplateRequest()
});
}
}

restoreComplateRequest() {  
            this.iap.restoreComplateRequest({}, function(results) {  
                // results 格式为数组存放恢复的IAP商品交易信息对象 IAPTransaction,通用需将返回的支付凭证传给后端进行二次认证    
            });  
        },

要回复问题请先登录注册