Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed PayPal API request causing strange error (376) #347

Closed
AlexP11223 opened this issue Nov 4, 2021 · 0 comments · Fixed by #348
Closed

failed PayPal API request causing strange error (376) #347

AlexP11223 opened this issue Nov 4, 2021 · 0 comments · Fixed by #348

Comments

@AlexP11223
Copy link
Contributor

CRITICAL Uncaught TypeError: Argument 3 passed to WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint::request_response_string() must be of the type array, object given

This error comes after the API answer and is causing the order processing to fail (or fatal errors in some places).

Is likely caused by this line which is supposed to log the answer in an array.

$this->logger->debug( $this->request_response_string( $url, $args, $response ) );

Most of the time it works, but sometimes when getting the API response we get an object instead of an array.

Steps to reproduce

  1. Make PayPal API inaccessible, such as by disabling internet in local env or blocking api.paypal.com via hosts or firewall.
  2. Make something to trigger a request to API, such as opening the webhooks status page or performing checkout.

Expected behaviour

The error should be logged properly, not causing fatal errors during logging.

Possible cause

Not handling failed requests which may return WP_Error instead of response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant