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

This page lists the Widget events and metadata available through `onEvent`. The Widget calls `onEvent` for each event. Define the callback as follows:

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

`eventName` identifies the event that triggered the callback. `metadata` contains information about the emitted event. Check each `metadata` attribute for `null` before using it.

The following `metadata` attribute is documented:

| Attribute   | Description                                                                  |
| :---------- | :--------------------------------------------------------------------------- |
| `timestamp` | Unix timestamp in milliseconds indicating when the Widget emitted the event. |

<Warning>
  The `metadata` object can include undocumented fields. Ignore fields that your integration does not recognize.
</Warning>

## List of events

The Widget emits the following events, including events for Cobro Digital (CoDi) payments:

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