Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(api): exclude Signed BAA from Pro seat quota and dunning

Richie McIlroy6e733cd121c0
diff --git a/apps/web/app/api/webhooks/stripe/route.ts b/apps/web/app/api/webhooks/stripe/route.ts
index 022b3ebdf..0e9ef268e 100644
--- a/apps/web/app/api/webhooks/stripe/route.ts
+++ b/apps/web/app/api/webhooks/stripe/route.ts
@@ -470,7 +470,10 @@ export const POST = async (req: Request) => {
// Stripe retries the card.
const entitledStatuses = new Set(["active", "trialing", "past_due"]);
const inviteQuota = subscriptions.data
- .filter((sub) => entitledStatuses.has(sub.status))
+ .filter(
+ (sub) =>
+ entitledStatuses.has(sub.status) && !isSignedBaaSubscription(sub),
+ )
.reduce((total, sub) => {
return (
total +
@@ -523,6 +526,12 @@ export const POST = async (req: Request) => {
return NextResponse.json({ received: true });
}
+ // Signed BAA renewals must not trigger the Cap Pro dunning email;
+ // its status is tracked via customer.subscription.updated instead.
+ if (invoice.subscription_details?.metadata?.type === "signed_baa") {
+ return NextResponse.json({ received: true });
+ }
+
const finalAttempt = invoice.next_payment_attempt === null;
// Email on the first failure and the final attempt only; the
// retries in between would just be noise.