GooglePayment

GooglePayment

This class represents a Google Payment component produced by braintree-web/google-payment.create. Instances of this class have methods for initializing the Google Pay flow.

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.

Constructor

new GooglePayment(options)

Do not use this constructor directly. Use braintree-web.google-payment.create instead.

Parameters:
Name Type Description
options object

Google Payment create options.

Source:

Methods

createPaymentDataRequest(overrides, merchantId, transactionInfo) → {object}

Create a configuration object for use in the loadPaymentData method.

Parameters:
Name Type Description
overrides object

The supplied parameters for creating the Payment Data Request object. Only required parameters are the merchantId provided by Google and a transactionInfo object, but any of the parameters in the Payment Data Request can be overwritten. See https://developers.google.com/payments/web/object-reference#PaymentDataRequest

merchantId string

The merchant id provided by registering with Google.

transactionInfo object

See https://developers.google.com/payments/web/object-reference#TransactionInfo for more information.

Source:
Example
var configuration = googlePaymentInstance.createPaymentDataRequest({
  merchantId: 'my-merchant-id-from-google',
  transactionInfo: {
    currencyCode: 'USD',
    totalPriceStatus: 'FINAL',
    totalPrice: '100.00'
  }
});
var paymentsClient = new google.payments.api.PaymentsClient({
  environment: 'TEST' // or 'PRODUCTION'
})

paymentsClient.loadPaymentData(paymentDataRequest).then(function (response) {
  // handle response with googlePaymentInstance.parseResponse
  // (see below)
});

parseResponse(response, callbackopt) → {Promise|void}

Parse the response from the tokenization.

Parameters:
Name Type Attributes Description
response object

The response back from the Google Pay tokenization.

callback callback <optional>

The second argument, data, is a tokenizePayload. If no callback is provided, parseResponse returns a promise that resolves with a tokenizePayload.

Source:
Examples
with callback
var paymentsClient = new google.payments.api.PaymentsClient({
  environment: 'TEST' // or 'PRODUCTION'
})

paymentsClient.loadPaymentData(paymentDataRequestFromCreatePaymentDataRequest).then(function (response) {
  googlePaymentInstance.parseResponse(response, function (err, data) {
    if (err) {
      // handle errors
    }
    // send parsedResponse.nonce to your server
  });
});
with promise
var paymentsClient = new google.payments.api.PaymentsClient({
  environment: 'TEST' // or 'PRODUCTION'
})

paymentsClient.loadPaymentData(paymentDataRequestFromCreatePaymentDataRequest).then(function (response) {
  return googlePaymentInstance.parseResponse(response);
}).then(function (parsedResponse) {
  // send parsedResponse.nonce to your server
}).catch(function (err) {
  // handle errors
});

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
googlePaymentInstance.teardown();

With callback

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

Type Definitions

tokenizePayload :object

Properties:
Name Type Description
nonce string

The payment method nonce.

details object

Additional account details.

Properties
Name Type Description
cardType string

Type of card, ex: Visa, MasterCard.

lastFour string

Last four digits of card number.

lastTwo string

Last two digits of card number.

description string

A human-readable description.

type string

The payment method type, CreditCard or AndroidPayCard.

binData object

Information about the card based on the bin.

Properties
Name Type Description
commercial string

Possible values: 'Yes', 'No', 'Unknown'.

countryOfIssuance string

The country of issuance.

debit string

Possible values: 'Yes', 'No', 'Unknown'.

durbinRegulated string

Possible values: 'Yes', 'No', 'Unknown'.

healthcare string

Possible values: 'Yes', 'No', 'Unknown'.

issuingBank string

The issuing bank.

payroll string

Possible values: 'Yes', 'No', 'Unknown'.

prepaid string

Possible values: 'Yes', 'No', 'Unknown'.

productId string

The product id.

Source: