Constructor
new LocalPayment(options)
Do not use this constructor directly. Use braintree-web.local-payment.create instead.
Parameters:
Name | Type | Description |
---|---|---|
options |
object |
Members
teardown
Cleanly remove anything set up by create.
Examples
localPaymentInstance.teardown();
localPaymentInstance.teardown(function () {
// teardown is complete
});
Methods
closeWindow() → {void}
Closes the LocalPayment window if it is open.
focusWindow() → {void}
Focuses the LocalPayment window if it is open.
hasTokenizationParams() → {Boolean}
Checks if required tokenizaiton parameters are available in querystring for manual toenization requests.
Example
// if query string contains
// ?btLpToken=token&btLpPaymentId=payment-id&btLpPayerId=payer-id
localPaymentInstance.hasTokenizationParams(); // true
// if query string is missing required params
localPaymentInstance.hasTokenizationParams(); // false
if (localPaymentInstance.hasTokenizationParams()) {
localPaymentInstance.tokenize();
}
startPayment(options, callbackopt) → {Promise|void}
Launches the local payment flow and returns a nonce payload. Only one local payment flow should be active at a time. One way to achieve this is to disable your local payment button while the flow is open.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
All options for initiating the local payment payment flow. Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
callback |
<optional> |
The second argument, |
Example
button.addEventListener('click', function () {
// Disable the button when local payment is in progress
button.setAttribute('disabled', 'disabled');
// Because startPayment opens a new window, this must be called
// as a result of a user action, such as a button click.
localPaymentInstance.startPayment({
paymentType: 'ideal',
fallback: {
buttonText: 'Return to Merchant',
url: 'https://example.com/my-checkout-page'
},
amount: '10.00',
currencyCode: 'EUR',
onPaymentStart: function (data, continueCallback) {
// Do any preprocessing before starting the flow
// data.paymentId is the ID of the localPayment
continueCallback();
}
}).then(function (payload) {
button.removeAttribute('disabled');
// Submit payload.nonce to your server
}).catch(function (startPaymentError) {
button.removeAttribute('disabled');
// Handle flow errors or premature flow closure
console.error('Error!', startPaymentError);
});
});
tokenize(paramsopt, callbackopt) → {Promise|void}
Manually tokenizes params for a local payment received from PayPal.When app switching back from a mobile application (such as a bank application for an iDEAL payment), the window may lose context with the parent page. In that case, a fallback url is used, and this method can be used to finish the flow.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object |
<optional> |
All options for tokenizing local payment parameters. If no params are passed in, the params will be pulled off of the query string of the page. Properties
|
||||||||||||
callback |
callback |
<optional> |
The second argument, |