Class

SKPaymentQueue

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.

Overview

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 SKDownload objects 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.

Symbols

Determining Whether the User Can Make Payments

class func canMakePayments()

Returns whether the user is allowed to make payments.

Getting the Queue

class func `default`()

Returns the singleton payment queue instance.

Adding and Removing the Observer

func add(SKPaymentTransactionObserver)

Adds an observer to the payment queue.

func remove(SKPaymentTransactionObserver)

Removes an observer from the payment queue.

Managing Transactions

var transactions: [SKPaymentTransaction]

Returns an array of pending transactions.

func add(SKPayment)

Adds a payment request to the queue.

func finishTransaction(SKPaymentTransaction)

Completes a pending transaction.

Restoring Purchases

func restoreCompletedTransactions()

Asks the payment queue to restore previously completed purchases.

func restoreCompletedTransactions(withApplicationUsername: String?)

Asks the payment queue to restore previously completed purchases, providing an opaque identifier for the user’s account.

Downloading Content

func start([SKDownload])

Adds a set of downloads to the download list.

func cancel([SKDownload])

Removes a set of downloads from the download list.

func pause([SKDownload])

Pauses a set of downloads.

func resume([SKDownload])

Resumes a set of downloads.

Relationships

Inherits From

Conforms To