A decoded and verified Rapyd webhook event.
After calling Rapyd.Services.Webhook.parse_and_verify/3, you receive
one of these structs. Pattern-match on :type to branch on event kind,
then cast :data to the specific payload struct using the helpers below.
Example
defmodule MyApp.WebhookHandler do
alias Rapyd.Types.WebhookEvent
def handle(%WebhookEvent{type: "PAYMENT_SUCCEEDED"} = event) do
MyApp.Payments.mark_paid(event.data["id"])
end
def handle(%WebhookEvent{type: "PAYOUT_COMPLETED"} = event) do
Logger.info("payout delivered", id: event.data["id"])
end
def handle(%WebhookEvent{}), do: :ok
end
Summary
Functions
Returns all known card issuing event type strings.
Returns all known contact event type strings.
Route the event to the matching handler from a map-based dispatch table.
Returns all known dispute event type strings.
Build a WebhookEvent from a decoded JSON map (the outer Rapyd envelope).
Returns all known invoice event type strings.
Returns all known payment event type strings.
Returns all known payout event type strings.
Returns all known refund event type strings.
Returns all known transfer event type strings.
Returns all known virtual account event type strings.
Returns all known wallet event type strings.
Types
Functions
Returns all known card issuing event type strings.
Returns all known contact event type strings.
@spec dispatch(t(), %{ optional(String.t()) => (t() -> any()), optional(:default) => (t() -> any()) }) :: any()
Route the event to the matching handler from a map-based dispatch table.
The table maps event type strings (or the atom :default) to 1-arity
functions. If no matching key is found the :default handler is called,
or :unhandled is returned when no default is provided.
Example
WebhookEvent.dispatch(event, %{
"PAYMENT_SUCCEEDED" => &handle_payment_ok/1,
"PAYMENT_FAILED" => &handle_payment_fail/1,
default: &log_unknown/1
})
Returns all known dispute event type strings.
Build a WebhookEvent from a decoded JSON map (the outer Rapyd envelope).
Returns all known invoice event type strings.
Returns all known payment event type strings.
Returns all known payout event type strings.
Returns all known refund event type strings.
Returns all known transfer event type strings.
Returns all known virtual account event type strings.
Returns all known wallet event type strings.