import { createSignal, Show } from "solid-js" import Modal from "@/components/Modal" import { updateActiveTenant } from "@/lib/hooks" import { createPortalSession } from "@/lib/api" import { account } from "@/lib/state" type Tab = "nwc" | "card" type PaymentSetupProps = { open: boolean onClose: () => void onSaved?: () => void } export default function PaymentSetup(props: PaymentSetupProps) { const [tab, setTab] = createSignal("nwc") const [nwcUrl, setNwcUrl] = createSignal("") const [saving, setSaving] = createSignal(false) const [saved, setSaved] = createSignal(false) const [error, setError] = createSignal("") const [redirecting, setRedirecting] = createSignal(false) async function saveNwc() { const url = nwcUrl().trim() if (!url) return setSaving(true) setError("") try { await updateActiveTenant({ nwc_url: url }) setSaved(true) props.onSaved?.() } catch (e) { setError(e instanceof Error ? e.message : "Failed to save wallet connection") } finally { setSaving(false) } } async function openPortal() { setRedirecting(true) setError("") try { const { url } = await createPortalSession(account()!.pubkey) window.location.href = url } catch (e) { setError(e instanceof Error ? e.message : "Failed to open billing portal") setRedirecting(false) } } function handleClose() { setNwcUrl("") setSaved(false) setError("") props.onClose() } return (

Set Up Payments

Choose how you'd like to pay once invoices are issued for your relay.

Pay with

Wallet connected!

Automatic payments are now enabled.

} >
setNwcUrl(e.currentTarget.value)} placeholder="nostr+walletconnect://..." class="w-full border border-gray-300 rounded-lg px-3 py-2" />

Add a payment card via Stripe to enable automatic billing. If an invoice is currently due, we will retry collection after card setup.

{error()}

) }