Commit ba9fcb6
feat: add crypto payment options to dashboard Stripe modal (CPL-274)
Switch the Add Funds modal from Stripe Card Element to Payment Element,
which auto-renders any payment methods enabled on the Stripe account
(card and supported crypto: USDC, USDP, ETH, SOL). Backend billing
endpoints already support crypto, so this is frontend-only.
Flow: user picks an amount → Continue creates a PaymentIntent and mounts
the Payment Element with its client_secret → Pay calls
stripe.confirmPayment with redirect: 'if_required'. Card stays inline;
crypto methods redirect to the wallet/Stripe-hosted flow and return to
the dashboard with ?payment_intent=...&redirect_status=...; the new
handleBillingReturn() picks that up on auth-ready, calls
confirm_payment, and refreshes the balance.
Carries forward the session-protection patterns the rest of billing.js
adopted in CPL-285/286: every handler captures billingAuthKey() up
front, uses ensureAbortController(), re-checks the captured key after
each await, attaches walletAuthHeader via billingRequestOptions in
sovereign mode, swallows AbortError, and evicts the wallet-auth cache
on auth errors. Also primes the wallet-auth signature when the modal
opens in sovereign mode so the user only sees one popup per session.
Payment Element is configured with
fields.billingDetails.address='never' so the address form is never
rendered; confirmPayment passes a default billing country in
payment_method_data so card AVS still works.
handleBillingReturn treats Stripe's `processing` redirect_status as a
non-error and shows "credits will appear once settled"; only `failed`,
`canceled`, and `requires_*` surface as errors. The
confirmPayment-backend-failure fallback now shows the pending-credit
message via the top-level status banner so closeBillingModal() can't
swallow it.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent dc935aa commit ba9fcb6
3 files changed
Lines changed: 284 additions & 141 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| 284 | + | |
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
| |||
0 commit comments