# `PhoenixKitBilling.WebhookEvent`
[🔗](https://github.com/BeamLabEU/phoenix_kit_billing/blob/0.5.1/lib/phoenix_kit_billing/schemas/webhook_event.ex#L1)

Schema for webhook event logging and idempotency.

Every webhook received from payment providers is logged here to:
- Ensure idempotency (same event_id is never processed twice)
- Track processing status and errors
- Enable debugging and auditing
- Support retry logic for failed events

## Idempotency

Before processing a webhook, we check if an event with the same
`provider` + `event_id` combination exists. If it does, we skip
processing and return success to prevent retries from provider.

## Retry Logic

Failed events can be retried:
1. Provider sends retry (we check idempotency, process if not done)
2. Manual retry via admin interface
3. Background worker for events stuck in processing

# `changeset`

Creates a changeset for a webhook event.

# `failed_changeset`

Changeset for marking an event as failed.

# `max_retries_exceeded?`

Returns true if the event has exceeded max retries.

# `processed?`

Returns true if the event was successfully processed.

# `processed_changeset`

Changeset for marking an event as processed.

# `retriable?`

Returns true if the event has failed and can be retried.

---

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