简体   繁体   English

iphone:应用内购买错误

[英]iphone: in-App Purchase Error

I am developing an application and using in-app purchases in it. 我正在开发一个应用程序并在其中使用应用程序内购买。 i have created in-app products in iTunes Connect. 我在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." “错误:付款请求仅限于通过Store Kit的didRecieveResponse方法返回的有效产品。”

i have no idea what is the issue. 我不知道是什么问题。 please reply 请回复

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). 根据Store Kit应用程序的官方数据流,您应该在尝试购买之前检索有关可用购买的信息(SKProductsRequest)(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. 我打了电话,验证了该项目的存在,并且刚刚向NSLOG倾倒了它。

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. 然后,我删除了名为SKProductsRequest的代码,并重新运行它,并得到“付款请求受限制...”错误消息。

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. 看起来商店套件框架的变化似乎是要求您调用SKProductsRequest,以便在将tehy添加到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). 尝试将此代码添加到您的应用程序中,并在对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]);

    }
}

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 跟进:如下所述,Apple技术说明QA1691证实了我认为发生的事情是正确的 - 我们发现它后两周:p

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. 我会注意到商店的“官方”数据流要求应用程序检索可供购买的产品列表,但是一旦在iTunes Connect中定义购买,我就会对标识符进行硬编码。 I checked if the purchase ID has changed and the answer there is that it hasn't. 我检查了购买ID是否已经改变,答案是否已经改变。

To make this more confusing, I pulled the live app build down from iTunes, and the purchase went through fine. 为了让这更令人困惑,我从iTunes中删除了实时应用程序,购买过程很顺利。 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 两个方案之间的差异是1.一个是使用我的开发配置文件而不是部署配置文件2.一个是在沙箱中运行而不是“真实”3.一个使用测试帐户进行购买

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!?! 更新 - 我通过电子邮件向Apple发送了此消息,但尚未收到回复,但错误突然消失,一切都按预期开始工作了!?!

Here's my theory regarding what's happening from my recent testing of IAPs for a new App: 这是我的理论,关于我最近为新应用程序测试IAP所发生的事情:

  1. The sandbox IAP env does NOT allow you to test IAP anymore AFTER you've approved and submitted it for review. 在您批准并提交审核后,沙箱IAP环境不允许您再次测试IAP。 This is a new undocumented behavior as far as I can tell that is causing many headaches for us iPhone SDK monkeys. 据我所知,这是一个新的无证件行为,这给我们的iPhone SDK猴子带来了许多麻烦。 Before this change, you could have test IAPs even after submitting them for Apple review and before the App got approved. 在此更改之前,即使在提交Apple审核之后以及应用程序获得批准之前,您也可以进行测试IAP。

So, in this case, even requesting the IAP store for valid product IDs will not help you out. 因此,在这种情况下,即使向IAP商店申请有效的产品ID也无济于事。

  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. 看来,作为审核流程的一部分,Apple添加了以下自动化测试:使您的所有IAP无效并测试您的应用,以确保在使用IAP填充UI之前发送有效IAP ID请求。 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. 因此,如果您没有使用您的代码解决此问题,您的应用程序将被拒绝,但他们会告诉您,请求有效ID只是建议的最佳做法而不是必需的,但根据我的经验,现在需要它。

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构建它才能使沙箱显然正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM