iPhone:应用内购买错误

发布于 2024-09-24 14:44:05 字数 189 浏览 5 评论 0原文

我正在开发一个应用程序并在其中使用应用内购买。我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

转瞬即逝 2024-10-01 14:44:05

好吧,这可能是铁证——

根据 Store Kit 应用程序的官方数据流,您应该在尝试购买 (SKPaymentQueue) 之前检索有关可用购买的信息 (SKProductsRequest)。

我添加了代码来做到这一点,即使没有使用本地化数据。我拨打了电话,验证了该项目是否存在,然后转储了有关它的 NSLOG。

购买成功,没有任何错误!

然后,我删除了名为 SKProductsRequest 的代码,然后重新运行它,并收到“付款请求受到限制...”错误消息。

商店工具包框架似乎已更改为要求您调用 SKProductsRequest,以便在将它们添加到 SKPaymentQueue 时购买行为正确。

用计算机科学的话说,它们似乎在两个逻辑相关但独立的模块之间引入了硬依赖。这是一个非常糟糕的做法。

尝试将此代码添加到您的应用程序中,并在对 SKPaymentQueue 进行“真正”调用之前的某个时刻调用 dumpProductInfo 并查看它是否开始工作 - 请务必使用您的实际产品标识符更新嵌入的字符串文字。

-(void) dumpProductInfo
{
        SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.company.domain.app.purchase"]];
        request.delegate = self;
        [request start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *myProduct = response.products;
    // populate UI
    NSLog(@"Products:");
    for (int i = 0; i < [myProduct count]; i++)
    {
        SKProduct *product = [myProduct objectAtIndex:i];
        NSLog(@"Name: %@ - Price: %f   ID: %@" ,
              [product localizedTitle],
              [[product price] doubleValue], 
              [product productIdentifier]);

    }
}

后续:如下所述,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).

-(void) dumpProductInfo
{
        SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.company.domain.app.purchase"]];
        request.delegate = self;
        [request start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *myProduct = response.products;
    // populate UI
    NSLog(@"Products:");
    for (int i = 0; i < [myProduct count]; i++)
    {
        SKProduct *product = [myProduct objectAtIndex:i];
        NSLog(@"Name: %@ - Price: %f   ID: %@" ,
              [product localizedTitle],
              [[product price] doubleValue], 
              [product productIdentifier]);

    }
}

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

乄_柒ぐ汐 2024-10-01 14:44:05

我突然也开始明白这个了!我最后一次测试购买代码是在上周末,当时一切正常!

我什至使用了以前的版本进行测试,以确保没有代码更改的责任。该版本正在运行,并已提交给商店。

肯定有一些东西发生了变化,而且似乎是来自应用程序商店方面的变化!

我会注意到,商店的“官方”数据流要求应用程序检索可购买的产品列表,但在 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!?!

素罗衫 2024-10-01 14:44:05

以下是我最近对新应用程序的 IAP 测试所发生情况的理论:

  1. 沙盒 IAP 环境不允许您在批准并提交 IAP 供审核后再测试 IAP。据我所知,这是一种新的未记录行为,给我们 iPhone SDK 猴子带来了很多麻烦。在此更改之前,即使在提交 IAP 供 Apple 审核之后且在应用程序获得批准之前,您也可以对其进行测试。

因此,在这种情况下,即使向 IAP 商店请求有效的产品 ID 也无济于事。

  1. 作为审查过程的一部分,Apple 似乎添加了以下自动化测试:使您的所有 IAP 无效并测试您的应用程序,以确保您在使用 IAP 填充 UI 之前发送有效 IAP ID 的请求。因此,如果您不使用代码解决此问题,您的应用程序将被拒绝,但他们会告诉您,请求有效 ID 只是建议的最佳实践,而不是必需的,但根据我的经验,现在是必需的。

我希望这能为某人节省一些时间 - 在这方面花费了数小时,并且不得不经历几次应用程序拒绝,直到我弄清楚并开始工作。

Here's my theory regarding what's happening from my recent testing of IAPs for a new App:

  1. The sandbox IAP env does NOT allow you to test IAP anymore AFTER you've approved and submitted it for review. This is a new undocumented behavior as far as I can tell that is causing many headaches for us iPhone SDK monkeys. Before this change, you could have test IAPs even after submitting them for Apple review and before the App got approved.

So, in this case, even requesting the IAP store for valid product IDs will not help you out.

  1. It appears that as part of the review process, Apple added the following automated test: invalidate ALL your IAP and test your App to ensure that you are sending a request for valid IAP IDs before populating your UI with IAP. So, if you do not address this with your code, your App will be rejected but they will tell you that requesting valid IDs is only a recommended best practice and not a required one but in my experience it is now required.

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.

柠檬 2024-10-01 14:44:05

显然,您必须直接从 xcode 构建它才能使沙箱正常工作。

You have to have it build directly from xcode to have the sandbox work now apparently.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文