• Resolved Brian Henry

    (@brianhenryie)


    Hey,

    Customers were getting an error at checkout:

    “Sorry, there was a problem preparing your payment.”

    There was a corresponding PHP Notice:

    “Trying to get property ‘token’ of non-object in /…/wp-content/plugins/sezzle-woocommerce-payment/woocommerce-gateway-sezzle.php on line 558”

    which is in the get_sezzlepay_authorization_code() function.

    We were able to fix it by resetting our API keys.

    You might want to catch that with:

    if( ! is_object( $body ) || ! isset( $body->token ) ) {
        set_transient( 'sezzle_api_error', 'Bearer token missing from get_sezzlepay_authorization_code() response. Try resetting your API keys or contact support.', WEEK_IN_SECONDS );
        throw new Exception('Problem communicating with Sezzle');
    } else {
        delete_transient( 'sezzle_api_error' );
        return "Bearer $body->token";
    }

    then add in your constructor:

    add_action( 'admin_notices', function() {
      $message = get_transient('sezzle_api_error');
      if( !empty( $message ) ) {
        echo '<div class="notice error is-dismissible"> <p><strong>' . $message . '</strong></p> </div>';
      }
    });

    That way, site admins/shop managers will know there is a problem as soon as it happens to one customer.

  • The topic ‘“Sorry, there was a problem preparing your payment.”’ is closed to new replies.