Accrue.Entitlements.PurchaseDecision (accrue v1.5.1)

Copy Markdown View Source

Revision-bound, rail-neutral purchase preflight decisions.

The value contains host-renderable decision facts and, only after a durable override, an opaque short-lived capability. It never carries provider evidence or customer identity; the public fields themselves are not mutation authority.

Summary

Types

reason()

@type reason() ::
  :no_equivalent_grant
  | :equivalent_other_rail
  | :missing_snapshot
  | :stale_snapshot
  | :repairing_snapshot
  | :ambiguous_snapshot
  | :unmapped_target
  | :changed_revision

status()

@type status() :: :eligible | :block | :warn

t()

@type t() :: %Accrue.Entitlements.PurchaseDecision{
  guidance: String.t(),
  logical_plan: atom() | nil,
  override_capability: String.t() | nil,
  reason: reason(),
  revision: non_neg_integer() | nil,
  sources: [Accrue.Entitlements.Snapshot.source()],
  status: status(),
  target_rail: atom()
}

Functions

continue(decision, billable, price_spec, opts)

@spec continue(t(), term(), term(), keyword()) ::
  {:ok, term()} | {:error, atom() | map() | term()}

Rechecks a decision immediately before delegating a controllable Stripe command.

evaluate(snapshot, target_rail, product_id, opts \\ [])

@spec evaluate(Accrue.Entitlements.Snapshot.t() | nil, atom(), String.t(), keyword()) ::
  t()

override(decision, reason, actor_id, opts \\ [])

@spec override(t(), String.t(), term(), keyword()) :: t()