views:

755

answers:

5

Hi,

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

+1  A: 

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!?!

software evolved
+1  A: 

I'm having the exact same problem. Emailed Apple but haven't received an answer yet.

avive
+8  A: 

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 see if it starts working -- be sure to update the embedded string literal with your actual product identifier.

-(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]);

    }
}
software evolved
A: 

Yeah. We have some problem... We are change test users, change programm id.. But no result.

Danil
A: 

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.

avive