Skip to content

fix(billing): tighten self-serve checkout and Enterprise reconciliation - #10470

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/billing-checkout-hardening
Nov 28, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/billing-checkout-hardening

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Self-serve checkout (/subscription/upgrade) refuses Enterprise in any casing with a 400 (fix(billing): refuse self-serve Enterprise checkout with a client error #10469 covered the exact name), before taking the checkout admission claim. Enterprise is issued by the team with its own Stripe price and terms, and naming it in checkout used to end in a 500 from the Enterprise metadata constraint
  • The Stripe plugin is no longer offered the Enterprise plan. Sim's own lookups and Enterprise webhooks don't resolve it through the plugin's list
  • Checkout refuses caller-supplied subscription metadata (Sim's client never sends any; billing reads plan terms from Stripe subscription metadata) and seat counts that aren't whole numbers from 1 to 1000
  • Enterprise reconciliation skips subscriptions created by self-serve checkout, which always carry the plugin's row id
  • An organization checkout checks owner/admin membership before any billing-state check, so refusals don't describe another organization's billing
  • Plan checks in checkout match the plugin's case-insensitive, trimmed lookup
  • /api/billing/update-cost answers a failed internal auth with a constant Unauthorized
  • A free payer's hosted-key refusal logs at info in the provider and workflow executor, keeping error for real key-resolution faults

Type of Change

  • Bug fix

Testing

  • enterprise-missing-organization.integration.ts (real Postgres, real Better Auth Stripe webhook): a self-serve checkout subscription whose metadata claims Enterprise terms stays on its checked-out plan. Fails without the reconciliation guard
  • authorization.test.ts: Enterprise refused in three casings, metadata refused, five bad seat values refused, Pro/Team admitted, non-member refused without any billing-state reads. Each fails with its guard reverted
  • update-cost/route.test.ts, enterprise.test.ts, providers/index.test.ts, execute-workflow.test.ts
  • biome, check:api-validation:strict, check:test-patterns, check:comment-hygiene, check:explicit-any, check:source-conventions

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

- checkout refuses Enterprise in any casing, caller-supplied subscription metadata, and seat
  counts outside 1..1000; the Stripe plugin is no longer offered the Enterprise plan
- Enterprise reconciliation skips subscriptions created by self-serve checkout
- an organization checkout checks membership before any billing state
- the usage callback answers a failed internal auth with a constant message
@vercel

vercel Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 28, 2026 11:11am UTC

Request Review

A refused hosted key is the payer's plan, not a fault, and logging it at error hid real key
resolution failures among retry loops of expected refusals.
@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues were found.RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no actionable issues were found.

Summary

Tightens self-serve checkout and separates it from Enterprise billing.

  • Self-serve checkout rejects Enterprise and restricted request details.
  • Organization checkout checks membership before billing details.
  • Enterprise webhooks preserve the plan on self-serve subscriptions.
  • Failed internal billing auth always returns the same message.
  • Free-payer hosted-key refusals are logged as expected outcomes.

No new actionable issues were found in the changes since the previous review. No previous finding threads were supplied. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "fix(billing): log a free payer's hosted-..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review completed against the latest diff

This PR changes payment, billing, or quota logic. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit d5a727d into staging Nov 28, 2026
83 of 84 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/billing-checkout-hardening branch November 28, 2026 11:26

This branch was previously deployed

1 inactive deployment
Preview — 15c33ee6 Deployed Nov 28, 2026 by vercel[bot]
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