Timeouts and Retries
Connections built by the SDK time out and retry transient failures by default:
ruby
client = PaystackSdk::Client.new(
secret_key: "sk_test_xxx",
timeout: 30, # seconds to wait for a response
open_timeout: 5, # seconds to wait for the connection to open
max_retries: 2, # retries after the first attempt (0 disables retrying)
retry_interval: 0.5 # base backoff in seconds, doubled on each retry with jitter
)- Read-only requests (
GET) are retried on network failures and429/502/503/504responses. - Anything that writes (
POST,PUT,DELETE) is retried only on429, where Paystack rejected the request for exceeding the rate limit. A timeout or5xxon a write may mean Paystack processed it, so it is not retried. Passretry_non_idempotent: trueonly if you deduplicate yourself (e.g. verify by reference first). - On a
429the SDK waits for Paystack'sx-ratelimit-resetheader (seconds) before retrying. If the wait exceeds 10 seconds it stops retrying and raisesPaystackSdk::RateLimitError(#retry_afterholds the value). - Errors that survive all retries are raised as
PaystackSdk::RateLimitError,PaystackSdk::ServerError,PaystackSdk::TimeoutErrororPaystackSdk::ConnectionError, all of which inherit fromPaystackSdk::Error. - These options only apply to connections the SDK creates. Passing them together with your own
Faraday::ConnectionraisesArgumentError; configure your connection yourself. Invalid values (e.g. a negativemax_retries) also raiseArgumentError.