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

A buyer's bank asking for a payment back (a chargeback, `dp_...` at Stripe). A guarded_struct
the provider fills in, read with `MishkaPay.fetch_dispute/3` and `MishkaPay.list_disputes/3`;
answered with evidence (`MishkaPay.update_dispute/1`) or accepted (`MishkaPay.accept_dispute/3`).
A file seller usually takes back what the payment gave while a dispute is open.

  * `:id`, `:payment_id`, `:charge_id`: the dispute and the payment it takes back.
  * `:amount`: how much, as `Money`.
  * `:status`: `:warning_needs_response`, `:warning_under_review`, `:warning_closed` (an
    inquiry before a dispute), `:needs_response`, `:under_review`, `:won`, `:lost` or
    `:prevented`.
  * `:reason`: the bank's reason, in the provider's words (`"fraudulent"`,
    `"product_not_received"`...).
  * `:evidence_due_by`: the last moment to answer; `:has_evidence`, `:submission_count`: what
    was sent so far.
  * `:refundable`: whether the payment can still be refunded instead.
  * `:metadata`, `:created_at`.

# `t`

```elixir
@type t() :: %MishkaPay.Dispute{
  amount: Money.t() | nil,
  charge_id: String.t() | nil,
  created_at: DateTime.t() | nil,
  evidence: MishkaPay.Dispute.Evidence.t() | nil,
  evidence_due_by: DateTime.t() | nil,
  has_evidence: boolean() | nil,
  id: String.t(),
  metadata: map() | nil,
  payment_id: String.t() | nil,
  provider: String.t(),
  reason: String.t() | nil,
  refundable: boolean() | nil,
  status: atom() | nil,
  submission_count: non_neg_integer() | nil,
  tenant: term() | nil
}
```

The struct that `builder/1` returns.

| Field | Type | Required | Default | Description | Derives |
| --- | --- | --- | --- | --- | --- |
| `:provider` | `String.t()` | yes |  |  | `validate(not_nil_value, string)` |
| `:tenant` | `term()` \| `nil` | no |  |  |  |
| `:id` | `String.t()` | yes |  |  | `validate(not_nil_value, string, not_empty)` |
| `:payment_id` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:charge_id` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:amount` | `Money.t()` \| `nil` | no |  |  | validator `{MishkaPay.Money, :field}` |
| `:status` | `atom()` \| `nil` | no |  |  | `validate(enum=Atom[warning_needs_response::warning_under_review::warning_closed::needs_response::under_review::won::lost::prevented])` |
| `:reason` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:evidence_due_by` | `DateTime.t()` \| `nil` | no |  |  | `validate(struct)` |
| `:has_evidence` | `boolean()` \| `nil` | no | `false` |  | `validate(boolean)` |
| `:submission_count` | `non_neg_integer()` \| `nil` | no | `0` |  | `validate(integer)` |
| `:refundable` | `boolean()` \| `nil` | no |  |  | `validate(boolean)` |
| `:metadata` | `map()` \| `nil` | no | `%{}` |  | `validate(map)` |
| `:created_at` | `DateTime.t()` \| `nil` | no |  |  | `validate(struct)` |
| `:evidence` | [`MishkaPay.Dispute.Evidence.t()`](`t:MishkaPay.Dispute.Evidence.t/0`) \| `nil` | no |  | The answer to a `MishkaPay.Dispute`, given to `MishkaPay.update_dispute/1`. A guarded_struct. |  |

# `builder`

# `enforce_keys`

# `enforce_keys`

# `example`

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

# `keys`

# `keys`

# `statuses`

```elixir
@spec statuses() :: [atom()]
```

The statuses a dispute can have, as atoms.

---

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