purchase
Called when the user initiates purchasing of a product that should replace one of their existing subscriptions, e.g. an upgrade, downgrade or plan switch.
The SDK calls this instead of purchase(activity, product, basePlanId, offerId) for every purchase. replacement is non-null only when the paywall's Purchase action is set to replace an existing subscription and the user has an active subscription that shares an entitlement with product. For Google Play products, pass ProductReplacement.oldPurchaseToken and ProductReplacement.mode to the billing flow's SubscriptionUpdateParams (or the equivalent in your billing library, such as RevenueCat's oldProductId and googleReplacementMode).
The default implementation ignores replacement and calls purchase(activity, product, basePlanId, offerId), so existing implementations keep working.
Return
A PurchaseResult object, which is the result of your purchase logic.
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.
The identifier of the offer to buy, already chosen by the SDK from the paywall's product (including sw-auto resolution). null means buy the base plan with no offer: don't pick a free trial or other offer yourself.
The existing subscription this purchase replaces, if any.
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.
The identifier of the offer to buy, already chosen by the SDK from the paywall's product (including sw-auto resolution). null means buy the base plan with no offer: don't pick a free trial or other offer yourself.