g***@tocs.cn
g***@tocs.cn
  • 发布:2020-02-27 18:17
  • 更新:2020-05-12 18:34
  • 阅读:2648

【报Bug】苹果IAP支付成功后不走回调方法

分类:uni-app

在做苹果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);    
});
2020-02-27 18:17 负责人:DCloud_iOS_XHY 分享
已邀请:
DCloud_uniAD_HDX

DCloud_uniAD_HDX

沙箱环境 频繁支付是存在这个问题,苹果的Bug,正式环境不存在此问题
沙箱环境 调用几次后过会再调用可恢复

  • 6***@qq.com

    过会大概是多长时间,,据上次支付已经过了30分钟了,还是没有调用包括成功、失败、完成再内的任何一个回调方法;

    2020-05-11 17:00

  • 5***@qq.com

    你好,我的正式环境下,有时候支付成功也不走成功回调,这是什么问题

    2022-03-15 15:49

DCloud_iOS_XHY

DCloud_iOS_XHY

沙箱环境每次都要换一个新的测试账号来测试

  • 5***@qq.com

    你好,我的正式环境下,有时候支付成功也不走成功回调,这是什么问题

    2022-03-15 15:56

该问题目前已经被锁定, 无法添加新回复