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
The ID of your Evervault team. This can be found inside of your team settings on the Evervault dashboard.
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.
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
A Client-Side Token with permission to decrypt the given payload.
The encrypted data to decrypt.
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
The cardholder name field.
The card number field.
The expiry field, with the month and year in a single input.
The expiry month field of a split expiry.
The expiry year field of a split expiry.
The CVC field.
A custom field for your own, non-card data.
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
The ID of your Evervault team. Used with
appidto mount the component without callingui.mountElements().The ID of your Evervault app. Used with
teamidto mount the component without callingui.mountElements().The name of a built-in theme:
clean,material, orminimal. Defaults toclean. An unknown name logs a warning and usesclean. To use a custom theme, set thethemeproperty to a theme definition instead. See Custom Styling for more information.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.
Displays an icon for the detected card brand. To use your own icons, set the
iconsproperty to an object with the brand as the key and the icon URL as the value.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. TheacceptedBrandsproperty is an array.Focuses the Card component when it mounts. A field's own
autofocusattribute takes precedence.Moves focus to the next field after the current one is complete. A field's own
autoprogressattribute takes precedence.Enables browser autocomplete for every field. Use
offorfalseto turn it off. A field's ownautocompleteattribute takes precedence.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
A built-in theme name, or a theme definition. See Custom Styling for more information.
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.
Custom card brand definitions created with brands.create. Custom brands are always accepted, even when
acceptedBrandsis set. See the custom card brands section for usage examples.Default values for the component's fields.
Customizes the text shown in the component. A field's own
label,placeholder, anderrormessageattributes take precedence.The label for the name field.
The placeholder for the name field.
The error message for the name field when the value is invalid.
The error message for when the name field fails regex validation.
The label for the number field.
The placeholder for the number field.
The error message for the number field when the value is invalid.
The error message for a card brand that isn't accepted.
The label for the expiry field.
The placeholder for the expiry field.
The error message for an invalid expiry, for both the combined and the split expiry.
The label for the expiry month field.
The placeholder for the expiry month field.
The label for the expiry year field.
The placeholder for the expiry year field.
The label for the CVC field.
The placeholder for the CVC field.
The error message for the CVC field when the value is invalid.
The error message for every custom field that's required but empty. Defaults to
This field is required.The error message for every custom field with an invalid value. Defaults to
Please enter a valid value.The
label,placeholder,errors.required, anderrors.invalidtext of a single custom field, by name. Takes precedence overtranslations.field.
Customizes the validation of the fields.
A regex pattern that the name must match in order to be considered valid. The
patternattribute of<ev-card-holder>takes precedence.When set to
true, CVCs aren't required. CVCs are still validated if provided. Theoptionalattribute of<ev-card-cvc>takes precedence.Validation rules for a single custom field, by name. Accepts
required,pattern,minLength,maxLength,min,max, andstep, which work like the <ev-field> attributes of the same name. A field's own attributes take precedence.
Registers WebMCP tools inside the iframe so browser agents can interact with the component. Accepts the same object as the
agentToolsoption ofui.card(). Only read when the component mounts.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
The text of the field's label.
The field's placeholder.
Text shown beside the label. Themes can target it as
[ev-tooltip].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.
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).Enables browser autocomplete for the field. Use
offorfalseto turn it off.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.<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.<ev-card-holder>only. A regular expression the whole cardholder name must match.<ev-card-number>only. Added to the field as theev-icon-positionattribute, so your theme can position the brand icon.<ev-card-number>only. Replaces the error text for a card brand that isn't accepted.<ev-card-cvc>only. Masks the CVC as it's typed.<ev-card-cvc>only. Makes the CVC optional. CVCs are still validated if provided.<ev-card-cvc>only. Useallow3digitamex="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
The field's name. Its value is reported under this key in the
fieldsobject of the card payload.The input type. One of
text,email,tel,url,number, ordate. Defaults totext. Any other type renders astextand logs a warning.Rejects an empty value.
A regular expression the whole value must match. Doesn't apply to
numberordatefields.The minimum length of the value. Doesn't apply to
numberordatefields.The maximum length of the value. With
autoprogressset, focus moves to the next field after the value reaches this length.The minimum value of a
numberordatefield.The maximum value of a
numberordatefield.The step of a
numberordatefield, counted frommin. Defaults to1, measured in days for adatefield. Useanyto accept any value.Prevents the customer from editing the value. A read-only field isn't validated.
An autocomplete token, such as
postal-code. Declaring the attribute without a value, or withtrue, turns autofill on. Useofforfalseto turn it off.One of
characters,words,sentences,on,none, oroff. Capitalizes the value as it's typed, socharacterslets a lowercase value match an uppercasepattern. Only applies totextandtelfields.The inputmode.
Enables the browser's spell checking.
The enterkeyhint.
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
Information about the entered card, including metadata as well as the encrypted number and CVC.
The encrypted card number.
The card brand.
The last four digits of the card number. Only present when the number is valid.
The BIN for the card.
The month of the card expiry date.
The year of the card expiry date.
The encrypted CVC.
The cardholder name.
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.Validation errors for each field. Errors for custom fields are under
errors.fields, by name, asrequiredorinvalid.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().
isValidrepresents whether any errors are shown, not whether the card details are valid. UseisCompleteto determine whether the customer has entered a valid card.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
The encrypted card number.
The card brand.
The last four digits of the card number. Only present when the number is valid.
The BIN for the card.
The month of the card expiry date.
The year of the card expiry date.
The cardholder first name, if one was detected.
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
The field the event happened in. One of
name,number,expiry,cvc, orfieldfor a custom field. Both fields of a split expiry reportexpiry.The name of the custom field. Only present when
fieldisfield.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
A unique identifier for the brand. This value is returned in the
localBrandsarray of the card change payload.Configuration for the custom brand.
Rules used to validate card numbers for this brand.
Bank identification number (BIN) prefixes or ranges that identify cards belonging to this brand. A single number matches cards starting with that prefix (e.g.,
9900). A two-element tuple defines an inclusive range of BIN prefixes (e.g.,[88000, 88999]).The valid card number lengths for this brand.
Whether to validate the card number using the Luhn algorithm. Defaults to
true.
A URL for the brand's icon. Displayed in the card component when a matching card number is entered.
ui.pin
Initializes a component for collecting and encrypting PIN numbers in a PCI-compliant environment.
Parameters
Allows you to customize the component's appearance. See Custom Styling for more information.
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.
The number of PIN digits to collect. Defaults to
4, maximum10.If set to true, the component automatically focuses when it mounts.
If set to
"alphanumeric", the PIN field accepts letters as well as digits. Defaults to"numeric".Sets the
typeattribute 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
The encrypted PIN value, or
nullif the field is empty.Whether the PIN field is complete.
pin.on('complete')
Fired when the user enters all PIN digits.
Callback Parameters
The encrypted PIN value.
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
The 3D Secure session ID. A 3D Secure session can be created using the Create 3D Secure Session API endpoint.
Configuration options for the ThreeDSecure component.
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.
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.
This size of the 3D Secure iframe. Card issuers are required to support content at 250x400, 390x400, 500x600, 600x400. The default size is 500x600.
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.mount()
Mounts the component to the DOM. If no selector is provided the component will be rendered as a modal window.
Parameters
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
A unique code representing the error that occurred.
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
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.
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.
This size of the 3D Secure iframe. Card issuers are required to support content at 250x400, 390x400, 500x600, 600x400. The default size is 500x600.
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
The JSON path to the field you want to display.
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.
Allows you to completely customize the appearance of the component. See Custom Styling for more information.
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.
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
The transaction amount in smallest currency unit (e.g., cents).
The three-letter ISO currency code.
The two-letter ISO country code.
Your Evervault merchant ID.
Specify the type of transaction. Disbursement requests are only available with Apple Pay. Default:
payment.Optional array of line items to display in the payment sheet.
The line item amount in the smallest currency unit.
Description of the line item.
Whether the line item amount is final or still estimated. When
"pending", the Apple Pay sheet hides the amount. Defaults to"final".The kind of line item. Currently only used by Google Pay, where it maps to
displayItems[].type. Has no effect on Apple Pay or disbursements. Defaults to"line_item".
Optional array of recipient details required for collection on a disbursement transaction. Possible values:
name,email,phone,address.Optional array of Apple Pay merchant capabilities for disbursement transactions. When omitted, defaults to
supports3DS, and addssupportsInstantFundsOutwheninstantTransferis set. Supported values:supports3DS,supportsEMV,supportsCredit,supportsDebit,supportsInstantFundsOut. On iOS the equivalent is the singularmerchantCapabilityfield onDisbursementTransaction.URL for managing the recurring payment subscription. Required when
typeisrecurring.Description of the billing agreement shown to the user. Required when
typeisrecurring.Description of the recurring payment. Required when
typeisrecurring.Billing details for the recurring charge. Required when
typeisrecurring.The billing amount as a decimal string (e.g.,
"2.13").Description of the billing charge.
The start date for the recurring payment.
The interval unit for the recurring payment frequency. The default value is "month".
The number of interval units between each recurring charge. The default value is 1.
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
The transaction object created with
transactions.create.Configuration options for the Apple Pay button.
Callback function called when payment is authorized. Receives encrypted payment data and helper functions.
Apple Pay button type. Possible values:
add-money,book,buy,check-out,continue,contribute,donate,order,pay,plain,reload,rent,set-up,subscribe,support,tip,top-upApple Pay button style. Possible values:
black,white,white-outlineAn ISO-639-1 code for localization.
The padding around the button as a CSS string with units (e.g.,
"10px").The border radius of the button. This can be a string with units (e.g.,
"10px") or a number (e.g.,10).An object defining the width and height of the button.
An array of supported card networks. Supported card networks:
amex,bancomat,bancontact,cartesBancaires,chinaUnionPay,dankort,discover,eftpos,electron,elo,girocard,interac,jcb,mada,maestro,masterCard,mir,privateLabel,visa,vPayAn array of payer details to request. Possible values:
name,email,phone,postalAddress.postalAddresshas no effect on recurring transactions. It's only honored for one-off payment transactions.Whether to request billing address information.
Whether to request shipping information.
Label for the shipping section on the Apple Pay sheet. One of
shipping,delivery,storePickup, orservicePickup. Defaults toshipping.Shipping methods the customer can choose on the sheet. One-off payment transactions only — rejected for recurring and disbursement. Providing methods enables shipping on the sheet. Amounts use the same smallest-currency-unit convention as line items (e.g. cents).
Unique identifier for the method. Returned as
shippingMethod.idon theprocess()payload.Display label on the sheet (e.g.
"Standard Shipping").Cost in the smallest currency unit (e.g. cents).
Optional secondary description (e.g. delivery estimate).
When
true, this method is selected by default. If none are marked selected, the first method is selected. If the transactionamountalready includes this method's cost, mark it selected.
Prefill billing contact details on the Apple Pay sheet. Requires
requestBillingAddress: truefor the postal address to appear. Payment and recurring transactions only — ignored for disbursements.Given (first) name.
Family (last) name.
Email address.
Phone number.
Street address lines.
City or locality.
State, province, or region.
Postal or ZIP code.
Two-letter ISO country code.
Country name.
Phonetic reading of the given name (common in locales like Japan).
Phonetic reading of the family name (common in locales like Japan).
Neighborhood or district within the locality.
County or subdivision within the administrative area.
Prefill shipping contact details on the Apple Pay sheet. Requires
requestShipping: truefor the postal address to appear. Payment and recurring transactions only — ignored for disbursements. Accepts the same fields asbillingContact.When
true, shows a coupon code field on the Apple Pay sheet.Initial coupon code shown in the sheet when
supportsCouponCodeistrue.Called when the customer changes the coupon code on the sheet. Receives the new coupon code string and must return a promise resolving to an updated
amountand optionallineItems. You can also return an optionalerror(code:couponCodeInvalidorcouponCodeExpired, plusmessage) to show validation feedback in the Apple Pay UI. RequiressupportsCouponCode: true.Opaque merchant data included on the Apple Pay request (
ApplePayRequest.applicationData). Must be a Base64-encoded string.Restrict payments to cards issued in these ISO 3166 country codes (
ApplePayRequest.supportedCountries).Called when the user changes their payment method. Receives the new payment method and returns a promise resolving to an updated
amountand optionallineItems. RequiresrequestBillingAddress: trueto receive billing address data.Called when the user changes their shipping address. Receives the new address and returns a promise resolving to an updated
amountand optionallineItems. RequiresrequestShipping: true.Called when the user selects a shipping method on the sheet. Receives the selected method (
id,label,amount, optionaldetail) and returns a promise resolving to an updatedamountand optionallineItems. RequiresshippingMethods. If omitted, the SDK recomputes the total from the selected method's amount.Called before the Apple Pay modal is shown. Use this to perform async logic (e.g., fetch a discount) and return an updated
amountand optionallineItems.Optional Apple Pay merchant identifier for the payment sheet. Defaults to
merchant.com.evervault.{merchantId}, which works with Evervault's domain verification and merchant-session flow. A custom value is only used by the browser to open the Apple Pay sheet. It doesn't change merchant validation — that still uses Evervault's registered identifier unless separately configured with Apple for your domain.Advanced overrides for the underlying Payment Request.
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
The transaction object created with
transactions.create.Configuration options for the Google Pay button.
Callback function called when payment is authorized. Receives encrypted payment data and helper functions.
Google Pay button type. Possible values:
short,book,buy,checkout,donate,order,pay,plain,subscribeGoogle Pay button color. Possible values:
black,whiteAn ISO-639-1 code for localization.
An object defining the width and height of the button.
Allowed authentication methods. With
CRYPTOGRAM_3DSset, users on mobile can authenticate with their fingerprint which acts as a Strong Customer Authentication and so a cryptogram and ECI value are returned. Users on web cannot authenticate with their fingerprint so only the PAN is returned. Possible values:PAN_ONLY,CRYPTOGRAM_3DSAn array of supported card networks. Supported card networks:
AMEX,DISCOVER,ELECTRON,ELO,ELO_DEBIT,INTERAC,JCB,MAESTRO,MASTERCARD,VISAAllows 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.
When set to true, the user will be required to provide their email address.
Collect a shipping address in the sheet. Pass
trueto accept any supported country, or an object to restrict which countries are allowed and to require a phone number.Offer shipping options in the sheet. Setting this also enables shipping-address collection when
shippingAddressis omitted.An array of shipping options, each with an
id, alabel, an optionaldescription, and an optionalamountin minor units.labelis shown to the customer exactly as given. Google Pay has no price field of its own, so add a price into the label if you want one shown.amountis Evervault-only metadata for your own totals math and is never sent to Google Pay.Which option to preselect. Defaults to the first option when omitted.
Called when the customer picks or changes their shipping address, while the sheet is still open. Return
{ amount, lineItems, shippingOptions }to update the sheet or{ error }to reject the selection. Omitted fields keep their current value. If you returned an error or an emptyshippingOptions.optionslist, or haven't updated the sheet within 10 seconds, a generic error is displayed.Called when the customer picks a different shipping option. Same return shape and timeout behavior as
onShippingAddressChange.Whether to show a
ContinueorPay Nowbutton on the Google Pay sheet. Possible values:DEFAULT,COMPLETE_IMMEDIATE_PURCHASE,CONTINUE_TO_REVIEW.COMPLETE_IMMEDIATE_PURCHASErequirestotalPriceStatusto beFINAL(the default), or Google Pay rejects the request. Defaults toDEFAULT.A merchant-generated ID for this transaction, used by Google Pay for fraud correlation.
Whether the total price is known and final, or still an estimate. Possible values:
FINAL,ESTIMATED. Defaults toFINAL.Whether to allow prepaid cards. Defaults to
true.Whether to allow credit cards. Defaults to
true.When true, requests that Google Pay perform cardholder ID&V or possession checks and return the result as
assuranceDetailson theprocesspayload. Defaults tofalse.When true, the button is only displayed if the user has a saved payment method in their Google account. This is checked when the button is set up, not when it's clicked. Defaults to
false.When true, Google Pay prepares the payment sheet as soon as the button is ready, so it opens faster on click. It has no effect on the
processresult. Defaults tofalse.
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'sname[ev-tooltip]on the text of a field'stooltip[ev-icon-position]on the card number field, set from itsiconpositionattribute
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.