On this page
No Headings
Last updated: June 4, 2026
Handle payer errors to provide a unique payer experience.
Required
Run in Postman
If an error prevents buyer checkout, alert the user that an error has occurred with the buttons using the onError callback:
paypal
.Buttons({
onError: function (err) {
// For example, redirect to a specific error page
window.location.href = "/your-error-page-here";
},
})
.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.
If null pointer errors prevent the script from loading, provide a different checkout experience:
if (window.paypal && window.paypal.Buttons) {
// render the buttons
} else {
// show a fallback experience
}