Stripe Checkout
block / payments / stripe
Checkout button plus the API route that creates a Stripe Checkout Session, with a server-side Price ID allow-list.
- type
- block
- files
- 4
- registry deps
- button
- npm deps
- stripe, lucide-react
- env vars
- STRIPE_SECRET_KEY, NEXT_PUBLIC_APP_URL
installs
- lib/automindz/pricing.ts
- lib/automindz/stripe.ts
- components/automindz/stripe-checkout-button.tsx
- app/api/checkout/route.ts
- Button posts to app/api/checkout/route.ts
- Route rejects any Price ID outside the pricing config
- Needs STRIPE_SECRET_KEY + NEXT_PUBLIC_APP_URL
Put the client's real Stripe Price IDs in lib/automindz/pricing.ts. The API route only accepts Price IDs present in that config, so a caller cannot check out an arbitrary price.
Variations
one state per section
- 01Subscription checkout
- 02Session could not be created
- 03One-off payment, fixed quantity
- 04Unavailable plan
Subscription checkout
Pending, then redirecting: the button stays busy while the tab leaves, so a second session can't be created.
Session could not be created
The reason is shown in place and the button becomes a retry. The onError callback still fires for logging.
One-off payment, fixed quantity
Same button, mode="payment". The server clamps quantity, so a tampered client cannot buy 10,000 seats.
Unavailable plan
Plain disabled when entitlement or a feature flag says no. No spinner, no error, nothing to retry.
