JavaScript Client Reference v3.0.0-beta.8

Overview

The Braintree JavaScript SDK is split up into several modules. Each module is also represented by a class encapsulating the actions that module can perform. In general, each SDK feature is represented by its own standalone module. You can include as many or as few of these modules in your page depending on the Braintree features you will be using.

Each module exports a create function which is responsible for returning an instance of that module's class. For instance, the braintree-web/paypal module's create method will return an instance of the PayPal class.

Module hierarchy

Many modules of this SDK require an instance of our Client for communicating to our servers. In these cases, a single Client instance can be used for the creation of several other module instances.

braintree.client.create(...) --------> Client ─┐
                         ┌─────────────────────┤
braintree.paypal.create(...) --------> PayPal  │
                               ┌───────────────┘
braintree.hostedFields.create(...) --> HostedFields

Callbacks

This SDK uses the Node.js callback style, with callbacks passed as the last argument to a function. Callbacks are expected to receive possible errors as the first parameter, and any returned data as the second:

braintree.client.create({...}, callback);

function callback(err, clientInstance) { ... }

While we do not directly support promises, many promise libraries such as bluebird allow for automatic conversion of APIs that follow this callback style.

Browser support

braintree.js provides support for numerous browsers and devices. There are, however, caveats with certain integrations and browser combinations.

While braintree.js will work in browsers other than the ones below, these represent the platforms against which we actively test. If you have problems with a specific browser or device, contact our Support team.

Desktop

  • Internet Explorer 9+
  • Microsoft Edge
  • Firefox latest
  • Chrome latest
  • Safari 8+

Internet Explorer Quirks Mode

Quirks Mode is not supported for any version of IE. See our general best practices to learn more.

Mobile

iOS

  • Safari 8+
  • Chrome 48+ (iOS 9+)

Android

  • Native browser 4.4+
  • Chrome
  • Firefox

Webviews

Webviews on iOS and Android will be supported in the final release of the SDK but are not supported during the beta. PayPal is not supported in webviews on Android versions lower than 4.4 and will not be.

Additionally, braintree.js is neither tested nor developed for compile-to-native runtimes such as Cordova and PhoneGap. While some success may be had in such environments, our SDK is optimized for the browser and its security policies and may not function correctly outside of them.