Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(billing): handle Stripe/DB divergence on seat quantity update failure

Richie McIlroyb3a63b86e1ad
diff --git a/apps/web/actions/organization/update-seat-quantity.ts b/apps/web/actions/organization/update-seat-quantity.ts
index 78749d94a..8d7edc151 100644
--- a/apps/web/actions/organization/update-seat-quantity.ts
+++ b/apps/web/actions/organization/update-seat-quantity.ts
@@ -139,10 +139,23 @@ export async function updateSeatQuantity(
proration_behavior: "create_prorations",
});
- await db()
- .update(users)
- .set({ inviteQuota: newQuantity })
- .where(eq(users.id, user.id));
+ try {
+ await db()
+ .update(users)
+ .set({ inviteQuota: newQuantity })
+ .where(eq(users.id, user.id));
+ } catch (dbError) {
+ console.error(
+ "CRITICAL: Stripe updated to quantity",
+ newQuantity,
+ "but DB update failed for user",
+ user.id,
+ dbError,
+ );
+ throw new Error(
+ "Billing update succeeded but local state could not be saved. Please contact support.",
+ );
+ }
revalidatePath("/dashboard/settings/organization");