livery_stripe_webhook_handler behaviour (livery_stripe v0.1.0)
View SourceA mountable livery handler for the Stripe webhook endpoint.
Add it to a router with routes/0,1:
livery_router:compile(livery_stripe_webhook_handler:routes()).handle/1 reads the raw body and Stripe-Signature header, verifies the
event with livery_stripe_webhook, and dispatches it to the configured
callback (the webhook_callback config key). It always answers JSON: 200
when accepted, 400 on a bad payload or signature.
The callback may be a fun/1 (Event), a fun/2 (Type, Event), a
module implementing handle_event/2, or a {Module, Function} pair.
Persistence (updating a user's subscription, etc.) belongs in the
callback; this module stays storage-agnostic.
Summary
Callbacks
Functions
-spec handle(livery_req:req()) -> livery_resp:resp().
livery route handler. Reads secret and callback from app config.
-spec handle(livery_req:req(), map()) -> livery_resp:resp().
Like handle/1 but with explicit #{secret, callback} opts.
-spec routes() -> [tuple()].
Routes for the default path /stripe/webhook.