Skip to content

feat(billing): scaffold dual Stripe account support (EE default) - #3219

Draft
riderx wants to merge 1 commit into
mainfrom
cursor/dual-stripe-account-scaffolding-7cf6
Draft

feat(billing): scaffold dual Stripe account support (EE default)#3219
riderx wants to merge 1 commit into
mainfrom
cursor/dual-stripe-account-scaffolding-7cf6

Conversation

@riderx

@riderx riderx commented Aug 27, 2026

Copy link
Copy Markdown
Member

Summary (AI generated)

  • Add billing_account (ee | us) on stripe_info, default/backfill ee for all existing rows.
  • Add nullable US catalog columns on plans (stripe_id_us, price_m_id_us, price_y_id_us, credit_id_us) — left empty.
  • Introduce stripe_billing_account.ts with getStripe(c, account), resolveBillingAccount, and getNewCustomersBillingAccount (defaults to EE; US only when US secrets exist).
  • EE keeps STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET; optional STRIPE_SECRET_KEY_US + STRIPE_WEBHOOK_SECRET_US (US client fails closed if missing).
  • Add /triggers/stripe_event_us webhook route; stamp billing_account on processed_stripe_events (composite PK).
  • New org Stripe provisioning stores billing_account from STRIPE_NEW_CUSTOMERS_ACCOUNT (safe default EE).
  • Unit tests for account resolution and EE-only operation without US secrets.

Motivation (AI generated)

Capgo will eventually bill new customers on a US Stripe account while existing customers remain on the Estonian account. This PR adds the data model, env wiring, and client routing scaffolding without routing live traffic to US.

Business Impact (AI generated)

Enables a future US billing cutover without migrating existing cus_ / sub_ IDs. No customer-facing billing change in this PR: all orgs stay on EE until US secrets and operational flag flip (out of scope here).

Test Plan (AI generated)

  • tests/stripe-billing-account.unit.test.ts — EE default, US fail-closed, US client when billing_account=us + US key
  • tests/stripe-redirects.unit.test.ts — checkout/portal/customer updates with EE-only secrets
  • tests/stripe-subscription-events.unit.test.ts, tests/stripe-revenue-movement.unit.test.ts, tests/plans-billing-history.unit.test.ts
  • bun run typecheck:backend (pre-commit)
  • CI backend/integration Stripe tests

Generated with AI

Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

Add billing_account on stripe_info, nullable US plan catalog columns,
account-scoped Stripe client resolution, US webhook route, and tests.
Existing orgs and new customers stay on EE until US secrets and flag are set.
@riderx
riderx deployed to deepsec-pr August 27, 2026 00:10 — with GitHub Actions Active
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

@codspeed-hq

codspeed-hq Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing cursor/dual-stripe-account-scaffolding-7cf6 (4320fdc) with main (c703c09)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants