From f2141f35a02559ec9f5478293de513a4bd64a40a Mon Sep 17 00:00:00 2001 From: Steven Tey Date: Sat, 21 Feb 2026 17:42:59 -0800 Subject: [PATCH] reset paymentFailedAt in charge.succeeded --- .../api/stripe/webhook/charge-succeeded.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/apps/web/app/(ee)/api/stripe/webhook/charge-succeeded.ts b/apps/web/app/(ee)/api/stripe/webhook/charge-succeeded.ts index 3b3ff1a4a24..70951547693 100644 --- a/apps/web/app/(ee)/api/stripe/webhook/charge-succeeded.ts +++ b/apps/web/app/(ee)/api/stripe/webhook/charge-succeeded.ts @@ -14,7 +14,29 @@ export async function chargeSucceeded(event: Stripe.Event) { const { transfer_group: invoiceId } = charge; if (!invoiceId) { - console.log("No transfer group found, skipping..."); + // check if the customer's workspace has paymentFailedAt, if so, reset it to null + const stripeId = charge.customer as string; + if (stripeId) { + const workspace = await prisma.project.findUnique({ + where: { + stripeId, + }, + }); + if (workspace?.paymentFailedAt) { + console.log("Workspace has paymentFailedAt, resetting it to null..."); + await prisma.project.update({ + where: { + id: workspace.id, + }, + data: { + paymentFailedAt: null, + }, + }); + } + } + console.log( + "No transfer_group (invoiceId) found, skipping invoice update flow...", + ); return; }