A component to integrate with PayPal.
- Deprecated:
-
- Use the PayPal Checkout component instead.
- Source:
Members
(static) VERSION :string
The current version of the SDK, i.e. 3.113.0
.
- Source:
Methods
(static) create(options, callback) → {Promise|void}
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Creation options: Properties
|
||||||||||||
callback |
callback |
The second argument, |
- Source:
Example
// We recommend creating your PayPal button with button.js
// For an example, see https://codepen.io/braintree/pen/LNKJWa
var paypalButton = document.querySelector('.paypal-button');
braintree.client.create({
authorization: CLIENT_AUTHORIZATION
}, function (clientErr, clientInstance) {
if (clientErr) {
console.error('Error creating client:', clientErr);
return;
}
braintree.paypal.create({
client: clientInstance
}, function (paypalErr, paypalInstance) {
if (paypalErr) {
console.error('Error creating PayPal:', paypalErr);
return;
}
paypalButton.removeAttribute('disabled');
// When the button is clicked, attempt to tokenize.
paypalButton.addEventListener('click', function (event) {
// Because tokenization opens a popup, this has to be called as a result of
// customer action, like clicking a button. You cannot call this at any time.
paypalInstance.tokenize({
flow: 'vault'
// For more tokenization options, see the full PayPal tokenization documentation
// https://braintree.github.io/braintree-web/current/PayPal.html#tokenize
}, function (tokenizeErr, payload) {
if (tokenizeErr) {
if (tokenizeErr.type !== 'CUSTOMER') {
console.error('Error tokenizing:', tokenizeErr);
}
return;
}
// Tokenization succeeded
paypalButton.setAttribute('disabled', true);
console.log('Got a nonce! You should submit this to your server.');
console.log(payload.nonce);
});
}, false);
});
});
(static) isSupported() → {Boolean}
Returns true if PayPal supports this browser.
- Source: