From 20fc59dcda36c98dbe2aca9049cc524be3ae6307 Mon Sep 17 00:00:00 2001 From: Owen Date: Wed, 29 Apr 2026 21:25:58 -0700 Subject: [PATCH] Delete trial when upgrading --- .../billing/hooks/handleSubscriptionCreated.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/private/routers/billing/hooks/handleSubscriptionCreated.ts b/server/private/routers/billing/hooks/handleSubscriptionCreated.ts index c7a47d1b7..947f28c14 100644 --- a/server/private/routers/billing/hooks/handleSubscriptionCreated.ts +++ b/server/private/routers/billing/hooks/handleSubscriptionCreated.ts @@ -174,6 +174,19 @@ export async function handleSubscriptionCreated( // TODO: update user in Sendy } } + + // delete the trial subscrition if we have one + await db + .delete(subscriptions) + .where( + and( + eq( + subscriptions.customerId, + subscription.customer as string + ), + eq(subscriptions.trial, true) + ) + ); } else if (type === "license") { logger.debug( `License subscription created for org ${customer.orgId}, no lifecycle handling needed.`