Skip to content

Buy widget (F2C)

The buy widget allows users to purchase cryptocurrency with fiat currency directly from your website. It handles the entire order flow including currency selection, amount input, payment method selection, and payment processing.

Embed the following script to load the buy widget from the BTC Direct CDN:

<script lang="js">
(function (btc, d, i, r, e, c, t) {
btc[r] = btc[r] || function () {
(btc[r].q = btc[r].q || []).push(arguments)
};
c = d.createElement(i);
c.id = r; c.src = e; c.async = true;
c.type = 'module'; c.dataset.btcdirect = '';
t = d.getElementsByTagName(i)[0];
t.parentNode.insertBefore(c, t);
})(window, document, 'script', 'btcdirect',
'https://cdn.btcdirect.eu/fiat-to-coin/fiat-to-coin.js'
);
btcdirect('init', { token: 'API_KEY' });
</script>

Make sure you have set up your API key and added the stylesheet.

The widget requires wallet addresses to be provided so the user can select where to receive their cryptocurrency. See Provide wallet addresses for details.

In addition to the shared init parameters, the buy widget supports:

KeyTypeDescriptionDefault
returnUrlstringURL the user returns to after being redirected to a BTC Direct page.Current page URL
useSameWindowForPaymentbooleanSet to false to open the payment page in a new window.true
walletConfirmationRequiredbooleanIf true, the widget emits a confirmation event before completing the order. Used for hardware wallet integrations.false
  • Parameters: prefill and control the order form
  • Events: respond to order confirmations and wallet verifications