Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Created February 7, 2017 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iloveitaly/41b7a2372026bcd8d59b07c445086f41 to your computer and use it in GitHub Desktop.
Save iloveitaly/41b7a2372026bcd8d59b07c445086f41 to your computer and use it in GitHub Desktop.
Retry Stripe operations on backend errors
Stripe.max_network_retries = 100
# https://github.com/stripe/stripe-ruby/pull/501
Stripe.class_eval do
def self.should_retry?(e, retry_count)
retry_count < self.max_network_retries &&
(
Stripe::RETRY_EXCEPTIONS.any? { |klass| e.is_a?(klass) } ||
(e.is_a?(RestClient::ExceptionWithResponse) && e.response.include?('Error while communicating with one of our backends.'))
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment