Constructor
new Masterpass(options)
You cannot use this constructor directly. Use braintree.masterpass.create instead.
Parameters:
Name | Type | Description |
---|---|---|
options |
object |
- Source:
Methods
teardown(callbackopt) → {Promise|void}
Cleanly tear down anything set up by create.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
callback |
<optional> |
Called on completion. If no callback is provided, |
Examples
masterpassInstance.teardown();
masterpassInstance.teardown(function () {
// teardown is complete
});
tokenize(options, callbackopt) → {Promise|void}
Launches the Masterpass flow and returns a nonce payload. Only one Masterpass flow should be active at a time. One way to achieve this is to disable your Masterpass button while the flow is open.
Braintree will apply these properties in options.config
. Merchants should not override these values, except for advanced usage.
environment
requestToken
callbackUrl
merchantCheckoutId
allowedCardTypes
version
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | All options for initiating the Masterpass payment flow. Properties
|
|||||||||||||||||||||||||||||||||||||||||
callback |
callback |
<optional> |
The second argument, |
Example
button.addEventListener('click', function () {
// Disable the button so that we don't attempt to open multiple popups.
button.setAttribute('disabled', 'disabled');
// Because tokenize opens a new window, this must be called
// as a result of a user action, such as a button click.
masterpassInstance.tokenize({
currencyCode: 'USD',
subtotal: '10.00'
}).then(function (payload) {
button.removeAttribute('disabled');
// Submit payload.nonce to your server
}).catch(function (tokenizeError) {
button.removeAttribute('disabled');
// Handle flow errors or premature flow closure
switch (tokenizeErr.code) {
case 'MASTERPASS_POPUP_CLOSED':
console.error('Customer closed Masterpass popup.');
break;
case 'MASTERPASS_ACCOUNT_TOKENIZATION_FAILED':
console.error('Masterpass tokenization failed. See details:', tokenizeErr.details);
break;
case 'MASTERPASS_FLOW_FAILED':
console.error('Unable to initialize Masterpass flow. Are your options correct?', tokenizeErr.details);
break;
default:
console.error('Error!', tokenizeErr);
}
});
});
Type Definitions
Address :object
Masterpass Address object.
Properties:
Name | Type | Description |
---|---|---|
countryCodeAlpha2 |
string | The customer's country code. |
extendedAddress |
string | The customer's extended address. |
locality |
string | The customer's locality. |
postalCode |
string | The customer's postal code. |
region |
string | The customer's region. |
streetAddress |
string | The customer's street address. |
- Source:
tokenizePayload :object
Properties:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
nonce |
string | The payment method nonce. |
|||||||||||||||
description |
string | The human readable description. |
|||||||||||||||
type |
string | The payment method type, always |
|||||||||||||||
details |
object | Additional account details. Properties
|
|||||||||||||||
contact |
object | The customer's contact information. Properties
|
|||||||||||||||
billingAddress |
Masterpass~Address | The customer's billing address. |
|||||||||||||||
shippingAddress |
Masterpass~Address | The customer's shipping address. |
- Source: