Ryabov Konstantin
Ryabov Konstantin

Reputation: 101

StoreKit multiple transactions

I'm stucked solving problem with In-App Purchases using StoreKit framework for Mac OS. The problem is this:

1) I call addPayment method when purchase started

2) Then updatedTransactions method called twice with transaction state SKPaymentTransactionStatePurchasing. And after second call [[SKPaymentQueue defaultQueue].transactions count] returns 2.

3) When purchase completed updatedTransactions called third time with transaction state SKPaymentTransactionStatePurchased. And [[SKPaymentQueue defaultQueue].transactions count] returns 3.

4) Then I finishTransaction with state SKPaymentTransactionStatePurchased. But in defaultQueue still remain two transactions with SKPaymentTransactionStatePurchasing. They alive till the app terminates. When I launch app again the problem repeats.

Why so many transactions for only one addPayment call? And how this problem can be solved?

Upvotes: 1

Views: 1008

Answers (1)

technerd
technerd

Reputation: 14504

Make sure to call finishTransaction method after any of the below transaction state :

1) SKPaymentTransactionStatePurchased

2) SKPaymentTransactionStateFailed

3) SKPaymentTransactionStateRestored

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

Calling finishTransaction: on a transaction removes it from the queue.

Upvotes: 1

Related Questions