Methods
teardown(callbackopt) → {Promise|void}
Cleanly tear down anything set up by create.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
callback |
<optional> |
Called once teardown is complete. No data is returned if teardown completes successfully. |
Examples
usBankAccountInstance.teardown();
usBankAccountInstance.teardown(function () {
// teardown is complete
});
tokenize(options, callbackopt) → {Promise|void}
Tokenizes bank information to return a payment method nonce. You can tokenize bank details by providing information like account and routing numbers. You can also tokenize with a bank login UI that prompts the customer to log into their bank account.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
All tokenization options for the US Bank Account component. Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
callback |
<optional> |
The second argument, |
Examples
var routingNumberInput = document.querySelector('input[name="routing-number"]');
var accountNumberInput = document.querySelector('input[name="account-number"]');
var accountTypeInput = document.querySelector('input[name="account-type"]:checked');
var ownershipTypeInput = document.querySelector('input[name="ownership-type"]:checked');
var firstNameInput = document.querySelector('input[name="first-name"]');
var lastNameInput = document.querySelector('input[name="last-name"]');
var businessNameInput = document.querySelector('input[name="business-name"]');
var billingAddressStreetInput = document.querySelector('input[name="street-address"]');
var billingAddressExtendedInput = document.querySelector('input[name="extended-address"]');
var billingAddressLocalityInput = document.querySelector('input[name="locality"]');
var billingAddressRegionSelect = document.querySelector('select[name="region"]');
var billingAddressPostalInput = document.querySelector('input[name="postal-code"]');
submitButton.addEventListener('click', function (event) {
var bankDetails = {
routingNumber: routingNumberInput.value,
accountNumber: accountNumberInput.value,
accountType: accountTypeInput.value,
ownershipType: ownershipTypeInput.value,
billingAddress: {
streetAddress: billingAddressStreetInput.value,
extendedAddress: billingAddressExtendedInput.value,
locality: billingAddressLocalityInput.value,
region: billingAddressRegionSelect.value,
postalCode: billingAddressPostalInput.value
}
};
if (bankDetails.ownershipType === 'personal') {
bankDetails.firstName = firstNameInput.value;
bankDetails.lastName = lastNameInput.value;
} else {
bankDetails.businessName = businessNameInput.value;
}
event.preventDefault();
usBankAccountInstance.tokenize({
bankDetails: bankDetails,
mandateText: 'I authorize Braintree to debit my bank account on behalf of My Online Store.'
}, function (tokenizeErr, tokenizedPayload) {
if (tokenizeErr) {
console.error('There was an error tokenizing the bank details.');
return;
}
// Send tokenizePayload.nonce to your server here!
});
});
var ownershipTypeInput = document.querySelector('input[name="ownership-type"]:checked');
var firstNameInput = document.querySelector('input[name="first-name"]');
var lastNameInput = document.querySelector('input[name="last-name"]');
var businessNameInput = document.querySelector('input[name="business-name"]');
var billingAddressStreetInput = document.querySelector('input[name="street-address"]');
var billingAddressExtendedInput = document.querySelector('input[name="extended-address"]');
var billingAddressLocalityInput = document.querySelector('input[name="locality"]');
var billingAddressRegionSelect = document.querySelector('select[name="region"]');
var billingAddressPostalInput = document.querySelector('input[name="postal-code"]');
bankLoginButton.addEventListener('click', function (event) {
var bankLogin = {
displayName: 'My Online Store',
ownershipType: ownershipTypeInput.value,
billingAddress: {
streetAddress: billingAddressStreetInput.value,
extendedAddress: billingAddressExtendedInput.value,
locality: billingAddressLocalityInput.value,
region: billingAddressRegionSelect.value,
postalCode: billingAddressPostalInput.value
}
}
event.preventDefault();
if (bankLogin.ownershipType === 'personal') {
bankLogin.firstName = firstNameInput.value;
bankLogin.lastName = lastNameInput.value;
} else {
bankLogin.businessName = businessNameInput.value;
}
usBankAccountInstance.tokenize({
bankLogin: bankLogin,
mandateText: 'I authorize Braintree to debit my bank account on behalf of My Online Store.'
}, function (tokenizeErr, tokenizedPayload) {
if (tokenizeErr) {
console.error('There was an error tokenizing the bank details.');
return;
}
// Send tokenizePayload.nonce to your server here!
});
});
Type Definitions
tokenizePayload :object
Properties:
Name | Type | Description |
---|---|---|
nonce |
string |
The payment method nonce. |
type |
string |
The payment method type, always |
details |
object |
Additional account details. Currently empty. |