Documentation menu

Purpl Documentation

Products and purchases

Load StoreKit products and purchase the product selected by the customer.

Load products

Purchases sends the identifiers in PurchaseConfiguration to StoreKit. Price, subscription period, and availability come directly from StoreKit.

Purchase a product

Swift
let products = try await Purchases.shared.products()

guard let yearlyProduct = products.first(where: {
    $0.id == "time.plus.yearly"
}) else {
    return
}

let result = try await Purchases.shared.purchase(yearlyProduct)

PurchaseResult distinguishes completion, approval pending, and user cancellation. Transaction verification and store failures are thrown as errors.