views:

1691

answers:

5

Hi

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...

A: 
  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.

Oleg Andreev
1. Thanks. will try2. testing on a device and i don;t get the prompt for uname/pwd3. Have an observer already. thats where the failed transaction info comes up4. Getting the product list in the beginning only.The problem is I don;t see the alert which asks for uname/pwd!
lostInTransit
+1  A: 

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

pottedmeat
in-app purchases are turned on. To confirm, you mean my app id should not have a *? It does not. And I'm using the same app id for the products I've added to itunes connect.
lostInTransit
+1  A: 

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!

lostInTransit
Strange, I pretty sure we succesfully tested in-app purchasing with an ad hoc build.
eelco
This is what the Apple tech support told me.
lostInTransit
I've tested in app purchase from ad-hoc distributions and from debug builds not connected to xcode.
Carl Coryell-Martin
A: 

I have just one question, where do you put this code?

SKPayment *payment = [SKPayment paymentWithProductIdentifier:productId];

[[SKPaymentQueue defaultQueue] addPayment: payment];

in the rootController?

thanks

edgard rodriguez
I have productId undeclared, what I should use my produc ID from Itunes connect and How?thakns
edgard rodriguez
No. I place it when the user buys a product (presses the Download button)
lostInTransit
but when you said the user buys a product, is the app itself when you download or aditional products that you sell within your app?thanks.My app is .99$, to be able to get the money from the user Do I need to place this code somewhere or that apple job,thank again
edgard rodriguez
A: 

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.

Wayne Lo