> ## 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

The widget calls `onEvent` for every event it emits. Define the callback as follows:

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

`eventName` is a string naming the event that triggered the callback. `metadata` is an object with information about that event. Some `metadata` attributes can be `null`.

The `metadata` object can contain the following attribute:

| Parameter   | Description                                          |
| :---------- | :--------------------------------------------------- |
| `timestamp` | Timestamp marking when the widget emitted the event. |

<Warning>
  The `metadata` object can include more fields over time, so do not assume the object's fields are limited to the ones documented today.
</Warning>

## List of events

The widget emits the following events:

| Event name                             | Description                                                                                                                                           |
| :------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `opened`                               | Triggers when your user opens the widget.                                                                                                             |
| `on_terms_and_conditions`              | Triggers when your user visits the terms and conditions.                                                                                              |
| `codi_helper`                          | Triggers when your user visits the CoDi Helper Guide.                                                                                                 |
| `on_available_institutions`            | Triggers when your user opens the financial institution selection view.                                                                               |
| `on_request_bank`                      | Triggers when your user opens the view to request a new bank.                                                                                         |
| `on_authentication_form`               | Triggers when your user opens the view to authenticate with their financial institution.                                                              |
| `codi_username_required`               | Triggers when your user is prompted to enter their mobile phone to receive a CoDi payment request.                                                    |
| `payment_in_progress`                  | Triggers when your user is asked to select the payment provider.                                                                                      |
| `creating_link`                        | Triggers when the financial institution verifies the credentials and Fintoc connects the account.                                                     |
| `link_created`                         | Triggers when the financial institution approves the credentials and Fintoc creates a `Link`.                                                         |
| `selecting_account`                    | Triggers when your user opens the view to select an account.                                                                                          |
| `payment_intent_confirmation_required` | Triggers when your user is prompted to authorize the payment.                                                                                         |
| `app_authentication_required`          | Triggers when the financial institution requires a second factor through an app.                                                                      |
| `creating_subscription`                | Triggers when your user starts creating a subscription.                                                                                               |
| `payment_direct_transfer`              | Triggers when your user views the direct transfer screen.                                                                                             |
| `device_authentication_required`       | Triggers when the financial institution requires a second factor through a physical device.                                                           |
| `card_authentication_required`         | Triggers when the financial institution requires a second factor through a coordinate card.                                                           |
| `sms_authentication_required`          | Triggers when the financial institution requires a second factor by SMS.                                                                              |
| `email_authentication_required`        | Triggers when the financial institution requires a second factor by email.                                                                            |
| `captcha_authentication_required`      | Triggers when the financial institution requires a second factor through a captcha.                                                                   |
| `validating_second_factor`             | Triggers when the financial institution validates the second factor your user entered.                                                                |
| `subscription_created`                 | Triggers when Fintoc creates a subscription.                                                                                                          |
| `subscription_aborted`                 | Triggers when a constraint prevents Fintoc from completing the subscription. For example, your user may have already completed the same subscription. |
| `payment_created`                      | Triggers when a payment succeeds.                                                                                                                     |
| `payment_error`                        | Triggers when a payment fails.                                                                                                                        |
| `payment_selecting_auth`               | Triggers when your user selects a second factor method to authenticate.                                                                               |
| `validating_payment`                   | Triggers when Fintoc validates the payment.                                                                                                           |
| `closed`                               | Triggers when your user closes the widget.                                                                                                            |
| `on_error`                             | Triggers when an error occurs in the flow.                                                                                                            |
