Skip to content

feat(agent): API credit top-ups; remove the Starter plan - #1252

Merged
AnthonyRonning merged 3 commits into
masterfrom
claude/gracious-shannon-85e5jy
Oct 25, 2026
Merged

AnthonyRonning merged 3 commits into
masterfrom
claude/gracious-shannon-85e5jy

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

API credit top-ups (Settings → API keys → API credits), modeled on Research's ApiCreditsSection:

  • Shows the prepaid balance (GET /v1/maple/api-credits/balance) with a Refresh button.
  • Offers $20 / $50 / $100 / $500 packages, or a custom whole-dollar amount from $10 to $1,000 (1,000 credits per $1).
  • Pay with card calls POST /v1/maple/api-credits/purchase (Stripe). Pay with Bitcoin calls POST /v1/maple/api-credits/purchase-zaprite, which sends no cancel_url, the same as Research. The checkout URL opens in the system browser through the existing https-only open_in_browser.
  • Guest accounts see Pay with card disabled, with a tooltip, the same as Research. The backend also refuses a Stripe purchase for a guest.
  • Checkout feedback appears directly under the pay buttons. If the balance can't load, the host logs the billing error and the section shows a short message under the last known balance.
  • The section is gated the same way as API keys: Pro, Max, or Team.

Callback / return URL (no deep links): the success URL is {WEB_URL}/?credits_success=true and the Stripe cancel URL is {WEB_URL}/. These are new profile constants CREDITS_SUCCESS_URL and CREDITS_CANCEL_URL. Research's desktop (Tauri) build already uses exactly these, with app.maple.ai or app-dev.maple.ai by billing environment. Only Research mobile uses universal links. The billing service credits the account from the Stripe/Zaprite webhook, so the redirect only affects what the browser shows: the web app's home route sends a signed-in user to /settings/api with the success banner. The desktop app just re-reads the balance when you press Refresh; it doesn't poll.

Plans: the app no longer models Starter. PlanTier is Free, Pro, Max or Team. The Billing plan list keeps only Pro, Max and Team products (PlanTier::is_for_sale). Free and any product name the app doesn't recognize are never listed.

Plumbing: maple-billing gets PaymentMethod, CreditPurchaseRequest, credit_checkout_url, and the purchase limits. There are two new host operations, api_credit_balance and purchase_api_credits. Both are local-only: they are added to the wire test that asserts they are not remote commands.

Validation

  • CI passed on Linux, macOS, and Windows for the first commit. That includes the new unit tests: return URLs, amount parsing and limits, plan filtering, selection, and request serialization.
  • just ci passes locally on macOS with the follow-up commit: fmt, all four clippy passes, and the workspace and headless tests.
  • The pre-commit hook passed for the Starter removal commit: fmt, workspace clippy and the workspace tests.
  • Local run of the Agent against a maple-dev-env stack: local OpenSecret, plus billing with fixtures and the Zaprite mock, and no Stripe key.
    • Free: API keys shows "Unlock API access" and no credits section.
    • Pro with a Zaprite subscription:
      • The balance shows. Custom "5" says "The minimum is $10" and disables both buttons; "$25" shows "25,000 credits for $25".
      • Pay with Bitcoin creates the 25,000-credit order. After the mock payment completes, Refresh shows 25,000 credits.
      • The mock's http:// checkout link is refused by the https-only opener, as intended. The notice shows under the buttons.
      • Pay with card gets as far as billing's Stripe call, which fails locally without a key.
    • With billing stopped, Refresh keeps the last balance and shows "Could not load the latest balance. Refresh to try again." The billing error goes to the log.
  • A Pro account on a subscription pass can't buy credits. Billing refuses the purchase with "Active subscription required to purchase API credits". That gap is on the billing side, tracked in MaplePrivacyLabs/maple-billing-server#132.
  • Not checked: real Stripe and Zaprite checkouts, and the browser return to the web app. The guest layout was checked only with a temporary local override; the Agent has no guest sign-in.

Generated by Claude Code


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

claude and others added 3 commits October 24, 2026 07:25
Settings > API keys now shows the prepaid credit balance and lets Pro,
Max, and Team accounts buy credits with a card (Stripe) or Bitcoin
(Zaprite), matching Research's API credits settings: $20/$50/$100/$500
packages or a custom $10-$1,000 amount. Checkout opens in the system
browser and returns to the hosted web app, as Research's desktop build
does; the billing service credits the account from the provider webhook,
so no desktop callback or deep link is needed. Guests pay with Bitcoin.

The Billing plan list now only offers Pro, Max, and Team, so the
deprecated Starter product is never listed even when the products API
returns it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016CZNsmxzRaVTcRMiJ5m6hq
Checkout feedback in Settings > API keys > API credits now appears
directly under the pay buttons. Before, it sat below the purchase card,
where it could fall past the bottom of the window.

When the balance cannot load, the host logs the billing error and the
section shows a short message under the last known balance, instead of
the raw error text in place of the number. A failed Refresh now shows
this message too.

Guests now see Pay with card disabled with a tooltip, as on the web,
instead of no card button at all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Starter is no longer sold and no account is on it, so PlanTier no
longer has a Starter variant. The Billing plan list still shows only
Pro, Max and Team. Any other product name reads as Free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AnthonyRonning AnthonyRonning changed the title feat(agent): API credit top-ups; never list the Starter plan feat(agent): API credit top-ups; remove the Starter plan Oct 24, 2026
@AnthonyRonning
AnthonyRonning merged commit c663cd2 into master Oct 25, 2026
39 checks passed
@AnthonyRonning
AnthonyRonning deleted the claude/gracious-shannon-85e5jy branch October 25, 2026 06:29
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