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:
Returns:
configuration
- Type
- Client~configuration
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 |
errback | The second argument, |
- Source:
Returns:
- Type
- void
Example
Direct Credit Card Tokenization
var createClient = require('braintree-web/client').create;
createClient({
authorization: CLIENT_TOKEN
}, function (err, client) {
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
}
}
};
client.request({
endpoint: 'payment_methods/credit_cards',
method: 'post',
data: data
}, function (err, response) {
if (err) { throw new Error(err); }
console.log('Got nonce:', response.creditCards[0].nonce);
});
});
teardown(callback) → {void}
Cleanly tear down anything set up by create
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
errorCallback | An errback |
- Source:
Returns:
- Type
- void
Type Definitions
configuration
This object is returned by getConfiguration. This information is used extensively by other Braintree modules to properly configure themselves.
Type:
- Object
Properties:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
client |
Object | braintree/client parameters Properties
|
||||||||||||
gatewayConfiguration |
Object | Gateway-supplied configuration |
||||||||||||
analyticsMetadata |
Object | Analytics-specific data Properties
|
- Source: