purchase
abstract fun purchase(productDetails: ProductDetails, basePlanId: String?, offerId: String?, completion: (PurchaseResult) -> Unit)(source)
Called when the user initiates purchasing of a product.
Add your purchase logic here and call the completion lambda with the result. You can use Google's Play Billing APIs, or if you use RevenueCat, you can call Purchases.instance.purchase(product).
Parameters:
Parameters
product Details
The ProductDetails the user would like to purchase.
base Plan Id
An optional base plan identifier of the product that's being purchased.
offer Id
An optional offer identifier of the product that's being purchased. Call this with the result of your purchase logic. When you pass a .failed result, make sure you also pass the error. Note: Make sure you handle all cases of PurchaseResultJava.