SKPaymentTransactionObserver Protocol Reference

The SKPaymentTransactionObserver protocol declares methods that are implemented by observers of an SKPaymentQueue object. In a nutshell, what the SKPaymentTransactionObserver class does is observe and catch the callbacks from the payment queue when the iTunes store processes the payment. i.e. it let’s you catch the success and failure events.

The SKPaymentQueue class provides a queue of payment transactions to be processed by the App Store. The payment queue communicates with the App Store and presents a user interface so that the user can authorize payment. The contents of the queue are persistent between launches of your app.

An observer is called when transactions are updated by the queue or removed from the queue. An observer should process all successful transactions, unlock the functionality purchased by the user, and then finish the transaction by calling the payment queue’s finishTransaction: method.

Methods:

Handling Transactions

– paymentQueue:updatedTransactions: // Required method

– paymentQueue:removedTransactions:

Handling Restored Transactions

– paymentQueue:restoreCompletedTransactionsFailedWithError:

– paymentQueueRestoreCompletedTransactionsFinished:

Handling Download Actions

– paymentQueue:updatedDownloads: // required method

Summary:
1. you implement the required methods, e.g.

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

which lets you run through all the updated transactions.

2. Then you check the transaction state and, for each state, do the required action. E.g.
If it’s SKPaymentTransactionStatePurchased then you need to complete the transaction.

Remember to call:

    [[SKPaymentQueue defaultQueue] finishTransaction: transaction];

after processing each transaction.

Lots more here:
http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKPaymentTransactionObserver_Protocol/Reference/Reference.html%23//apple_ref/doc/uid/TP40008262

and a good SO post here:
http://stackoverflow.com/questions/1622116/how-to-provide-storekit-content/1622568#1622568

One thought on “SKPaymentTransactionObserver Protocol Reference

  1. […] implemented the SKPaymentTransactionObserver protocol correctly (see my earlier post – http://www.snowcrash.eu/skpaymenttransactionobserver-protocol-reference/) this method will get […]

Leave a Reply to » In App Purchase Restore Button SnowCrash Cancel reply

Your email address will not be published. Required fields are marked *