Braintree Web Drop-in provides a pre-built, customizable user interface for accepting various payment methods (cards, Apple Pay, Google Pay, Venmo) in web applications. It simplifies the integration of Braintree's payment processing services by offering a ready-to-use UI component. The current stable version is 1.46.1. The library typically sees minor releases every few weeks, incorporating updates to the underlying Braintree JavaScript client SDK, adding new payment methods, improving accessibility, and fixing bugs. Key differentiators include its ease of integration for common payment flows, out-of-the-box support for multiple payment methods, localization into 23 languages, and its open-source nature, allowing for significant UI customization if needed, unlike traditional iframe-based solutions. It abstracts away much of the complexity of direct SDK integration for standard use cases, accelerating development.
npm install braintree-web-drop-inVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Braintree Drop-in UI, configure it to require a cardholder name, and retrieve a payment method nonce when a button is clicked, suitable for server-side processing.
Consult the `braintree-web` changelog and Braintree developer documentation for specific migration guides.
Ensure the `authorization` value (client token or client authorization) is fresh, valid, and generated securely on your server for the current session. Do not hardcode client tokens.
Ensure the `requestPaymentMethod` call is triggered by user interaction (e.g., clicking a 'Pay with Apple Pay' or 'Pay with Venmo' button within the Drop-in UI, or a submit button after the user has selected one of these methods).
Refer to the Braintree documentation for the most up-to-date and complete CSP directives required for all integrated payment methods. Specifically check `script-src`, `style-src`, `img-src`, `connect-src`, and `frame-src`.
Upgrade to the latest `braintree-web-drop-in` version (v1.x) for improved customization, modern UI, and better integration with site styling. Refactor any styling assumptions based on iframe encapsulation.
Regenerate a new client token on your server using your Braintree API keys and ensure it is passed correctly to the `authorization` option during Drop-in creation.
Update your server's CSP headers or `<meta>` tag to include the necessary domains for Braintree, Google Pay, Apple Pay, etc., as specified in the official Braintree documentation.
Verify that the HTML element specified by the `selector` (e.g., `<div id="dropin-container"></div>`) exists in the DOM before `dropin.create` is called and that the selector string matches its ID or class.
Ensure your development and production environments are served over HTTPS. For local development, enable specific browser flags or use tools that provide a secure local context if possible, though HTTPS is generally required for production.