Package 

Class PurchaseLogicWithCallback

  • 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 PurchaseLogic directly.

    • Method Summary

      Modifier and Type Method Description
      abstract Unit performPurchaseWithCompletion(Activity activity, Package rcPackage, Function1<PurchaseLogicResult, Unit> completion) Performs an in-app purchase for the specified package with a completion callback.
      abstract Unit performRestoreWithCompletion(CustomerInfo customerInfo, Function1<PurchaseLogicResult, Unit> completion) Restores previously completed purchases for the given customer with a completion callback.
      final PurchaseLogicResult performPurchase(Activity activity, Package rcPackage) This method is called by RevenueCat, which in turn calls performPurchaseWithCompletion where your app's custom purchase logic is performed.
      final PurchaseLogicResult performRestore(CustomerInfo customerInfo) This method is called by RevenueCat, which in turn calls performRestoreWithCompletion where your app's custom purchase logic is performed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PurchaseLogicWithCallback

        PurchaseLogicWithCallback()
    • 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, syncPurchases will automatically be called by RevenueCat to update our database. However, if you are using Amazon's store, you must call syncAmazonPurchase in your code.

        Parameters:
        activity - The current Android Activity triggering the purchase.
        rcPackage - The package representing the in-app product that the user intends to purchase.
        completion - A callback function that receives a PurchaseLogicResult object 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, syncPurchases will automatically be called by RevenueCat to update our database. However, if you are using Amazon's store, you must call syncAmazonPurchase in your code.

        Parameters:
        customerInfo - An object containing information about the customer.
        completion - A callback function that receives a PurchaseLogicResult object 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 performPurchaseWithCompletion where your app's custom purchase logic is performed.

        Parameters:
        activity - The current Android Activity triggering 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 performRestoreWithCompletion where your app's custom purchase logic is performed.

        Parameters:
        customerInfo - An object containing information about the customer.