Payment form
Card or bank (SEPA) details, formatted and checked as typed. Test mode is announced.
import { PaymentForm, luhnValid, ibanValid, TEST_CARDS, TEST_IBANS } from "@forgeron/ui";import { PaymentForm } from "@forgeron/ui";
import { useState } from "react";
export default function Card() {
const [done, setDone] = useState("");
return (
<div style={{ display: "grid", gap: 12 }}>
<PaymentForm
submitLabel="Pay 120.00 EUR"
onSubmit={(p) => setDone(p.method === "card" ? `Test card ending ${p.last4} accepted` : "")}
/>
{done ? <p style={{ margin: 0, font: "12px var(--font-mono)" }}>{done}</p> : null}
</div>
);
}import { PaymentForm } from "@forgeron/ui";
export default function Bank() {
return <PaymentForm defaultMethod="bank" methods={["bank"]} submitLabel="Set up the debit" />;
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
method / defaultMethod | "card" | "bank" | "card" | Controlled or not, with onMethodChange. |
methods | PaymentMethod[] | — | Which are offered; one hides the switch. |
testMode | boolean | true | A Test mode banner and a button that fills a published test number. A live form is a deliberate `false`. |
onSubmit | (payment) => void | — | Once, when valid: { method, values } (card also brand and last4). The fields are cleared after. Nothing is stored or logged here. |
onValidityChange | (valid: boolean) => void | — | Only whether it could be sent, never a value. |
mandateText | string | — | The sentence the person accepts. |
submitLabel | string | "Pay" | The button. |
disabled | boolean | — | Locks the form. |
className | string | — | Extra classes. |