Skip to content

Sell widget: parameters

The widget accepts several calls to it with which additional information can be provided. These can be added to the script tag that loads the widget.

This call sets the selected currencies for the widget. This is for both the cryptocurrency and the fiat currency. The provided values result in these currencies being selected in the order form as initial values.

btcdirect('currencies', { crypto: 'BTC', fiat: 'EUR' });

This call makes the currency select box “read-only” and locks the selected cryptocurrency. This prevents customers from changing the coin through the currency select box in the widget.

// Preselect the desired currency to make sure you lock the preferred coin
btcdirect('currencies', { crypto: 'ETH', fiat: 'EUR' });
btcdirect('lock-cryptocurrency', { lockCryptocurrency: true });

It is possible to set up the basic information of an order, making it easier for your users to purchase crypto as most of the form will be pre-filled. In order to do this you can provide both currencies of the order (crypto and fiat), the order amount and if it is a fiat amount or crypto amount.

// JavaScript from previous code example
btcdirect('init', { token: 'API_KEY' });
btcdirect('order', {
crypto: 'LTC',
fiat: 'EUR',
amount: 1,
type: 'crypto'
});

This call sets the locale for the application. This determines the way monetary values are displayed. For example 0 Euro’s in the EN-GB locale is displayed as “€0.00” whereas the NL-NL locale results in ”€ 0,00”.

btcdirect('locale', { locale: 'en-GB' });

This call sets a callback url to which the result of the order is communicated. For example when setting the url to https://btcdirect.eu it will be called after an order has been completed. The status and ID of the order are added as query parameters, such as ?orderId=123456&status=success. This enables your website to catch the status of the order and display information accordingly.

btcdirect('callback', { callbackUrl: 'https://btcdirect.eu' });

The following values can be returned by the process, according to the status of the order:

StatusDescription
successThe order has been processed successfully.
expiredThe order’s payment window has expired. Therefore the order is stopped.
cancelledThe order has been canceled by the user.
deniedThe order has been denied by the payment provider. This is usually when a user tries to pay for an order with insufficient funds.
failedThe order has failed for unknown reasons.

This call is needed in order to fully complete the order. When the user has provided the needed data in the widget, an event is emitted from the widget to your application with data to create a transaction on the selected chain. This emitted event is described in Sell widget: events. Once the transaction is broadcasted and a transaction ID is available, it can be supplied to the widget which will add it to the order to finalize the process.

btcdirect('transaction-id-confirmation', {
orderId: '123456',
transactionId: 'abcdef-123456789'
});

If for some reason the transaction cannot be continued (for example when the wallet doesn’t have enough funds) or the user cancels the process the transaction can be canceled.

btcdirect('coin-to-fiat-order-canceled');