JavaScript v2
Configuration for braintree.setup
Braintree.js integrations are created with braintree.setup
.
- JavaScript
braintree.setup(authorization, integrationType, options)
Argument | Type | Value |
---|---|---|
authorization |
string |
A string representing your client token or tokenization key |
integrationType |
string |
'dropin' or 'custom' |
options |
Object |
An options object. See Setup options for more details. |
Setup method options
All available options which can be passed to the braintree.setup
method, under the options
object. These are independent from the options specific to the two supported integration types, Drop-in and Custom.
Key | Integration | Type | Value | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
paypal |
any | Object |
See PayPal options. | ||||||||||
dataCollector |
any | Object |
See Premium Fraud Management Tools. | ||||||||||
enableCORS |
any | boolean |
Enabling this allows Braintree.js to use AJAX with CORS to make requests instead of JSONP. If you are using a Content Security Policy, you may need to tweak your directives to allow Braintree.js to communicate from your webpage. See Using Braintree.js with a Content Security Policy. | ||||||||||
onReady |
any | function | This callback is called when the Braintree integration is ready. It is called with one object that represents the integration. It has the following properties:
| ||||||||||
onPaymentMethodReceived |
any | function | This callback is called after the successful tokenization of a payment method.
| ||||||||||
paymentMethodNonceReceived |
Drop-in | function | This callback is deprecated in favor of | ||||||||||
onError |
any | function | Called when an error occurs. This typically happens when you have a configuration error but can also happen when there is a failure in tokenization. The error object provides two keys:
| ||||||||||
container |
Drop-in | string |
The ID of the container that Drop-in should be placed into. This field is required for Drop-in. | ||||||||||
id |
Custom | string |
The ID of the form that Custom should be placed into. This field is required for Custom. | ||||||||||
hostedFields |
Custom | Object |
See Hosted Fields options. | ||||||||||
defaultFirst |
Drop-in | boolean |
When you specify a customerID that has vaulted payment methods associated with it, Drop-in displays a list of those payment methods and automatically pre-selects the one used most recently. If you pass defaultFirst , Drop-in will instead pre-select the payment method marked as default for the customer. Learn more about marking payment methods as default when creating a customer or creating a payment method. |
onPaymentMethodReceived
details
object
When the onPaymentMethodReceived
callback is passed as part of the options
parameter in braintree.setup
, the callback returns a details
object. The contents of the details
object vary depending on the type of payment method.
Credit card
A credit card will return basic information about the card used. This is generally useful when updating your UI to reflect the card type used.
Key | Type | Value |
---|---|---|
cardType | string | The type of card used. Can be 'Visa' , 'Mastercard' , 'Discover' , 'American Express' , 'UnionPay' , or 'JCB' . |
lastTwo | string | The last two digits of the supplied card |
PayPal
PayPal responses will contain the following:
Key | Type | Value |
---|---|---|
billingAddress |
object | Returns the customer's billing address with the following properties:
This option is not available to all merchants. Contact PayPal Support for details on eligibility and enabling this information. |
email |
string |
Email address associated with the customer's PayPal account. |
firstName |
string |
First name associated with the customer's PayPal account. |
lastName |
string |
Last name associated with the customer's PayPal account. |
payerId |
string |
Unique ID associated with the customer's PayPal account. |
phone |
string |
Phone number associated with the customer's PayPal account. This is only available if the option is enabled in your PayPal business account. |
shippingAddress |
object | Returns the customer's shipping address along with the following properties:
|