By Jake Mcdonald, founder of ShipEmber · November 26, 2026 · About a 10-minute read · Checked against the Stripe and Next.js docs
I'm Jake Mcdonald. The first time I wired up Stripe Checkout, my "billing system" was one line on the success page: if the user landed on /success, set plan = "pro". It worked perfectly in testing. It's also the most common billing mistake I see in Next.js SaaS tutorials, and it fails in ways that either give away your product or charge people without unlocking anything.
The short version: the success URL is a redirect, not a receipt. It tells you a browser arrived at a page. It doesn't tell you who paid, whether the money actually landed, or what happens next month. This post walks through the mistakes I made (and keep seeing), what Stripe's docs actually say, and the small pattern I use now. I checked every Stripe detail against the Checkout fulfillment guide, the custom success page guide, the subscription webhooks guide, the webhooks docs, and the Checkout Session object reference on November 26, 2026.
TL;DR: which signal should grant Pro?
| Signal | What it actually tells you | Grant Pro on it alone? |
|---|---|---|
User lands on your success_url |
A browser loaded a page. Anyone can type that URL. | No |
?session_id=... in the URL |
A string that might be a Checkout Session ID | No, not until your server retrieves it from Stripe |
Session retrieved server-side, belongs to this user, payment_status is not unpaid |
This user's Checkout really completed and was paid (or needed no payment) | Yes, as a fast path, through the same function your webhook uses |
Signed checkout.session.completed / checkout.session.async_payment_succeeded webhook |
Stripe told your server directly, whether or not the user came back | Yes, this is the reliable path |
Signed customer.subscription.* webhooks |
The subscription's current state: renewals, plan changes, cancellations, failed payments | Yes, this is what keeps Pro correct after day one |
What the success URL actually proves
When Checkout finishes, Stripe redirects the customer's browser to your success_url. That's it. It's a normal GET request to a normal page on your site. It isn't signed, it isn't sent by Stripe's servers, and it only happens if the customer's browser makes it there.
Stripe says this pretty bluntly in the fulfillment guide: you can't rely on triggering fulfillment only from your Checkout landing page, because customers aren't guaranteed to visit it. Their example is someone who pays successfully and then loses their internet connection before your landing page loads. The same guide says automatic fulfillment with webhooks is required if you sell subscriptions or accept payment methods with delayed success notification.
So the landing page is a nice-to-have fast path. The webhook is the source of truth.
Mistake 1: Granting Pro because the user landed on /success
This is the ?success=true pattern:
// Don't do this
export default async function Success() {
const user = await getCurrentUser();
await db.user.update({ where: { id: user.id }, data: { plan: "pro" } });
return <p>Welcome to Pro!</p>;
}
Anyone who's signed in can visit /success directly and get Pro for free. No Stripe involved. Your success page should never write a plan on its own. At most, it should ask Stripe what happened and then reuse your normal sync code (more on that below).
Mistake 2: Trusting the session_id without checking it
Stripe's custom success page guide shows the right way to know which Checkout Session just finished: add the literal {CHECKOUT_SESSION_ID} template variable to your success_url, and Stripe swaps in the real ID when it redirects. Then, on your server, look up the Checkout Session with that ID.
The mistake is treating the ID in the URL as proof. It's just a query string. Before you act on it:
- Retrieve the session on the server with your secret key. Never trust anything about it that came from the browser.
- Check it belongs to the signed-in user. I set
client_reference_idto my user's ID when I create the session. Stripe describes that field as a unique string you can use to reconcile the session with your internal systems. If the retrieved session'sclient_reference_idisn't the current user, do nothing. Otherwise someone could reuse another person's session ID. - Check it actually completed and was paid. That's the next mistake.
One small gotcha: {CHECKOUT_SESSION_ID} must go in exactly as written. Stripe says not to substitute it yourself. In a JavaScript template literal, {CHECKOUT_SESSION_ID} without a $ stays literal, which is what you want.
Mistake 3: Ignoring payment_status (and async payment methods)
A completed Checkout doesn't always mean the money is there. The Checkout Session object has a payment_status field with three values, per Stripe's reference:
paid: the funds are available in your account. For subscriptions with a free trial, it means the $0 trial invoice was processed.unpaid: the funds aren't available yet.no_payment_required: for example, asetupmode session that doesn't take a payment now.
Some payment methods aren't instant. Stripe's fulfillment guide calls out ACH Direct Debit and other bank transfers: the funds aren't available when Checkout completes, and you get a checkout.session.async_payment_succeeded event later when the payment succeeds (or checkout.session.async_payment_failed if it doesn't). Stripe's own sample fulfill_checkout function only fulfills when payment_status isn't unpaid.
If you only accept cards today, this still matters the day you turn on another payment method in the Dashboard. Build the check in now.
Mistake 4: Assuming the user comes back
People close tabs. Phones lose signal. Someone pays on a laptop and goes to bed before the redirect finishes. If Pro only gets granted on the success page, all of those people paid you and got nothing.
That's the core reason Stripe requires webhooks for fulfillment. The webhook goes straight from Stripe to your server and doesn't depend on the customer's browser at all. And if delivery fails, Stripe retries: in live mode, the webhooks docs say Stripe tries for up to three days with exponential back-off (sandbox events are retried three times over a few hours).
There's a nice detail here too. Per the fulfillment guide, if you have a webhook endpoint listening for checkout.session.completed and you set a success_url, Checkout waits up to 10 seconds for your server to respond to that event before redirecting the customer. So if your handler is fast, the database is often already updated by the time the user lands. Two caveats from the same docs: with the Stripe CLI locally, Checkout redirects immediately, and Stripe doesn't wait for webhook endpoints registered in an organization account. So your success page still needs a "we're confirming your payment" state.
Mistake 5: Only handling checkout.session.completed for subscriptions
checkout.session.completed happens once. A subscription lives for months. If that's the only event you handle, Pro never turns off when someone cancels, and it never reacts to a failed renewal.
Stripe's subscription webhooks guide lists the events that matter:
customer.subscription.created: sent when the subscription is created. Itsstatusmight beincompleteif the customer needs to authenticate the payment.customer.subscription.updated: sent when a subscription starts or changes, including renewals and plan changes.customer.subscription.deleted: sent when the subscription ends.invoice.paidandinvoice.payment_failed: payment results for each invoice.
The same guide's status table is the cleanest rule I've found for Free vs Pro:
trialingandactive: provision access.incomplete: the customer has to make a successful payment within 23 hours to activate the subscription. If they don't, it becomesincomplete_expired.past_due: a payment failed or wasn't attempted. What happens next depends on your Dashboard subscription settings. Whether you keep access on during this window is a business decision.canceledandunpaid: revoke access.
So I don't store "plan = pro" as a fact I set once. I store the subscription's status from Stripe and derive Pro from it. I covered that table design in Prisma Schema for SaaS Billing in Next.js.
Mistake 6: Fulfillment that isn't idempotent
Once you have two callers (the webhook and the success page), your fulfillment code will run more than once for the same purchase. Stripe's fulfillment guide says this directly: your fulfill_checkout function might be called multiple times, possibly concurrently, for the same Checkout Session, and it must handle that.
Webhooks add their own duplicates. Stripe's docs say endpoints might occasionally receive the same event more than once, and that event delivery order isn't guaranteed. Their advice: track event IDs to spot duplicates (don't use created timestamps), and use the API to retrieve the current objects instead of depending on order.
My rule: every sync function refetches the object from Stripe and writes its current state with an upsert. Running it twice writes the same row twice. Running it out of order still ends at Stripe's latest state. If you send emails or do anything else that must happen exactly once, put that behind an event-ID check. The full pattern, including a transactional event table, is in Stripe Webhooks in Next.js: Idempotency, Out-of-Order Events, and Retries.
Mistake 7: Doing slow work before you answer the webhook
Stripe's webhooks docs say your endpoint must quickly return a successful 2xx status before any complex logic that could cause a timeout. Combine that with the 10-second wait above, and a slow handler means slower redirects and more retries.
Keep the handler boring: verify the signature, refetch, upsert, return 200. Queue anything slow (welcome emails, analytics, provisioning a big resource) and do it after.
Mistake 8: Skipping signature verification
An unverified webhook endpoint is just another public URL that grants Pro. Stripe's docs warn that without verification, an attacker could send fake events to trigger actions like fulfilling orders or granting account access. Verify the raw request body with your endpoint's signing secret on every request.
If your verification works locally but fails on Vercel, it's almost always the wrong secret for that environment. I wrote up the three secrets (Stripe CLI, sandbox endpoint, live endpoint) in Stripe Webhook Secrets Across Local, Preview, and Production.
The pattern I use: one sync function, two callers
Here's the shape, trimmed down. It assumes Auth.js v5 for auth() and Prisma, but the idea works with anything.
1. Create the Checkout Session with your user's ID attached.
// app/api/checkout/route.ts (excerpt)
const checkout = await stripe.checkout.sessions.create({
mode: "subscription",
line_items: [{ price: process.env.STRIPE_PRO_PRICE_ID!, quantity: 1 }],
client_reference_id: user.id,
// Reuse the Stripe customer if this user already has one
...(user.stripeCustomerId
? { customer: user.stripeCustomerId }
: { customer_email: user.email }),
// {CHECKOUT_SESSION_ID} is literal: Stripe fills it in on redirect
success_url: `${process.env.APP_URL}/billing/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.APP_URL}/pricing`,
});
2. One idempotent sync function that only trusts Stripe.
// lib/billing.ts
import "server-only";
import Stripe from "stripe";
import { prisma } from "@/lib/db";
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
// Safe to call many times, from anywhere, for the same session.
export async function syncCheckoutSession(sessionId: string, expectedUserId?: string) {
const session = await stripe.checkout.sessions.retrieve(sessionId);
const userId = session.client_reference_id;
if (!userId) return;
if (expectedUserId && userId !== expectedUserId) return; // not this user's session
if (session.status !== "complete" || session.payment_status === "unpaid") return;
if (session.mode !== "subscription" || !session.subscription) return;
// Link the Stripe customer to our user (unique column, so this is idempotent)
await prisma.user.update({
where: { id: userId },
data: { stripeCustomerId: session.customer as string },
});
await syncSubscription(session.subscription as string);
}
// Always refetch: survives duplicates and out-of-order events.
export async function syncSubscription(subscriptionId: string) {
const sub = await stripe.subscriptions.retrieve(subscriptionId);
const user = await prisma.user.findUnique({
where: { stripeCustomerId: sub.customer as string },
});
if (!user) return;
await prisma.subscription.upsert({
where: { stripeSubscriptionId: sub.id },
create: { stripeSubscriptionId: sub.id, userId: user.id, status: sub.status },
update: { status: sub.status },
});
}
export const isProStatus = (status: string) =>
status === "active" || status === "trialing";
3. The webhook: the reliable caller.
// app/api/stripe/webhook/route.ts
import { stripe, syncCheckoutSession, syncSubscription } from "@/lib/billing";
export async function POST(req: Request) {
const body = await req.text(); // raw body for the signature check
const signature = req.headers.get("stripe-signature");
if (!signature) return new Response("Missing signature", { status: 400 });
let event;
try {
event = stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET!);
} catch {
return new Response("Invalid signature", { status: 400 });
}
switch (event.type) {
case "checkout.session.completed":
case "checkout.session.async_payment_succeeded":
await syncCheckoutSession(event.data.object.id);
break;
case "customer.subscription.created":
case "customer.subscription.updated":
case "customer.subscription.deleted":
await syncSubscription(event.data.object.id);
break;
}
return new Response("ok");
}
If the sync throws, the route returns a 500 and Stripe retries later, which is what you want. Don't wrap everything in a try/catch that returns 200 anyway.
4. The success page: the fast, optional caller.
// app/billing/success/page.tsx
import { redirect } from "next/navigation";
import { auth } from "@/auth";
import { syncCheckoutSession } from "@/lib/billing";
import { getViewer } from "@/lib/viewer";
export default async function BillingSuccess({
searchParams,
}: {
searchParams: Promise<{ session_id?: string }>;
}) {
const session = await auth();
if (!session?.user?.id) redirect("/login");
const { session_id } = await searchParams;
if (session_id) {
try {
await syncCheckoutSession(session_id, session.user.id);
} catch {
// Unknown or bogus ID: ignore it. The webhook is the source of truth.
}
}
const viewer = await getViewer(); // reads plan from the database
return viewer.isPro ? (
<p>You're on Pro. Thanks!</p>
) : (
<p>Thanks! We're confirming your payment with Stripe. Refresh in a moment.</p>
);
}
Note that searchParams is a Promise in current Next.js, per the page.js reference, so it gets awaited. And the page never writes "pro" itself. It only calls the same sync function the webhook uses, then reads the database like every other page. The actual gate lives in your server-side plan checks, which I covered in Free vs Pro Feature Gating in Next.js App Router.
How to test it
Run through these in a sandbox before you go live:
- Happy path: run
stripe listenforwarding to your webhook route, buy with test card4242 4242 4242 4242, and confirm the user flips to Pro. - Fake success: visit
/billing/successby hand, with nosession_idand with a made-up one. Nothing should change. - Someone else's session: sign in as a second user and open the first user's success URL. Nothing should change for either account.
- Closed tab: start a checkout, pay, and close the tab before the redirect loads. The webhook alone should still grant Pro.
- Webhook delayed: on a deployed sandbox endpoint, temporarily make the webhook route return a 500, pay, and land on the success page. The fast path should grant Pro. Restore the handler, click Resend on that event in the Stripe Dashboard, and confirm nothing changes (no duplicate rows, still Pro).
- Cancel: cancel the subscription (the customer portal is the easiest way) and confirm access goes away when the subscription ends.
Why choose ShipEmber
You can build all of this yourself, and I hope this post makes it easier. I built ShipEmber because I kept rebuilding exactly this code on every project, and kept relearning these mistakes the hard way.
ShipEmber is a Next.js App Router SaaS starter with auth, Stripe subscriptions from Free to Pro, and a gated dashboard already wired together. It uses Auth.js v5, Prisma with Postgres, Stripe Checkout, the customer portal, and signed, idempotent webhooks that keep the plan in sync from Stripe's data, with server-side plan checks on the dashboard. You add your keys and build your actual product.
Where it's not the right fit: if you need teams, organizations, SSO/SAML, per-seat or usage-based billing, or a merchant of record that handles sales tax for you, a bigger kit or a different payments setup will serve you better. I compared some options in Best Next.js SaaS boilerplates in 2026. And if you'd rather wire it yourself, the free starters in Free vs Paid Next.js SaaS Boilerplates are a fine place to start.
ShipEmber is a one-time payment of $49, the price on the site right now. You can use it in unlimited personal and client projects, and you can ask for a refund within 14 days if it doesn't work as described.
Prefer watching over reading? There's a short walkthrough:
Watch the ShipEmber walkthrough on YouTube
Related: Stripe Webhooks in Next.js: Idempotency, Out-of-Order Events, and Retries · Stripe Webhook Secrets Across Local, Preview, and Production · Free vs Pro Feature Gating in Next.js App Router
Doc note: landing-page vs webhook fulfillment, the subscriptions/delayed-payment webhook requirement, multiple concurrent fulfillment calls, checkout.session.async_payment_succeeded/_failed, and the up-to-10-second redirect wait (not with the Stripe CLI or organization endpoints) checked on docs.stripe.com/checkout/fulfillment; the {CHECKOUT_SESSION_ID} template variable and server-side session lookup on docs.stripe.com/payments/checkout/custom-success-page; payment_status, status, client_reference_id, and subscription on the Checkout Session object reference; subscription events and statuses (including the 23-hour incomplete window) on docs.stripe.com/billing/subscriptions/webhooks; retries, duplicate events, event ordering, quick 2xx responses, and signature verification on docs.stripe.com/webhooks; async searchParams on nextjs.org. All on November 26, 2026.
— Jake Mcdonald, Springfield, IL