Skip to main content

Factory

Options

All keys are optional.

fieldLayout shape

Example — stack every field:
Example — inline expiration and security code (the default layout):
Every visible card field is required and validated. Suppress optional atoms with fields.holderName.hidden, fields.postalCode.hidden, or fields.cardSecurityCode.hidden.

fields

cardNumber

Set fields.cardNumber.autoFocus: true to focus the card number field on mount. Use acceptedBrands to restrict the brand icons that render alongside the card number ('auto' uses every brand your merchant configuration supports). acceptedBrandsPlacement controls where the brand row renders: 'inline' alongside the input, 'stacked' below it, or 'hidden' to omit it.

cardExpiration

cardSecurityCode

Hide the security code only for card programs that do not require CVC (for example, some private-label or corporate cards). Hiding it removes the field from validation.

holderName

The card element does not autofocus on mount unless fields.cardNumber.autoFocus: true.

postalCode

Same shape as holderName. Default label 'Postal code'.

Value

The card element emits an encrypted value envelope on onSubmit. Sensitive fields are encrypted before they reach your handler.
Forward the full envelope to your server verbatim; do not try to unpack or transform the encrypted* fields. holderName and postalCode are present only when the corresponding field is visible and non-empty. encryptedSecurityCode is always present — it is an empty string ('') when fields.cardSecurityCode.hidden is true.

Card error codes

Card onError events surface validation_failed, not_mounted, network, tokenization_failed, and unknown. See Error codes.

Events

Every element event is supported: onReady, onChange, onSubmit, onError, onFocus, onBlur, onEscapeKeyPressed. See Events overview.

FieldError.field values

'cardNumber', 'cardExpiration', 'cardSecurityCode', 'holderName', 'postalCode'.

Methods

  • card.mount(selector)
  • card.update(partialOptions)
  • card.submit(): void — validates and emits onSubmit (encrypted envelope) or onError.
  • card.unmount()
  • card.destroy()
  • card.on(event, handler) — subscribe to events.
Last modified on July 29, 2026