registry
@automindzsheets 01–77shadcn 4.x
SHEET 05

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

01

Subscription checkout

Pending, then redirecting: the button stays busy while the tab leaves, so a second session can't be created.

fluid
02

Session could not be created

The reason is shown in place and the button becomes a retry. The onError callback still fires for logging.

fluid
03

One-off payment, fixed quantity

Same button, mode="payment". The server clamps quantity, so a tampered client cannot buy 10,000 seats.

fluid
04

Unavailable plan

Plain disabled when entitlement or a feature flag says no. No spinner, no error, nothing to retry.

fluid