Buy widget
The customer buys crypto with fiat, without leaving your site.
The buy widget takes the customer through the whole order: which coin, how much, how to pay, where to receive it, and the payment itself.
Implementing the widget
Load the buy widget's script, as in Getting started:
<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>Init options
Besides the options every widget takes:
returnUrloptional
string
Where the "Back to partner" button takes the customer. Default: the page the widget is on.
walletConfirmationRequiredoptional
boolean
Ask your app to confirm the wallet address (for example on a hardware wallet) before the order is placed. Default false.
partnerOrderIdentifieroptional
string
Your own reference for the order, carried onto it so you can match it in your systems and webhooks.
useSameWindowForPaymentoptional
boolean
Accepted for compatibility. Whether a payment page opens in place or in a new window is decided per payment method.
With walletConfirmationRequired, the widget asks before placing the order and
waits for your answer: see events.
Next steps
- Wallet addresses: give the customer their own wallets to receive into.
- Parameters: prefill and lock parts of the order form.
- Events: react to orders and wallet confirmations.