Behaviour for controlling retry logic on failed Stripe API requests.
Implement this behaviour to customize retry decisions. The default
implementation (LatticeStripe.RetryStrategy.Default) follows Stripe's
official SDK retry conventions.
Example
defmodule MyApp.RetryStrategy do
@behaviour LatticeStripe.RetryStrategy
@impl true
def retry?(attempt, context) do
if attempt <= 5 and context.status in [429, 500, 502, 503] do
{:retry, attempt * 1000}
else
:stop
end
end
end
Summary
Types
@type context() :: %{ error: LatticeStripe.Error.t() | nil, status: pos_integer() | nil, headers: [{String.t(), String.t()}], stripe_should_retry: boolean() | nil, method: atom(), idempotency_key: String.t() | nil }
Callbacks
@callback retry?(attempt :: pos_integer(), context()) :: {:retry, delay_ms :: non_neg_integer()} | :stop