Payment Card
The payment card screens: the saved card and the form to add one.
Overview
Saved card
- `PaymentCardDetails`: draws the saved card (
credit-card) beside adescription-list(issuer, last digits, holder, expiry) from the gateway's data (numberwith hidden digits,issuer,name,expiry), withactionsunder it. - `PaymentCardRemove`: the destructive button that asks through a
ConfirmDialogand runsonRemovewith the dialog pending, showing an error if it throws.
Adding a card
PaymentCardForm is a react-aria Form that lays PaymentCardPreview beside PaymentCardFields (stacked when narrow). The fields are ready-made react-aria TextFields that feed the live preview with their value and focus (the code field turns the card):
- `PaymentCardNumberField`: masked by issuer.
- `PaymentCardNameField`:
part="first"/"last"split it for gateways that take them apart. - `PaymentCardExpiryField`:
MM/YY. - `PaymentCardCodeField`: digits, sized by the issuer.
Each takes value/onChange or defaultValue, name, validate, isInvalid and errorMessage (for react-hook-form's Controller), label and description. Validate with the credit-card-validation lib.
Built-in text is in English; translate it with label, placeholder and i18n.labels.
Installation
CLI
Manual
- 1
Register the @fma-ds namespace in components.json (once)
- 2
Add the item
Files land in
components/fma-ds/payment-card/payment-card.tsx; npm and registry dependencies are installed along with them.
Dependencies
- npm
- cn@^0.5.0lucide-react@^1.61.0react-aria-components@^1.22.1
- Registry
- @fma-ds/button@fma-ds/confirm-dialog@fma-ds/credit-card@fma-ds/description-list@fma-ds/input@fma-ds/label@fma-ds/masked-input@fma-ds/use-dialog-promise@fma-ds/credit-card-validation