苹果内购获取商品问题。
已经通过如下代码获取ipaChannel
uni.getProvider({
service: 'payment',
success: (res) => {
iapChannel = res.providers.find((channel) => {
return (channel.id === 'appleiap')
})
}
});
打印ipaChannel显示
{
"id": "appleiap",
"description": "In-App Purchase",
"serviceReady": true,
"installService": "function() { [native code] }",
"appStoreReceipt": "function() { [native code] }",
"finishTransaction": "function() { [native code] }",
"restoreCompletedTransactions": "function() { [native code] }",
"restoreComplateRequest": "function() { [native code] }",
"requestProduct": "function() { [native code] }",
"requestOrder": "function() { [native code] }",
"isReadyToPay": "function() { [native code] }",
"isAppExist": true
}
接下来尝试获取商品列表(vue3)
pointProducts.value可以确定是如下数据(和在苹果后台设置的商品ID一致)
[ "point_500", "point_1000", "point_2000" ]
之后尝试获取商品列表
channel.value.requestProduct(pointProducts.value, function (orderList) {
console.log('商品信息', orderList);
}, function (err) {
console.error('获取商品失败', err);
});
直接打印出来的是“获取商品失败”:
{
"code": -100,
"message": "Payment_appleiap:返回订单信息失败,https://ask.dcloud.net.cn/article/282",
"errCode": -100,
"errMsg": "Payment_appleiap:返回订单信息失败,https://ask.dcloud.net.cn/article/282"
}
想知道可能出错的原因在哪里,是自己的问题,还是苹果的问题。
多谢高人指点。
工戈草头右框七 (作者)
没错,就是您说的这个情况。开始一直以为是技术问题。后来发现是商务问题。 感谢,好人一生平安。
2026-04-30 10:22