Constructor
new PayPalCheckout(options)
Do not use this constructor directly. Use braintree-web.paypal-checkout.create instead.
Parameters:
Name | Type | Description |
---|---|---|
options |
object |
Methods
createPayment(options, callbackopt) → {Promise|void}
Creates a PayPal payment ID or billing token using the given options. This is meant to be passed to PayPal's checkout.js library. When a callback is defined, the function returns undefined and invokes the callback with the id to be used with the checkout.js library. Otherwise, it returns a Promise that resolves with the id.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | All options for the PayPalCheckout component. Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
callback |
<optional> |
The second argument is a PayPal |
Example
// this paypal object is created by checkout.js
// see https://github.com/paypal/paypal-checkout
paypal.Button.render({
// when createPayment resolves, it is automatically passed to checkout.js
payment: function () {
return paypalCheckoutInstance.createPayment({
flow: 'checkout',
amount: '10.00',
currency: 'USD',
intent: 'sale'
});
},
// Add other options, e.g. onAuthorize, env, locale
}, '#paypal-button');
tokenizePayment(tokenizeOptions, callbackopt) → {Promise|void}
Tokenizes the authorize data from PayPal's checkout.js library when completing a buyer approval flow. When a callback is defined, invokes the callback with tokenizePayload and returns undefined. Otherwise, returns a Promise that resolves with a tokenizePayload.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokenizeOptions |
object | Tokens and IDs required to tokenize the payment. Properties
|
|||||||||||||||||
callback |
callback |
<optional> |
The second argument, |
Example
// this paypal object is created by checkout.js
// see https://github.com/paypal/paypal-checkout
paypal.Button.render({
onAuthorize: function (data, actions) {
return paypalCheckoutInstance.tokenizePayment(data).then(function (payload) {
// Submit payload.nonce to your server
}).catch(function (err) {
// handle error
});
},
// Add other options, e.g. payment, env, locale
}, '#paypal-button');
Type Definitions
tokenizePayload :object
PayPal Checkout tokenized payload. Returned in PayPalCheckout#tokenizePayment's callback as the second argument, data
.
Properties:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
nonce |
string | The payment method nonce. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type |
string | The payment method type, always |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
details |
object | Additional PayPal account details. Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
creditFinancingOffered |
object |
<nullable> |
This property will only be present when the customer pays with PayPal Credit. Properties
|