Stripe says paid but the user isn't upgraded: fixing webhooks in Lovable and Supabase apps

When Stripe shows a payment but your user isn't upgraded, the webhook never reached your Supabase Edge Function, was rejected, or ran without changing the database. Open the endpoint's Event deliveries in Stripe first. Then check, in order: the URL and mode, JWT verification, the raw-body signature check, the database key and RLS, event types and user matching.

It is the support ticket every subscription app dreads: "I paid, but I'm still on the free plan." The money is in Stripe and the customer has a receipt. Your database, though, still says free. In apps built with Lovable, Bolt or an AI coding agent on Supabase, this nearly always comes down to one link in the chain. That link is the webhook: the request Stripe sends to your server when something happens, which your code turns into "this user is now on Pro".

This guide follows the order we debug it in, from Stripe's delivery logs to upgrading the customers who were missed. Figures come from Stripe, Supabase and Lovable documentation.

  • Start in Stripe Workbench: each endpoint's Event deliveries tab shows every attempt and the status code your function returned.
  • A 401 from a Supabase Edge Function usually means JWT verification is still on. Stripe cannot send a Supabase user token.
  • Signature checks fail when the body is parsed before verification or the wrong whsec_ secret is used. Test, live and CLI secrets all differ.
  • A 200 with no upgrade usually means Row Level Security silently matched zero rows because the function used the public key.
  • Stripe retries failed live deliveries for up to three days. After that, backfill from the Events API, which keeps 30 days.
Key takeaways

Why does Stripe say paid but my user isn't upgraded?

Because payment and upgrade are two separate systems. Stripe takes the money, then tells your app through a webhook. If that message is lost, rejected or mishandled, Stripe stays correct and your database stays wrong.

Stripe is clear that you should not rely on the success page alone. Its fulfilment guide says webhooks are required, because a customer can pay and then lose their connection before your landing page loads. Renewals, failed cards and cancellations happen when the customer is nowhere near your app at all.

How do I find where a Stripe webhook is failing?

Open Workbench in the Stripe Dashboard, choose your endpoint under Webhooks, then open the Event deliveries tab. Stripe's webhooks documentation says it lists each event as Delivered, Pending or Failed. Click an event to see the HTTP status code and when the next retry is due.

  1. Check the Dashboard is in the same mode as the payment: a sandbox (test) or live.
  2. Find the payment's event in Event deliveries. If there is no attempt, the endpoint or its event list is wrong.
  3. Read the status code: 401, 400, 404 or 3xx, timeout, 500, or 200.
  4. Open the Edge Function's logs in Supabase, or in Lovable's Cloud logs, for the same time.
  5. For a 200, query the user's row in the database and confirm whether it changed.
  6. Fix the cause, then resend the event and confirm the upgrade.
Diagnose a failed Stripe webhook in this order

To reproduce the problem without real customers, use the Stripe CLI. Run stripe listen --forward-to with your function's URL to forward events, and stripe trigger checkout.session.completed to fire a test event. Remember that stripe listen prints its own signing secret. It is not the one shown in the Dashboard.

Symptom in Stripe's delivery log against the likely cause
Likely causeNo attempt401400404 or 3xx200, no upgrade
Wrong URL, mode or event listYesNoNoYesNo
Edge Function JWT check onNoYesNoNoNo
Parsed body or wrong whsec_ secretNoNoYesNoNo
Public key blocked by RLSNoNoNoNoYes
Event not handled, or user not matchedPartial, if not subscribedNoNoNoYes

Sources: Stripe docs, Manage webhook endpoints; Supabase docs, Edge Function 401 error response

Stripe treats a redirect as a failure, so register the final URL. A 404 usually means the function was renamed or never deployed.

Is the endpoint pointing at the right place and mode?

Test and live modes are separate in Stripe. An endpoint added in a sandbox never receives live payments, and the same URL gets a different signing secret in each mode. AI builders often keep the test secret after launch. Check the endpoint's event list too: if invoice.paid is not ticked, Stripe never sends it. Handlers that call constructEvent also expect Snapshot payloads; Thin destinations need parseEventNotification.

Why does my Supabase Edge Function return 401 to Stripe?

Because Supabase checks for a user's JWT before your code runs, and Stripe does not have one. Supabase's function configuration guide says Edge Functions require a valid JWT by default. Stripe webhooks are its own example of when to turn that off.

Supabase's 401 troubleshooting page says a gateway 401 means the function never ran. The usual messages are "Missing authorization header" or "Invalid Token or Protected Header formatting". If your logs show nothing at all for the request, this is the likely cause.

Turn verification off for that one function only. Set it in supabase/config.toml, or deploy with the --no-verify-jwt flag:

[functions.stripe-webhook]
verify_jwt = false

This makes the function public, so the Stripe signature check below becomes your only gate. Supabase warns that the setting lets anyone call the function without a valid JWT. Never switch it off on functions that act for signed-in users.

Why does Stripe webhook signature verification fail in a Supabase Edge Function?

Almost always for one of two reasons: the code changed the body before verifying it, or it used the wrong whsec_ secret. Stripe's guide to managing webhook endpoints names the wrong secret as the most common cause.

The signature is calculated over the exact bytes Stripe sent. If the code calls req.json() first and re-serialises the result, or a framework tidies the body, the bytes change and the check fails. In Deno, the runtime behind Supabase Edge Functions, read the raw text. Then use the async verifier with Web Crypto, as Supabase's own Stripe example does:

import Stripe from "npm:stripe@^22";

const stripe = new Stripe(Deno.env.get("STRIPE_SECRET_KEY")!);
const cryptoProvider = Stripe.createSubtleCryptoProvider();

Deno.serve(async (req) => {
  const body = await req.text(); // raw body: no req.json() first
  const sig = req.headers.get("Stripe-Signature") ?? "";
  let event;
  try {
    event = await stripe.webhooks.constructEventAsync(
      body, sig, Deno.env.get("STRIPE_WEBHOOK_SECRET")!, undefined, cryptoProvider,
    );
  } catch {
    return new Response("Invalid signature", { status: 400 });
  }
  // handle event.type here, then:
  return new Response(JSON.stringify({ received: true }), { status: 200 });
});

If verification still fails, print the secret your function reads and compare it with the endpoint's revealed secret, including stray spaces. Stripe's libraries also reject signatures more than five minutes old by default. Do not set the tolerance to 0: Stripe says that turns the recency check off.

Timings that shape a Stripe webhook handler on Supabase
  • 5 minutes default tolerance between a signature's timestamp and your server's clock in Stripe's libraries
  • 10 seconds Checkout waits for your endpoint to answer checkout.session.completed before redirecting the customer
  • 150 seconds Supabase Edge Function request idle timeout before the caller gets a 504
  • 3 retries over a few hours for events in a Stripe sandbox, against three days in live mode

Sources: Stripe docs, Receive Stripe events; Stripe docs, Fulfill orders; Supabase docs, Edge Function limits

Why does the webhook return 200 but the database doesn't change?

Usually because the function writes with the public key, and Row Level Security quietly filters the update out. A blocked update is not an error. Supabase's Row Level Security guide says a row filtered by a policy's using clause "raises nothing, matches zero rows".

Stripe sends no user session, so a function using the publishable (anon) key acts as an anonymous visitor. Your policies rightly block that, the update touches nothing, and the function still returns 200.

The fix is a server-side key that only the function can read. Supabase's API keys guide says a secret key, or the legacy service_role key in older projects, bypasses Row Level Security. It must never go in a browser, a shipped app or source control. Keep it in the function's secrets. Then check the update's result: if it matched no rows, log it and return a 500 so Stripe retries.

Do not "fix" this by loosening a policy so anyone can update the plan column. That lets any signed-in user upgrade themselves from the browser console. Our Supabase and Lovable security checklist covers why plan and role columns must only be writable by the server.

Which Stripe events should a Lovable or Supabase app listen to?

For one-off payments, checkout.session.completed, plus the async success and failure events if you accept bank debits. For subscriptions, use invoice.paid to grant or extend access, and customer.subscription.updated and .deleted to change or remove it.

EventWhat it meansUse it to
checkout.session.completedThe customer submitted CheckoutFulfil one-off card payments when payment_status is not unpaid; link the Stripe customer to the user
checkout.session.async_payment_succeededA delayed payment, such as Bacs Direct Debit, clearedFulfil orders paid by bank debit
checkout.session.async_payment_failedA delayed payment failedTell the customer; do not grant access
invoice.paidA subscription invoice was paid, including renewalsGrant or extend access once the subscription is active
invoice.payment_failedA renewal or first payment failedWarn the customer; the subscription may go past_due
customer.subscription.updatedPlan, status or renewal changedSync plan and status from the subscription
customer.subscription.deletedThe subscription endedRemove paid access
Stripe events for app upgrades and when to use each

The classic AI-generated bug is handling only checkout.session.completed. The first month works, but renewals, cancellations and failed cards never reach the database. Stripe's subscription webhooks guide says to provision on invoice.paid after confirming the subscription is active. Revoke access when it becomes canceled or unpaid.

There is a UK-specific trap here. Bacs Direct Debit is a delayed payment method. Stripe's Bacs documentation says confirmation typically takes 4 business days with an existing mandate, or up to 7 with a new one. It also warns that checkout.session.completed does not mean a Bacs payment succeeded. Upgrade only after checkout.session.async_payment_succeeded, or after invoice.paid for subscriptions.

How do you match a Stripe payment to the right user?

Pass your own user ID into Stripe when you create the Checkout Session on the server. Then save the Stripe customer ID against that user on the first event, and use it for every later event.

The Checkout Session API offers client_reference_id for this: a string of up to 200 characters for reconciling the session with your own system. Set it to the Supabase user's ID. Renewal events do not carry it, though. They name the Stripe customer, so store that customer ID on the user's row when the first checkout completes.

Matching by email is fragile: people pay with a work address and sign in with a personal one. Lovable's own Stripe integration matches subscriptions to users by email, which is one reason a Lovable app can show "paid" in Stripe and "free" in the app.

How do you handle duplicate, late and out-of-order Stripe events?

Assume every event can arrive twice, late or out of order. Stripe says it does not guarantee delivery order, and that endpoints may occasionally receive the same event more than once.

Three habits cover it. Record each event ID in a table with a unique key and skip IDs you have seen. Stripe suggests pairing the object ID with the event type to catch the rarer case of two separate events. Next, do not trust the event's created time for ordering: Stripe records it in seconds, so events can share a timestamp. Finally, when status matters, retrieve the subscription from Stripe and save its current status, rather than applying events one by one.

create table public.stripe_events (
  id text primary key,          -- the evt_ ID
  type text not null,
  received_at timestamptz not null default now()
);
alter table public.stripe_events enable row level security;

With RLS on and no policies, only the function's server-side key can use this table. Insert the event ID first; if it clashes with the primary key, return 200 and stop.

How do you fix users who paid but were never upgraded?

Fix the cause first, then replay the missed events through the repaired handler rather than editing plans by hand.

How long you have to recover a missed Stripe event

Maximum days after the event was created, live mode

Recovery routeWindow
Stripe's automatic retries3 days
Resend button in the Dashboard15 days
stripe events resend in the CLI30 days
List Events API with delivery_success=false30 days

Sources: Stripe docs, Receive Stripe events; Stripe docs, Manage webhook endpoints

Within three days, Stripe's own retries often catch up. For a backlog, call the List Events API with delivery_success=false and the event types you handle, and run each event through the same idempotent code. Resending an event by hand does not cancel Stripe's automatic retries. That is fine if duplicates are skipped and answered with a 200.

Beyond 30 days, events are no longer available, so reconcile from the objects instead. List active subscriptions and paid Checkout Sessions in Stripe, match them to users by customer ID or client_reference_id, and correct any mismatches.

Should you use Lovable's Stripe integration or your own webhook?

Lovable offers two routes. Its documentation recommends built-in payments, which Lovable manages, for most projects. The other connects your own Stripe account with a key stored as a backend secret.

Lovable's Stripe integration documentation says the own-account route does not use webhooks by default. The app checks status directly with Stripe instead. If you add webhooks, you manage the endpoints and secrets yourself, so everything above applies. Note too that the preview has no separate test environment: a live key in the preview takes real payments.

Add a proper webhook once access must change without the user visiting, or when other systems depend on payment state: renewals, failed cards, refunds, disputes, team seats or usage limits. If you are moving the backend off Lovable altogether, our guide to moving an app off Lovable covers the payment hand-over. Our Lovable to production guide covers the rest of launch.

When should you get help with Stripe webhooks?

When customers are already affected, or when an AI agent says payments are fixed but the delivery log disagrees. Our piece on when a coding agent says done but isn't explains why.

Circlemount's Lovable developers review the full path: endpoint, Edge Function, signature check, database keys and policies, event handling and backfill. They test it with the Stripe CLI before anything goes live. If payments are one of several broken areas, our vibe-coded app fix service covers the whole app. To scope that work, see how much it costs to fix a vibe-coded app.

Frequently asked questions

Why does Stripe show a successful payment but my app still shows the free plan?

Because Stripe and your database are separate systems connected by a webhook. If the webhook never arrives, is rejected with a 401 or 400, or runs without updating the user, Stripe stays correct and your app stays wrong. Check the endpoint's Event deliveries tab in Stripe Workbench to see which of those happened.

How do I stop a Supabase Edge Function returning 401 to Stripe webhooks?

Turn off JWT verification for that one function, either with verify_jwt set to false in supabase/config.toml or by deploying with the no-verify-jwt flag. Stripe cannot send a Supabase user token. Because the function is then public, you must verify the Stripe signature on every request before acting on it.

Why does Stripe webhook signature verification keep failing in Deno?

The usual causes are reading the body as JSON before verifying it, or using the wrong signing secret. Read the raw body with req.text, verify with constructEventAsync and a Web Crypto provider, and check the secret matches the endpoint and mode. Test, live and Stripe CLI secrets are all different.

Which Stripe event should I use to upgrade a user's subscription?

Use invoice.paid to grant or extend access, after confirming the subscription is active, because it also fires on every renewal. Use customer.subscription.updated and customer.subscription.deleted to change or remove access. Handling only checkout.session.completed works for the first month, then misses renewals, cancellations and failed payments.

Can the webhook use the Supabase anon key to update the user's plan?

No. Stripe sends no user session, so the anon or publishable key acts as an anonymous visitor and Row Level Security blocks the update without an error. Use a server-side secret key stored in the function's secrets, never in the browser, and check that the update actually changed a row.

How do I upgrade customers who paid while my webhook was broken?

Fix the handler, then replay the missed events. Stripe retries live deliveries for up to three days. For older failures, list events with delivery_success set to false, which covers the last 30 days. Beyond that, reconcile active subscriptions and paid Checkout Sessions in Stripe against your users by customer ID.

Does Lovable's Stripe integration use webhooks?

Not by default. When you connect your own Stripe account, Lovable's documentation says the app checks payment and subscription status directly with Stripe and matches subscriptions to users by email. You can ask Lovable to add webhooks, but you then manage the endpoints and signing secrets yourself.

Sources

Checked on 20 November 2026. Product features and figures change quickly, so check the current source before you rely on a detail.

Payments not reaching your database?

Our Lovable developers trace the webhook from Stripe to Supabase, fix the handler, keys and policies, and backfill the customers who were missed. If the problems go wider than payments, see our vibe-coded app fix service. The initial app assessment is free, project work starts from £1,000 + VAT, and ongoing support plans start from £125 a month + VAT. Join the Circle to book yours.