Skip to content

Show the card on file and gate auto recharge behind a saved payment method - #139

Merged
mrmps merged 1 commit into
mainfrom
claude/payment-method-on-file
Sep 27, 2026
Merged

mrmps merged 1 commit into
mainfrom
claude/payment-method-on-file

Conversation

@mrmps

@mrmps mrmps commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #137, matching the billing UX pattern where the saved card is visible on the billing page rather than hidden behind the Stripe portal.

  • Card on file, inline: the billing page shows Visa ···· 4242 · valid until 12/2030 (brand/last4/expiry) with the Manage portal next to it. When no method is saved, it says so and offers an explicit Add payment method button that opens Autumn's billing.setup_payment hosted page and returns to /app/credits?billing=refresh.
  • Auto recharge is gated: the enable toggle is disabled with an "Add a payment method first" callout until a method is on file, so owners can't enable, fail a charge, and land in the one-hour cooldown.
  • No provider call on page load: reconciliation already fetches the customer, now with expand: ["payment_method"]; a display-only summary is cached in app_autumn_customers.payment_method (migration 0017) and the snapshot reads it from Neon. It refreshes on checkout return, webhooks, and the scheduled sweep — null (never observed) never blocks anything.
  • The summary is parsed defensively: only a well-formed {brand, last4, exp_month, exp_year} survives; anything else renders as a generic "payment method on file".

Verified live against the Autumn sandbox: reconcile cached the e2e account's saved 4242 card, the page renders it, the forced no-card state shows both add-payment-method flows and disables the toggle, and reconciliation restores the cache. 864 tests pass (3 new), typecheck green.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Billing details now show saved card brand, last four digits, and expiration date, or a message for other or missing payment methods.
    • Workspace owners can add a payment method when none is saved, manage payments and invoices, and see a setup prompt if auto-recharge requires a card.
    • Auto-recharge is unavailable when a missing card is confirmed; an unobserved payment method does not block it.
  • Bug Fixes
    • Non-owners now see a message directing them to an owner for payment-method management.

…ethod

Reconciliation caches a display-only card summary (brand, last4, expiry)
from the provider's expanded customer, so the billing page shows the saved
card and an explicit add-payment-method flow without a provider call on
page load. Auto recharge cannot be enabled until a method is on file.

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: cd534979-3ae8-4b11-9c32-4f8ed63d6c3a

📥 Commits

Reviewing files that changed from the base of the PR and between feffe23 and bc6bfd6.

📒 Files selected for processing (8)
  • migrations/postgres/0017_payment_method_cache.sql
  • src/features/billing/credits.tsx
  • src/server/autumn.ts
  • src/server/billing-sync.ts
  • src/server/billing.ts
  • src/server/contracts.ts
  • tests/autumn.test.ts
  • tests/payment-method.test.ts
 ____________________________________________________
< Fluent in over six million forms of bug detection. >
 ----------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ 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.

@mrmps
mrmps merged commit fdcbf3a into main Sep 27, 2026
2 of 3 checks passed
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