Venmo

Venmo

This class represents a Venmo component produced by braintree-web/venmo.create. Instances of this class have methods for tokenizing Venmo payments.

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.

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:
Examples
venmoInstance.teardown();

With callback

venmoInstance.teardown(function () {
  // teardown is complete
});

tokenize(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
callback callback <optional>

The second argument, data, is a tokenizePayload. If no callback is provided, the method will return a Promise that resolves with a tokenizePayload.

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');
  });
});

Type Definitions

tokenizePayload :object

Venmo tokenize payload.

Properties:
Name Type Description
nonce string

The payment method nonce.

type string

The payment method type, always VenmoAccount.

details object

Additional Venmo account details.

Properties
Name Type Description
username string

Username of the Venmo account.

Source: