Skip to content

Commit ba9fcb6

Browse files
GTC6244claude
andcommitted
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

File tree

lit-static/dapps/dashboard/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { isAuthenticated, setTheme, getTheme, logOut, setOnAuthReady, updateStatCards, initLogin, setUsageKeyOverride, toggleOverrideEnabled, updateUsageKeyOverrideUI, setChainSecuredRpcUrl, toggleChainSecuredRpcPanel, updateChainSecuredRpcUrlUI, getMode, getApiKey, convertToChainSecured, changeChainSecuredOwnership } from './auth.js';
77
import { initModalClose, initConfirmClose, showStatus, hideStatus, logError } from './ui-utils.js';
8-
import { initBilling } from './billing.js';
8+
import { initBilling, handleBillingReturn } from './billing.js';
99
import { initGroups, loadGroups } from './groups.js';
1010
import { initKeys, loadUsageKeys } from './keys.js';
1111
import { initActions, loadActions } from './actions.js';
@@ -281,6 +281,7 @@ setOnAuthReady(() => {
281281
refreshConvertVisibility();
282282
refreshChangeOwnershipVisibility();
283283
updateChainSecuredRpcUrlUI();
284+
handleBillingReturn();
284285
});
285286

286287
// ----- Init -----

0 commit comments

Comments
 (0)