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
createSupportedPaymentMethodsConfiguration(overridesopt) → {object}
Create an object to pass into the tokenize
method to specify a custom configuration. If no overrides are provided, the default configuration will be used in tokenize
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
overrides |
object |
<optional> |
The configuration overrides for the data property on the supported payment methods objects. This object will be merged with the default configuration object based on the settings in the Braintree Gateway. If no object is passed in, the default configuration object will be returned. |
- Source:
Examples
var configuration = googlePaymentInstance.createSupportedPaymentMethodsConfiguration();
configuration.supportedMethods; // ['https://google.com/pay']
configuration.data.allowedCardNetworks; // ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'] <- whatever the supported card networks for the merchant account are
var configuration = googlePaymentInstance.createSupportedPaymentMethodsConfiguration({
merchantName: 'My Custom Merchant Account Name',
allowedCardNetworks: ['VISA']
});
configuration.data.merchantName; // 'My Custom Merchant Account Name'
configuration.data.allowedCardNetworks; // ['VISA']
tokenize(configuration, callbackopt) → {Promise|void}
Initializes a Pay with Google flow and provides a nonce payload.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
configuration |
object |
The payment details. Properties
|
|||||||||||||
callback |
callback |
<optional> |
The second argument, |
- Source:
Examples
googlePaymentInstance.tokenize({
details: {
total: {
label: 'Price',
amount: {
currency: 'USD',
value: '100.00'
}
}
}
}).then(function (payload) {
// send payload.nonce to server
}).catch(function (err) {
if (err.code === 'PAYMENT_REQUEST_CANCELED') {
// Pay with Google payment request was canceled by user
} else {
// an error occurred while processing
}
});
googlePaymentInstance.tokenize({
details: {
total: {
label: 'Price',
amount: {
currency: 'USD',
value: '100.00'
}
}
},
options: {
requestPayerName: true,
requestPayerPhone: true,
requestPayerEmail: true
}
}).then(function (payload) {
// Send payload.nonce to your server
// Examine additional info in the raw payment response
console.log(payload.details.rawPaymentResponse);
});
googlePaymentInstance.tokenize({
supportedPaymentMethods: googlePaymentInstance.createSupportedPaymentMethodsConfiguration({merchantName: 'Custom Name'}),
details: {
total: {
label: 'Price',
amount: {
currency: 'USD',
value: '100.00'
}
}
},
options: {
requestPayerName: true,
requestPayerPhone: true,
requestPayerEmail: true
}
}).then(function (payload) {
// Send payload.nonce to your server
// Examine additional info in the raw payment response
console.log(payload.details.rawPaymentResponse);
});