# `Payzum.Client`
[🔗](https://github.com/payzum-dev/payzum-elixir/blob/main/lib/payzum/client.ex#L1)

HTTP client for the Payzum API: auth, retries, backoff, typed errors.

Only three of the sixteen error codes are retryable. `QUOTA_EXCEEDED` arrives as
a 429 and is NOT one of them — it means too many invoices are open, so retrying
makes the situation worse. Treating every 429 as retryable is the obvious
mistake.

More importantly, an unsafe request is never retried automatically: invoice
creation accepts an `Idempotency-Key`, but the API documents that as best-effort
with roughly 60 seconds of eventual consistency, and it does not enforce
order_id uniqueness. A blind retry can create a second real invoice and charge
twice.

Every function returns `{:ok, value}` or `{:error, exception}`, which is how
Elixir reports a failure a caller may want to handle.

# `t`

```elixir
@type t() :: %Payzum.Client{
  config: Payzum.Config.t(),
  sleeper: (non_neg_integer() -&gt; any()),
  transport: (Payzum.Request.t() -&gt;
                {:ok, Payzum.Response.t()} | {:error, Exception.t()})
}
```

# `consistency_window_seconds`

Seconds to wait before the first safe retry of a create call.

# `health`

```elixir
@spec health(t()) :: {:ok, map()} | {:error, Exception.t()}
```

Query `GET /v1/status`, unauthenticated.

Useful as a connectivity probe before blaming your own network.

# `new`

```elixir
@spec new(String.t(), keyword()) ::
  {:ok, t()} | {:error, Payzum.Errors.Validation.t()}
```

Create a client for production.

# `sandbox`

```elixir
@spec sandbox(String.t(), keyword()) ::
  {:ok, t()} | {:error, Payzum.Errors.Validation.t()}
```

Create a client for staging, which has isolated data and separate keys.

# `webhooks`

```elixir
@spec webhooks(String.t(), keyword()) ::
  {:ok, Payzum.Webhooks.t()} | {:error, Payzum.Errors.Signature.t()}
```

A webhook verifier for the given signing secret.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
