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

ConnectException not managed if the host is down #242

Closed
benschumi opened this issue Mar 4, 2024 · 3 comments · Fixed by #241 or #246
Closed

ConnectException not managed if the host is down #242

benschumi opened this issue Mar 4, 2024 · 3 comments · Fixed by #241 or #246
Assignees

Comments

@benschumi
Copy link

Environment

  • Checkout SDK version: 3.0.21
  • Platform and version: PHP 7.1
  • Operating System and version: MacOs 14.2.1

Description

While integrating paypal, i try to simulate a case where the host api.sandbox.checkout.com is down by putting an unreachable ip in the host file.
I want to manage the case if checkout is down, the call for a paymentRequest should not impact our payment page.
The execption is a GuzzleHttp\Exception\ConnectException but there is an error in the CheckoutApiException file

Expected behavior

The invoke method in ApiClient should return a CheckoutApiException

Current behavior

A FatalThrowableError from the method from in CheckoutApiException.

The response is null in a ConnectException

ConnectException {#4544 ▼
  -request: Request {[#4547 ▶](https://mywebsite.com)}
  -response: null
  -handlerContext: array:30 [▶]
  #message: "cURL error 7: Failed to connect to api.sandbox.checkout.com port 443: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)"
  #code: 0
  #file: "/srv/app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php"
  #line: 200
  trace: {▶}
}

Error on Class CheckoutApiException (line 25)
Call to a member function getBody() on null

public static function from(RequestException $requestException)    
{               
     $body = json_decode($requestException->getResponse()->getBody()->getContents(), true);        
     $ex = new CheckoutApiException(sprintf(            
         "The API response status code (%s) does not indicate success.",            
...

Steps to reproduce

put 0.0.0.0 on the host api.sandbox.checkout.com on host file

Possible solution

Just manage differently the ConnectException in class CheckoutApiException

@armando-rodriguez-cko armando-rodriguez-cko self-assigned this Mar 4, 2024
@armando-rodriguez-cko
Copy link
Contributor

Thank you @benschumi! Thank you. We have improvement to release to improve this point.

@armando-rodriguez-cko
Copy link
Contributor

I hope the new release https://github.com/checkout/checkout-sdk-php/releases/tag/3.1.0 help you

This was linked to pull requests Mar 27, 2024
@benschumi
Copy link
Author

Perfect, thank you @armando-rodriguez-cko

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