Handle buyer checkout errors

DocsCurrentLast updated: March 16th 2023, @ 11:23:55 am

Use onError callbacks and alternate checkout pages to handle buyer checkout errors.

Know before you code

This feature modifies an existing checkout integration and uses the following:

Buyer checkout error

If an error prevents buyer checkout, alert the user that an error has occurred with the buttons using the onError callback:

  onError: function (err) {
    // For example, redirect to a specific error page
    window.location.href = "/your-error-page-here";

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.

Script not loading error

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