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.
- iOS 3.0+
- macOS 10.7+
- tvOS 3.0+
To process a payment, first attach at least one observer object to the queue. Then, add a payment object for the item the user wants to purchase. Each time you add a payment object, the queue creates a transaction object to process that payment and enqueues it to be processed. After payment is fulfilled, the queue updates the transaction object and then calls any observer objects to provide them the updated transaction. Your observer should process the transaction and then remove it from the queue.
The exact mechanism you use to process a processed transaction depends on the design of your app and the product being purchased. Here are a few common examples:
If the product is a feature already built into your app, then to process the transaction, your app would enable the feature.
If the product includes downloadable content provided by the App Store, your app would retrieve the
SKDownloadobjects from the transaction and ask the payment queue to download them. You would provide the actual content files to be served by the App Store to iTunes Connect when you create the product information.
If the product represents downloadable content provided by your own server, your app might open a network connection to your server and download the content from there.
For more information on designing the payment processing portion of your app, see In-App Purchase Programming Guide.