### 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