cardToken to pass to your server for payment processing.
This element is the standard way to collect card details in a Headless Checkout flow.
Usage
validate() then submit():
Options
styles CardStyles
Optional. Customize the appearance of the card input fields.
CardStyles reference
| Field | Type | Description |
|---|---|---|
cardNumber | CardElementStyle | Styles for the card number field |
cardExpiration | CardElementStyle | Styles for the expiration date field |
cardVerification | CardElementStyle | Styles for the CVV/CVC field |
container | CSSProperties | Styles applied to the outer container element |
inputWrappers | CSSProperties | Styles applied to each field wrapper |
section1 | CSSProperties | Styles applied to the first row (card number) |
section2 | CSSProperties | Styles applied to the second row (expiry + CVV) |
fonts | string[] | Font URLs to load inside the iframe |
CardElementStyle reference
Each field style (cardNumber, cardExpiration, cardVerification) accepts:
| Field | Type | Description |
|---|---|---|
base | CardElementStyleVariant | Default state styles |
complete | CardElementStyleVariant | Styles when the field is filled and valid |
invalid | CardElementStyleVariant | Styles when the field contains an error |
empty | CardElementStyleVariant | Styles when the field is empty |
container | CardElementStyleVariant | Styles for the field’s inner container |
placeholder | string | Custom placeholder text |
label | string | Custom label text |
labelContainer | CSSProperties | Styles for the label element |
fonts | string[] | Field-specific font URLs |
CardElementStyleVariant supports these CSS properties:
Methods
validate() → Promise<boolean>
Returns true if all card fields contain valid input. Use this before submitting to surface validation errors to the buyer.
submit() → Promise<{ cardToken: string }>
Tokenizes the card and returns a cardToken. Pass this token to your server to complete the payment - never send raw card data from your frontend.
destroy()
Removes the iframe and cleans up all event listeners. Call this when navigating away or unmounting a component.
Full example
React
Related
Checkout Widget
Embed a complete buy-now checkout button and modal
Server SDK - Checkout
Build headless checkout flows server-side