v3

Events

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.

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

btcdirect:order-created

{ orderId, amount, currency }

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 }

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

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.

btcdirect:wallet-confirmation-requested

{ address, id }

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 }

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

btcdirect:registration-started

no detail

The customer began creating an account.

btcdirect:onboarding-complete

no detail

The onboarding journey reached its successful end. Hand the customer on to wherever they were going.

btcdirect:signed-in

no detail

The customer signed in inside the widget.

btcdirect:identified

no detail

The widget resolved who the customer is from your user-identifier.

btcdirect:signed-out

no detail

The session ended, through signOut or inside the widget.

btcdirect:upgrade-change

{ target }

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

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: they are delivered server-side and survive the customer closing the tab.