inference bureau
← Changelog
NewAppsFrom the roadmap

Stripe for web apps: Checkout, subscriptions and webhooks

A web app takes payments into your own Stripe account through Stripe's hosted Checkout and customer portal. Connect a sandbox key for development and your live key for production in Settings · Integrations; the webhook endpoint is made for you, each user's customer and subscription are kept in the app's records, and api/actions/stripe<Type>.ts runs on Stripe's events. Build with the assistant on the Stripe card writes the Billing page for you.

From @inferencebureau/apps-sdk/stripe: checkout(user, { price }) for a Checkout URL (a price id or its lookup key), billingPortal(user) for the portal, subscriptionOf(user), and requireSubscription(user, { prices }), which throws a 402 unless the subscription is active.

Each event is checked against the endpoint's signing secret, handled once however often Stripe sends it, logged as a webhook from stripe, and caught up within the hour if it never arrives. stripeCustomer and stripeSubscription are filled from the account when you connect.

In Preview, Stripe's pages can't open inside the frame, so a bar says your checkout is working and opens Stripe's page in a new tab, with the test card behind a toggle.

More in Stripe.