---
title: Buy widget
description: 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](https://partner.btcdirect.eu/v2/widget/getting-started.md):

```html
<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:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `returnUrl` | string | optional | Where the "Back to partner" button takes the customer. Default: the page the widget is on. |
| `walletConfirmationRequired` | boolean | optional | Ask your app to confirm the wallet address (for example on a hardware wallet) before the order is placed. Default false. |
| `partnerOrderIdentifier` | string | optional | Your own reference for the order, carried onto it so you can match it in your systems and webhooks. |
| `useSameWindowForPayment` | boolean | optional | 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](https://partner.btcdirect.eu/v2/widget/buy/events.md).

## Next steps

- [Wallet addresses](https://partner.btcdirect.eu/v2/widget/buy/wallet-addresses.md): give the customer their own
  wallets to receive into.
- [Parameters](https://partner.btcdirect.eu/v2/widget/buy/parameters.md): prefill and lock parts of the order form.
- [Events](https://partner.btcdirect.eu/v2/widget/buy/events.md): react to orders and wallet confirmations.
