---
title: Events
description: The DOM events the element dispatches, and what to do with each.
---

The element tells your page what happened by dispatching plain DOM events on
itself. Listen with `addEventListener` — none of them cross into the shadow
root, so listen on the element, not on `document`.

```js
const el = document.querySelector('btcdirect-journey');
el.addEventListener('btcdirect:order-created', (e) => {
  console.log('order', e.detail.orderId, e.detail.amount, e.detail.currency);
});
```

## The order

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `btcdirect:order-created` | { orderId, amount, currency } | optional | The customer confirmed and an order now exists. amount and currency are what the customer pays, as a decimal string and a ticker. Store the id: it is what your webhooks arrive with, and what you need to restore the order if the element remounts. |
| `btcdirect:payment-complete` | { orderId, returnUrlBase } | optional | Payment for that order is done. returnUrlBase is the order’s own recorded return host, the only host a hosted page may redirect to. |
| `btcdirect:close` | no detail | optional | The customer pressed Close. Only dispatched when you set closable. |

## Your wallet handshakes

Each of these waits for your answer through a method. See [Methods](https://partner.btcdirect.eu/v3/widget/methods.md).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `btcdirect:wallet-confirmation-requested` | { address, id } | optional | Confirm this payout address on the customer's device. Only with wallet-confirmation-required. id is your own id for the wallet, when you gave one. |
| `btcdirect:sell-transaction-requested` | { orderId, currency, amount, walletAddress, destinationTag, userWalletAddress, userWalletIdentifier } | optional | Send amount of currency to walletAddress, with destinationTag on the networks that need one. userWalletAddress and userWalletIdentifier are the wallet the customer sells from and your id for it, empty when you named none. |

## The customer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `btcdirect:registration-started` | no detail | optional | The customer began creating an account. |
| `btcdirect:onboarding-complete` | no detail | optional | The onboarding journey reached its successful end. Hand the customer on to wherever they were going. |
| `btcdirect:signed-in` | no detail | optional | The customer signed in inside the widget. |
| `btcdirect:identified` | no detail | optional | The widget resolved who the customer is from your user-identifier. |
| `btcdirect:signed-out` | no detail | optional | The session ended, through signOut or inside the widget. |
| `btcdirect:upgrade-change` | { target } | optional | The inline tier-upgrade flow was entered (target set) or left (target null). Reflect it in your URL if you want a refresh to come back to it. |
| `btcdirect:upgrade-complete` | no detail | optional | The upgrade flow reached its success screen. |

## Remounting loses the subscription

If your page remounts the element — a buy/sell tab toggle, a re-render that
replaces the node — the widget's subscription goes with it. Remember the
`orderId` from `btcdirect:order-created` and feed it back through `subjects` so
the order is restored rather than started again.

> **There is no per-step event**
>
> What the customer is looking at is the widget's business, and a page that
> reacted to individual steps would break the first time a journey gained one. If
> you need order state, use the [webhooks](https://partner.btcdirect.eu/v3/webhooks.md): they are delivered
> server-side and survive the customer closing the tab.
