BraintreeUtils

BraintreeUtils

new BraintreeUtils(token)

Helper utility class that parses a given encoded token object corresponding to an Braintree account and provides info about account settings like 3DS and AVS support, errors, etc

Parameters:
Name Type Description
token string

The base64 token that encapsulates the Braintree account settings.

Version:
  • 1.0
Since:
  • 1.0
Author:
License:
Source:

Methods

decodeToken(token) → {Object}

Decode a base64 Braintree encoded JSON-formatted token

Parameters:
Name Type Description
token string

The base64 Braintree encoded token

Since:
  • 1.0
Source:
Returns:

Returns a JSON object containing the info encoded within the given token on success, FALSE otherwise

Type
Object

getAccountSettings(key) → {boolean|Object}

Get the Braintree settings value associated with the given key.

Parameters:
Name Type Description
key string

The key which value is to be returned. To specify a nested key use the dot notation.

Since:
  • 1.0
Source:
Returns:

Returns the value associate with the key on success, false otherwise

Type
boolean | Object
Example
myBUtilInstance.getAccountSettings("paypal.currencyIsoCode"); // return "USD"

getAVSChallenges(valueopt) → {boolean|Array.<string>}

Check if the Braintree settings defines the given AVS rule name.

Parameters:
Name Type Attributes Description
value string <optional>

The Braintree AVS challange name to check

Since:
  • 1.0
Source:
Returns:

When value argument specified returns true|false if the value argument is within the Braintree AVS challanges, otherwise returns an array of Braintree AVS challanges

Type
boolean | Array.<string>

is3DSEnabled() → {boolean}

Check if the Braintree settings has 3DS enabled.

Since:
  • 1.0
Source:
Returns:
  • Returns TRUE on success, FALSE otherwise
Type
boolean

parseError(err) → {string}

Parse a Braintree.js v2|v3 SDK error and return a complete error message

Parameters:
Name Type Description
err string | Object

The error string|object to parse. When an Object is provided then it should be compatible with Braintree.js error.

Since:
  • 1.0
Source:
Returns:

Returns an error message for the given input argument

Type
string

toBoolean(value) → {boolean}

Convert the given argument to its true boolean value.

Parameters:
Name Type Description
value string | number | boolean

A boolean string value, a boolean value or a numeric value

Since:
  • 1.0
Source:
Returns:

Returns the true boolean value of argument

Type
boolean
Example
BraintreeUtils.toBoolean("false"); // returns FALSE

BraintreeUtils.toBoolean(true); // returns TRUE

BraintreeUtils.toBoolean(1); // returns TRUE