Instance Method

purchase(product:promotionalOffer:completion:)

Initiates a purchase of a StoreProduct with a PromotionalOffer.

Declaration

@objc(purchaseProduct:withPromotionalOffer:completion:) func purchase(product: StoreProduct, promotionalOffer: PromotionalOffer, completion: @escaping PurchaseCompletedBlock)

Parameters

product

The StoreProduct the user intends to purchase.

promotionalOffer

The PromotionalOffer to apply to the 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 with an applied PromotionalOffer. If you are using the Offerings system, use purchase(package:promotionalOffer: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 Error. If the user cancelled, userCancelled will be true.

See Also

Making Purchases with Subscription Offers