Skip to main content

BraintreePlugin

This plugin enables payments to be processed by Braintree, a popular payment provider.

Requirements

  1. You will need to create a Braintree sandbox account as outlined in https://developers.braintreepayments.com/start/overview.
  2. Then install braintree and @types/braintree from npm. This plugin was written with v3.x of the Braintree lib.
    Shell
    or

Setup

  1. Add the plugin to your VendureConfig plugins array:
    Ts
  2. Create a new PaymentMethod in the Admin UI, and select "Braintree payments" as the handler.
  3. Fill in the Merchant ID, Public Key & Private Key from your Braintree sandbox account.

Storefront usage

The plugin is designed to work with the Braintree drop-in UI. This is a library provided by Braintree which will handle the payment UI for you. You can install it in your storefront project with:

The high-level workflow is:

  1. Generate a "client token" on the server by executing the generateBraintreeClientToken mutation which is exposed by this plugin.
  2. Use this client token to instantiate the Braintree Dropin UI.
  3. Listen for the "paymentMethodRequestable" event which emitted by the Dropin.
  4. Use the Dropin's requestPaymentMethod() method to get the required payment metadata.
  5. Pass that metadata to the addPaymentToOrder mutation. The metadata should be an object of type { nonce: string; }

Here is an example of how your storefront code will look. Note that this example is attempting to be framework-agnostic, so you'll need to adapt it to fit to your framework of choice.

Ts

Storing payment details (vaulting)

Braintree has a vault feature which allows the secure storage of customer's payment information. Using the vault allows you to offer a faster checkout for repeat customers without needing to worry about how to securely store payment details.

To enable this feature, set the storeCustomersInBraintree option to true.

Ts

Since v1.8, it is possible to override vaulting on a per-payment basis by passing includeCustomerId: false to the generateBraintreeClientToken mutation:

GraphQL

as well as in the metadata of the addPaymentToOrder mutation:

Ts
Signature

options

init

method(options: BraintreePluginOptions) => Type<BraintreePlugin>
Was this chapter helpful?
Report Issue
Edited Mar 31, 2026ยทEdit this page