Instance Method

purchase(product:completion:)

Initiates a purchase of a StoreProduct.

Declaration

@objc(purchaseProduct:withCompletion:) func purchase(product: StoreProduct, completion: @escaping PurchaseCompletedBlock)

Parameters

product

The StoreProduct the user intends to purchase.

completion

A completion block that is called when the purchase completes.

Discussion

Use this function if you are not using the Offerings system to purchase a StoreProduct. If you are using the Offerings system, use purchase(package:completion:) instead.

From here Purchases will handle the purchase with StoreKit and call the PurchaseCompletedBlock.

If the purchase was successful there will be a StoreTransaction and a CustomerInfo.

If the purchase was not successful, there will be an NSError.

If the user cancelled, userCancelled will be true.

See Also

Making Purchases