Skip to content

fix(billing): refuse Stripe checkout for AWS Marketplace-billed customers - #9748

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/marketplace-billing-gate
Nov 6, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/marketplace-billing-gate

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • AWS Marketplace customers are billed by AWS, and a listed product must be billed entirely through AWS Marketplace. But nothing on the server stopped a Marketplace-billed org or account from reaching Stripe checkout, and such a customer looks Free to Stripe. The only gate was a client hook that, when its license lookup failed, reported "not Marketplace-billed" and showed the plans. Found in review of the v0.9.45 release (v0.9.45: AWS Marketplace contracts, multiple accounts per integration, Thinking Machines provider, Gauge Chat, Jama and Flow search, request ids in log metadata #9744).
  • Server: checkout refuses a reference with a pending or active Marketplace license.
    • Orgs are checked in authorizeSubscriptionReference.
    • Personal accounts are checked in assertPersonalCheckoutAllowed, because the Stripe plugin skips authorizeReference for personal checkouts.
    • Only upgrade-subscription is affected: billing portal, cancel and list still work, and staff Enterprise provisioning uses a separate path.
    • It does nothing when AWS_MARKETPLACE_PRODUCT_CODE is unset, so self-hosted and non-prod are unchanged.
  • Client: an unresolved lookup now keeps plans hidden, as Marketplace billing does. If it fails, the upgrade page says it couldn't confirm how the workspace is billed and offers "Try again", so a Stripe customer can't get stuck there.

Type of Change

  • Bug fix

Testing

  • checkout-guard.integration.ts (real Postgres), 9 pass:
    • refuses an org with a pending or active license, and an account-registered license;
    • allows an inactive license, no license, and an unset product code (org and account);
    • other billing actions still pass.
  • hooks/queries/aws-marketplace.test.tsx, 2 pass: a rejected lookup leaves billing unresolved, and [] resolves it as not Marketplace-billed. The existing authorization.test.ts still passes.
  • Red-proofed each guard separately: the org check, the personal check, the product-code switch, the inactive filter, the upgrade-only scope, and the hook's resolved state. Each fails only its own tests.
  • tsc --noEmit -p apps/sim, bun run lint, plus source-conventions, api-validation:strict, boundaries, react-query, client-boundary, comment-hygiene, test-patterns, explicit-any and utils.

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)

@vercel

vercel Bot commented Nov 6, 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 6, 2026 8:00pm UTC

Request Review

@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.

All reported issues were addressed across 8 files

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Blocks Stripe checkout for accounts and organizations with pending or active AWS Marketplace licenses.

  • Marketplace-billed accounts and organizations cannot start Stripe checkout.
  • Billing screens keep plan choices hidden until Marketplace billing is confirmed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Request[Stripe checkout request] --> Scope{Billing reference}
  Scope --> Personal[Personal checkout guard]
  Scope --> Organization[Organization checkout guard]
  Personal --> Config{AWS product configured?}
  Organization --> Config
  Config -->|No| Existing[Continue existing billing checks]
  Config -->|Yes| License{Pending or active license?}
  License -->|Yes| Refuse[Refuse checkout]
  License -->|No| Existing
Loading

Reviews (2) · Last reviewed commit: "fix(billing): keep the Marketplace looku..." · Reviewed by Greptile

…mers

AWS bills a Marketplace customer, and AWS's SaaS guidelines require a listed
product to be billed entirely through its Marketplace dimensions. A
Marketplace-billed organization or account looks Free to Stripe, so a
Stripe checkout would start a second, real subscription. Until now only a
client gate stood in the way, and it failed open: a failed license lookup
reported "not Marketplace-billed" and showed Stripe plans, with no retry
short of a reload.

Server: authorizeSubscriptionReference (organization references) and
assertPersonalCheckoutAllowed (personal references) now refuse an upgrade
with 409 when the reference holds a Marketplace license that is not
inactive, only where AWS_MARKETPLACE_PRODUCT_CODE is set. The personal
check lives in assertPersonalCheckoutAllowed because the Better Auth Stripe
plugin never calls authorizeReference for a personal reference, so a check
there would never run for one. Other actions, and staff Enterprise
provisioning, are unaffected.

Client: useAwsMarketplaceBilling exposes isResolved, isError, isRetrying
and retry, and an unknown billing state now gates plan changes. The billing
page hides "Explore plans" until the lookup resolves; the upgrade page
shows "Workspace plans unavailable" with a "Try again" chip when the lookup
fails.
@waleedlatif1
waleedlatif1 force-pushed the fix/marketplace-billing-gate branch from 49fd889 to 7e8f519 Compare November 6, 2026 20:00
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@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.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 1bf1b85 into staging Nov 6, 2026
79 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/marketplace-billing-gate branch November 6, 2026 20:08

This branch was previously deployed

1 inactive deployment
Preview — 7e8f519b Deployed Nov 6, 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