# `Daraja.Callback.Guard`
[🔗](https://github.com/okothkongo/daraja/blob/v0.1.1/lib/daraja/callback/guard.ex#L1)

Optional idempotency guard for inbound M-PESA callbacks.

Safaricom may deliver the same callback more than once. Track seen transaction
identifiers (`CheckoutRequestID`, `TransID`, `OriginatorConversationID`, etc.)
before fulfilling orders or updating balances.

Add to your supervision tree when you want in-memory deduplication:

    children = [
      {Daraja.Callback.Guard, []}
    ]

Entries expire after `:ttl` seconds (default 86_400) so the table does not
grow without bound.

# `ensure_fresh`

```elixir
@spec ensure_fresh(
  term(),
  keyword()
) :: :ok | {:error, :duplicate}
```

Records `id` if it has not been seen within the TTL window.

Returns `:ok` on first sighting or `{:error, :duplicate}` when the same `id`
was recorded recently.

`server` defaults to `Daraja.Callback.Guard`. Pass a custom atom when running
multiple named guards.

# `start_link`

---

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