Payment Card
A company card face that stays masked until the reader asks, then shows each detail with a copy button.
c2-payment-card shows a card the way Brex, Mercury and Ramp do: the face is masked down to the last four digits until the reader asks to see it, and then the number, expiry and security code each get a copy button.
Import
import '@c2n/components/payment-card'Usage
The details stay with your app
The full number never sits in an attribute. last4, holder and label describe the masked face. “Show details” fires reveal-request; your app fetches the details (usually behind a re-authentication) and sets the details property:
const card = document.querySelector('c2-payment-card')!
card.addEventListener('reveal-request', async () => {
try {
card.details = await api.cardDetails(cardId) // { number, expiry, cvc }
} catch {
card.revealFailed()
}
})While the request runs, the button shows its running state and the number line is a skeleton. The card masks itself again, dropping details from memory, after hide-after seconds (60 by default), when the page is hidden, when it is frozen, and through hide(). Details that arrive after the reveal was cancelled (the card hidden, frozen, or the page left) are dropped rather than shown.
Copy and accessibility
Each shown field has a c2-copy-button (“Copy card number”, “Copy expiry date”, “Copy security code”), and a copy fires field-copy with the field, for an audit log (named apart from the native clipboard copy). The masked number reads “Card ending in 4242”; showing and hiding the details is announced.
Styling
The face is designed dark, so its colours stay in both themes. --c2-payment-card__face--background takes any colour or gradient, and the chip, the expiry row and the button row each have a display variable, which is how the compact card above drops them. The brand slot takes the network’s or issuer’s logo, as your app is licensed to show it; actions takes more buttons (“Freeze”) beside “Show details”.