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) → {object|Promise}
Create a configuration object for use in the loadPaymentData
method.
Note: Version 1 of the Google Pay Api is deprecated and will become unsupported in a future version. Until then, version 1 will continue to be used by default, and version 1 schema parameters and overrides will remain functional on existing integrations. However, new integrations and all following examples will be presented in the GooglePay version 2 schema. See Google Pay's upgrade guide to see how to update your integration.
If options.googlePayVersion === 2
was set during the initial create call, overrides must match the Google Pay v2 schema to be valid.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
overrides |
object |
The supplied parameters for creating the PaymentDataRequest object. Required parameters are: Properties
|
- Source:
Examples
var paymentDataRequest = googlePaymentInstance.createPaymentDataRequest({
merchantInfo: {
merchantId: 'my-merchant-id-from-google'
},
transactionInfo: {
currencyCode: 'USD',
totalPriceStatus: 'FINAL',
totalPrice: '100.00'
}
});
// Update card payment methods to require billing address
var cardPaymentMethod = paymentDataRequest.allowedPaymentMethods;
cardPaymentMethod.parameters.billingAddressRequired = true;
cardPaymentMethod.parameters.billingAddressParameters = {
format: 'FULL',
phoneNumberRequired: true
};
var paymentsClient = new google.payments.api.PaymentsClient({
environment: 'TEST' // or 'PRODUCTION'
})
paymentsClient.loadPaymentData(paymentDataRequest).then(function (response) {
// handle response with googlePaymentInstance.parseResponse
// (see below)
});
googlePaymentInstance.createPaymentDataRequest({
merchantInfo: {
merchantId: 'my-merchant-id-from-google'
},
transactionInfo: {
currencyCode: 'USD',
totalPriceStatus: 'FINAL',
totalPrice: '100.00'
}
}).then(function (paymentDataRequest) {
// Update card payment methods to require billing address
var cardPaymentMethod = paymentDataRequest.allowedPaymentMethods;
cardPaymentMethod.parameters.billingAddressRequired = true;
cardPaymentMethod.parameters.billingAddressParameters = {
format: 'FULL',
phoneNumberRequired: true
};
var paymentsClient = new google.payments.api.PaymentsClient({
environment: 'TEST' // or 'PRODUCTION'
})
return 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, |
- 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();
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
|
||||||||||||||||||||||||||||||
description |
string |
A human-readable description. |
||||||||||||||||||||||||||||||
type |
string |
The payment method type, |
||||||||||||||||||||||||||||||
binData |
object |
Information about the card based on the bin. Properties
|
- Source: