iPhone:应用内购买错误
我正在开发一个应用程序并在其中使用应用内购买。我在 iTunes Connect 中创建了应用内产品。直到昨天一切都工作正常。但今天。它开始给出这个错误。
“错误:付款请求仅限于通过 Store Kit 的 didRecieveResponse 方法返回的有效产品。”
我不知道问题是什么。请回复
I am developing an application and using in-app purchases in it. i have created in-app products in iTunes Connect. till yesterday everything was working fine. but today. it started giving this error.
"Error: Payment requests are restricted to products returned as valid via Store Kit's didRecieveResponse method."
i have no idea what is the issue. please reply
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,这可能是铁证——
根据 Store Kit 应用程序的官方数据流,您应该在尝试购买 (SKPaymentQueue) 之前检索有关可用购买的信息 (SKProductsRequest)。
我添加了代码来做到这一点,即使没有使用本地化数据。我拨打了电话,验证了该项目是否存在,然后转储了有关它的 NSLOG。
购买成功,没有任何错误!
然后,我删除了名为 SKProductsRequest 的代码,然后重新运行它,并收到“付款请求受到限制...”错误消息。
商店工具包框架似乎已更改为要求您调用 SKProductsRequest,以便在将它们添加到 SKPaymentQueue 时购买行为正确。
用计算机科学的话说,它们似乎在两个逻辑相关但独立的模块之间引入了硬依赖。这是一个非常糟糕的做法。
尝试将此代码添加到您的应用程序中,并在对 SKPaymentQueue 进行“真正”调用之前的某个时刻调用 dumpProductInfo 并查看它是否开始工作 - 请务必使用您的实际产品标识符更新嵌入的字符串文字。
后续:如下所述,Apple 技术说明 QA1691 证实了我所认为的情况是正确的——在我们弄清楚之后两周:p
Ok, This may be the smoking gun --
According to the official dataflow from the Store Kit apps, you are supposed to retrieve information about the available purchases (SKProductsRequest) before trying to make a purchase (SKPaymentQueue).
I added code to do just that, even though the localized data wasn't being used. I made the call, verified the item was present, and just dumped an NSLOG about it.
The purchase went through, with no errors!
I then removed the code that called SKProductsRequest, and re-ran it, and got the "Payment requests are restricted..." error message.
It almost seems like the store kit framework was changed in such a way as to REQUIRE you to make a call to SKProductsRequest, in order for purchases to behave correctly when tehy are added to SKPaymentQueue.
In computer science speak, they seem to have introduced a hard dependence between the two logically related, but separate modules. This is a REALLY bad practice.
Try adding this code into your app, and call dumpProductInfo at some point prior to making "real" calls to SKPaymentQueue and see if it starts working -- be sure to update the embedded string literal with your actual product identifier(s).
Follow-up: as mentioned below, Apple Technical Note QA1691 confirms that what I thought was happening was correct -- two weeks after we figured it out :p
我突然也开始明白这个了!我最后一次测试购买代码是在上周末,当时一切正常!
我什至使用了以前的版本进行测试,以确保没有代码更改的责任。该版本正在运行,并已提交给商店。
肯定有一些东西发生了变化,而且似乎是来自应用程序商店方面的变化!
我会注意到,商店的“官方”数据流要求应用程序检索可购买的产品列表,但在 iTunes Connect 中定义购买后,我会硬编码标识符。我检查了购买 ID 是否已更改,答案是没有。
为了让这更令人困惑,我从 iTunes 中下载了实时应用程序版本,购买过程顺利。两种场景的区别是
1. 一个是使用我的开发配置文件而不是部署配置文件构建的
2. 一个是在沙箱中运行,而不是“真实”运行
3. 使用测试帐户进行购买
为了确保它不是一个糟糕的测试帐户,我刚刚创建了一个新帐户并尝试用它进行测试。这没有什么区别。
更新——我就此事向苹果公司发送了电子邮件,但尚未收到回复,但错误突然消失了,一切都开始按预期工作!?!
I suddenly started getting this also! The last time I tested the purchase code was the end of last week, and it was working fine then!
I even used a previous version to test, in order to ensure that no code changes were responsible. This version was working, and had been submitted to the store.
Something is definitely changed, and it appears to be from the app store side of things!
I will note that the "official" data flow for the store requires the app to retrieve the list of products available for purchase but I instead hard-coded the identifier once the purchase was defined in iTunes Connect. I checked if the purchase ID has changed and the answer there is that it hasn't.
To make this more confusing, I pulled the live app build down from iTunes, and the purchase went through fine. The differences between the two scenarios are
1. one was built using my development profile instead of deployment profile
2. one was running in the sandbox instead of "real"
3. one used a test account to do the purchase
To ensure it wasn't a bad test account, I just now created a new one and tried to test with it. It made no difference.
UPDATE -- I emailed Apple regarding this, received no reply (yet) but the error suddenly went away and everything started working as expected!?!
以下是我最近对新应用程序的 IAP 测试所发生情况的理论:
因此,在这种情况下,即使向 IAP 商店请求有效的产品 ID 也无济于事。
我希望这能为某人节省一些时间 - 在这方面花费了数小时,并且不得不经历几次应用程序拒绝,直到我弄清楚并开始工作。
Here's my theory regarding what's happening from my recent testing of IAPs for a new App:
So, in this case, even requesting the IAP store for valid product IDs will not help you out.
I hope this will save somebody some time - been spending hours on this and had to go through several Apps rejection until I figured it out and got working.
显然,您必须直接从 xcode 构建它才能使沙箱正常工作。
You have to have it build directly from xcode to have the sandbox work now apparently.