Billing
Wire Autumn (Stripe billing layer) for a universal credit balance: Clerk userId as the customer id, hosted checkout, Svix-signed webhooks, and grant-on-verify.
1 file
Description
Wire Autumn (Stripe billing layer) for a universal credit balance: Clerk userId as the customer id, hosted checkout, Svix-signed webhooks, and grant-on-verify.
Selling credits (not per-app subscriptions) where one purchase should spend across every app you run. Autumn owns the purchase side; your own store owns the spendable balance.
Set the Autumn customer id to the Clerk userId. Because that id is stable across every app, a customer buys once and spends the same balance everywhere. Do not mint per-app customer records.
// createCheckout: Clerk userId + product id -> hosted Stripe URL
const res = await autumnFetch("/checkout", {
method: "POST",
body: JSON.stringify({ customer_id: clerkUserId, product_id: productId, success_url, cancel_url }),
});
Autumn signs deliveries with Svix (svix-id, svix-timestamp, svix-signature). Verify the signature first. Then re-fetch the customer from Autumn to confirm they actually own the product before you grant credits. Never grant on the webhook payload alone; a forged or replayed body must not mint credits.
if (!verifyAutumnWebhook(headers, rawBody)) return new Response("bad sig", { status: 400 });
if (await customerHasProduct(customerId, productId)) await grant(customerId, credits);
AUTUMN_SECRET_KEY at module load can crash a build without the env. Read it at call time and never log it.Added 2026-07-01. Back to the Skill Library.

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.