Parameters
Prefill the sell widget, and confirm the transfer.
The prefill calls below go straight after init, in the same script: they are
read once, when the widget loads. The transaction calls further down answer the
widget while the customer is selling.
Currencies
btcdirect('currencies', { crypto: 'BTC', fiat: 'EUR' });Lock the coin
Makes the coin read-only, so the customer cannot pick another:
btcdirect('currencies', { crypto: 'ETH', fiat: 'EUR' });
btcdirect('lock-cryptocurrency', { lockCryptocurrency: true });Order information
Prefill both currencies and an amount, in crypto or in fiat:
btcdirect('order', {
crypto: 'LTC',
fiat: 'EUR',
amount: 1,
type: 'crypto' // or 'fiat'
});Transaction confirmation
When the customer confirms, the widget asks your app to send the crypto (see events). Once the transfer is broadcast and has a transaction id, tell the widget, which adds it to the order:
btcdirect('transaction-id-confirmation', {
orderId: '3f2b8c1e-…',
transactionId: 'abcdef-123456789'
});Cancelling
If the transfer cannot go ahead, for example because the wallet holds too little, or the customer cancels it, cancel the order:
btcdirect('coin-to-fiat-order-canceled');Order updates
Order updates reach you through webhooks, configured once for your
account. An integration that already calls callback with a per-order URL keeps
receiving updates there, once your account manager has enabled it.