Skip to content

Sync workspace Stripe seat billing - #6808

Merged
ComputelessComputer merged 1 commit into
mainfrom
fix/anlg-215-workspace-billing-bridge
Aug 16, 2026
Merged

Sync workspace Stripe seat billing#6808
ComputelessComputer merged 1 commit into
mainfrom
fix/anlg-215-workspace-billing-bridge

Conversation

@ComputelessComputer

@ComputelessComputer ComputelessComputer commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • recognize workspace-owned Stripe customers without changing personal billing behavior
  • reconcile Team subscription quantities through a service-role-only workspace billing RPC
  • keep Team price IDs optional until pricing and checkout are intentionally configured
  • report workspaces as billed only for active or trialing subscriptions

Validation

  • bunx tsc --noEmit in apps/stripe
  • bun test --pass-with-no-tests in apps/stripe (41 passed)
  • supabase db reset on OrbStack
  • supabase test db (39 files, 1080 tests)
  • pnpm exec dprint fmt
  • pnpm fmt:check

Note

High Risk
Changes payment reconciliation, workspace seat limits, and SECURITY DEFINER RPCs that can alter billing state; incorrect webhook handling could mis-cap seats or misreport billing.

Overview
Extends the Stripe billing bridge so workspace-owned customers (via workspaceId metadata) reconcile Team plan seat limits from subscription webhooks, while user-owned customers keep the existing profile assignment and metadata repair path.

syncBillingBridge is refactored behind injectable dependencies and handles customer.subscription.deleted. Workspace events call a new sync_workspace_stripe_billing RPC (service role only) with seat updates derived from configured Team price IDs (STRIPE_TEAM_*, optional until checkout exists). The bridge throws on customer assignment conflicts and no-ops when the workspace row is missing.

Customer metadata parsing adds getCustomerOwner / workspace aliases with strict agreement rules (user vs workspace ambiguity returns null). is_billed for seat usage now requires an active or trialing Stripe subscription, not merely a bound customer ID.

Reviewed by Cursor Bugbot for commit 2cda0d6. Bugbot is set up for automated code reviews on this repo. Configure here.

@netlify

netlify Bot commented Aug 16, 2026

Copy link
Copy Markdown

Deploy Preview for anarlog canceled.

Name Link
🔨 Latest commit 2cda0d6
🔍 Latest deploy log https://app.netlify.com/projects/anarlog/deploys/6a81724355210500087e6dda

Comment thread apps/stripe/src/billing-bridge.ts
@ComputelessComputer
ComputelessComputer force-pushed the fix/anlg-215-workspace-billing-bridge branch from 2d57c66 to 1c4ec0b Compare August 16, 2026 08:11

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1c4ec0b. Configure here.

Comment thread apps/stripe/src/workspace-billing.ts
@ComputelessComputer
ComputelessComputer force-pushed the fix/anlg-215-workspace-billing-bridge branch from 1c4ec0b to 2cda0d6 Compare August 16, 2026 08:18
@ComputelessComputer
ComputelessComputer merged commit 34f85c5 into main Aug 16, 2026
10 checks passed
@ComputelessComputer
ComputelessComputer deleted the fix/anlg-215-workspace-billing-bridge branch August 19, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant