Stripe payment succeeded but the user is still on the Free plan

Updated · by Zane

Why a successful payment does not upgrade anyone

Paying and upgrading are two different steps. The payment happens on Stripe. Your app only learns about it when Stripe sends a webhook, which is a request from Stripe to a URL you gave it. For Checkout, the event is checkout.session.completed.

The success page and the "Payment successful" toast prove nothing. Anyone can open a success URL.

The chain has five links: Checkout, webhook delivery, signature check, database write, and your app reading the new plan. When money was taken and nobody was upgraded, one of the middle three is broken. I recorded this exact failure and its fix in a video on the home page.

Where the chain breaks. Stripe takes the payment, but the webhook either fails the signature check (response 400, case 2) or reaches the database with the public key and changes 0 rows (case 3), so the account stays on Free. The two log lines are the ones from the demo project described below.

Step 1: look at the evidence in Stripe

  1. Open the Stripe Dashboard, then Developers, then Webhooks. Some accounts show this under Workbench.
  2. Check that the test/live switch matches the payment.
  3. Click your endpoint, find the event, and read the response code.
Stripe test-mode dashboard, Event deliveries tab, showing a failed customer.created delivery with HTTP status code 400, the Response box and the Resend button
A demo endpoint in Stripe's test mode that always answers with HTTP 400, so the delivery fails. This is an illustration, not a real customer's case. (1) The delivery status: Failed, with a 400 ERR badge in the list. This is step 1's "read the response code". (2) The Response box, where your endpoint's status code and any error text appear; in cases 2 and 3 the reason is in your function's own log. (3) The Resend button, which you use only after fixing the cause. Account details are hidden.

What you see sends you to one of three cases. For cases 2 and 3 you also need your function's own log. In Supabase that is Edge Functions, then your function, then Logs.

Case 1: no endpoint, or no delivery at all

Stripe never reached your app. The usual reasons:

  • There is no webhook endpoint.
  • The endpoint points at a preview or local address.
  • The endpoint was set up in test mode only. Test and live mode have separate endpoints and separate signing secrets.

Create the endpoint in the mode where the payment happened. Use the URL of your deployed function and subscribe it to checkout.session.completed. Then copy its signing secret into your app. A new endpoint has a new secret, so case 2 is the next thing to check.

Case 2: response 400 and a signature error

Your function rejected the request. In my demo project the log shows this line. The part after the colon is Stripe's own error text, so yours will read the same:

Function log
[webhook] signature verification failed: No signatures found matching the expected signature for payload

Stripe signs every webhook with a secret that belongs to that one endpoint. It starts with whsec_. Your function checks the signature with STRIPE_WEBHOOK_SECRET. If the two values differ, the check fails. The common causes:

  • The secret came from stripe listen, the local testing tool.
  • Test and live values are mixed up.
  • The endpoint was recreated and the environment variable was never updated.

There is one more cause. If the code turns the body into JSON before checking the signature, the check fails even with the right secret. The signature covers the exact raw text, so verify with await req.text() and parse afterwards.

The fix: in Supabase, open Edge Functions, then Secrets, and set the value to the endpoint's signing secret. Redeploy the function. Then open the failed event in Stripe and click Resend.

Case 3: response 200 or 500, but the user is still Free

The function ran and the database did not change. I reproduced this on purpose in a demo project. The function created its Supabase client with the public anon key. Row Level Security (RLS) then blocked the update to the plan column, and it did so without an error. The update simply changed 0 rows. The log line looks like this:

Function log
[webhook] profiles update affected 0 rows for user <id> (blocked by RLS or missing row)

That line exists because the function counts the rows it changed. Without that check it returns 200 and looks healthy.

The mistake
// Wrong: the anon key is public, so RLS applies to it
const supabase = createClient(
  Deno.env.get("SUPABASE_URL")!,
  Deno.env.get("SUPABASE_ANON_KEY")!,
);

The fix is to create the client with the service role key inside the function. Newer Supabase projects call the two keys the publishable key and the secret key. The rule is the same: the secret one stays on the server. Keep that key in the function's server environment variables. It must never appear in frontend code. Do not switch RLS off, and do not loosen the policy, just to make this pass.

Also check the row count after the update. If it is 0, return a non-2xx response. Stripe then retries, and the failure stays visible.

Another reason for 0 rows is a missing client_reference_id. When you create the Checkout Session, pass the logged-in user's id as client_reference_id. Otherwise the webhook cannot tell whom to upgrade.

Here is the whole handler, trimmed from the demo project. Your table and column names will differ.

Webhook handler (Stripe client setup omitted)
Deno.serve(async (req) => {
  const body = await req.text(); // raw text, not req.json()
  let event: Stripe.Event;
  try {
    event = await stripe.webhooks.constructEventAsync(
      body,
      req.headers.get("Stripe-Signature")!,
      Deno.env.get("STRIPE_WEBHOOK_SECRET")!,
      undefined,
      cryptoProvider,
    );
  } catch {
    return new Response("bad signature", { status: 400 });
  }

  if (event.type === "checkout.session.completed") {
    const session = event.data.object as Stripe.Checkout.Session;
    const userId = session.client_reference_id;
    if (!userId) return new Response("missing user", { status: 400 });

    // Service role key: server environment only, never frontend code
    const supabase = createClient(
      Deno.env.get("SUPABASE_URL")!,
      Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!,
    );
    const { data, error } = await supabase
      .from("profiles")
      .update({ plan: "pro", stripe_customer_id: session.customer as string })
      .eq("id", userId)
      .select("id");
    if (error || !data?.length) return new Response("not updated", { status: 500 });
  }
  return new Response(JSON.stringify({ received: true }));
});

Test the fix

  1. Switch Stripe to test mode. Never test with a real card.
  2. Pay with the test card 4242 4242 4242 4242, any future expiry date and any CVC.
  3. In the webhook log, confirm the event shows a 200 response.
  4. In the database, confirm the user's plan changed.
  5. Refresh the app and confirm the screen changed.

Customers who already paid

After the fix, open the event that failed in Stripe's event list and click Resend. Stripe retries failed deliveries for up to three days in live mode, so recent payments may repair themselves once the function works. Anything older needs a manual resend. Stripe only keeps events available to resend for a limited time, so do this soon. After that you have to edit the database row by hand.

Two related problems

Cancellations and renewals

If you only handle the first payment, cancellations and renewals never reach your database. A cancelled customer keeps the paid plan. Handle customer.subscription.updated and customer.subscription.deleted as well.

Duplicate events

Stripe can deliver the same event more than once. Your handler should be safe to run twice. Store each event id and skip ids you have already processed.

FAQ

Can I just upgrade the user from the success page instead?

No. Anyone can open your success URL, so it proves nothing about payment. Use it to show a message, but let only the webhook change the plan.

Is it safe to turn off RLS to make it work?

No. Anyone with your public key could then read and edit every user's data. Write with the service role key on the server and leave the policies alone.

Do I need to refund the customers who paid and got nothing?

Not necessarily. Fix the cause first, then resend the failed events from Stripe. The upgrade is applied and the customer gets what they paid for.

Checklist

Still stuck?

Send me the app link and what's broken. The first look is free and you get a fixed quote before I touch anything.

Related guides