I am writing an mac application for the Mac App Store that uses in app purchase. I double checked and I think I have implemented everything correctly. So when I am making a product request the delegate method
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
is called, with the correct product id. Then I make a payment using
[[SKPaymentQueue defaultQueue] addPayment:payment];
The issue appears at this point. In the first 10-15 minutes the purchase dialog does not show up at all, and I neither do I receive the updatedTransactions notification. After some time if I try again, everything works correctly, I am prompted in 1-2 seconds for my credentials. This seems very strange for me, because they should work from the start.
Because of this my app was rejected several times, stating that in app purchases do not work.
Yes, I have added the receipt verification code, and if it doesn’t exist then I exit the app with code 173, I am prompted for my credentials, then the app reopens but the in apps do not work even after this. And yes, I have tested this with a built that has been created with a distribution profile. I am using XCode 4.2, and my OS is Lion.
After adding the payment to the queue, I tried starting a timer to check the transactions property of SKPaymentQueue periodically. The transactionIdentifier is the correct one, and it’s transactionState is SKPaymentTransactionStatePurchasing. This tells me that there is some communication issue between StoreKit and the Apple servers.
Anyone else experienced this issue? Any help would be appreciated, I am struggling with this for 3 days now and could not find a solution for this, and it’s driving me crazy.
I’ve found the answer at last. I have indeed implemented everything correctly according to the In App Purchase Programming Guide.
It seems what I’ve been doing wrong is to add the transaction observer, before the receipt verification code. After I have changed the order (first verify the receipt, then add the observer) everything worked correctly. This detail should be mentioned somewhere. It caused a lot of headache.