# `Accrue.Connect.PlatformFee`
[🔗](https://github.com/szTheory/accrue/blob/accrue-v0.3.0/lib/accrue/connect/platform_fee.ex#L1)

Pure `Accrue.Money` math for platform fee computation.

**Caller-inject semantics.** This helper computes the platform fee amount
as a value. It does NOT auto-apply to charges or transfers. Callers thread
the result into `application_fee_amount:` on their own charge/transfer
calls so the fee line is always auditable at the call site.

## Computation order

Stripe's documented order of operations for a flat-rate platform fee
(percent + fixed, optionally clamped):

  1. Percent component — `gross * (percent / 100)` in minor units, with
     banker's rounding (`:half_even`) at integer precision. Minor units
     are integer across all currencies, so this is currency-exponent
     agnostic: JPY (0-decimal), USD (2-decimal), and KWD (3-decimal) all
     round at the same integer boundary.
  2. Fixed component — if present, added verbatim (same currency).
  3. Floor clamp — if `:min` is present and the result is below it,
     raise to the min.
  4. Ceiling clamp — if `:max` is present and the result exceeds it,
     lower to the max.

Zero gross short-circuits to zero fee before any math.

## Config

Opts override per-call; unset opts fall back to
`Accrue.Config.get!(:connect) |> Keyword.get(:platform_fee)`.

# `opts`

```elixir
@type opts() :: [
  percent: Decimal.t(),
  fixed: Accrue.Money.t() | nil,
  min: Accrue.Money.t() | nil,
  max: Accrue.Money.t() | nil
]
```

# `compute`

```elixir
@spec compute(
  Accrue.Money.t(),
  keyword()
) :: {:ok, Accrue.Money.t()} | {:error, Exception.t()}
```

# `compute!`

```elixir
@spec compute!(
  Accrue.Money.t(),
  keyword()
) :: Accrue.Money.t()
```

Bang variant. Raises on validation failure.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
