If an error prevents buyer checkout, alert the user that an error has occurred with the buttons using the onError
callback.
Handle buyer checkout errors
DocsCurrent
Last updated: Mar 2nd, 1:37am
Use onError
callbacks and alternate checkout pages to handle buyer checkout errors.
1paypal.Buttons({2 onError: function(err) {3 // For example, redirect to a specific error page4 window.location.href = "/your-error-page-here";5 }6}).render('#paypal-button-container');
This error handler is a catch-all. Errors at this point are not expected to be handled beyond showing a generic error message or page.
Know before you code
Standard Checkout
RequiredThis feature modifies an existing standard Checkout integration and uses the following:
JavaScript SDK: Adds PayPal-supported payment methods
Orders REST API: Create, update, retrieve, authorize, and capture orders.
Explore PayPal APIs with Postman
OptionalYou can use Postman to explore and test PayPal APIs. Learn more in our Postman guide.