purchase
Called when the user initiates purchasing of a product.
Add your purchase logic here and return its result. You can use Android's Billing APIs, or if you use RevenueCat, you can call Purchases.shared.purchase(product).
For Google Play products, the underlying ProductDetails are available via StoreProduct.rawStoreProduct's underlyingProductDetails.
Custom products: when StoreProduct.isCustomProduct is true, the product's metadata is sourced from the Superwall API rather than Google Play — route the purchase through your own payment system (e.g. Stripe, web checkout). The SDK does not grant entitlements for custom products: on a successful purchase you must update the user's entitlements yourself by calling Superwall.instance.setSubscriptionStatus(...). The product's StoreProduct.customTransactionId is pre-generated by the SDK and used as the original transaction identifier in analytics.
The default implementation routes Google Play products to the deprecated purchase(activity, productDetails, basePlanId, offerId) so existing implementations keep working, and fails for custom products.
Return
A PurchaseResult object, which is the result of your purchase logic. Note: Make sure you handle all cases of PurchaseResult.
Parameters
The Activity from which the purchase was initiated.
The Superwall StoreProduct the user would like to purchase.
An optional base plan identifier of the product that's being purchased.
An optional offer identifier of the product that's being purchased.
Deprecated
Implement purchase(activity, product, basePlanId, offerId) instead. It receives a StoreProduct, which also supports custom store products.
Replace with
purchase(activity, product, basePlanId, offerId)Called when the user initiates purchasing of a product.
Add your purchase logic here and return its result. You can use Android's Billing APIs, or if you use RevenueCat, you can call Purchases.shared.purchase(product).
Return
A PurchaseResult object, which is the result of your purchase logic. Note: Make sure you handle all cases of PurchaseResult.
Parameters
The ProductDetails the user would like to purchase.
An optional base plan identifier of the product that's being purchased.
An optional offer identifier of the product that's being purchased.