I am using in-app purchase for an iPhone app. I have a class that acts as SKProductsRequestDelegate
and SKPaymentTransactionObserver
, and it\'s all
I had this problem too. The bug turned out to be on my side. The problem was that there was a past transaction lurking around that had been executed (the content provided) but not cleaned up using finishTransaction
. Unfortunately, on asking at several places including an Apple TSI, I discovered that there was no way to poll such 'undead' transactions - you just had to register for notifications and wait for the corresponding paymentQueue:updatedTransactions:
. This complicated my code, but not by much.
What I do now, which has been working fine:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self]
[[SKPaymentQueue defaultQueue] addPayment:payment]
paymentQueue:updatedTransactions:
check the state variable. If it has not been set, it means you have received a notification for a past payment. In that case, honor that payment rather than pushing a new one.This method naturally assumes that you have the time to wait for old transactions to show up before starting a new transaction.