Accrue.Webhook.Plug (accrue v0.3.1)

Copy Markdown View Source

Core webhook ingestion plug.

Processes incoming webhook requests by:

  1. Extracting the raw body from conn.assigns[:raw_body] (populated by Accrue.Webhook.CachingBodyReader in the pipeline)
  2. Verifying the Stripe-Signature header via Accrue.Webhook.Signature
  3. Projecting the verified event into %Accrue.Webhook.Event{}
  4. Storing the verified event and raw body in conn.private for downstream processing

Signature failures raise Accrue.SignatureError, rescued to HTTP 400.

Transactional pipeline

After verification, Accrue.Webhook.Ingest.run/4 atomically persists the webhook event, enqueues an Oban dispatch job, and records an accrue_events ledger entry -- all in a single Ecto.Multi transaction.