Superwall

PurchaseController

An abstract class for handling custom purchase flows and subscription management.

Implementing a custom PurchaseController is advanced functionality. Most developers should use the default purchase controller with RevenueCat integration.

For RevenueCat integration, see the Using RevenueCat guide instead of implementing a custom PurchaseController.

Purpose

Allows custom implementation of purchase flows, subscription validation, and cross-platform purchase handling.

Signature

abstract class PurchaseController {
  Future<PurchaseResult> purchaseFromAppStore(String productId);
  Future<PurchaseResult> purchaseFromGooglePlay(
    String productId,
    String? basePlanId,
    String? offerId,
  );
  Future<RestorationResult> restorePurchases();
}

Parameters

MethodParametersDescription
purchaseFromAppStoreproductId: StringHandles iOS App Store purchases.
purchaseFromGooglePlayproductId: String, basePlanId: String?, offerId: String?Handles Google Play Store purchases with optional base plan and offer.
restorePurchasesNoneRestores previous purchases across platforms.

Returns / State

  • purchaseFromAppStore and purchaseFromGooglePlay return Future<PurchaseResult>
  • restorePurchases returns Future<RestorationResult>

Usage

For most use cases, use RevenueCat integration instead:

See the Using RevenueCat guide for complete setup instructions.

Custom implementation is only needed for advanced use cases where you have your own purchase handling system.

How is this guide?

On this page