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 |
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, |
- 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: