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

MethodParametersReturn TypeDescription
purchaseactivity: Activity, product: StoreProductPurchaseResultCalled when user initiates purchasing. Implement your purchase logic here. Activity is needed for Google Play Billing.
restorePurchasesNoneRestorationResultCalled when user initiates restore. Implement your restore logic here.

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?

On this page