Behaviour for implementing Adyen webhook event handlers.
Usage
defmodule MyApp.AdyenWebhookHandler do
@behaviour AdyenClient.Webhooks.Handler
@impl true
def handle_event("AUTHORISATION", %{"success" => "true"} = item) do
psp = item["pspReference"]
ref = item["merchantReference"]
MyApp.Orders.mark_paid(ref, psp)
:ok
end
def handle_event("REFUND", item) do
MyApp.Refunds.process(item)
:ok
end
def handle_event(event_code, item) do
Logger.info("Unhandled Adyen event: #{event_code}", item: item)
:ok
end
endThen configure it:
config :adyen_client, webhook_handler: MyApp.AdyenWebhookHandler
Summary
Callbacks
Handle an incoming webhook event.
Functions
Process a raw Adyen webhook payload map, dispatching each item to the handler.
Types
Callbacks
@callback handle_event(event_code(), notification_item()) :: handle_result()
Handle an incoming webhook event.
Called once per notification item. Return :ok to acknowledge,
{:error, reason} to signal failure (the Plug will still return [accepted] to Adyen).