0

Stripe Checkout & Customer Portal

Paymentsused in ~55% of apps

Charging money is the line where bugs stop being annoying and start being refunds, chargebacks, and angry users who paid but got nothing. The single most common payment bug in tutorials is fulfilling the order in the success redirect — which means a user who closes the tab pays and never gets access, and a user who guesses the URL gets access without paying. Get the webhook right and you look like someone who has shipped real billing.

Core idea. Never trust the browser to confirm a payment. You create a Checkout Session on the server (via a Server Action), redirect the user to Stripe's hosted page, and you only grant access when Stripe's server tells your server — through a verified, idempotent `checkout.session.completed` webhook — that the money actually moved. Attach a Stripe customer id to your user so every future event (renewals, cancellations) maps back to the right account, and hand returning users the hosted Customer Portal to manage their own subscription.
Playground, this isn't a screenshot
CRUD ↔ HTTP verb
POSTCreateGETReadPATCHUpdateDELETEDelete
local list (React state)2 items
#1Ship the feed
#2Review PRs
network — request / response
Add, edit, or delete an item. Watch the HTTP verb fire, then the local list update after the response.

Each mutation waits for the server's response, then updates the local list immutably (map / filter / spread) — no full refetch. Showing the change before the response is optimistic UI (#71).

↑ play a little first, then dig in