addEventListener on a Secure Fields instance or on fields,
passing one of the supported events and a callback. removeEventListener
removes a previously attached event handler.
Global Events
The following events can be listened to by attaching an event handler to theSecureFields instance using the addEventListener method.
| Name | Description |
|---|---|
CARD_VAULT_SUCCESS | Triggered when the card is successfully vaulted. |
CARD_VAULT_FAILURE | Triggered when the card vaulting fails. The data includes the API status and additional data about the failure. |
READY | Triggered when Secure Fields is loaded and ready to be used. An object is available as an argument in the callback, containing: - environment (sandbox or production) - gr4vyId - sessionId - version (of the Secure Fields SDK in use) |
FORM_CHANGE | Triggered when any value of the card form changes. An object is available as an argument in the callback, containing: - fields (object of fields, each with validation information) - complete (a form is complete if number and expiry date are filled and valid and security code is empty or valid) |
Field Events
The following events can be listened to by attaching an event handler to a field (returned by theaddCardNumberField, addExpiryDateField,
addSecurityCodeField and addField methods) using the addEventListener method.
Some of these provide additional useful data like the card BIN, validation
status, and scheme. For example, the input event on a card number field might
include { schema: 'visa', codeLabel: 'CVV', valid: true, ... }.
| Name | Description |
|---|---|
blur | Triggered when the field loses focus. |
focus | Triggered when the field gains focus. |
input | Triggered when the field value has been changed. |