BLOG
BlogGuides

Paid, but still on the free plan: test the Stripe webhook

Stripe takes the money, the app never hears about it. A test that pays in test mode and checks the plan changed catches it.

The money arrives, the upgrade does not#

A customer pays. Stripe shows an active subscription. Your app still says "Free plan". The customer emails you, annoyed, and you refund them while you work out why.

People write about this bug again and again, and the titles say it all: Stripe shows an active subscription, but my app didn't unlock; why your Stripe webhooks are silently failing; a no-code builder who spent hundreds on freelancers and still could not get the plan into the database.

The reason is how Stripe works. The checkout page takes the payment, then Stripe tells your app what happened by calling a webhook: an address on your server. Your app turns that call into "this user is now on Pro". If the webhook is not set up for the deployed app, the payment succeeds and nothing in your app changes.

Why it works on your laptop#

While you build, the Stripe CLI forwards events to your local server (stripe listen --forward-to localhost:3000/...). Everything works. Then the app is deployed and one of these is missing:

  • the webhook endpoint in the Stripe dashboard, pointing at the deployed address;
  • the webhook signing secret in the deployed app's environment, so every call is rejected;
  • one of the events the code waits for. Stripe sends several for one subscription (Stripe's list), and handling only payment_intent.succeeded can miss the one that carries the plan.

A coding agent that writes the handler cannot see your Stripe dashboard or your host's environment variables, so it cannot tell you which one is missing. A test that pays and looks at the result can.

The test#

Run it on a deployed copy of the app that uses Stripe's test mode keys and has its own test-mode webhook: a staging site or a preview. Never on live keys: test cards only work in test mode.

Sign in as the account "new-customer".
Go to Billing and choose the Pro plan.
On the Stripe page pay with card 4242 4242 4242 4242,
expiry 12/34, CVC 123, and the name "Test Customer".
Back in the app, wait for the page to settle, then reload it.
Check the plan shown on the Billing page is "Pro".
Check a Pro-only feature, the Export button, is now available.

The reload matters. Some apps show "Pro" from the redirect's address for a moment, before the webhook has landed. After a reload, the screen shows what your database says.

Use a stored sign-in account on the free plan. After the run, put it back on the free plan (or use a new account each time with the run's mailbox), so the next run starts from the same place.

What the result tells you#

If the plan check fails, the result shows what it expected and what it saw ("Free"), the step it was judged at and a replay. Then look at the webhook's delivery log in Stripe's dashboard for the same minute: a failed delivery points at the address or the secret, no delivery at all points at a missing endpoint.

We have not run this flow on a live app of our own for this post. The card numbers and the test-mode rules come from Stripe's documentation; the full flow, with declined cards and 3D Secure, is in Test Stripe checkout and plan upgrades.

Run it after every deploy#

Billing breaks quietly when something else changes: a new environment, a renamed variable, a redeploy to another host. Run this test after every deploy to staging, and it fails before a customer pays.

This post is part of Testing an app you built with AI.

Filed underWebAI-built appsReleases and regressions