Ibanity.Webhook (ibanity v0.12.0)
Creates an Ibanity Event from webhook's payload if signature is valid.
Link to this section Summary
Functions
Verify webhook payload and return an Ibanity webhook event.
payload
is the raw, unparsed content body sent by Ibanity, which can be
retrieved with Plug.Conn.read_body/2
. Note that Plug.Parsers
will read
and discard the body, so you must implement a custom body reader if the
plug is located earlier in the pipeline.
signature_header
is the value of Signature
header, which can be fetched
with Plug.Conn.get_req_header/2
.
application
is the configured Ibanity application that should be used to
fetch the webhook signing keys from the API and compare with the webhook
audience. Defaults to :default
tolerance
is the allowed deviation in seconds from the current system time
to the timestamps found in the signature
token. Defaults to 30 seconds.
Link to this section Functions
construct_event(payload, signature_header, application \\ :default, tolerance \\ 30)
Verify webhook payload and return an Ibanity webhook event.
payload
is the raw, unparsed content body sent by Ibanity, which can be
retrieved with Plug.Conn.read_body/2
. Note that Plug.Parsers
will read
and discard the body, so you must implement a custom body reader if the
plug is located earlier in the pipeline.
signature_header
is the value of Signature
header, which can be fetched
with Plug.Conn.get_req_header/2
.
application
is the configured Ibanity application that should be used to
fetch the webhook signing keys from the API and compare with the webhook
audience. Defaults to :default
tolerance
is the allowed deviation in seconds from the current system time
to the timestamps found in the signature
token. Defaults to 30 seconds.
example
Example
case Ibanity.Webhook.construct_event(payload, signature) do
{:ok, event} ->
# Return 200 to Ibanity and handle event
{:error, reason} ->
# Reject webhook by responding with non-2XX
end