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.
Currencies
Section titled “Currencies”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' });- Available values for cryptocurrency: List of supported cryptocurrencies
- Available values for fiat: List of supported fiat currencies
Lock cryptocurrency
Section titled “Lock cryptocurrency”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 coinbtcdirect('currencies', { crypto: 'ETH', fiat: 'EUR' });
btcdirect('lock-cryptocurrency', { lockCryptocurrency: true });Order information
Section titled “Order information”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 examplebtcdirect('init', { token: 'API_KEY' });
btcdirect('order', { crypto: 'LTC', fiat: 'EUR', amount: 1, type: 'crypto'});- Available values for type:
cryptoandfiat - Available values for cryptocurrency: List of supported cryptocurrencies
- Available values for fiat: List of supported fiat currencies
Locale
Section titled “Locale”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' });Callback url
Section titled “Callback url”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:
| Status | Description |
|---|---|
| success | The order has been processed successfully. |
| expired | The order’s payment window has expired. Therefore the order is stopped. |
| cancelled | The order has been canceled by the user. |
| denied | The order has been denied by the payment provider. This is usually when a user tries to pay for an order with insufficient funds. |
| failed | The order has failed for unknown reasons. |
Transaction confirmation
Section titled “Transaction confirmation”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'});Canceling transaction confirmation
Section titled “Canceling transaction confirmation”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');