Constructor
new PaymentRequestComponent(options)
Do not use this constructor directly. Use braintree-web.payment-request.create instead.
Parameters:
Name | Type | Description |
---|---|---|
options |
object |
The Payment Request Component create options. |
Methods
createSupportedPaymentMethodsConfiguration(type, overridesopt) → {object}
Create an object to pass into tokenize to specify a custom configuration. If no overrides are provided, the default configuration will be provided.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string |
The supported payment method type. Possible values are |
|
overrides |
object |
<optional> |
The configuration overrides for the data property on the supported payment methods objects. If not passed in, the default configuration for the specified type will be provided. If a property is not provided, the value from the default configruation will be used. |
Examples
var configuration = paymentRequestInstance.createSupportedPaymentMethodsConfiguration('basicCard');
configuration.supportedMethods; // ['basic-card']
configuration.data.supportedNetworks; // ['visa', 'mastercard', 'amex'] <- whatever the supported card networks for the merchant account are
var configuration = paymentRequestInstance.createSupportedPaymentMethodsConfiguration('basicCard', {
supportedNetworks: ['visa'],
supportedTypes: ['credit', 'debit']
});
configuration.supportedMethods; // ['basic-card']
configuration.data.supportedNetworks; // ['visa']
configuration.data.supportedTypes; // ['credit', 'debit']
teardown(callbackopt) → {Promise|void}
Cleanly remove anything set up by create.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
callback |
<optional> |
Called on completion. |
Examples
paymentRequestInstance.teardown();
paymentRequestInstance.teardown(function () {
// teardown is complete
});
tokenize(configuration, callbackopt) → {Promise|void}
Tokenizes a Payment Request
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
configuration |
object |
The payment details. Properties
|
|||||||||||||||||
callback |
callback |
<optional> |
The second argument, |
Examples
paymentRequestInstance.tokenize({
details: {
total: {
label: 'Price',
amount: {
currency: 'USD',
value: '100.00'
}
}
}
}).then(function (payload) {
// send payload.nonce to server
// examine the raw response (with card details removed for security) from the payment request
console.log(payload.details.rawPaymentResponse);
}).catch(function (err) {
if (err.code === 'PAYMENT_REQUEST_CANCELED') {
// payment request was canceled by user
} else {
// an error occurred while processing
}
});
var basicCardConfiguration = paymentRequestInstance.createSupportedPaymentMethodsConfiguration('basicCard', {
supportedNetworks: ['visa']
};
paymentRequestInstance.tokenize({
supportedPaymentMethods: [basicCardConfiguration],
details: {
total: {
label: 'Price',
amount: {
currency: 'USD',
value: '100.00'
}
}
}
}).then(function (payload) {
// send payload.nonce to your server
});
paymentRequestInstance.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
// collect shipping information from payload
console.log(payload.details.rawPaymentResponse.shippingAddress);
});
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
|