braintree-web/payment-request

A component to integrate with the Payment Request API.

Note: This component is currently in beta and the API may include breaking changes when upgrading. Please review the Changelog for upgrade steps whenever you upgrade the version of braintree-web.

Source:

Members

(static) VERSION :string

The current version of the SDK, i.e. 3.112.0.

Source:

Methods

(static) create(options, callbackopt) → {Promise|void}

Parameters:
Name Type Attributes Description
options object

Creation options:

Properties
Name Type Attributes Default Description
client Client <optional>

A Client instance.

authorization string <optional>

A tokenizationKey or clientToken. Can be used in place of options.client.

enabledPaymentMethods object <optional>

An object representing which payment methods to display.

Properties
Name Type Attributes Default Description
basicCard boolean <optional>
true

Whether or not to display credit card as an option in the Payment Request dialog. If left blank or set to true, credit cards will be displayed in the dialog if the merchant account is set up to process credit cards.

googlePay boolean <optional>
true

Whether or not to display Google Pay as an option in the Payment Request dialog. If left blank or set to true, Google Pay will be displayed in the dialog if the merchant account is set up to process Google Pay.

googlePayVersion Number <optional>
1

Ignored if options.enabledPaymentMethods.googlePay = false. If true, this option specifies the version of Google Pay to use. Choose either 1 (default) or 2.

callback callback <optional>

The second argument, data, is the PaymentRequestComponent instance. If no callback is provided, create returns a promise that resolves with the PaymentRequestComponent instance.

Source:
Examples
if (window.PaymentRequest) {
  braintree.paymentRequest.create({
    client: clientInstance
  }, cb);
} else {
  // fall back to Hosted Fields if browser does not support Payment Request API
  braintree.hostedFields.create(hostedFieldsOptions, cb);
}

Explicitly turning off credit cards from Payment Request API dialog

braintree.paymentRequest.create({
  client: clientInstance,
  enabledPaymentMethods: {
    googlePay: true,
    basicCard: false
  }
}, cb);

Using Google Pay v2 or basic card

braintree.paymentRequest.create({
  client: clientInstance,
  enabledPaymentMethods: {
    basicCard: true,
    googlePay: true
  },
  googlePayVersion: 2
}, cb);