-
- All Implemented Interfaces:
-
com.revenuecat.purchases.ui.revenuecatui.PurchaseLogic
public abstract class PurchaseLogicWithCallback implements PurchaseLogic
Abstract class extending
PurchaseLogic, providing methods for handling in-app purchases and restorations with completion callbacks rather than co-routines.If you prefer to implement custom purchase and restore logic with coroutines, please implement
PurchaseLogicdirectly.
-
-
Constructor Summary
Constructors Constructor Description PurchaseLogicWithCallback()
-
Method Summary
Modifier and Type Method Description abstract UnitperformPurchaseWithCompletion(Activity activity, Package rcPackage, Function1<PurchaseLogicResult, Unit> completion)Performs an in-app purchase for the specified package with a completion callback. abstract UnitperformRestoreWithCompletion(CustomerInfo customerInfo, Function1<PurchaseLogicResult, Unit> completion)Restores previously completed purchases for the given customer with a completion callback. final PurchaseLogicResultperformPurchase(Activity activity, Package rcPackage)This method is called by RevenueCat, which in turn calls performPurchaseWithCompletionwhere your app's custom purchase logic is performed.final PurchaseLogicResultperformRestore(CustomerInfo customerInfo)This method is called by RevenueCat, which in turn calls performRestoreWithCompletionwhere your app's custom purchase logic is performed.-
-
Method Detail
-
performPurchaseWithCompletion
abstract Unit performPurchaseWithCompletion(Activity activity, Package rcPackage, Function1<PurchaseLogicResult, Unit> completion)
Performs an in-app purchase for the specified package with a completion callback.
If a purchase is successful,
syncPurchaseswill automatically be called by RevenueCat to update our database. However, if you are using Amazon's store, you must callsyncAmazonPurchasein your code.- Parameters:
activity- The current AndroidActivitytriggering the purchase.rcPackage- The package representing the in-app product that the user intends to purchase.completion- A callback function that receives aPurchaseLogicResultobject containing the outcome of the purchase operation.
-
performRestoreWithCompletion
abstract Unit performRestoreWithCompletion(CustomerInfo customerInfo, Function1<PurchaseLogicResult, Unit> completion)
Restores previously completed purchases for the given customer with a completion callback.
If restoration is successful,
syncPurchaseswill automatically be called by RevenueCat to update our database. However, if you are using Amazon's store, you must callsyncAmazonPurchasein your code.- Parameters:
customerInfo- An object containing information about the customer.completion- A callback function that receives aPurchaseLogicResultobject containing the outcome of the restoration process.
-
performPurchase
final PurchaseLogicResult performPurchase(Activity activity, Package rcPackage)
This method is called by RevenueCat, which in turn calls
performPurchaseWithCompletionwhere your app's custom purchase logic is performed.- Parameters:
activity- The current AndroidActivitytriggering the purchase.rcPackage- The package representing the in-app product that the user intends to purchase.
-
performRestore
final PurchaseLogicResult performRestore(CustomerInfo customerInfo)
This method is called by RevenueCat, which in turn calls
performRestoreWithCompletionwhere your app's custom purchase logic is performed.- Parameters:
customerInfo- An object containing information about the customer.
-
-
-
-