Skip to main content

Making Purchases

The SDK has a simple method, purchase(package:), that takes a package from the fetched Offering and purchases the underlying product with Apple, Google, or Amazon.

Purchases.shared.purchase(package: package) { (transaction, customerInfo, error, userCancelled) in
if customerInfo.entitlements["your_entitlement_id"]?.isActive == true {
// Unlock that great "pro" content
}
}

The purchase(package:) completion block will contain an updated CustomerInfo object if successful, along with some details about the transaction.

If the error object is present, then the purchase failed. See our guide on Error Handling for the specific error types.

The userCancelled boolean is a helper for handling user cancellation errors. There will still be an error object if the user cancels, but you can optionally check the boolean instead of unwrapping the error completely.

⚠️Warning: Automatic Transaction Finishing/Acknowledgement/Consumption

Transactions (new and previous transactions that are synced) will be automatically finished (acknowledged and consumed in Android), and will be made available through the RevenueCat SDK / Dashboard / ETL Exports.

You can use observer mode if you don't wish to have transactions finished (or consumed, in Android) automatically, but you will have to make sure that you finish/consume them yourself.

Next Steps