Class

SKPaymentQueue

A queue of payment transactions to be processed by the App Store.

Declaration

class SKPaymentQueue : NSObject

Overview

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.

To process a payment, first add at least one observer object (SKPaymentTransactionObserver) to the queue (see add(_:)). Then, add a payment object (SKPayment) for the item the user wants to purchase. Each time you add a payment object, the queue creates a transaction object (SKPaymentTransaction) 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, your app enables the feature to process the transaction.

  • If the product includes downloadable content provided by the App Store, your app retrieves the SKDownload objects from the transaction and ask the payment queue to download them. You provide the actual content files to be served by the App Store to App Store 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.

Topics

Determining Whether the User Can Make Payments

class func canMakePayments() -> Bool

Indicates whether the user is allowed to make payments.

Determining Store Content

var storefront: SKStorefront?

The current App Store storefront for the payment queue.

Beta

Getting the Queue

class func `default`() -> Self

Returns the default 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 delegate: SKPaymentQueueDelegate?

A delegate that provides information needed to complete transactions.

Beta
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

See Also

Initiating a Purchase

Requesting a Payment from the App Store

Submit a payment request to the App Store when a user selects a product to buy.

class SKPayment

A request to the App Store to process payment for additional functionality offered by your app.

class SKMutablePayment

A mutable request to the App Store to process payment for additional functionality offered by your app.

class SKPaymentDiscount

The signed discount applied to a payment.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software