### Set Widget CDN Domain Source: https://developer.btcdirect.eu/widget/getting-started Configure the WIDGET_CDN_URL in your embedded script to point to the correct BTC Direct CDN environment (production or sandbox). This ensures the widget sources are loaded from the appropriate location. ```javascript const WIDGET_CDN_URL = "https://cdn.btcdirect.eu/"; // Production // OR // const WIDGET_CDN_URL = "https://cdn-sandbox.btcdirect.eu/"; // Sandbox ``` -------------------------------- ### Embed and Initialize BTC Direct Widget Source: https://developer.btcdirect.eu/widget/getting-started This script loads the BTC Direct widget from a CDN and initializes it with an API key. It's designed for easy integration, similar to Google Tag Manager. ```html ``` -------------------------------- ### Add Optional Stylesheet Source: https://developer.btcdirect.eu/widget/getting-started Link the default stylesheet to your page, preferably within the head tag, to apply a responsive layout and BTC Direct's visual styling to the widget. The stylesheet path depends on the specific widget being implemented. ```html ``` -------------------------------- ### Add Target Element for Widget Rendering Source: https://developer.btcdirect.eu/widget/getting-started Include a target HTML element, typically a div with the class 'btcdirect-widget', in your page's body. This element serves as the container where the BTC Direct widget will render itself. ```html
``` -------------------------------- ### User Authentication Guide Source: https://developer.btcdirect.eu/api/guides This guide helps you authenticate users in different flows. It covers methods like email and password authentication. ```APIDOC User Authentication: Description: This guide will help you authenticate users in different flows. Flows: - Email address and password authentication ``` -------------------------------- ### Customizing Target Element Identifier Source: https://developer.btcdirect.eu/widget/getting-started If you need to use a different identifier for your target element while still applying the default styling, add your custom identifier to the element instead of replacing the 'btcdirect-widget' class. ```html
``` -------------------------------- ### OpenAPI Documentation Overview Source: https://developer.btcdirect.eu/api/open-api Provides an overview of BTC Direct's API versions (V1 and V2), highlighting their differences and guiding developers to the OpenAPI specifications for detailed endpoint information, including error codes, authentication requirements, and example responses. ```APIDOC OpenAPI Documentation: - Overview of BTC Direct API versions (V1 and V2). - V1 API: Original version with basic functionalities. - V2 API: Enhanced endpoints, improvements to select existing V1 endpoints. - Integration may require a combination of V1 and V2 endpoints. - OpenAPI docs provide up-to-date details: error codes, authentication, example responses. - Links to specific documentation: - V1 API Documentation: https://developer.btcdirect.eu/api/v1/ - V2 API Documentation: https://developer.btcdirect.eu/api/v2/ ``` -------------------------------- ### API Authentication Guide Source: https://developer.btcdirect.eu/api/v1 Details the process of authenticating with the BTC Direct API. This section covers the necessary steps and credentials required to make secure API calls. ```APIDOC API Authentication: URL: https://developer.btcdirect.eu/api/api-authentication.html ``` -------------------------------- ### API Documentation Overview Source: https://developer.btcdirect.eu/api This section provides an overview of the BTC Direct API documentation. It guides users on how to integrate with the platform, obtain API credentials, and access support. It also clarifies the intended audience and purpose of the documentation. ```APIDOC API documentation: Purpose: Provides information for developers and partners to integrate with BTC Direct's platform. Content: - Introduction to API services and use cases. - Obtaining API credentials (contact business development manager). - Usage guidelines and security recommendations for credentials. - FAQ and support contact information. Audience: Developers and partners integrating with BTC Direct API. Exclusions: Not for end-users buying/selling cryptocurrency; refer to btcdirect.eu. Related Documentation: - Unified Checkout: https://developer.btcdirect.eu/unified-checkout/ - Widget: https://developer.btcdirect.eu/widget/getting-started.html - API Authentication: https://developer.btcdirect.eu/api/api-authentication.html - FAQ: https://developer.btcdirect.eu/api/faq.html ``` -------------------------------- ### Requesting and Using JWT Tokens Source: https://developer.btcdirect.eu/api/api-authentication This section details the process of obtaining a JWT token by authenticating with the `/api/v1/authenticate` endpoint and how to include this token in subsequent API requests. ```APIDOC Endpoint: POST /api/v1/authenticate Description: Authenticates with the API using client credentials to obtain a JWT token. Returns: - Authorization token: A token to be included in the header of each API request. - Refresh token: A token used to request a new authorization token. Example Header: Authorization: Bearer {token} ``` -------------------------------- ### Authenticating Users with Email and Password Source: https://developer.btcdirect.eu/api/v1 A guide on how to authenticate users using their email address and password for the BTC Direct API. This covers the specific flow for username/password authentication. ```APIDOC Authenticating Users (Email/Password): URL: https://developer.btcdirect.eu/api/guides/authenticating-users/email-password.html ``` -------------------------------- ### Provide Selected Wallet Address Source: https://developer.btcdirect.eu/widget/provide-wallet-address-es This example demonstrates how to provide a pre-selected wallet address to the BTC Direct widget. This is useful if a wallet address has already been chosen within your application. ```javascript btcdirect('init', { token: 'API_KEY' }); btcdirect('wallet-address-selected', { addresses: { address: 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn' } }); ``` -------------------------------- ### Provide Single Wallet Address Source: https://developer.btcdirect.eu/widget/provide-wallet-address-es This example demonstrates how to provide a single wallet address for Bitcoin to the BTC Direct widget. It includes the wallet address, currency, an optional ID, and an optional name. ```javascript btcdirect('init', { token: 'API_KEY' }); btcdirect('wallet-addresses', { addresses: { address: 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn', currency: 'BTC', id: '123456789', name: 'My wallet' } }); ``` -------------------------------- ### Token Expiry and Refresh Source: https://developer.btcdirect.eu/api/api-authentication Explains token validity, the error response for expired tokens, and the process of refreshing the authorization token using a refresh token. ```APIDOC Token Validity: Tokens are valid for 1 hour. Error Response for Expired Token: HTTP Status: 400 Bad Request JSON Payload: { "errors": { "ER801": { "code": "ER801", "message": "Authorization token has expired.", "solution": "Request a new authorization token." } } } Endpoint for Refreshing Token: POST /api/v1/refresh Description: Sends a POST request with the refresh token to obtain a new authorization token. The new authorization token is valid for 1 hour, and the refresh token is valid for 1 month (reset upon new token generation). ``` -------------------------------- ### Set Payment Method Source: https://developer.btcdirect.eu/widget/buy-order-form Sets the selected payment method for the order form. Payment methods are only visible after the user logs in. The example shows setting 'iDeal' as the payment method. ```javascript btcdirect('payment-method', { method: 'iDeal' }); ``` -------------------------------- ### Provide Multiple Wallet Addresses Source: https://developer.btcdirect.eu/widget/provide-wallet-address-es This example shows how to provide multiple wallet addresses to the BTC Direct widget, including addresses for different cryptocurrencies like Bitcoin and Ripple. It also shows how to include a destination tag for XRP. ```javascript btcdirect('init', { token: 'API_KEY' }); btcdirect('wallet-addresses', { addresses: [ { address: 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn', currency: 'BTC' }, { address: 'n1sBtodW8oz8xjwZGcZnLVoRrbQK3My8Vb', currency: 'BTC' }, { address: 'rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', currency: 'XRP', destinationTag: '123456' } ] }); ``` -------------------------------- ### Set Widget Locale Source: https://developer.btcdirect.eu/widget/buy-order-form Sets the locale for the application, which affects how monetary values are displayed. For example, 'en-GB' displays '€0.00' while 'NL-NL' displays '€ 0,00'. ```javascript btcdirect('locale', { locale: 'en-GB' }); ``` -------------------------------- ### Handle Widget Events with TypeScript Source: https://developer.btcdirect.eu/widget/handling-events Listen for custom events emitted by the BTC Direct widget using the native `window.addEventListener` method in TypeScript. Event details are available in `event.detail`. This example includes type casting for the event listener. ```typescript window.addEventListener('EVENT_NAME', ((event: CustomEvent) => { // Handle the event // Note that the sent information from the widget is found inside event.detail }) as EventListener); ``` -------------------------------- ### Initialize Onboarding Widget Source: https://developer.btcdirect.eu/widget/onboarding-form Embed this script to load the BTC Direct onboarding widget from the CDN and initialize it. Ensure a valid API key is provided for functionality. ```javascript (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/onboarding/onboarding.js' ); btcdirect('init', { token: 'API_KEY' }); ``` -------------------------------- ### Widget Initialization and Configuration Source: https://developer.btcdirect.eu/widget/buy-order-form This section details how to initialize the BTC Direct buy order form widget and configure its behavior using various parameters. It covers essential settings like providing wallet addresses, setting currencies, defining order information, and specifying payment methods. ```javascript // Example of initializing the widget with basic parameters const widget = new BTCDirectWidget({ partnerOrderId: 'YOUR_PARTNER_ORDER_ID', callbackUrl: 'YOUR_CALLBACK_URL', locale: 'en-US' }); // Example of setting additional parameters after initialization widget.setParameters({ currency: 'EUR', amount: 100, paymentMethod: 'ideal' }); // Example of providing wallet addresses widget.provideWalletAddresses({ bitcoin: 'YOUR_BITCOIN_ADDRESS', ethereum: 'YOUR_ETHEREUM_ADDRESS' }); ``` -------------------------------- ### Cancel Transaction Confirmation Source: https://developer.btcdirect.eu/widget/sell-order-form Cancels a transaction confirmation if the process cannot continue, for example, due to insufficient wallet funds or user cancellation. ```javascript btcdirect('coin-to-fiat-order-canceled'); ``` -------------------------------- ### Multiple Widgets Initialization Source: https://developer.btcdirect.eu/widget/common-questions-and-issues Demonstrates how to initialize multiple BTC Direct widgets (Buy and Sell) on a single page by assigning unique names and selectors to each widget instance. ```javascript buyWidget('init', { token: 'API_KEY', selector: 'buy-widget' }); sellWidget('init', { token: 'API_KEY', selector: 'sell-widget' }); ``` -------------------------------- ### Initialize and Set Order Information Source: https://developer.btcdirect.eu/widget/buy-order-form Initializes the BTC Direct widget with an API token and sets the basic information for a buy order, including currencies, amount, and type. This pre-fills the order form for users. ```javascript btcdirect('init', { token: 'API_KEY' }); btcdirect('order', { crypto: 'LTC', fiat: 'EUR', amount: 1, type: 'crypto' }); ``` -------------------------------- ### Set Widget Locale Source: https://developer.btcdirect.eu/widget/dca-form Sets the locale for the application, affecting how monetary values are displayed. For example, 'en-GB' displays '€0.00' while 'nl-NL' displays '€ 0,00'. ```javascript btcdirect('locale', { locale: 'en-GB' }); ``` -------------------------------- ### Embed and Initialize BTC Direct Widget Source: https://developer.btcdirect.eu/widget/buy-order-form This script loads the BTC Direct widget from their CDN and initializes it. It requires an API key for proper functionality. The script is designed to be embedded directly into an HTML page. ```javascript (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' }); ``` -------------------------------- ### Initialize BTC Direct DCA Widget Source: https://developer.btcdirect.eu/widget/dca-form Embed this script to load the BTC Direct DCA widget from the CDN and initialize it with your API key. Ensure a valid API key is provided for proper functionality. ```html ``` -------------------------------- ### Set Widget Parameters Source: https://developer.btcdirect.eu/widget/buy-order-form Allows prefilling fiat-to-coin order parameters such as base and quote currencies, amounts, payment methods, wallet addresses, and more. Most parameters are optional. The signature parameter is required if walletAddress, fee, returnUrl, or callbackUrl are provided. ```javascript btcdirect('set-parameters', { baseCurrency: 'BTC', quoteCurrency: 'EUR', baseCurrencyAmount: 0.001, quoteCurrencyAmount: 123, paymentMethod: 'creditCard', walletAddress: '3FZbgi29cpjq2GjdwV8eyHuJJnkLtktZc5', walletAddressTag: '1513155290', signature: '67890fghij', returnUrl: 'https://btcdirect.eu', callbackUrl: 'https://btcdirect.eu', partnerOrderIdentifier: '12345abcde', fee: 0.5, expiryDateTime: 1701423182, fixedAmount: true, fixedCurrency: true, fixedPaymentMethod: true, showWalletAddress: true }); ``` -------------------------------- ### Widget Integration for In-App Transactions Source: https://developer.btcdirect.eu/index Enable onramp and offramp solutions directly within your application using customizable widgets. These widgets manage user onboarding and transaction processes. ```APIDOC Widget Integration: Purpose: Embed onramp/offramp functionality within your application. Features: Customizable widgets, handles user onboarding, onramp, and offramp. Customization: Allows full control over UI and UX. ``` -------------------------------- ### Set Locale for Sell Order Widget Source: https://developer.btcdirect.eu/widget/sell-order-form Sets the locale for the sell order widget, which affects how monetary values are displayed. For example, it controls decimal separators and currency symbol placement. ```javascript btcdirect('locale', { locale: 'en-GB' }); ``` -------------------------------- ### Unified Checkout Integration Source: https://developer.btcdirect.eu/index Integrate BTC Direct's fiat-to-crypto onramp and crypto-to-fiat offramp solutions with minimal development effort. Users are redirected to a hosted checkout page. ```APIDOC Unified Checkout: Purpose: Facilitates seamless fiat-to-crypto and crypto-to-fiat transactions. Integration: Redirect users to a hosted checkout page. Benefits: Minimal development investment, hosted by BTC Direct. ``` -------------------------------- ### Supported Cryptocurrencies Source: https://developer.btcdirect.eu/index BTC Direct offers its onramp and offramp solutions for a variety of cryptocurrencies, providing flexibility for users. ```APIDOC Supported Crypto: Description: BTC Direct supports multiple cryptocurrencies for onramp and offramp services. Benefit: Offers users greater flexibility and caters to diverse needs. ``` -------------------------------- ### Multiple Widgets HTML Structure Source: https://developer.btcdirect.eu/widget/common-questions-and-issues Provides the HTML structure for displaying multiple BTC Direct widgets, using custom elements with unique selectors that correspond to the initialization parameters. ```html
``` -------------------------------- ### Turnkey API for Buy/Sell Crypto Source: https://developer.btcdirect.eu/index Utilize the turnkey API to allow users to buy and sell cryptocurrency without leaving your platform. This provides complete control over the user interface and experience. ```APIDOC Turnkey API: Purpose: Enables users to buy and sell crypto directly within your platform. Control: Full control over UI and UX. Functionality: Facilitates crypto transactions without external redirection. ``` -------------------------------- ### Buy Order Form (F2C) Widget Implementation Source: https://developer.btcdirect.eu/widget/buy-order-form This snippet demonstrates the basic HTML structure and JavaScript integration for embedding the BTC Direct buy order form widget. It includes the necessary script tag and a placeholder element for the widget. ```html BTC Direct Buy Widget
``` -------------------------------- ### OpenAPI Specification for Client Generation Source: https://developer.btcdirect.eu/api/faq BTC Direct provides an OpenAPI specification that can be used to generate API clients in various programming languages. This is an alternative to using language-specific SDKs. ```APIDOC OpenAPI Specification: Available for API V1 and V2. Purpose: Generate API clients for different programming languages. Reference: [API V1 documentation](https://developer.btcdirect.eu/api/v1/) Reference: [API V2 documentation](https://developer.btcdirect.eu/api/v2/) ``` -------------------------------- ### Provide Wallet Addresses Source: https://developer.btcdirect.eu/widget/method-calls Demonstrates how to pass wallet addresses and their currency to the BTC Direct widget using the 'wallet-addresses' method. This can be done synchronously or asynchronously. ```javascript btcdirect('init', { token: 'API_KEY' }); btcdirect('wallet-addresses', { addresses: { address: 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn', currency: 'BTC' } }); ``` ```javascript btcdirect('wallet-addresses', { addresses: { address: 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn', currency: 'BTC' } }); // or window.btcdirect('wallet-addresses', { addresses: { address: 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn', currency: 'BTC' } }); // or window['btcdirect']('wallet-addresses', { addresses: { address: 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn', currency: 'BTC' } }); ``` -------------------------------- ### Embed Transaction History Widget Source: https://developer.btcdirect.eu/widget/transaction-history This script loads the BTC Direct transaction history widget from a CDN and initializes it. It requires an API key for proper functionality and can be customized with optional parameters. ```html ``` -------------------------------- ### Widget Event Handling Source: https://developer.btcdirect.eu/widget/buy-order-form This section outlines the events emitted by the BTC Direct buy order form widget, allowing developers to react to user actions and widget status changes. It includes handling order confirmations and requests for wallet address confirmation. ```javascript // Example of handling the 'orderConfirmation' event widget.on('orderConfirmation', (event) => { console.log('Order confirmed:', event.detail); // Handle order confirmation logic here }); // Example of handling the 'walletConfirmationRequested' event widget.on('walletConfirmationRequested', (event) => { console.log('Wallet confirmation requested for:', event.detail.currency); // Implement logic to request wallet confirmation from the user }); // Example of handling other events like 'setParameters', 'locale', 'currencies', 'orderInformation', 'paymentMethod', 'callbackUrl', 'walletAddressConfirmation', 'skipOrderForm', 'includeDCA', 'partnerOrderIdentifier' widget.on('anyEvent', (event) => { console.log('Widget event:', event.type, event.detail); }); ``` -------------------------------- ### Widget Initialization Parameters Source: https://developer.btcdirect.eu/widget/init-call-parameters These are optional key-value pairs that can be passed during the widget's initialization to customize its functionality and appearance. They allow for fine-tuning aspects like DOM element selection, debugging output, language, and visual theme. ```APIDOC Key | Type | Description | Default ---|---|---|--- `selector` | `string` | The CSS selector of the HTML element to bind the order form to. | `.btcdirect-widget` `debug` | `boolean` | Setting this to ‘true’ enables more console logging for the widget. Recommended for development. | `false` `locale` | `string` | The locale to use. This is the same as used in [Locale](https://developer.btcdirect.eu/widget/method-calls.html#locale). | `en-GB` `theme` | `string` | The styling theme to use. Can either be `light` or `dark`. | `light` ``` -------------------------------- ### Set Widget Currencies Source: https://developer.btcdirect.eu/widget/buy-order-form Sets the initial selected cryptocurrency and fiat currency for the widget's order form. Links to lists of supported cryptocurrencies and fiat currencies are provided. ```javascript btcdirect('currencies', { crypto: 'BTC', fiat: 'EUR' }); ``` -------------------------------- ### Authenticate as a Partner (PHP) Source: https://developer.btcdirect.eu/unified-checkout Authenticates with the BTC Direct API to obtain a token and refresh token. Requires your API username and password. This call should be made from a backend server. ```PHP // Production: 'https://api.btcdirect.eu/api/v1/authenticate' // Sandbox: 'https://api-sandbox.btcdirect.eu/api/v1/authenticate' $endpoint = 'https://api-sandbox.btcdirect.eu/api/v1/authenticate'; // Create the body values $data = array( 'username' => 'USERNAME', 'password' => 'PASSWORD' ); $options = array( 'http' => array( 'header' => "Content-type: application/json\r\n", 'method' => 'POST', 'content' => json_encode($data, JSON_THROW_ON_ERROR), ), ); $context = stream_context_create($options); $response = file_get_contents($endpoint, false, $context); $result = json_decode($response, true); $token = $result['token']; $refreshToken = $result['refreshToken']; ``` -------------------------------- ### Create Checkout URL API Request Source: https://developer.btcdirect.eu/unified-checkout This snippet demonstrates how to make a POST request to the checkout endpoint to generate a checkout URL. It includes sample data for various parameters like currency, payment method, amounts, and callback URLs. The `TOKEN` in the Authorization header needs to be replaced with the actual token obtained from partner authentication. ```PHP 'BTC', 'quoteCurrency' => 'EUR', 'paymentMethod' => 'creditCard', 'baseCurrencyAmount' => 131, 'quoteCurrencyAmount' => null, 'returnUrl' => 'https://example.com/return', 'callbackUrl' => 'https://example.com/callback', 'partnerOrderIdentifier' => '123456789', 'walletAddress' => 'n4Pp8vCDNk8mZdGsckLhfycQdc7YZSPDrt', 'walletAddressTag' => null, 'expireTime' => '500', 'fixedAmount' => true, 'fixedCurrency' => true, 'fixedPaymentMethod' => true, 'showWalletAddress' => true ); $options = array( 'http' => array( 'header' => "Content-type: application/json\r\n" . "Authentication: bearer TOKEN" 'method' => 'POST', 'content' => json_encode($data, JSON_THROW_ON_ERROR) ) ); $context = stream_context_create($options); $response = file_get_contents($endpoint, false, $context); $result = json_decode($response, true); $checkoutUrl = $result['checkoutUrl']; ?> ``` ```NodeJS // Production: 'https://api.btcdirect.eu/api/v2/buy/checkout' // Sandbox: 'https://api-sandbox.btcdirect.eu/api/v2/buy/checkout' const endpoint = 'https://api-sandbox.btcdirect.eu/api/v2/buy/checkout'; // Call the authentication endpoint const response = await fetch(endpoint, { method: 'POST', headers: { "Authorization": "Bearer TOKEN", "Content-Type": "application/json" }, body: JSON.stringify({ 'baseCurrency': 'BTC', 'quoteCurrency': 'EUR', 'paymentMethod': 'creditCard', 'baseCurrencyAmount': 131, 'quoteCurrencyAmount': null, 'returnUrl': 'https://example.com/return', 'callbackUrl': 'https://example.com/callback', 'partnerOrderIdentifier': '123456789', 'walletAddress': 'n4Pp8vCDNk8mZdGsckLhfycQdc7YZSPDrt', 'walletAddressTag': null, 'expireTime': '500', 'fixedAmount': true, 'fixedCurrency': true, 'fixedPaymentMethod': true, 'showWalletAddress': true }) }); // Get the URL from the response const { checkoutUrl } = await response.json(); ``` -------------------------------- ### OpenAPI Specification V1 Source: https://developer.btcdirect.eu/api/v1 Provides the OpenAPI specification for version 1 of the BTC Direct API. This allows developers to understand and interact with the API's endpoints, parameters, and responses. ```APIDOC OpenAPI Specification V1: URL: https://developer.btcdirect.eu/api/v1/ ``` -------------------------------- ### Handle Order Confirmation Event Source: https://developer.btcdirect.eu/widget/buy-order-form Listens for the 'btcdirect-embeddable-fiat-to-coin-order-confirmed' event, which is emitted when a user confirms their order before being redirected to the payment page. The event provides details about the fiat currency, exchange amount, and order ID. ```javascript // event.detail: { currencyCode: 'iso:EUR', // The fiat currency code exchangeAmount: 100, // The fiat amount that will be paid orderId: '123456789'; // The order ID } ``` -------------------------------- ### OpenAPI Specification V2 Source: https://developer.btcdirect.eu/api/v1 Provides the OpenAPI specification for version 2 of the BTC Direct API. This allows developers to understand and interact with the API's endpoints, parameters, and responses. ```APIDOC OpenAPI Specification V2: URL: https://developer.btcdirect.eu/api/v2/ ``` -------------------------------- ### Attempt to Skip Order Form Source: https://developer.btcdirect.eu/widget/buy-order-form Enables skipping the initial order form if all required data (fiat/crypto amount, crypto currency, wallet address, payment method) is provided and valid. If data is missing or invalid, the user is notified. ```javascript btcdirect('attempt-direct-confirm', { enableAttemptDirectConfirm: true }); ``` -------------------------------- ### Set Callback URL Source: https://developer.btcdirect.eu/widget/buy-order-form Sets a callback URL to receive the result of an order. The status and ID of the order are appended as query parameters to this URL upon completion. ```javascript btcdirect('callback', { callbackUrl: 'https://btcdirect.eu' }); ``` -------------------------------- ### API Authentication with JWT Token Source: https://developer.btcdirect.eu/api/faq To authenticate with the API, you need to obtain a JWT token by calling the `/api/v1/authenticate` endpoint. This is the primary method for securing API access. ```APIDOC Endpoint: /api/v1/authenticate Method: POST (assumed) Description: Obtain a JWT token for API authentication. Parameters: Requires authentication credentials (e.g., username/password or API key). Returns: JWT token. ``` -------------------------------- ### Authenticate as a Partner (Node.js) Source: https://developer.btcdirect.eu/unified-checkout Authenticates with the BTC Direct API to obtain a token and refresh token. Requires your API username and password. This call should be made from a backend server. ```NodeJS // Production: 'https://api.btcdirect.eu/api/v1/authenticate' // Sandbox: 'https://api-sandbox.btcdirect.eu/api/v1/authenticate' const endpoint = 'https://api-sandbox.btcdirect.eu/api/v1/authenticate'; // Create the body values const data = { 'username': 'USERNAME', 'password': 'PASSWORD' } // Call the authentication endpoint const response = await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data), }); // Get the data from the response const { token, refreshToken } = await response.json(); ``` -------------------------------- ### Set Widget Locale Source: https://developer.btcdirect.eu/widget/onboarding-form This JavaScript call sets the locale for the BTC Direct widget, influencing how monetary values are displayed. For instance, the EN-GB locale formats '€0.00' while NL-NL uses '€ 0,00'. ```javascript btcdirect('locale', { locale: 'en-GB' }); ``` -------------------------------- ### OpenAPI Specification V2 Source: https://developer.btcdirect.eu/api/v2 This section details the OpenAPI specification for version 2 of the BTC Direct API. It outlines the structure and endpoints available for interacting with the API. ```APIDOC OpenAPI Specification V2: - Introduction: https://developer.btcdirect.eu/api/v2/ - Related: OpenAPI Introduction (https://developer.btcdirect.eu/api/open-api/) ``` -------------------------------- ### Confirm Wallet Address Source: https://developer.btcdirect.eu/widget/buy-order-form Sends a confirmation message to the widget when wallet confirmation is required. This is used after the user confirms the wallet address on their hardware wallet. ```javascript btcdirect('wallet-address-confirmation', { address: 'address' }); ``` -------------------------------- ### Embed BTC Direct Sell Order Form Widget Source: https://developer.btcdirect.eu/widget/sell-order-form This script loads the BTC Direct sell order form widget from the CDN and initializes it. It requires an API key for authentication and optionally accepts styling configurations. ```html ``` -------------------------------- ### Handle Wallet Confirmation Requested Event Source: https://developer.btcdirect.eu/widget/buy-order-form Emits the 'btcdirect-embeddable-wallet-address-confirmation-requested' event when the 'walletConfirmationRequired' setting is true. This event includes the ID of the selected wallet, useful for matching with provided wallet addresses. ```javascript // event.detail: { id: '123456789'; // The ID of the selected wallet } ``` -------------------------------- ### User Authentication Methods Source: https://developer.btcdirect.eu/api/guides/authenticating-users Provides an overview of user authentication methods, their scenarios, and required credentials. Currently, 'Email and password' is the supported method for traditional authentication and user identification via email. ```APIDOC Method | Scenario's | What is required | 📘 ---|---|---|--- Email and password | * When a user authenticates through an app or interface that requires traditional authentication. * You have email address information available and this used as a primary way to identify users. | * Email address * Password | [Read more](https://developer.btcdirect.eu/api/guides/authenticating-users/email-password.html) ``` -------------------------------- ### Handle Widget Events with JavaScript Source: https://developer.btcdirect.eu/widget/handling-events Listen for custom events emitted by the BTC Direct widget using the native `window.addEventListener` method in JavaScript. Event details are available in `event.detail`. ```javascript window.addEventListener('EVENT_NAME', (event) => { // Handle the event // Note that the sent information from the widget is found inside event.detail }); ``` -------------------------------- ### Checkout API Response Body Source: https://developer.btcdirect.eu/unified-checkout This JSON structure represents a successful response from the checkout endpoint. It includes the generated `checkoutUrl` for user redirection, along with a `signature`, `partner` details, and all the parameters that were sent in the request, confirming the order details. ```JSON { "checkoutUrl": "string", "signature": "string", "partner": "string", "baseCurrency": "string", "quoteCurrency": "string", "paymentMethod": "string", "returnUrl": "string", "callbackUrl": "string", "baseCurrencyAmount": 131, "quoteCurrencyAmount": null, "partnerOrderIdentifier": "string", "walletAddress": "string", "walletAddressTag": "string", "expireTime": "500", "fixedAmount": true, "fixedCurrency": true, "fixedPaymentMethod": true, "showWalletAddress": true } ``` -------------------------------- ### Set Partner Order Identifier for Buy Orders Source: https://developer.btcdirect.eu/widget/buy-order-form Assigns a custom identifier to a confirmed order, facilitating the mapping of widget-created orders with your internal systems. Note that all orders within the same session will receive the same identifier. ```javascript btcdirect('partner-order-identifier', { partnerOrderIdentifier: '12345abcde' }); ``` -------------------------------- ### Cancel Wallet Address Confirmation Source: https://developer.btcdirect.eu/widget/buy-order-form Sends a cancellation message to the widget to stop the wallet confirmation process and return the user to the order form. ```javascript btcdirect('wallet-address-confirmation-canceled'); ``` -------------------------------- ### Supported Cryptocurrencies Table Source: https://developer.btcdirect.eu/widget/supported-cryptocurrencies Displays a list of cryptocurrencies and their ticker symbols supported by BTC Direct widgets. ```APIDOC Cryptocurrency | Ticker ---|--- Bitcoin | BTC Bitcoin Cash | BCH Litecoin | LTC Ethereum | ETH Ripple | XRP Tether | USDT USD Coin | USDC Algorand | ALGO Chainlink | LINK Uniswap | UNI ```