Reputation: 12262
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
Upvotes: 4
Views: 5102
Reputation: 4973
You have to have it build directly from xcode to have the sandbox work now apparently.
Upvotes: 0
Reputation: 4352
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
Upvotes: 13
Reputation: 361
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.
Upvotes: 2
Reputation: 4352
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!?!
Upvotes: 2