chargebee / chargebee-php

PHP library for the Chargebee API.

Home Page:https://apidocs.chargebee.com/docs/api?lang=php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No way to retrieve the 'retry-after' header in case of 429 OperationFailedException

yched opened this issue · comments

From the "Error handling" section of the API docs :

If you receive an HTTP 429 Too Many Requests error response to an API call, it means that the API requests for your Chargebee site have exceeded acceptable limits. Chargebee may also send a Retry-After header indicating the time duration to wait before sending a new request.

But on a HTTP 429 error, trhe Chargebee-php library throws an OperationFailedException, and offers no way to access the response headers, and thus no way to read the "Retry-After" value sent by Chargbee API.

Hi @yched, sorry for the delay in response. This has been fixed on the latest release, v3.28.0. You'll be able to access headers in the following manner. Please give it a try and let us know if you face any issues.

catch (APIError $e) {
        $errorHeaders = $e->getHeaders();
        $retryAfterHeaders = $errorHeaders['Retry-After'][0];
        echo $retryAfterHeaders . "\n";
}

Tnanjs @cb-alish , this works great ! 👍

Thanks for the confirmation @yched 👍