lostInTransit
lostInTransit

Reputation: 70997

iPhone - cannot test in-app purchases

I have created a test account for sandbox testing of in-app purchases. I am following these steps to test

  1. Logged out of any existing accounts
  2. Open app and start getting list of products available
  3. Start process to download a product

    SKPayment *payment = [SKPayment paymentWithProductIdentifier:productId];

    [[SKPaymentQueue defaultQueue] addPayment: payment];

Now ideally I should be asked for the user name/pwd at this point. But I am not prompted for anything and the transaction fails (obviously because I am not logged in)

If I try to login from Settings->Store, it asks for my credit info which I'm sure is not necessary.

Can someone please help me with this issue.

Thanks...

Upvotes: 1

Views: 6705

Answers (4)

lostInTransit
lostInTransit

Reputation: 70997

Ok. This was stupid! But hope someone can learn from my mistakes :) I was testing the in-app purchase with a adhoc distribution profile. And acc to Apple engineers, as soon as you do that, the test account "stops" being a test account.

In-app purchases CAN ONLY BE TESTED by launching your app via XCode in debug mode!

Update

This is not true any more. It supposedly works fine with adhoc builds as well now.

Source: recent testing of in-app purchases using an adhoc build.

Upvotes: 3

Wayne Lo
Wayne Lo

Reputation: 3719

I ran into the same problem. As suggested by Oleg, the issue was that the productID was invalid. Set a break point at

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response and check response.products. 

You may find that the productID is not in response.products. When this happen, the transaction will proceed as purchase cancel by user, therefore, never prompt for login.

Upvotes: 0

pottedmeat
pottedmeat

Reputation: 3421

Make sure that you have in-app purchases turned on in your provisioning file

Upvotes: 1

Oleg Andreev
Oleg Andreev

Reputation: 486

  1. Check canMakePayments
  2. In Simulator the StoreKit just does not respond : you should test on the device
  3. You must have at least one observer added to the SKPaymentQueue
  4. Try to ask for the product list first (besides the fact that you know the productId already); it sounds silly, but SK framework is far from perfect.

Also, when sending {"receipt-data":...} to verification server do encode the receipt with Base64 before inserting it into json object. This is not mentioned in official docs anywhere: only on a couple of blogs.

Upvotes: 0

Related Questions