views:

243

answers:

1

Hello,

I have implemented In App purchase in my application. While testing (with SandBox environment), when I tap on any locked feature, I get alert message from iTunes that "Do you want to buy xxx feature at $xxx ?", with Cancel / Buy buttons.

I want to know that can I access these Cancel / Buy buttons, because I want to implement something based on which button user taps. OR. is there any way achieve like do something if user taps Cancel button and do something else if user taps Buy button.

Regards, Pratik

+1  A: 

To react to the user's tap, you need to implement the following method

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions;

Within the method, you need to inspect the state of each transaction and act as required. Therefore, you check the transactionState property of each transaction: it can be SKPaymentTransactionStatePurchased, SKPaymentTransactionStateFailed, SKPaymentTransactionStateRestored or SKPaymentTransactionStatePurchasing. Ignore the latter which simply means that the transaction is not yet finished. For SKPaymentTransactionStatePurchased and SKPaymentTransactionStateRestored you need to provide the user with the feature/content just bought. For SKPaymentTransactionStateFailed you may show an error message.In this case be careful: if the error code is SKErrorPaymentCancelled, then this is not technically an error. The user voluntarily decided to cancel and not to buy. Apple recommends that you treat this situation not as an error.

unforgiven