Superwall

PurchaseController

An interface for handling Superwall's subscription-related logic with your own purchase implementation.

This interface is not required. By default, Superwall handles all subscription-related logic automatically using Google Play Billing.

When implementing PurchaseController, you must manually update subscriptionStatus whenever the user's entitlements change.

Purpose

Use this interface only if you want complete control over purchase handling, such as when using RevenueCat or other third-party purchase frameworks.

Signature

interface PurchaseController {
    suspend fun purchase(
        activity: Activity,
        product: StoreProduct
    ): PurchaseResult
    
    suspend fun restorePurchases(): RestorationResult
}
// Java
public interface PurchaseController {
    CompletableFuture<PurchaseResult> purchase(
        Activity activity, 
        StoreProduct product
    );
    
    CompletableFuture<RestorationResult> restorePurchases();
}

Parameters

Prop

Type

Returns / State

  • purchase() returns a PurchaseResult (.Purchased, .Failed(Throwable), .Cancelled, or .Pending)
  • restorePurchases() returns a RestorationResult (.Restored or .Failed(Throwable?))

When using a PurchaseController, you must also manage subscriptionStatus yourself.

Usage

For implementation examples and detailed guidance, see Using RevenueCat.

How is this guide?

Edit on GitHub