Stack cloud para apps de IA — Maestria4 / 8
Stripe — Payments & Subscriptions
Charging money is a solved problem — if you let Stripe solve it. Checkout, subscriptions, and the webhook that is the real source of truth.

Do not build a payment form. Stripe's hosted Checkout handles cards, wallets, taxes, SCA, and fraud — you redirect to it and get a result. Your job is wiring, not cryptography.
Checkout in one call
Create a Checkout Session server-side with a price id and success/cancel URLs; redirect the user. One-time products and recurring subscriptions are the same flow with a different mode (payment vs subscription).
const session = await stripe.checkout.sessions.create({
mode: 'subscription',
line_items: [{ price: priceId, quantity: 1 }],
success_url: `${APP}/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${APP}/pricing?canceled=1`,
})
The webhook is the source of truth
The redirect is for UX (a thank-you page); the webhook is for truth (provision the account, send the email, flip the entitlement).
Subscriptions need lifecycle handling
Handle the recurring events: invoice.paid (extend access), customer.subscription.deleted / updated (revoke or change tier), failed payments (dunning). Access should follow Stripe's state, not a one-time flag.
Next: the email that confirms the purchase — Resend.
Série — Stack cloud para apps de IA — Maestria
- Parte 01A Pilha de Produtos IA com OpiniãoEscolher infraestrutura é onde semanas desaparecem. Aqui está uma pilha padrão que permite a um pequeno time entregar um produto IA em dias — e quando desviar.
- Parte 02Next.js no Vercel — A Camada de AppUm framework para UI, API e server rendering; uma plataforma que faz deploy no git push. A camada de app deve ser a parte em que você nunca pensa.
- Parte 03Supabase — Postgres, Auth & Storage in OneReal Postgres, auth, file storage and pgvector behind one SDK. For an AI product, having your data and your vectors in the same database is a quiet superpower.
- Parte 04Stripe — Payments & Subscriptions — você está aquiCharging money is a solved problem — if you let Stripe solve it. Checkout, subscriptions, and the webhook that is the real source of truth.
- Parte 05Resend — Email Transacional Que ChegaO recibo, o link de download, a redefinição de senha — se caírem no spam, seu produto parece quebrado. Entregabilidade é um recurso.
- Parte 06AWS — When You Outgrow the Managed PathThe managed stack covers 90% of an AI product. AWS is the escape hatch for the other 10% — long jobs, GPU inference, large files. Use it surgically.
- Parte 07Secrets, Env & Config Across EnvironmentsFive services, three environments, one leaked key away from a bad week. Config discipline is unglamorous and non-negotiable.
- Parte 08Shipping in Days — The Wiring PlaybookThe whole stack assembled into a build order: from empty repo to a paid, emailing, AI-powered product in a working week.