Skip to content

Add Scale plan, pay-as-you-go top-ups and auto recharge - #137

Merged
mrmps merged 4 commits into
mainfrom
claude/payg-plans
Sep 27, 2026
Merged

mrmps merged 4 commits into
mainfrom
claude/payg-plans

Conversation

@mrmps

@mrmps mrmps commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Plans now change only rate limits and included credits, and workspaces can pay as they go.

Plans

  • Scale, $200/month: $200 of usage each month, unlimited seats, 100× rate limits (fast 300,000/min · 2,000,000/day). Pro stays $20 / 10×.
  • Rate-limit multipliers now come from the plan catalogue (rateLimitMultiplier in src/lib/billing.ts) instead of the hardcoded funded ? 10 : 1, on both the spending path and the legacy path. The unused max tier is removed.
  • Checkout is plan-aware; any active paid subscription still routes to the portal to prevent duplicates.
  • Reconciliation is generalized across plans: the invoice matcher, grant amount, plan id, downgrade and schedule branches are parameterized. The Pro behavior is byte-compatible for existing subscribers.

Pay as you go

  • Top-ups: $5–$1,000 (whole dollars) through Autumn checkout against a new one-off top_up plan ($1 = 100,000 credits). Purchased funds never expire and are credited only after the paid invoice is verified, exactly once per invoice id (app_autumn_topups). Refunds revoke once; consumed usage is not reverse-charged.
  • Auto recharge: owner-configurable enable / amount / balance threshold / calendar-month maximum (existing auto_top_up_* columns, finally wired). A claimed attempt row (app_auto_topup_attempts) is the single-flight lock, the one-hour failure cooldown, and the monthly-cap ledger, so concurrent settlements cannot double-charge or exceed the cap. The charge uses billing.attach with redirect_mode: "never" against the saved payment method; crediting always goes through invoice-verified reconciliation. Triggers: post-settlement hook in the spending path + a 5-account scheduled sweep.
  • Billing page: Top-up dialog, Exa-style auto-recharge panel (amount / threshold / monthly max, month-used meter, failure alert with a billing.setup_payment link), return-from-checkout refresh.
  • New optional Worker secrets AUTUMN_SCALE_PLAN_ID / AUTUMN_TOPUP_PLAN_ID (already set in prod); everything degrades gracefully when unset.

Verified end to end (Autumn sandbox + Stripe test mode, real dev server)

  • $10 top-up through hosted checkout with the 4242 test card → invoice-verified grant, idempotent under repeat reconciliation.
  • Auto recharge: 3 off-session charges on the saved card, each invoice-verified and attributed auto_top_up; the 4th blocked by the $30/month cap; single-flight and cooldown observed.
  • Scale subscription checkout → real $200 invoice matched, billing_plan='scale', +$200 credits, monthly reset set.
  • Dashboard, /app/plans, and both /pricing renderings (HTML + plaintext/Markdown) verified.

Production Autumn already has scale and top_up pushed (additive; Pro untouched), and migration 0016_pay_as_you_go.sql applies on deploy.

Tests: 861 pass (14 new: auto-top-up engine, top-up/Scale reconciliation, per-plan rate limits e2e), typecheck and CLI suites green.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added the Scale plan, with 100× rate limits, alongside Pro’s 10× limits.
    • Added pay-as-you-go credit top-ups from $5 to $1,000, with optional automatic recharges, balance thresholds, and monthly spending caps.
    • Added controls to manage top-ups and automatic recharge from the Credits page. Purchased credits are added after payment is verified and do not expire.
  • Documentation
    • Updated pricing and billing information to explain plan allowances, top-ups, and automatic recharge.

mrmps and others added 3 commits September 26, 2026 02:56
Plans now change only rate limits and included credits: Pro stays $20/10x
and Scale is $200/month with $200 of usage and 100x limits. Pay-as-you-go
top-ups ($5-$1,000) credit purchased funds only after invoice-verified
reconciliation, and owners can enable auto recharge with an amount, a
balance threshold and an optional calendar-month maximum enforced by a
claimed-attempt ledger.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 5310b9de-6712-4bbe-a3b4-ef6821efebe5

📥 Commits

Reviewing files that changed from the base of the PR and between 43818f8 and 0583a33.

📒 Files selected for processing (31)
  • BILLING.md
  • autumn.config.ts
  • migrations/postgres/0016_pay_as_you_go.sql
  • src/docs.ts
  • src/features/billing/billing.functions.ts
  • src/features/billing/checkout.ts
  • src/features/billing/credits.tsx
  • src/features/billing/plans.tsx
  • src/features/dashboard/app-view.tsx
  • src/http/classification.ts
  • src/http/spending-classification.ts
  • src/index.ts
  • src/lib/billing.ts
  • src/openapi.ts
  • src/pages.ts
  • src/pricingui.ts
  • src/server.ts
  • src/server/agents.ts
  • src/server/auto-top-up.ts
  • src/server/autumn.ts
  • src/server/billing-sync.ts
  • src/server/billing.ts
  • src/server/contracts.ts
  • src/server/db.ts
  • src/wellknown.ts
  • test/discovery.test.ts
  • tests/accounts.test.ts
  • tests/auto-top-up.test.ts
  • tests/autumn.test.ts
  • tests/dashboard-analytics.test.ts
  • tests/spending.e2e.test.ts
 ________________________________________________________________________
< This is like dependency injection, except the dependency is suffering. >
 ------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mrmps
mrmps merged commit feffe23 into main Sep 27, 2026
1 check passed
@mrmps
mrmps deleted the claude/payg-plans branch September 27, 2026 06:36
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