# 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

# Elements Checkout Reference

Every prop, option, return field and result of StripeCheckout, useCheckout and PurchaseButton, plus which Stripe elements work in the form.

This page lists the API of the [Elements checkout](/docs/framework/elements-checkout). It has two entry points:

* **`superwall/checkout`** holds what every store's form shares: `useCheckout()`, `<PurchaseButton>` and their types. A button built on them works in any form.
* **`superwall/checkout/stripe`** holds what is Stripe's: `<StripeCheckout>`, `ExpressCheckoutElement`, `LinkAuthenticationElement` and Stripe's own elements. A paywall that never imports it ships none of Stripe's React code.

```tsx
import { PurchaseButton, useCheckout } from "superwall/checkout";
import { StripeCheckout, PaymentElement } from "superwall/checkout/stripe";
```

## `checkout: "elements"`

The config mode that turns the form on. Set it in `config.ts`, with an optional `prefetch` to load a plan's price as the paywall opens:

```ts title="config.ts"
checkout: { mode: "elements", prefetch: "trial" },
```

In this mode:

* `<StripeCheckout>` takes payment on a web paywall, the [Web SDK](/docs/web) and a [teleport](/docs/framework/teleport) checkout route.
* A plain `purchase()` opens Superwall's sheet.
* `purchase(product, { checkout: "applePay" })` opens Superwall's Apple Pay sheet, prepared from the same price as the form. Check `useApplePay(product)` before you show its button.
* Inside the iOS app, in Studio and in a native SDK below 4.10.8, the form is `unavailable` and a purchase uses the hosted checkout instead. See [Unavailable reasons](#unavailable-reasons).

See [Web Checkout](/docs/framework/web-checkout#modes) for every mode.

## `<StripeCheckout>`

Sells one Stripe product. It wraps Stripe's `<Elements>` in deferred mode: it prices the form from the product, so it renders at once, and nothing is created in Stripe until the shopper pays. Every element and `useCheckout()` call inside it pays through it.

```tsx
<StripeCheckout
  product="annual"
  stripeMetadata={{ campaign: "spring" }}
  onComplete={() => track("subscribed")}
>
  <LinkAuthenticationElement />
  <PaymentElement />
  <PurchaseButton>Subscribe</PurchaseButton>
</StripeCheckout>
```

<TypeTable
  type="{
  product: {
    type: &#x22;ProductReference | SuperwallProduct&#x22;,
    description: &#x22;The Stripe product the form sells, by reference or as a product. Changing it re-prices the form; Stripe's fields keep what the shopper typed.&#x22;,
    required: true,
  },
  options: {
    type: &#x22;StripeCheckoutOptions&#x22;,
    description: &#x22;Stripe's Elements options, such as `appearance`, `fonts`, `locale` and `paymentMethodTypes`. See below.&#x22;,
    default: &#x22;Stripe's own&#x22;,
  },
  email: {
    type: &#x22;string&#x22;,
    description: &#x22;The shopper's email, for a paywall with its own email field. Pass `\&#x22;\&#x22;` while the field is empty.&#x22;,
    default: &#x22;The email from `LinkAuthenticationElement`, a wallet or the Payment Element, then the user's `email` attribute&#x22;,
  },
  stripeMetadata: {
    type: &#x22;Record<string, string>&#x22;,
    description: &#x22;Metadata to set on the Stripe subscription, as on `purchase()`.&#x22;,
    default: &#x22;none&#x22;,
  },
  postPurchase: {
    type: &#x22;SuperwallPostPurchase&#x22;,
    description: &#x22;What happens after the purchase, as on `purchase()`.&#x22;,
    default: &#x22;The paywall's config&#x22;,
  },
  onStart: {
    type: &#x22;(product) => void&#x22;,
    description: &#x22;A purchase from this form started.&#x22;,
  },
  onSubmit: {
    type: &#x22;(product) => void&#x22;,
    description: &#x22;The shopper submitted payment: the form was read, or a wallet authorized it.&#x22;,
  },
  onComplete: {
    type: &#x22;(product) => void&#x22;,
    description: &#x22;The purchase was paid.&#x22;,
  },
  onAbandon: {
    type: &#x22;(product) => void&#x22;,
    description: &#x22;The shopper closed a wallet or Link in `ExpressCheckoutElement` without paying.&#x22;,
  },
  onFailure: {
    type: &#x22;(failure: PurchaseFailure) => void&#x22;,
    description: &#x22;A payment failed, with why in `failure.reason`. The form stays open.&#x22;,
  },
  children: {
    type: &#x22;ReactNode&#x22;,
    description: &#x22;The form: elements from `superwall/checkout/stripe`, a `<PurchaseButton>` and your own UI.&#x22;,
  },
}"
/>

The callbacks hear only this form's purchases. `usePurchase()`'s callbacks hear them too. See [Elements Checkout Events](/docs/framework/elements-checkout/events) for their order.

### `options`

`StripeCheckoutOptions` is Stripe's [Elements options](https://docs.stripe.com/js/elements_object/create_without_intent) for deferred mode, less what Superwall sets from the product.

* **Superwall sets:** `mode`, `amount`, `currency`, `paymentMethodCreation` and `setupFutureUsage`. They aren't in the type, and the form ignores them if passed anyway.
* **`paymentMethodTypes`** defaults to `["card", "link"]`, which covers cards, Apple Pay, Google Pay and Link. Any other type is dropped with a console warning.
* **`locale`** defaults to the paywall's locale, so Stripe's labels and errors match the paywall's language.
* **Everything else**, such as `appearance`, `fonts` and `loader`, is passed to Stripe unchanged.

### Email

Every purchase needs the shopper's email. It's the Stripe customer's email, for the receipt, the redemption link and the billing portal. The form takes the first of:

1. The `email` prop.
2. The email typed into `LinkAuthenticationElement`.
3. The email a wallet or the Payment Element returns.
4. The user's `email` attribute.

A form with no way to get one logs a warning once it's ready. Without an email, `submit()` returns `incomplete` with an `email_required` error and charges nothing.

## `useCheckout()`

The state of the nearest checkout form, and `submit()` to pay with what the shopper entered. Call it from any component inside `<StripeCheckout>`; outside one it throws. It reads the same for every store.

```tsx
const PayButton = () => {
  const checkout = useCheckout();
  return (
    <button disabled={!checkout.canSubmit} onClick={() => checkout.submit()}>
      {checkout.status === "paying" ? "Paying…" : "Subscribe"}
    </button>
  );
};
```

It returns `UseCheckoutResult`:

<TypeTable
  type="{
  status: {
    type: '&#x22;preparing&#x22; | &#x22;ready&#x22; | &#x22;paying&#x22; | &#x22;unavailable&#x22;',
    description: &#x22;`preparing`: Stripe.js and the price are loading. `ready`: the shopper can pay. `paying`: a payment is in flight. `unavailable`: the form can't take payment.&#x22;,
    required: true,
  },
  reason: {
    type: &#x22;CheckoutUnavailableReason&#x22;,
    description: &#x22;Why the form can't take payment. Set only when `status` is `\&#x22;unavailable\&#x22;`. See [Unavailable reasons](#unavailable-reasons).&#x22;,
  },
  message: {
    type: &#x22;string&#x22;,
    description: &#x22;The reason in a sentence, in English, for logs. Set with `reason`.&#x22;,
  },
  error: {
    type: &#x22;CheckoutError&#x22;,
    description: &#x22;What the browser or Stripe threw, as `{ name, message }`, when a step threw.&#x22;,
  },
  product: {
    type: &#x22;SuperwallProduct&#x22;,
    description: &#x22;The product the form sells. Absent when the paywall has no such product.&#x22;,
  },
  amounts: {
    type: &#x22;CheckoutAmounts&#x22;,
    description: &#x22;What the shopper pays. Absent until the price has loaded.&#x22;,
  },
  canSubmit: {
    type: &#x22;boolean&#x22;,
    description: &#x22;Whether `submit()` can pay now: `status` is `\&#x22;ready\&#x22;`.&#x22;,
    required: true,
  },
  submit: {
    type: &#x22;() => Promise<CheckoutSubmitResult>&#x22;,
    description: &#x22;Pays for the product with what the shopper entered. Bind it to your own button, or use `<PurchaseButton>`.&#x22;,
    required: true,
  },
  failure: {
    type: &#x22;CheckoutFailure&#x22;,
    description: &#x22;Why the form's last payment failed, cleared when the next one starts. See [Payment failure reasons](/framework/payment-failures).&#x22;,
  },
}"
/>

### `CheckoutAmounts`

Amounts are in the currency's minor units, such as cents for USD.

<TypeTable
  type="{
  currency: {
    type: &#x22;string&#x22;,
    description: &#x22;The ISO 4217 currency code, lowercase, such as `\&#x22;usd\&#x22;`.&#x22;,
    required: true,
  },
  dueNow: {
    type: &#x22;number&#x22;,
    description: &#x22;What the shopper pays today: `0` during a free trial, or with a 100% discount.&#x22;,
    required: true,
  },
  recurring: {
    type: &#x22;number&#x22;,
    description: &#x22;What each period renews at, after any discount.&#x22;,
    required: true,
  },
  interval: {
    type: '&#x22;day&#x22; | &#x22;week&#x22; | &#x22;month&#x22; | &#x22;year&#x22;',
    description: &#x22;The renewal period's unit.&#x22;,
    required: true,
  },
  intervalCount: {
    type: &#x22;number&#x22;,
    description: &#x22;How many `interval`s one period lasts.&#x22;,
    required: true,
  },
  trialDays: {
    type: &#x22;number&#x22;,
    description: &#x22;The free trial's length in days. Absent without a trial.&#x22;,
  },
  discount: {
    type: &#x22;AppliedDiscount&#x22;,
    description: &#x22;The discount applied with `useDiscount()`. Absent without one.&#x22;,
  },
}"
/>

`dueNow === 0` alone doesn't mean a free trial: check `trialDays` before you say "Start free trial".

### `submit()` results

`submit()` resolves with a `CheckoutSubmitResult`:

| `status`      | Means                                                                                                                                                                                                                    | Callbacks                                                                                                               |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `completed`   | The purchase was paid.                                                                                                                                                                                                   | `onStart`, `onSubmit`, `onComplete`                                                                                     |
| `failed`      | The payment failed; `failure` says why. The form stays open.                                                                                                                                                             | `onStart`, `onSubmit`, `onFailure`; a payment method the form can't take (`card_not_supported`) fails before `onSubmit` |
| `abandoned`   | Never from `submit()`. It ends a wallet or Link purchase in `ExpressCheckoutElement` that the shopper closed.                                                                                                            | `onStart`, `onAbandon`                                                                                                  |
| `incomplete`  | No purchase started. The form isn't filled in and its fields show what's missing, or Stripe couldn't read the form, such as with no `PaymentElement` mounted. `error` says why; `email_required` means there's no email. | None                                                                                                                    |
| `unavailable` | The form can't take payment now. `reason` is an [unavailable reason](#unavailable-reasons), or `preparing` or `paying` while the form is busy.                                                                           | None                                                                                                                    |

```tsx
const result = await checkout.submit();
if (result.status === "incomplete" && result.error.name === "email_required") {
  setError("Enter your email to continue.");
}
```

`<PurchaseButton>` shows nothing for `incomplete`. A paywall with its own email field should call `submit()` from its own button and show the message itself.

## `<PurchaseButton>`

A `<button>` that calls `submit()` on the nearest checkout form.

* It's disabled until the form can take payment and while it pays.
* It sets `data-status` to `useCheckout().status` and `aria-busy` while paying, so you can style each state.
* `onClick` runs before the payment; call `event.preventDefault()` to stop it.
* Every other prop goes to the `<button>`, except `type`, which is always `"button"`.

```tsx
<PurchaseButton className="cta">Start free trial</PurchaseButton>
```

```css
.cta[data-status="paying"] { opacity: 0.6; }
```

## Stripe elements

Every element comes from `superwall/checkout/stripe` and takes all of Stripe's own options. Two are wrapped, because Superwall needs their events.

### `ExpressCheckoutElement`

Stripe's [Express Checkout Element](https://docs.stripe.com/elements/express-checkout-element): one-tap buttons for Apple Pay, Google Pay and Link, each shown where the device and browser offer it. It takes Stripe's props except `onClick`, `onConfirm` and `onCancel`, which `<StripeCheckout>` handles:

* A wallet payment completes the purchase without a `<PurchaseButton>`.
* Closing the wallet reports `onAbandon`.
* The wallet always asks for the shopper's email, which Superwall sets on the customer.

Use `paymentMethods` to choose the buttons, such as only Link:

```tsx
<ExpressCheckoutElement
  options={{ paymentMethods: { applePay: "never", googlePay: "never", link: "auto" } }}
/>
```

On a device with no wallet it renders nothing; its `onReady` tells you which buttons it shows.

### `LinkAuthenticationElement`

Stripe's email field, which also signs Link shoppers in. It hands the email to the purchase, and fills itself in from the user's `email` attribute unless `options.defaultValues.email` is set. Its `onChange` still fires.

### Which elements work

| Element                                                                   | Supported | Notes                                                                                            |
| ------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------ |
| `PaymentElement`                                                          | Yes       | Cards and Link.                                                                                  |
| `ExpressCheckoutElement`                                                  | Wrapped   | Apple Pay, Google Pay and Link. Superwall owns `onClick`, `onConfirm` and `onCancel`.            |
| `LinkAuthenticationElement`                                               | Wrapped   | Hands the email to the purchase.                                                                 |
| `AddressElement`                                                          | Yes       | With `mode: "billing"`: the address goes onto the payment method.                                |
| `CardElement`, `CardNumberElement`, `CardExpiryElement`, `CardCvcElement` | Yes       | The classic card fields, styled with `options.style`. A mounted `PaymentElement` wins over them. |
| `useStripe()`, `useElements()`                                            | Yes       | For reading the form. Don't confirm with them; call `useCheckout().submit()`.                    |
| `ShippingAddressElement`, `AddressElement` with `mode: "shipping"`        | No        | A subscription ships nothing, and the purchase has nowhere to send it.                           |
| `TaxIdElement`                                                            | No        | The purchase has nowhere to send a tax ID.                                                       |
| `IbanElement`, SEPA, ACH, iDEAL, Klarna, Afterpay, Cash App Pay           | No        | They redirect or need a bank mandate, a return-and-resume flow Superwall doesn't support yet.    |
| `PaymentMethodMessagingElement`                                           | No        | It advertises the buy-now-pay-later methods above.                                               |
| `EmbeddedCheckout`, `CheckoutProvider`                                    | No        | Stripe's own hosted checkout. Use `checkout: "sheet"` instead.                                   |

Saved cards aren't offered: the form pays as a new customer each time.

The form enforces this list. It drops `paymentMethodTypes` beyond `card` and `link` with a console warning. A payment method of any other type fails with `card_not_supported`, code `payment_method_unsupported`, before anything is charged.

> **Warning:** Import every element from `superwall/checkout/stripe`, never from `@stripe/react-stripe-js`. Your own copy of Stripe's React package has its own context, so its elements can't see `<StripeCheckout>` and throw "Could not find Elements context".

## Unavailable reasons

When `useCheckout().status` is `"unavailable"`, `reason` is a `CheckoutUnavailableReason`:

| `reason`                 | Means                                                                                                                                                                          |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `unsupported_host`       | This host never takes payment in the paywall: inside the iOS app, in Studio, or in a native SDK below 4.10.8.                                                                  |
| `external_checkout`      | The config's `checkout` is `external` or not set, so it sends shoppers to Superwall's hosted checkout. Set it to `"elements"`. With `sheet` or `applePay` the form still pays. |
| `missing_public_api_key` | The host supplied no public API key.                                                                                                                                           |
| `unknown_product`        | The paywall has no product with this reference.                                                                                                                                |
| `unsupported_product`    | Stripe doesn't sell this product, such as an App Store product. Buy it with `usePurchase().purchase()`.                                                                        |
| `session_failed`         | Fetching the product's price failed; `error` holds what went wrong.                                                                                                            |
| `session_unsupported`    | The backend can't take this product's payment in a form, such as a one-time price or an account on Stripe managed payments. A plain `purchase()` still opens the sheet.        |
| `store_load_failed`      | Stripe.js didn't load.                                                                                                                                                         |

Inside the iOS app, a Stripe purchase always leaves for the browser: the hosted checkout or your [teleport](/docs/framework/teleport) route, where the form can pay.

## Types

`superwall/checkout` exports `UseCheckoutResult`, `CheckoutSubmitResult`, `CheckoutAmounts`, `CheckoutUnavailableReason`, `CheckoutError` and `PurchaseButtonProps`.

`superwall/checkout/stripe` exports `StripeCheckoutProps`, `StripeCheckoutOptions`, `ExpressCheckoutElementProps`, and Stripe's own prop types for the elements it re-exports.

## Related

* [Elements Checkout](/docs/framework/elements-checkout): build a paywall with Apple Pay, Link and a card form
* [Elements Checkout Events](/docs/framework/elements-checkout/events): which callbacks fire, and when
* [Payment failure reasons](/docs/framework/payment-failures): what `onFailure` and `failure` hold