Before you can add a PayPal button, make sure you have a few prerequisites out of the way:
- Create, verify, and link your PayPal account in the Braintree Control Panel
- Generate a client token on your server
To begin, add a div container for the PayPal button to your page:
Next, use the
braintree.setup call to place the button inside of the provided container element:
Make sure to replace
CLIENT-TOKEN-FROM-SERVER with your generated client token.
onPaymentMethodReceived option is a callback function that will return the payment method object. This occurs after the customer authenticates with PayPal and completes the flow. You can use the
nonce contained in this object with your server side call to run a transaction and complete the checkout.
The rest of your configuration will be determined by how you'd like to use PayPal.
- Want one-click payments for repeat customers? Have a subscription model? Use our Vault.
- Want a checkout from your cart/product page? Use Checkout with PayPal.
Still have questions?
If you can’t find an answer, contact our Support team.