# `MishkaPay.Balance`
[🔗](https://github.com/mishka-group/mishka_pay/blob/v0.0.1/lib/mishka_pay/balance.ex#L5)

The money a provider holds for the seller, read with `MishkaPay.fetch_balance/2`. A
guarded_struct the provider fills in.

  * `:provider`: whose balance.
  * `:available`: one `Money` per currency, ready to pay out.
  * `:pending`: one `Money` per currency, not available yet.

A balance may be below zero, such as after refunds or disputes larger than new sales.

# `t`

```elixir
@type t() :: %MishkaPay.Balance{
  available: [Money.t()] | nil,
  payout: MishkaPay.Balance.Payout.t() | nil,
  pending: [Money.t()] | nil,
  provider: String.t() | nil,
  transaction: MishkaPay.Balance.Transaction.t() | nil
}
```

The struct that `builder/1` returns.

| Field | Type | Required | Default | Description | Derives |
| --- | --- | --- | --- | --- | --- |
| `:provider` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:available` | `[Money.t()]` \| `nil` | no | `[]` |  | `validate(list)` |
| `:pending` | `[Money.t()]` \| `nil` | no | `[]` |  | `validate(list)` |
| `:transaction` | [`MishkaPay.Balance.Transaction.t()`](`t:MishkaPay.Balance.Transaction.t/0`) \| `nil` | no |  | One movement of the seller's balance at the provider: a charge, a refund, a fee, a payout. Listed with `MishkaPay.list_balance_transactions/3`, such as every one a payout paid out. A guarded_struct the provider fills in. |  |
| `:payout` | [`MishkaPay.Balance.Payout.t()`](`t:MishkaPay.Balance.Payout.t/0`) \| `nil` | no |  | Money paid out of an account's balance to its bank account or card (a payout, `po_...` at Stripe): the platform's own, or, with a site's keys that name a connected account, the seller's. Read with `MishkaPay.fetch_payout/3` and `MishkaPay.list_payouts/3`, and stopped with `MishkaPay.cancel_payout/3` while it is still `:pending`. A guarded_struct the provider fills in. |  |

# `builder`

# `enforce_keys`

# `enforce_keys`

# `example`

A sample %MishkaPay.Balance{} populated from defaults + type-based fallbacks.

# `keys`

# `keys`

---

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