# `AdyenClient.Webhooks.Plug`
[🔗](https://github.com/iamkanishka/adyen_client/blob/v1.0.0/lib/adyen_client/webhooks/plug.ex#L2)

A `Plug` that handles Adyen webhook HTTP requests end-to-end.

Reads the raw body, validates the HMAC signature, dispatches events
to your handler module, and responds with `[accepted]` as Adyen requires.

## Usage in Phoenix router

    # In your endpoint.ex, add raw body passthrough BEFORE Plug.Parsers:
    plug Plug.Parsers,
      parsers: [:urlencoded, :multipart, :json],
      pass: ["*/*"],
      body_reader: {AdyenClient.Webhooks.Plug, :read_body, []},
      json_decoder: Jason

    # In your router.ex:
    forward "/webhooks/adyen", AdyenClient.Webhooks.Plug,
      handler: MyApp.AdyenWebhookHandler,
      hmac_key: System.get_env("ADYEN_HMAC_KEY")

## Options

- `:handler` — module implementing `AdyenClient.Webhooks.Handler` (required)
- `:hmac_key` — HMAC key string (optional; falls back to config)
- `:validate_hmac` — boolean, default `true`; set to `false` in dev only

# `read_body`

Passthrough body reader — stores raw body in conn private for later HMAC use.

---

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