Accrue.Billing.MeterEvents (accrue v0.3.0)

Copy Markdown View Source

Phase 4 Plan 02 helper for asynchronous meter-event state transitions driven by Stripe webhooks (BILL-13, Pitfall 5).

Kept separate from Accrue.Billing.MeterEventActions so the webhook path (Accrue.Webhook.DefaultHandler) doesn't pull the outbox/ NimbleOptions surface into its dependency graph.

Summary

Functions

Looks up the meter-event row by identifier and flips it to failed with the Stripe error-report object sanitized into stripe_error. Returns {:ok, row} on success or {:error, :not_found} if the identifier is unknown (late or synthetic report).

Functions

mark_failed_by_identifier(identifier, stripe_obj)

@spec mark_failed_by_identifier(String.t() | nil, map()) ::
  {:ok, Accrue.Billing.MeterEvent.t()} | {:error, :not_found}

Looks up the meter-event row by identifier and flips it to failed with the Stripe error-report object sanitized into stripe_error. Returns {:ok, row} on success or {:error, :not_found} if the identifier is unknown (late or synthetic report).