JavaScript

Installation


Our JavaScript SDK is distributed from our CDN and can be loaded with a simple script tag. The SDK must be loaded directly from our CDN and cannot be bundled with your application or self hosted.

Using npm


You can also install Evervault via the @evervault/js package on npm. This package is a light wrapper which handles loading the SDK from our CDN and also provides TypeScript definitions.

Note: It is important to note that for PCI Compliance you must load the Evervault SDK directly from our CDN and cannot bundle it with your application. The loadEvervault function will always load the latest version of the Evervault SDK regardless of which version of @evervault/js you are using.

Asynchronous Loading


You can load the SDK asynchronously using the async attribute on the script tag to prevent blocking the loading of your page. However, it is important to note that you will need to wait for the SDK to load before making any API calls.

Usage


Once loaded, you can initialize the Evervault SDK with your Team and App ID found in the Evervault Dashboard.

Reference


Evervault


Creates an instance of the Evervault SDK using your Team and App ID.

Parameters

  • teamIdRequiredstring

    The ID of your Evervault team. This can be found inside of your team settings on the Evervault dashboard.

  • appIdRequiredstring

    The ID of your Evervault app. This can be found inside of your app settings on the Evervault dashboard.

encrypt


Encrypts data using Evervault Encryption. The encrypted data can be stored in your database or file storage as normal. Evervault Strings can be used across all of our products. Evervault File Encryption is currently in Early Access, and files can only be decrypted with Relay.

Parameters

  • dataRequiredstring | Data | File | Blob

    The data to encrypt

decrypt


Decrypts data previously encrypted with an Evervault product or SDK.

The decrypt() function uses Client-Side Tokens. The token can be generated using our backend SDKs or through our REST API.

The payload must be the same payload that was used to create the token and expires in a maximum of 10 minutes depending on the expiry set when creating the token.

Parameters

  • clientSideTokenRequiredstring

    A Client-Side Token with permission to decrypt the given payload.

  • encryptedDataRequiredstring

    The encrypted data to decrypt.

Card


The Card component collects and encrypts card data for Card Collection in a completely PCI-compliant environment. You can build it in two ways.

  • Composable: compose the fields yourself as HTML elements inside <ev-card>. They render in the order you write them, so you control the layout.
  • Config: initialize the card with ui.card() and configure it with a JavaScript object. The fields render in a fixed order.

Declare the Card component's fields as child elements of <ev-card>, and listen for its events on the element. The SDK registers <ev-card> and its child elements when it loads.

Attribute names are the property names in lowercase, as in HTML, so the acceptedBrands property is the acceptedbrands attribute. Changes to attributes, properties, and child elements apply to a mounted Card component, and the details a customer has already entered are kept.

Mount the Card component


Pass your Team and App IDs to <ev-card> using the teamid and appid attributes. The component mounts itself after the SDK loads.

If you've already created an Evervault instance, call ui.mountElements() instead. It mounts every <ev-card> on the page that isn't mounted yet.

An <ev-card> without child elements renders the card number, followed by the expiry and CVC side by side. Declaring any child element replaces these default fields. To remove the component, remove the <ev-card> element from the page.

Card component field elements


Each field is declared as its own element. Declare each field once. A duplicate field is ignored and logs a warning.

Elements
  • <ev-card-holder>

    The cardholder name field.

  • <ev-card-number>

    The card number field.

  • <ev-card-expiry>

    The expiry field, with the month and year in a single input.

  • <ev-card-expiry-month>

    The expiry month field of a split expiry.

  • <ev-card-expiry-year>

    The expiry year field of a split expiry.

  • <ev-card-cvc>

    The CVC field.

  • <ev-field>

    A custom field for your own, non-card data.

  • <ev-row>

    Places the fields side by side, sharing the width of the component.

Any other child element is ignored, and the console logs a warning that names it. The declared fields are available from the read-only spec property.

With autoprogress set, focus moves to the next field in the order the fields are declared, including fields inside an <ev-row>. Backspace in an empty field moves focus back to the previous one.

Split expiry


The expiry can be declared as a single <ev-card-expiry> field or as separate <ev-card-expiry-month> and <ev-card-expiry-year> fields. The month and year can be placed independently of each other, but a warning is logged if other fields are declared between them.

A split expiry still reports a single expiry in the card payload, under card.expiry, and its errors under errors.expiry. When the date is invalid, both fields are marked invalid.

You can't combine the two forms. A Card component that declares a month without a year, a year without a month, or either one alongside <ev-card-expiry> logs an error and isn't rendered. If the component is already mounted, it keeps its previous fields.

Custom fields


<ev-field> collects your own, non-card data inside the component, such as a postcode or an email address. It's styled by the same theme as the card fields. Each value is encrypted before it leaves the iframe.

The encrypted values are reported in the fields object of the card payload, by name. A field that's empty or invalid is reported as null, and its error is reported under errors.fields as required or invalid.

Validation follows the same rules as HTML form validation. Errors show after the customer leaves the field, or on every field when you validate the fields. The Card component isn't complete until every custom field is valid.

Changing a field's validation rules clears its value, so a value is only ever validated against the rules it was entered under. This prevents a script on your page from changing a pattern repeatedly to determine what was typed.

A field without a name, or with the same name as another field, isn't rendered and logs a warning. Themes can target the field as [ev-name="field-<name>"].

Card component attributes


Component-wide settings are attributes and properties of <ev-card>.

Attributes
  • teamidstring

    The ID of your Evervault team. Used with appid to mount the component without calling ui.mountElements().

  • appidstring

    The ID of your Evervault app. Used with teamid to mount the component without calling ui.mountElements().

  • themestring

    The name of a built-in theme: clean, material, or minimal. Defaults to clean. An unknown name logs a warning and uses clean. To use a custom theme, set the theme property to a theme definition instead. See Custom Styling for more information.

  • colorschemestring

    The root color-scheme of the iframe document. For a seamless transparent background, use the same color scheme as the parent document. Only read when the Card component mounts.

  • iconsBoolean

    Displays an icon for the detected card brand. To use your own icons, set the icons property to an object with the brand as the key and the icon URL as the value.

  • acceptedbrandsstring

    A space-separated list of the card brands to accept. If not set, all brands are accepted. Possible values are visa, mastercard, american-express, diners-club, discover, jcb, unionpay, maestro, elo, mir, hiper, hipercard, szep, uatp, rupay. The acceptedBrands property is an array.

  • autofocusBoolean

    Focuses the Card component when it mounts. A field's own autofocus attribute takes precedence.

  • autoprogressBoolean

    Moves focus to the next field after the current one is complete. A field's own autoprogress attribute takes precedence.

  • autocompleteBoolean

    Enables browser autocomplete for every field. Use off or false to turn it off. A field's own autocomplete attribute takes precedence.

  • preloadBoolean

    Hides the component when loaded. Call show() to show it. Only read when the component mounts.

Boolean attributes follow the HTML convention: declaring the attribute turns the setting on, and only ="false" turns it off. autocomplete also accepts off, as it does in HTML.

Card component properties


Settings that are objects are only available as properties. Properties set before the SDK loads are applied after it loads.

Properties
  • themestring | Object | Function

    A built-in theme name, or a theme definition. See Custom Styling for more information.

  • iconsBoolean | Record<brand, string>

    Displays an icon for the detected card brand. You can customize icons by passing an object with the brand as the key and the icon URL as the value.

  • customBrandsCustomBrand[]

    Custom card brand definitions created with brands.create. Custom brands are always accepted, even when acceptedBrands is set. See the custom card brands section for usage examples.

  • defaultValuesObject

    Default values for the component's fields.

  • translationsObject

    Customizes the text shown in the component. A field's own label, placeholder, and errormessage attributes take precedence.

  • validationObject

    Customizes the validation of the fields.

  • agentToolsObject

    Registers WebMCP tools inside the iframe so browser agents can interact with the component. Accepts the same object as the agentTools option of ui.card(). Only read when the component mounts.

  • specObject[]

    The declared fields. Read only.

Card component field attributes


Each field element takes its own settings, as attributes and properties. A field's own setting takes precedence over the same setting on <ev-card>.

Attributes
  • labelstring

    The text of the field's label.

  • placeholderstring

    The field's placeholder.

  • tooltipstring

    Text shown beside the label. Themes can target it as [ev-tooltip].

  • autofocusBoolean

    Focuses the field when the component renders. If more than one field sets it, the first is focused. Focus doesn't move after the customer starts entering details.

  • autoprogressBoolean

    Moves focus to the next field after this one is complete. Use autoprogress="false" to turn it off for this field only. The cardholder name doesn't auto-progress. The CVC advances after the max number of digits are entered (the max depends on the card brand).

  • autocompleteBoolean

    Enables browser autocomplete for the field. Use off or false to turn it off.

  • errormessagestring

    Replaces the text of the field's error. On a split expiry, either the month or the year can set it. On the card number field, the error for a card brand that isn't accepted is set separately, with unsupportedbrandmessage.

  • defaultvaluestring

    <ev-card-holder> only. Fills in the cardholder name. The value only applies while the field is untouched, and never replaces a name the customer has typed.

  • patternstring

    <ev-card-holder> only. A regular expression the whole cardholder name must match.

  • iconpositionstring

    <ev-card-number> only. Added to the field as the ev-icon-position attribute, so your theme can position the brand icon.

  • unsupportedbrandmessagestring

    <ev-card-number> only. Replaces the error text for a card brand that isn't accepted.

  • redactBoolean

    <ev-card-cvc> only. Masks the CVC as it's typed.

  • optionalBoolean

    <ev-card-cvc> only. Makes the CVC optional. CVCs are still validated if provided.

  • allow3digitamexBoolean

    <ev-card-cvc> only. Use allow3digitamex="false" to require a 4-digit CVC for American Express cards. Accepted by default.

Custom field attributes


<ev-field> takes label, placeholder, tooltip, autofocus, autoprogress, errormessage, and defaultvalue, as well as the following attributes.

Attributes
  • nameRequiredstring

    The field's name. Its value is reported under this key in the fields object of the card payload.

  • typestring

    The input type. One of text, email, tel, url, number, or date. Defaults to text. Any other type renders as text and logs a warning.

  • requiredBoolean

    Rejects an empty value.

  • patternstring

    A regular expression the whole value must match. Doesn't apply to number or date fields.

  • minlengthnumber

    The minimum length of the value. Doesn't apply to number or date fields.

  • maxlengthnumber

    The maximum length of the value. With autoprogress set, focus moves to the next field after the value reaches this length.

  • minstring

    The minimum value of a number or date field.

  • maxstring

    The maximum value of a number or date field.

  • stepstring

    The step of a number or date field, counted from min. Defaults to 1, measured in days for a date field. Use any to accept any value.

  • readonlyBoolean

    Prevents the customer from editing the value. A read-only field isn't validated.

  • autocompletestring

    An autocomplete token, such as postal-code. Declaring the attribute without a value, or with true, turns autofill on. Use off or false to turn it off.

  • autocapitalizestring

    One of characters, words, sentences, on, none, or off. Capitalizes the value as it's typed, so characters lets a lowercase value match an uppercase pattern. Only applies to text and tel fields.

  • inputmodestring
  • spellcheckBoolean

    Enables the browser's spell checking.

  • enterkeyhintstring

An email or url field must also hold a valid email address or URL. An empty required field shows This field is required, and an invalid value shows Please enter a valid value, unless the field sets an errormessage. You can also change this text with the translations property.

Change event


This is dispatched any time the component's state changes, including when the customer types in a field, leaves a field, or an error is shown. The encrypted card details are available as event.detail. Unlike the component's other events, change bubbles up to the parent elements of <ev-card>, so you can listen for it on any of them.

Event detail
  • detail.cardObject

    Information about the entered card, including metadata as well as the encrypted number and CVC.

  • detail.fieldsRecord<string, string | null>

    The encrypted values of the custom fields, by name. A field that's empty or invalid is null. A component without custom fields reports an empty object.

  • detail.errorsObject

    Validation errors for each field. Errors for custom fields are under errors.fields, by name, as required or invalid.

  • detail.isValidBoolean

    Whether or not any errors are shown on the card fields. Errors on custom fields don't affect it. Validation occurs as the customer leaves a field, or when you call validate().

    isValid represents whether any errors are shown, not whether the card details are valid. Use isComplete to determine whether the customer has entered a valid card.

  • detail.isCompleteBoolean

    Whether or not the card details are valid. Only true if every field, including custom fields, holds a valid value.

Complete event


This is dispatched after the customer fills out every field with a valid value, and again on each change while every field stays valid. event.detail has the same shape as the change event.

Ready event


This is dispatched after the component loads and is ready to be displayed. This is often used to show a loading state while the component loads.

Error event


This is dispatched if the component fails to load. To respond to validation errors, use the change event instead.

Swipe event


This is dispatched when a card reader is used. The component must have focus for the card reader to be detected.

Event detail
  • detail.numberstring

    The encrypted card number.

  • detail.brandstring

    The card brand.

  • detail.lastFourstring

    The last four digits of the card number. Only present when the number is valid.

  • detail.binstring

    The BIN for the card.

  • detail.expiry.monthstring

    The month of the card expiry date.

  • detail.expiry.yearstring

    The year of the card expiry date.

  • detail.firstNamestring

    The cardholder first name, if one was detected.

  • detail.lastNamestring

    The cardholder last name, if one was detected.

Validate event


This is dispatched when validate() is called. event.detail has the same shape as the change event.

Focus and keyboard events


The focus, blur, keydown, and keyup events are dispatched when a field gains focus, loses focus, or receives a key press. They don't bubble up to the parent elements, so listen for them on the <ev-card> element itself.

Event detail
  • detail.fieldstring

    The field the event happened in. One of name, number, expiry, cvc, or field for a custom field. Both fields of a split expiry report expiry.

  • detail.namestring

    The name of the custom field. Only present when field is field.

  • detail.dataObject

    The current card payload. Same shape as the change event detail.

Validate fields


Validates every field and shows any errors. This is asynchronous, so the result is dispatched as a validate event.

Show a preloaded Card component


Shows a Card component loaded with the preload attribute. If it's called before the component mounts, the component mounts visible.

brands.create


Creates a custom card brand definition that can be passed to the customBrands option of the Card component. Use this to add support for card networks that aren't included in Evervault's built-in brand list.

Parameters

  • nameRequiredstring

    A unique identifier for the brand. This value is returned in the localBrands array of the card change payload.

  • optionsRequiredObject

    Configuration for the custom brand.

ui.pin


Initializes a component for collecting and encrypting PIN numbers in a PCI-compliant environment.

Parameters

  • theme

    Allows you to customize the component's appearance. See Custom Styling for more information.

  • colorSchemestring

    Allows you to set the root color-scheme for the iframe document. For a seamless transparent background, use the same color scheme as the parent document.

  • lengthnumber

    The number of PIN digits to collect. Defaults to 4, maximum 10.

  • autoFocusBoolean

    If set to true, the component automatically focuses when it mounts.

  • mode"numeric" | "alphanumeric"

    If set to "alphanumeric", the PIN field accepts letters as well as digits. Defaults to "numeric".

  • inputType"number" | "text" | "password"

    Sets the type attribute of the underlying input elements used to capture the PIN. Defaults to "number".

pin.mount()


Mounts the component to a given DOM node.

pin.on('change')


Fired whenever the PIN value changes.

Callback Parameters

  • data.valuestring | null

    The encrypted PIN value, or null if the field is empty.

  • data.isCompleteBoolean

    Whether the PIN field is complete.

pin.on('complete')


Fired when the user enters all PIN digits.

Callback Parameters

  • data.valuestring | null

    The encrypted PIN value.

  • data.isCompleteBoolean

    Whether the PIN field is complete.

pin.on('ready')


Fired when the component loads and is ready to be displayed.

pin.on('error')


Fired if the component fails to load.

pin.update()


Updates the component configuration after initialization. Any arguments passed are merged with the original options.

pin.unmount()


Removes the component from the DOM.

ui.threeDSecure


The ThreeDSecure component can be used in combination with the Evervault API to perform 3D Secure authentication. In order to use the ThreeDSecure component you must first create a 3D Secure session on your backend and pass it to your frontend. The component will display the 3D Secure iframe and handle the authentication process.

Parameters

  • sessionRequiredstring

    The 3D Secure session ID. A 3D Secure session can be created using the Create 3D Secure Session API endpoint.

  • options

    Configuration options for the ThreeDSecure component.

threeDSecure.mount()


Mounts the component to the DOM. If no selector is provided the component will be rendered as a modal window.

Parameters

  • selectorstring

    The selector of the DOM node to mount the component to. If no selector is provided the component will be rendered as a modal window.

threeDSecure.on('success')


The 'success' event will be fired once the 3D Secure authentication process has been completed successfully. You should use this event to trigger your backend to finalize the payment. Your backend can use the Retrieve 3DS Session endpoint to retrieve the cryptogram for the session and complete the payment.

Note: The component is automatically unmounted after the 'success' event is fired.

threeDSecure.on('failure')


The 'failure' event will be fired if the 3D Secure authentication process fails. You should use this event to handle the failure and inform the user and prompt them to try again.

Note: The component is automatically unmounted after the 'failure' event is fired.

threeDSecure.on('ready')


The ready event will be fired once the component has fully loaded and is ready to be displayed. This is often used to show a loading state while the component loads.

threeDSecure.on('error')


The error event will be fired if the component fails to load.

Callback Parameters

  • error.errorString

    A unique code representing the error that occurred.

  • error.messageString

    A human readable message describing the error.

threeDSecure.update()


Update the configuration for the component after it has been initialized. Any arguments passed will be merged with the arguments passed when the component was initialized.

Parameters

  • colorSchemestring

    Allows you to set the root color-scheme for the iframe document. For a seamless transparent background, use the same color scheme as the parent document.

  • theme

    Allows you to customize the appearance of the component. See Custom Styling for more information.

    Note: You can't customize the appearance of the iframe content itself. This is controlled by the card issuer.

  • size{ width: string, height: string }

    This size of the 3D Secure iframe. Card issuers are required to support content at 250x400, 390x400, 500x600, 600x400. The default size is 500x600.

  • failOnChallengeBoolean | () => Boolean | () => Promise<Boolean>

    If set to true, the component will fail 3DS authentication when a challenge is requested and no challenge will be shown. Alternatively, you can provide a function which will be called when a challenge is requested. If the function returns true 3DS authentication will fail, if it returns false the challenge will be shown.

threeDSecure.unmount()


Removes the component from the DOM.

ui.reveal


The Reveal component allows you to display previously encrypted card data to your users in plaintext in a secure iframe hosted by Evervault. Before using Reveal you'll first need to have a JSON endpoint to retrieve data from. This is often your own API endpoint combined with Relay to decrypt previously encrypted data from your database or a third-party API.

It is important that the endpoint that you create sets the applicable CORS headers so that it can be accessed from the Reveal iframe. Otherwise your requests will fail!

reveal.on("ready")


The ready event will be fired once the request has been completed and all reveal consumer components are ready to be shown.

reveal.on("error")


The error event will be fired if the Reveal Component fails to load or the passed request fails.

reveal.text()


Creates a Reveal Text consumer. The Reveal Text consumer allows you to render a selected field from the request response.

Parameters

  • pathRequiredstring

    The JSON path to the field you want to display.

  • options.colorSchemestring

    Allows you to set the root color-scheme for the iframe document. For a seamless transparent background, use the same color scheme as the parent document.

  • options.themeTheme

    Allows you to completely customize the appearance of the component. See Custom Styling for more information.

  • options.formatObject

    Allows you to use regex matching to format the field value.

text.mount()

Mounts the Reveal Text component to a given DOM node.

text.unmount()

Removes the Text Component from the DOM.

reveal.copyButton()


Creates a Reveal Copy Button consumer. This renders a button which when clicked will copy a response field to the users clipboard.

Parameters

  • pathRequiredstring

    The JSON path to the field you want to display.

  • options.textstring

    The text to display on the button.

  • options.iconstring

    A URL for an icon to display on the button.

  • options.colorSchemestring

    Allows you to set the root color-scheme for the iframe document. For a seamless transparent background, use the same color scheme as the parent document.

  • options.themeTheme

    Allows you to completely customize the appearance of the component. See Custom Styling for more information.

  • options.formatObject

    Allows you to use regex matching to format the field value.

copyButton.on("copy")

The copy event will be fired when the button is clicked and the value has been copied to the clipboard.

copyButton.mount()

Mounts the Reveal Copy Button component to a given DOM node.

copyButton.unmount()

Removes the Copy Button Component from the DOM.

transactions.create


Creates a transaction object that can be used with Apple Pay and Google Pay components.

Parameters

  • options.amountRequirednumber

    The transaction amount in smallest currency unit (e.g., cents).

  • options.currencyRequiredstring

    The three-letter ISO currency code.

  • options.countryRequiredstring

    The two-letter ISO country code.

  • options.merchantIdRequiredstring

    Your Evervault merchant ID.

  • options.typepayment | disbursement | recurring

    Specify the type of transaction. Disbursement requests are only available with Apple Pay. Default: payment.

  • options.lineItemsTransactionLineItem[]

    Optional array of line items to display in the payment sheet.

  • options.requiredRecipientDetailsstring[]

    Optional array of recipient details required for collection on a disbursement transaction. Possible values: name, email, phone, address.

  • options.merchantCapabilitiesstring[]

    Optional array of Apple Pay merchant capabilities for disbursement transactions. When omitted, defaults to supports3DS, and adds supportsInstantFundsOut when instantTransfer is set. Supported values: supports3DS, supportsEMV, supportsCredit, supportsDebit, supportsInstantFundsOut. On iOS the equivalent is the singular merchantCapability field on DisbursementTransaction.

  • options.managementURLstring

    URL for managing the recurring payment subscription. Required when type is recurring.

  • options.billingAgreementstring

    Description of the billing agreement shown to the user. Required when type is recurring.

  • options.descriptionstring

    Description of the recurring payment. Required when type is recurring.

  • options.regularBillingobject

    Billing details for the recurring charge. Required when type is recurring.

  • options.trialBillingobject

    Optional trial billing details for the recurring payment.

ui.applePay


Initializes an Apple Pay button that handles the payment flow and returns encrypted payment details.

In Sandbox apps, the encrypted networkToken.number maps to a test card that matches the brand of the card the customer selects in their Apple Wallet.

Parameters

  • transactionRequiredTransaction

    The transaction object created with transactions.create.

  • optionsRequiredObject

    Configuration options for the Apple Pay button.

The object passed to options.process includes metadata on card when present. Optional card.paymentMethodType is credit, debit, prepaid, or store when the wallet reports the funding type for the card the user selected. See the Apple Pay guide for how this relates to BIN-derived fields such as funding.

paymentDataType reflects the Apple token format from the credentials API (for example 3DSecure). transactionType indicates the transaction category (oneOff, recurring, or disbursement) based on how you created the transaction. transactionId is Apple's identifier for the token, and comes from the PKPaymentToken header. Some payment gateways require it to be passed through, though it isn't used to authorize the transaction itself. billingContact and shippingContact are only populated when the transaction requested those contact fields. shippingMethod is populated when you configured shippingMethods and the customer selected one. phoneticFamilyName and phoneticGivenName are populated when the customer's Apple Wallet contact card includes a phonetic reading of their name (common in locales like Japan). If there's no phonetic reading, then these two values are null.

applePay.mount()


Mounts the Apple Pay button to a given DOM node.

applePay.unmount()


Removes the Apple Pay button from the DOM. If an Apple Pay session is active, the sheet is dismissed first.

applePay.abort()


Programmatically dismisses the Apple Pay sheet while a session is in progress. This maps to the browser's PaymentRequest.abort() API. When the sheet closes, the cancel event is fired.

Use this when you need to close and reopen Apple Pay — for example, when a shipping address change requires a different currency. Currency cannot be updated mid-session via onShippingAddressChange; abort the session, update the transaction, and let the user open Apple Pay again.

abort() is a no-op when no session is in progress. After the user authorizes payment, use fail() in the process callback instead.

applePay.availability()


Checks whether Apple Pay is available on the current device. Returns a promise resolving to "available", "unavailable", or "unsupported".

applePay.on("ready")


Fired when the Apple Pay button is mounted and ready to be displayed.

applePay.on("success")


Fired when the payment has been successfully authorized.

applePay.on("error")


Fired if there's an error initializing the Apple Pay button.

applePay.on("cancel")


Fired when the user cancels the Apple Pay payment flow.

ui.googlePay


Initializes a Google Pay button that handles the payment flow and returns encrypted payment details.

Parameters

  • transactionRequiredTransaction

    The transaction object created with transactions.create.

  • optionsRequiredObject

    Configuration options for the Google Pay button.

The object passed to options.process includes metadata on card when present. Optional card.paymentMethodType matches Google Pay's funding source for the selected card when available. Fields like brand, funding, segment, country, currency, and issuer are optional and omitted when unavailable. See the Google Pay guide.

When assuranceDetailsRequired is set, the payload also includes an assuranceDetails object (cleartext, not processed by Evervault's backend) when Google Pay returns one.

When shippingAddress or shippingOptions is set, the payload also includes shippingAddress and shippingOption. See Collect a shipping address and offer shipping options for more information.

googlePay.on("success")


Fired when the payment has been successfully authorized.

googlePay.on("error")


Fired if there's an error initializing the Google Pay button.

googlePay.on("cancel")


Fired when the user cancels the Google Pay payment flow.

googlePay.on("ready")


Fired when the Google Pay button is ready to be displayed.

Custom Styling


Some components in the SDK allow you to customize the appearance of the component using a theme object. A theme is just an object with a styles property. This styles property uses a CSS-as-JS format to define CSS rules for the component. These rules will be compiled to CSS and injected into the iframe.

Although you can customize the CSS inside of the iframe, you cannot modify the HTML. We know that layout can have a big impact on style definitions and so to help with this, we apply custom attributes to various elements within the iframe. These attributes are prefixed with ev-.

You can see our premade Card Collection themes for an example of how these attributes can be used when creating themes.

A Card component declared with ev-card adds the following attributes for its declared layout:

  • [ev-row] on each <ev-row>
  • [ev-name="expiry-month"] and [ev-name="expiry-year"] on the fields of a split expiry
  • [ev-name="field-<name>"] on each <ev-field>, where <name> is the field's name
  • [ev-tooltip] on the text of a field's tooltip
  • [ev-icon-position] on the card number field, set from its iconposition attribute

Responsive Styling


You can define media queries inside of the themes styles object, however, this may lead to unexpected behaviour as the media queries will be matched against the iframe document, not the parent document. To get around this, we provide a media utility which allows you to define styles based on media queries that match the parent document.

To access the media utility you will need to define your theme as a function that returns a theme object. This function will be passed a utilities object as an argument, which contains the media utility. The media utility should be spread into the styles object of the returned theme.