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.
Implementing the widget
Section titled “Implementing the widget”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.
Wallet addresses
Section titled “Wallet addresses”The widget requires wallet addresses to be provided so the user can select where to receive their cryptocurrency. See Provide wallet addresses for details.
Init parameters
Section titled “Init parameters”In addition to the shared init parameters, the buy widget supports:
| Key | Type | Description | Default |
|---|---|---|---|
returnUrl | string | URL the user returns to after being redirected to a BTC Direct page. | Current page URL |
useSameWindowForPayment | boolean | Set to false to open the payment page in a new window. | true |
walletConfirmationRequired | boolean | If true, the widget emits a confirmation event before completing the order. Used for hardware wallet integrations. | false |
Next steps
Section titled “Next steps”- Parameters: prefill and control the order form
- Events: respond to order confirmations and wallet verifications