diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index 34c5d77bd..7673e397d 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -366,11 +366,13 @@ private function shouldRetry($errno, $rcode, $rheaders, $numRetries) // The API may ask us not to retry (eg; if doing so would be a no-op) // or advise us to retry (eg; in cases of lock timeouts); we defer to that. - if (isset($rheaders['stripe-should-retry']) && $rheaders['stripe-should-retry'] === 'false') { - return false; - } - if ($rheaders['stripe-should-retry'] === 'true') { - return true; + if (isset($rheaders['stripe-should-retry'])) { + if ($rheaders['stripe-should-retry'] === 'false') { + return false; + } + if ($rheaders['stripe-should-retry'] === 'true') { + return true; + } } // 409 Conflict @@ -416,7 +418,7 @@ private function sleepTime($numRetries, $rheaders) $sleepSeconds = max(Stripe::getInitialNetworkRetryDelay(), $sleepSeconds); // And never sleep less than the time the API asks us to wait, assuming it's a reasonable ask. - $retryAfter = floatval($rheaders['retry-after']); + $retryAfter = isset($rheaders['retry-after']) ? floatval($rheaders['retry-after']) : 0.0; if (floor($retryAfter) == $retryAfter && $retryAfter <= Stripe::getMaxRetryAfter()) { $sleepSeconds = max($sleepSeconds, $retryAfter); }