Check if user cancelled SKPaymentTransaction

dariaa picture dariaa · Nov 26, 2012 · Viewed 9.1k times · Source

How can I check if user tapped cancel button (either when he was asked if he wants to purchase smth or perhaps if he already purchased this SKProduct whether he wants to download it)?

For now I just receive SKPaymentTransactionStateFailed in paymentQueue:updatedTransactions: method both after user taps cancel button and for instance when there is no internet. Any way to differentiate these two cases?

Answer

Ellen S picture Ellen S · Mar 8, 2013

This code works for me:

if (transaction.error.code != SKErrorPaymentCancelled) {
    NSLog(@"Other error");
} else {
    NSLog(@"User canceled");
}