Constructor
new Client(configuration)
Do not use this constructor directly. Use braintree.client.create instead.
Parameters:
Name | Type | Description |
---|---|---|
configuration |
Client~configuration | Options |
- Source:
Methods
getConfiguration() → {Client~configuration}
Returns a copy of the configuration values.
- Source:
request(options, callback) → {void}
Used by other modules to formulate all network requests to the Braintree gateway. It is also capable of being used directly from your own form to tokenize credit card information. However, be sure to satisfy PCI compliance if you use direct card tokenization.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | Request options: Properties
|
|||||||||||||||||||||||||
callback |
callback | The second argument, |
- Source:
Example
var createClient = require('braintree-web/client').create;
createClient({
authorization: CLIENT_AUTHORIZATION
}, function (createErr, clientInstance) {
var form = document.getElementById('my-form-id');
var data = {
creditCard: {
number: form['cc-number'].value,
cvv: form['cc-cvv'].value,
expirationDate: form['cc-date'].value,
billingAddress: {
postalCode: form['cc-postal'].value
},
options: {
validate: false
}
}
};
// Warning: For a merchant to be eligible for the easiest level of PCI compliance (SAQ A),
// payment fields cannot be hosted on your checkout page.
// For an alternative to the following, use Hosted Fields.
clientInstance.request({
endpoint: 'payment_methods/credit_cards',
method: 'post',
data: data
}, function (requestErr, response) {
// More detailed example of handling API errors: https://codepen.io/braintree/pen/MbwjdM
if (requestErr) { throw new Error(requestErr); }
console.log('Got nonce:', response.creditCards[0].nonce);
});
});
Type Definitions
configuration :object
This object is returned by getConfiguration. This information is used extensively by other Braintree modules to properly configure themselves.
Properties:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
client |
object | The braintree-web/client parameters. Properties
|
||||||||||||
gatewayConfiguration |
object | Gateway-supplied configuration. |
||||||||||||
analyticsMetadata |
object | Analytics-specific data. Properties
|
- Source: