Constructor
new Venmo(options)
Do not use this constructor directly. Use braintree-web.venmo.create instead.
Parameters:
Name | Type | Description |
---|---|---|
options |
object |
The Venmo create options. |
- Source:
Methods
hasTokenizationResult() → {boolean}
Returns a boolean indicating whether a Venmo tokenization result is ready to be processed immediately.
This method should be called after initialization to see if the result of Venmo authorization is available. If it returns true, call tokenize immediately to process the results.
- Source:
isBrowserSupported() → {boolean}
Returns a boolean indicating whether the current browser supports Venmo as a payment method.
If options.allowNewBrowserTab
is false when calling venmo.create, this method will return true only for browsers known to support returning from the Venmo app to the same browser tab. Currently, this is limited to iOS Safari and Android Chrome.
If options.allowWebviews
is false when calling venmo.create, this method will return true only for mobile browsers that are not webviews.
- Source:
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. |
- Source:
tokenize(optionsopt, callbackopt) → {Promise|void}
Launches the Venmo flow and returns a nonce payload.
If hasTokenizationResult returns true, calling tokenize will immediately process and return the results without initiating the Venmo payment authorization flow.
Only one Venmo flow can be active at a time. One way to achieve this is to disable your Venmo button while the flow is open.
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Options for tokenization. Properties
|
||||||||||
callback |
callback |
<optional> |
The second argument, |
- Source:
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.
venmoInstance.tokenize().then(function (payload) {
// Submit payload.nonce to your server
// Use payload.username to get the Venmo username and display any UI
}).catch(function (tokenizeError) {
// Handle flow errors or premature flow closure
switch (tokenizeErr.code) {
case 'VENMO_APP_CANCELED':
console.log('User canceled Venmo flow.');
break;
case 'VENMO_CANCELED':
console.log('User canceled Venmo, or Venmo app is not available.');
break;
default:
console.error('Error!', tokenizeErr);
}
}).then(function () {
button.removeAttribute('disabled');
});
});
(inner) cancelTokenization() → {Promise|void}
Cancels the venmo tokenization process
- Source:
Example
venmoTokenizeButton.addEventListener('click', function () {
venmoInstance.tokenize().then(function (payload) {
// handle payload
}).catch(function (err) {
if (err.code === 'VENMO_TOKENIZATION_CANCELED_BY_MERCHANT') {
// tokenization was canceled by calling cancelTokenization
}
});
});
venmoCancelButton.addEventListener('click', function () {
// Hide the button when the venmo flow is not in progress
venmoCancelButton.style.display = "none";
venmoInstance.cancelTokenization().then(function () {
// done canceling the flow
}).catch(function (err) {
// should only get here if there is no tokenization in progress
});
});
Type Definitions
tokenizePayload :object
Venmo tokenize payload.
Properties:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
nonce |
string |
The payment method nonce. |
|||||||||
type |
string |
The payment method type, always |
|||||||||
details |
object |
Additional Venmo account details. Properties
|
- Source: