Skip to content

Buy widget: events

The buy widget emits events that your application can listen to. Use the native window.addEventListener to handle them:

window.addEventListener('EVENT_NAME', (event) => {
// The data sent by the widget is in event.detail
});

Replace EVENT_NAME with the event names described below.

Emitted when the user confirms their order and is about to be redirected to the payment page.

Event name: btcdirect-embeddable-fiat-to-coin-order-confirmed

// event.detail:
{
currencyCode: 'iso:EUR',
exchangeAmount: 100,
orderId: '123456789'
}
FieldDescription
currencyCodeThe fiat currency code
exchangeAmountThe fiat amount being paid
orderIdThe order ID

Emitted when walletConfirmationRequired is set to true in the init call. Your application should verify the wallet address (e.g. on a hardware wallet) and then confirm or cancel.

Event name: btcdirect-embeddable-wallet-address-confirmation-requested

// event.detail:
{
id: '123456789'
}

The id matches the wallet ID from Provide wallet addresses.

btcdirect('wallet-address-confirmation', { address: 'user-wallet-address' });

Returns the user to the order form:

btcdirect('wallet-address-confirmation-canceled');

If a callbackUrl is configured, the following statuses are sent as query parameters (?orderId=123&status=success):

StatusDescription
successThe order has been processed successfully.
expiredThe payment window has expired.
cancelledThe order was canceled by the user.
deniedThe payment was denied (e.g. insufficient funds).
failedThe order failed for unknown reasons.