Your handler logs "subscription not found" on invoice.paid, then customer.subscription.created shows up a moment later. That is normal. Stripe does not promise that webhook events arrive in the order they were generated.
Stripe: "Stripe doesn't guarantee the delivery of events in the order that they're generated." Creating a subscription might generate customer.subscription.created, invoice.created, invoice.paid and charge.created (if there's a charge). "Make sure that your event destination isn't dependent on receiving events in a specific order" (Stripe docs: Receive Stripe events; the same wording is on Stripe docs: How events work).
Don't use the event's created timestamp to sort them, either. "Snapshot events record created in seconds, so distinct events can share a timestamp. Don't use created to determine event order or whether you've already processed an event. Track event IDs to identify duplicate deliveries instead" (source; see duplicate events).
Stripe's own advice: "You can also use the API to retrieve any missing objects. For example, you can retrieve the invoice, charge, and subscription objects with the information from invoice.paid if you receive this event first" (source). So treat invoice.paid as enough information to look the subscription up. Don't wait for customer.subscription.created to create the local row, and don't return 500 hoping a retry arrives after that other event.
Retrieve the invoice (Stripe API: Retrieve an invoice). On the current Invoice object, parent is "The parent that generated this invoice" (Stripe API: The Invoice object). Since API version 2025-03-31.basil, Stripe says to "Use invoice.parent.subscription_details.subscription (verify invoice.parent.type is subscription_details) instead of invoice.subscription" (Stripe changelog: 2025-03-31.basil parent field). Then retrieve that subscription (Stripe API: Retrieve a subscription) and upsert it in your database.
Stripe's subscription-invoice guide matches that split: for API version 2025-03-31.basil or later, expand parent.subscription_details.subscription; for earlier versions, expand subscription (Stripe docs: Subscription invoices). Event payloads use the API version configured on the endpoint when the event was created, so generated code that still reads invoice.subscription is not wrong on older versions — it is wrong if your endpoint has moved to basil or later.
invoice.paid, retrieve the invoice and resolve the subscription ID from parent.subscription_details.subscription (current) or subscription (older API versions).customer.subscription.created."invoice.paid can arrive again (duplicate events).// Inside your verified Stripe webhook handler (after constructEvent succeeds)
if (event.type === 'invoice.paid') {
const invoice = await stripe.invoices.retrieve(event.data.object.id);
// Current Invoice object: parent is "the parent that generated this invoice".
// 2025-03-31.basil+: parent.subscription_details.subscription
// Older API versions: invoice.subscription
const raw =
invoice.parent && invoice.parent.type === 'subscription_details'
? invoice.parent.subscription_details.subscription
: invoice.subscription;
const subscriptionId = typeof raw === 'string' ? raw : raw && raw.id;
if (subscriptionId) {
const subscription = await stripe.subscriptions.retrieve(subscriptionId);
await upsertSubscription(subscription); // create or update; do not require .created first
}
}
return new Response('ok', { status: 200 });
Rename upsertSubscription to match your app. If you already expand the subscription on retrieve, you can skip the second call. Returning 5xx to "wait" for customer.subscription.created only delays things: Stripe retries for up to three days in live mode, and the other event may have been processed in the meantime — or it may not have been.
Fix this Stripe webhook so it does not depend on event order. Stripe does not guarantee delivery order: invoice.paid can arrive before customer.subscription.created. 1) After signature verification, on invoice.paid retrieve the invoice from the Stripe API. 2) Resolve the subscription ID from invoice.parent.subscription_details.subscription when invoice.parent.type is subscription_details (API 2025-03-31.basil+). If that path is missing, fall back to invoice.subscription for older API versions. 3) Retrieve the Subscription and upsert it in the database (insert if missing, update if present). Do not require customer.subscription.created to have run first. 4) Grant access from the retrieved subscription's current status. 5) Make the handler idempotent on event.id and on the subscription id. 6) Do not return 500 just because the local subscription row is missing. 7) Do not change the webhook signature check.
customer.subscription.created, invoice.created and invoice.paid, and log each event type as it arrives. Create a sandbox subscription and confirm they can show up in any order.customer.subscription.created (comment out that case) and resend a recent invoice.paid. The subscription row should still be created or updated from the retrieve + upsert path.invoice.paid must not create a second row or double-grant access.Paste your webhook URL. WebhookProof sends 3 harmless test requests and tells you whether Stripe can reach it and whether it rejects unsigned events. If it finds a problem, the $9 fix pack gives you the exact copy-paste fix for your stack (refundable for 14 days).
Run the free checkYes. Stripe does not guarantee delivery in the order events were generated. Creating a subscription can produce customer.subscription.created, invoice.created, invoice.paid and charge.created, and those may arrive in any sequence.
Retrieve the invoice, read the subscription ID from parent.subscription_details.subscription (or invoice.subscription on older API versions), retrieve that Subscription, and upsert it. Do not wait for the created event, and do not use the event created timestamp to sort them.
On API version 2025-03-31.basil and later, Stripe moved that field to invoice.parent.subscription_details.subscription and set parent.type to subscription_details. Older endpoint API versions still have invoice.subscription. Check the API version on the webhook endpoint.
Stripe webhook not working? Check these 7 things in order · A customer paid but didn't get access. What went wrong? · No signatures found matching the expected signature for payload · Stripe webhook failing with a 307 or 308 redirect
Last reviewed 2026-11-08. WebhookProof is an independent tool, not affiliated with Stripe, Inc.. Quotes are from the linked documentation.