# `MishkaPay.Balance.Payout`
[🔗](https://github.com/mishka-group/mishka_pay/blob/v0.0.1/nofile#L1)

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.

  * `:provider`, `:id`.
  * `:amount`: what is paid out.
  * `:status`: `:pending`, `:in_transit`, `:paid`, `:failed` or `:canceled`.
  * `:arrival_at`: when it is expected at the bank, or arrived.
  * `:automatic`: `true` when the provider's payout schedule made it, `false` when someone
    asked for it.
  * `:method`: `"standard"` or `"instant"`.
  * `:destination_id`: the bank account or card it goes to.
  * `:failure_code`, `:failure_message`: why it failed, in the provider's words.
  * `:description`, `:created_at`.

`MishkaPay.list_balance_transactions/3` with `payout_id:` lists what one automatic payout paid
out.

# `t`

```elixir
@type t() :: %MishkaPay.Balance.Payout{
  amount: Money.t() | nil,
  arrival_at: DateTime.t() | nil,
  automatic: boolean() | nil,
  created_at: DateTime.t() | nil,
  description: String.t() | nil,
  destination_id: String.t() | nil,
  failure_code: String.t() | nil,
  failure_message: String.t() | nil,
  id: String.t(),
  method: String.t() | nil,
  provider: String.t(),
  status: (:pending | :in_transit | :paid | :failed | :canceled) | nil
}
```

The struct that `builder/1` returns.

| Field | Type | Required | Default | Description | Derives |
| --- | --- | --- | --- | --- | --- |
| `:provider` | `String.t()` | yes |  |  | `validate(not_nil_value, string)` |
| `:id` | `String.t()` | yes |  |  | `validate(not_nil_value, string, not_empty)` |
| `:amount` | `Money.t()` \| `nil` | no |  |  | validator `{MishkaPay.Money, :field}` |
| `:status` | `:pending` \| `:in_transit` \| `:paid` \| `:failed` \| `:canceled` \| `nil` | no |  |  | `validate(enum=Atom[pending::in_transit::paid::failed::canceled])` |
| `:arrival_at` | `DateTime.t()` \| `nil` | no |  |  | `validate(struct)` |
| `:automatic` | `boolean()` \| `nil` | no | `false` |  | `validate(boolean)` |
| `:method` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:destination_id` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:failure_code` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:failure_message` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:description` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:created_at` | `DateTime.t()` \| `nil` | no |  |  | `validate(struct)` |

# `builder`

# `enforce_keys`

# `enforce_keys`

# `example`

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

# `keys`

# `keys`

---

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