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 implementingAdyenClient.Webhooks.Handler(required):hmac_key— HMAC key string (optional; falls back to config):validate_hmac— boolean, defaulttrue; set tofalsein dev only
Summary
Functions
Passthrough body reader — stores raw body in conn private for later HMAC use.