From 3ffdb445bbfd19e440bbedecec296e7297e8ff9f Mon Sep 17 00:00:00 2001 From: Narciso Date: Wed, 18 Nov 2026 16:18:48 -0400 Subject: [PATCH] fix(billing): only adopt live subscriptions from created events --- apps/dokploy/pages/api/stripe/webhook.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/dokploy/pages/api/stripe/webhook.ts b/apps/dokploy/pages/api/stripe/webhook.ts index 22a4a087d..c233ba38e 100644 --- a/apps/dokploy/pages/api/stripe/webhook.ts +++ b/apps/dokploy/pages/api/stripe/webhook.ts @@ -140,7 +140,11 @@ export default async function handler( const subscription = await stripe.subscriptions.retrieve( newSubscription.id, ); - if (hasEnded(subscription)) { + // A late event of an older subscription must not replace the current one. + if ( + subscription.status !== "active" && + subscription.status !== "trialing" + ) { break; }