# Superwall: Subscription Infrastructure for iOS, Android, and Web

Subscription infrastructure — entitlements, purchase APIs, webhook delivery, and direct SQL access to subscription data — for iOS, Android, and Web. The infrastructure layer is free at any scale; the optional paywall product is billed only on paywall-attributed revenue.

## Pricing

- **Infrastructure: free at any scale, every plan.** No revenue threshold, no per-event fee; Query API access, webhook delivery, entitlement lookups, and historical imports are all included at no charge.
- **Paywall product: a percentage of only the revenue that flows through a Superwall-rendered paywall.** Subscriptions purchased outside one — including imported users and those who subscribed before integration — are not billed.

Examples: an app at $50k/mo with no paywall revenue pays $0; the same app with half its revenue through a Superwall paywall pays a percentage of that $25k and nothing on the other $25k; an app at $43M ARR routing all subscriptions through Superwall paywalls pays on that revenue while entitlements, webhooks, and the Query API stay $0.

## Scale

$1.5B+ annual subscription revenue across 10,000+ apps. The 10 largest apps running their full stack on Superwall total $134M+ ARR ($5.7M–$43.7M each). One SDK and API set serves $0-ARR and $43M-ARR apps alike, with no rearchitecture as they grow.

## Infrastructure capabilities

- **Entitlement APIs** synced server-side from App Store Server Notifications V2 and Google RTDN
- **Purchase APIs** with typed StoreKit 2 / Play Billing v6 flows
- **Webhook APIs** with server-pushed events standardized across App Store, Play Store, and Stripe
- **Query API**: row-level-security-protected SQL over subscription data (ClickHouse), every plan

Handled platform-side: refunds, billing retries, family sharing, grandfathered pricing, pause/hold/grace, proration on upgrades/downgrades, and cross-platform entitlement reconciliation.

## Migration

Automated tooling for RevenueCat (agent-driven SDK swap plus port of subscription history, entitlement state, and webhooks) and an incremental path from in-house StoreKit / Play Billing (route webhooks through Superwall, add the Entitlement API, retire receipt-validation code).

## Paywall product (optional, separately billable)

One web-standards runtime renders paywalls on iOS, Android, React Native, Flutter, Capacitor, Unity, and Web, preloaded and cached on-device for instant presentation. Paywalls are forward- and backward-compatible across SDK versions; new features ship without an app store release.

## Architecture

Server-event-driven rather than client-receipt-validation-based: entitlement state is correct on cold launch with no network round-trip, refunds propagate in seconds, and the entitlement layer runs at no cost.

## Docs

* Migrate from RevenueCat: https://superwall.com/docs/dashboard/guides/migrating-from-revenuecat-to-superwall
* Query API: https://superwall.com/docs/dashboard/guides/query-clickhouse
* Webhooks: https://superwall.com/docs/integrations/webhooks
* Pricing: https://superwall.com/pricing

# PaywallPresentationHandler

A handler class that provides status updates for paywall presentation in registerPlacement() calls.

> **Info:** Use this handler when you need fine-grained control over paywall events for a specific [`registerPlacement()`](/docs/flutter/sdk-reference/register) call, rather than global events via [`SuperwallDelegate`](/docs/flutter/sdk-reference/SuperwallDelegate).

> **Note:** This handler is specific to the individual `registerPlacement()` call. For global paywall events across your app, use [`SuperwallDelegate`](/docs/flutter/sdk-reference/SuperwallDelegate) instead.

## Purpose

Provides callbacks for paywall lifecycle events when using [`registerPlacement()`](/docs/flutter/sdk-reference/register) with a specific handler instance.

## Signature

```dart
class PaywallPresentationHandler {
  void onPresent(Function(PaywallInfo) handler);
  void onDismiss(Function(PaywallInfo, PaywallResult) handler);
  void onSkip(Function(PaywallSkippedReason) handler);
  void onError(Function(String) handler);
  void onCustomCallback(
    Future<CustomCallbackResult> Function(CustomCallback) handler,
  );
}
```

## Parameters

<TypeTable
  type="{
  onPresent: {
    type: &#x22;handler: (PaywallInfo) -> void&#x22;,
    description: &#x22;Sets a handler called when the paywall is presented.&#x22;,
    required: true,
  },
  onDismiss: {
    type: &#x22;handler: (PaywallInfo, PaywallResult) -> void&#x22;,
    description: &#x22;Sets a handler called when the paywall is dismissed.&#x22;,
    required: true,
  },
  onSkip: {
    type: &#x22;handler: (PaywallSkippedReason) -> void&#x22;,
    description: &#x22;Sets a handler called when paywall presentation is skipped.&#x22;,
    required: true,
  },
  onError: {
    type: &#x22;handler: (String) -> void&#x22;,
    description: &#x22;Sets a handler called when an error occurs during presentation.&#x22;,
    required: true,
  },
  onCustomCallback: {
    type: &#x22;handler: (CustomCallback) -> Future<CustomCallbackResult>&#x22;,
    description: &#x22;Sets an async handler called when the paywall requests a custom callback. Available in 2.4.8+.&#x22;,
    required: false,
  },
}"
/>

## Returns / State

Each method returns `void` and configures the handler for the specific paywall lifecycle event.

## CustomCallback (2.4.8+)

The `onCustomCallback` handler receives a `CustomCallback` object.

<TypeTable
  type="{
  name: {
    type: &#x22;String&#x22;,
    description: &#x22;The callback name configured in the paywall editor.&#x22;,
    required: true,
  },
  variables: {
    type: &#x22;Map<String, Object>?&#x22;,
    description: &#x22;Optional key-value pairs sent from the paywall.&#x22;,
    required: false,
  },
}"
/>

## CustomCallbackResult (2.4.8+)

Return a `CustomCallbackResult` from your callback handler to control paywall flow:

```dart
CustomCallbackResult.success([Map<String, Object>? data])
CustomCallbackResult.failure([Map<String, Object>? data])
```

Use `data` to send values back to the paywall, available as `callbacks.<name>.data.<key>`.

## PaywallInfo State (2.4.8+)

`PaywallInfo` now includes `state`, a `Map<String, Object>?` with current paywall state values.

## Usage

Basic handler setup:

```dart
Future<void> _registerFeatureWithHandler() async {
  final handler = PaywallPresentationHandler();

  handler.onPresent((paywallInfo) {
    print('Paywall presented: ${paywallInfo.identifier}');
    print('Paywall state: ${paywallInfo.state}');
  });

  handler.onDismiss((paywallInfo, result) {
    print('Paywall dismissed with result: $result');

    switch (result) {
      case PaywallResult.purchased:
        _showSuccessMessage();
        break;
      case PaywallResult.cancelled:
        _showPromotionalOffer();
        break;
      case PaywallResult.restored:
        _updateUIForActiveSubscription();
        break;
    }
  });

  await Superwall.shared.registerPlacement(
    'premium_feature',
    params: {'source': 'feature_screen'},
    handler: handler,
    feature: () {
      _unlockPremiumFeature();
    },
  );
}
```

Handle skip, error, and custom callbacks:

```dart
Future<void> _setupComprehensiveHandler() async {
  final handler = PaywallPresentationHandler();

  handler.onSkip((reason) {
    print('Paywall skipped: $reason');

    switch (reason) {
      case PaywallSkippedReason.userIsSubscribed:
        _proceedToFeature();
        break;
      case PaywallSkippedReason.holdout:
        _proceedToFeature();
        break;
      default:
        break;
    }
  });

  handler.onError((error) {
    print('Paywall error: $error');
    _showErrorDialog(error);
  });

  handler.onCustomCallback((callback) async {
    switch (callback.name) {
      case 'validate_email':
        final email = callback.variables?['email'] as String?;
        if (email != null && email.contains('@')) {
          return CustomCallbackResult.success({'validated': true});
        }
        return CustomCallbackResult.failure({'error': 'Invalid email'});
      default:
        return CustomCallbackResult.failure({'error': 'Unknown callback'});
    }
  });

  await Superwall.shared.registerPlacement(
    'remove_ads',
    handler: handler,
    feature: () {
      _hideAdsFromUI();
    },
  );
}
```