> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fintoc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Listen to Widget events

When using the `onEvent` callback, it will be called for every event available on the widget. The callback should be defined as follows:

```javascript onEvent definition example theme={null}
function onEvent(eventName, metadata) {
	// use eventName and metadata
}
```

Here, `eventName` is a string that states the event that triggered the callback, and the `metadata` attribute is an object containing relevant information about the event that triggered the callback. It may be possible for some of the `metadata` attributes to be `null`.

| Parameter   | Description                                     |
| :---------- | :---------------------------------------------- |
| `timestamp` | Moment in time in which the event was triggered |

<Warning>
  The `metadata` object may include more fields over time, so you shouldn't assume its fields are just the one documented today.
</Warning>

## List of events

The events available on the widget are the ones documented on the table below:

| Event Name                             | Description                                                                                                                                                             |
| :------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `opened`                               | Triggers when the widget is opened                                                                                                                                      |
| `on_terms_and_conditions`              | Triggers when the user visits the terms and conditions                                                                                                                  |
| `codi_helper`                          | Triggers when the user visits the CoDi Helper Guide                                                                                                                     |
| `on_available_institutions`            | Triggers when the user enters the view to select the financial institution                                                                                              |
| `on_request_bank`                      | Triggers when the user enters the view to request a new bank                                                                                                            |
| `on_authentication_form`               | Triggers when the user enters the view to authenticate with its financial institution                                                                                   |
| `codi_username_required`               | Triggers when the user is prompted to enter their mobile phone to recieve a CoDi payment request                                                                        |
| `payment_in_progress`                  | Triggers when the user is asked to select the payment provider                                                                                                          |
| `creating_link`                        | Triggers when the financial institution is verifying the credentials and Fintoc is connecting the account                                                               |
| `link_created`                         | Triggers when the financial institution approves the credentials and a `Link` gets created in Fintoc                                                                    |
| `selecting_account`                    | Triggers when the user enters the view to select an account                                                                                                             |
| `payment_intent_confirmation_required` | Triggers when the user is prompted to authorize the payment                                                                                                             |
| `app_authentication_required`          | Triggers when the financial entity needs a second factor via application to authenticate                                                                                |
| `creating_subscription`                | Triggers when the user starts trying to create a subscription                                                                                                           |
| `payment_direct_transfer`              | Triggers when the user views the direct transfer screen                                                                                                                 |
| `device_authentication_required`       | Triggers when the financial entity needs a second factor via physical device to authenticate                                                                            |
| `card_authentication_required`         | Triggers when the financial entity needs a second factor via coordinate card to authenticate                                                                            |
| `sms_authentication_required`          | Triggers when the financial entity needs a second factor via SMS to authenticate                                                                                        |
| `email_authentication_required`        | Triggers when the financial entity needs a second factor via email to authenticate                                                                                      |
| `captcha_authentication_required`      | Triggers when the financial entity needs a second factor via captcha to authenticate                                                                                    |
| `validating_second_factor`             | Triggers when the financial entity is validating the second factor introduced by the user                                                                               |
| `subscription_created`                 | Triggers when a subscription is created correctly                                                                                                                       |
| `subscription_aborted`                 | Triggers when a constraint prevents Fintoc from completing the subscription. This could happen, for example, if the same subscription has already been completed before |
| `payment_created`                      | Triggers when a payment is successful                                                                                                                                   |
| `payment_error`                        | Trigger when a payment fails                                                                                                                                            |
| `payment_selecting_auth`               | Triggers when the user is selecting a second factor method to authenticate                                                                                              |
| `validating_payment`                   | Triggers when Fintoc is validating the payment                                                                                                                          |
| `closed`                               | Triggers when the user closes the widget                                                                                                                                |
| `on_error`                             | Triggers when an error occurrs on the flow                                                                                                                              |
