Checkout Endpoint
Reference for a custom store's checkout endpoint: the signed checkout.create request Superwall sends, how to verify it, what to answer, and how the customer returns to your app.
A checkout endpoint is a URL on your server. When a user taps one of the store's products on a paywall, Superwall asks it for a checkout URL and opens the answer. Your app needs no purchase code.
It works with the iOS SDK 4.19.0 and later and on hosted web paywalls. On other platforms, or if the store has no checkout endpoint, the paywall sends the purchase to your app's PurchaseController.
For a working implementation, see the example server.
Set the endpoint
Open the custom store in the dashboard. In its Checkout section, click Set up checkout and enter the URL. It must be an https:// URL on a public host name.
Or use the Superwall API with a key that has the custom_stores:write scope:
curl -X PUT https://api.superwall.com/v2/projects/$PROJECT_ID/custom-stores/$CUSTOM_STORE_ID/checkout-endpoint \
-H "Authorization: Bearer $SUPERWALL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://billing.example.com/superwall/checkout"}'Superwall shows the endpoint's signing secret (whsec_...) once, in the dashboard or as signing_secret in the API response. Store it on your server. Changing the URL later keeps the secret.
The request
Superwall sends a POST with a JSON body:
{
"type": "checkout.create",
"custom_store_id": "4821",
"product_id": "pro_monthly",
"app_user_id": "user_8812",
"custom_transaction_id": "9f2c1d3e-4b5a-4c6d-8e7f-0a1b2c3d4e5f",
"success_url": "https://...",
"cancel_url": "https://..."
}| Field | Description |
|---|---|
type | Always checkout.create today. Ignore types you don't know. |
custom_store_id | The store that sells the product. |
product_id | The product's identifier, as you created it in Superwall. |
app_user_id | The buyer, as the SDK knows them. Send it back unchanged as app_user_id on your events. For a user your app hasn't identified, it's an ID the SDK made. |
custom_transaction_id | Superwall's ID for this purchase. Send it back as custom_transaction_id on the purchase event. |
success_url | Where to send the customer after they pay. |
cancel_url | Where to send the customer if they leave without paying. |
Superwall may add fields at any time. Read the fields you need and ignore the rest. An endpoint that refuses unknown fields breaks on the day a new one ships.
Your answer
Create a checkout in your billing system, store app_user_id and custom_transaction_id in its metadata, and answer within ten seconds:
{ "url": "https://pay.example.com/checkout/cs_123" }The url must start with https://. Superwall opens it for the customer.
Answer with an error status when you can't create the checkout. Any non-2xx answer, a timeout or an invalid url fails the purchase, and the paywall stays open. These statuses are a good convention:
| Status | When |
|---|---|
401 | The signature is missing, wrong or too old. |
404 | You don't sell product_id. |
502 | Your billing system refused or didn't answer. |
Verify the signature
Anyone can find your endpoint's URL, so check that each request comes from Superwall. Requests are signed the Standard Webhooks way, with three headers:
| Header | Value |
|---|---|
webhook-id | A unique ID for the request. |
webhook-timestamp | When it was sent, in seconds since 1970. |
webhook-signature | One or more v1,<signature> values, separated by spaces. |
Each signature is the base64 HMAC-SHA256 of <webhook-id>.<webhook-timestamp>.<raw body>. The key is the base64-decoded part of the secret after whsec_.
Accept the request when any listed signature matches and the timestamp is less than five minutes old:
import { createHmac, timingSafeEqual } from "node:crypto"
export function isFromSuperwall(body: string, headers: Headers, secret: string): boolean {
const id = headers.get("webhook-id")
const timestamp = headers.get("webhook-timestamp")
const signatures = headers.get("webhook-signature")
if (!id || !timestamp || !signatures) return false
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 5 * 60) return false
const key = Buffer.from(secret.slice("whsec_".length), "base64")
const expected = createHmac("sha256", key).update(`${id}.${timestamp}.${body}`).digest()
return signatures.split(" ").some((entry) => {
const [version, value] = entry.split(",", 2)
const candidate = Buffer.from(value ?? "", "base64")
return (
version === "v1" && candidate.length === expected.length && timingSafeEqual(candidate, expected)
)
})
}Compute the signature over the body exactly as it arrived. If your framework parses JSON first, read the raw body instead: parsing and re-serializing changes the bytes. A Standard Webhooks library for your language also works.
After the customer pays
- Your billing system sends the customer to
success_url. It's a Superwall page that opens your app again. - Your billing system sends your server a webhook. Your server sends Superwall the
initial_purchaseevent with the request'sapp_user_idandcustom_transaction_id. - Superwall grants the entitlement. The paywall closes as purchased once an event with that
custom_transaction_idhas arrived.
The paywall waits for an event that carries the checkout's custom_transaction_id. An event without it still grants access, but the paywall doesn't close as purchased. Opening success_url alone never grants anything: only your events do.
If the customer leaves the checkout, send them to cancel_url. The paywall stays open so they can try again.
Returning to an iOS app
The return page opens your app through its URL scheme:
- Give your app a custom URL scheme.
- Enter it as the Apple custom URL scheme in the dashboard's app settings.
- Pass incoming links to
Superwall.handleDeepLink(_:).
Rotate the secret
Click Rotate secret in the store's Checkout section, or call POST .../checkout-endpoint/rotate-secret. The new secret is shown once.
For 24 hours after a rotation, every request carries two signatures, one for each secret. An endpoint that accepts any matching signature, like the code above, keeps working with either secret, so you can switch at any point in that window. After 24 hours, only the new secret signs.
Web paywalls
On a hosted web paywall, the same endpoint creates the checkout. Two things differ:
-
The buyer may not be signed in. A buyer the web paywall hasn't identified pays with a temporary ID as
app_user_id. Once your purchase event is accepted, the checkout gets a redemption code, and the return page shows it. The buyer enters it in your app to claim the purchase. -
The buyer may close the tab before the return page loads. Fetch the code yourself and send it, for example in your receipt email:
curl https://api.superwall.com/v2/custom-stores/$CUSTOM_STORE_ID/redemption-codes/$CUSTOM_TRANSACTION_ID \ -H "Authorization: Bearer $SUPERWALL_API_KEY"{ "object": "custom_store_redemption_code", "custom_transaction_id": "9f2c1d3e-4b5a-4c6d-8e7f-0a1b2c3d4e5f", "code": "redemption_0b8f6c1e-...", "expires_at": "2026-12-28T09:15:00.000Z", "redeemed": false, "redeem_url": "https://..." }The key needs the
custom_store_events:writescope. Every request for a checkout returns the same code.redeem_urlis a link on your web paywall's domain that opens your app with the code.
| Status | Meaning |
|---|---|
404 custom_store_checkout_not_found | No web paywall checkout has this ID. Checkouts started in the app have no code. |
409 purchase_not_recorded | No accepted purchase event carries this ID yet. Send the event, then try again. |
409 buyer_identified | The buyer was signed in, so the purchase is already theirs and there's no code. |
Without a checkout endpoint
When a store has no checkout endpoint, a paywall sends its products to your app's PurchaseController. Your app then starts the checkout itself:
- Read
product.productIdentifierandproduct.customTransactionIdinpurchase(product:). - Ask your server for a checkout for the signed-in user, and open it.
- Your server stores the user's ID and the
customTransactionIdin the checkout's metadata, then reports events the same way.
See Custom Store Products for iOS and PurchaseController for Android.
To go back to it later, click Remove checkout endpoint in the dashboard or call DELETE .../checkout-endpoint.
How is this guide?
Example Server
A complete custom store server in two files: a checkout endpoint that creates checkouts for Superwall paywalls, and a webhook handler that reports purchases, renewals, cancellations and refunds.
Events
Reference for custom store events: the endpoint, every event type and field, how retries, ordering and refunds work, and how sandbox and production revenue are counted.