# Refunds and disputes

## Refunds

A refund returns part or all of a **payment** (its `chg_` charge) to the buyer's card:

```bash
curl -X POST https://api.sandbox.staging.regoria.com/v1/refunds \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: refund-INV-1001-1" \
  -d '{"order_id": "ord_01HZX5Y3V8N2K7QJ4R9T6B3M1C", "amount_cents": 1000, "reason": "requested_by_customer"}'
```

- Send exactly one of `order_id` or `charge_id` (the order's `charge_id`); neither or both is `422` `validation`. An `order_id` is resolved to the order's charge and refunded exactly as by `charge_id`; an unknown order, or one with no captured charge (a free trial's voided hold), is `404`.
- `amount_cents` is at most what is left of the charge (`amount_cents - refunded_cents`); omit it to refund the rest.
- What a charge allows is its `capabilities.refund`: `partial` (any amount up to what is left), `full` (only what is left, in one refund) or `none`. A refund the charge does not allow is `422` `refund_not_supported`, and a partial amount on a `full` charge is `422` `partial_refund_not_supported` on `amount_cents`. Cards, Apple Pay and Google Pay read `partial`.
- A refund carries its `order_id` (null for a charge with no order). `decided_by` and `decided_at` are set only on older refunds that were held for approval; a refund is never held any more.
- `201` means the refund is on its way (`state: "sending"`, then `issued`). A refund of any size is sent to the processor at once; it is limited only by what is left of its charge.
- `refund.issued` is sent when the processor accepted it. `failed` carries a `failure_reason`; `rejected` is found only on older refunds whose approval was refused.
- The order's `refunded_cents` and `status` (`partially_refunded`, `refunded`) follow. Refunding a subscription period does not cancel the subscription.

Refund states: `sending`, `issued`, `failed`, `rejected`, `unknown` (the processor's answer was lost; it is reconciled nightly).

Sales tax is refunded in proportion and reported to the tax authority as a credit; you do nothing. The processing fee of the original sale is not returned to you.

`GET /v1/refunds` lists refunds (`state[]`, `charge_id[]`, `range`; `charge_public_id[]`, the older name of `charge_id[]`, is still read); `GET /v1/charges` and `GET /v1/charges/{charge}` show every charge with its `state`, card summary, `refunded_cents`, its `payment_system` (how the buyer paid: `credit_card`, `apple_pay`, `google_pay`), its `capabilities` (`refund` and `void`), and the decline code and category when it was declined.

### Currency

A refund is always in the currency the buyer was charged in, and `amount_cents` is in that currency's smallest unit. The buyer gets back the amount they paid, not a newly converted one. The refund leaves your balance in the same currency.

## Disputes

A **dispute** is a chargeback the card network opened against one of your payments. The buyer's bank took the money back pending the outcome. A payment can be charged back more than once (a second partial chargeback, or a new round after a won one); each chargeback is its own dispute.

| Field | Meaning |
|---|---|
| `source` | `chargeback` |
| `provider_case_id` | the processor's chargeback id, when Regoria received it |
| `status` | `open`, `evidence_submitted`, `won`, `lost`, `accepted`, `expired` |
| `amount_cents`, `fee_cents` | the disputed amount and the dispute fee |
| `reason_code`, `reason_label` | the network's reason code and its name ("Merchandise or services not received" for `13.1`); the name is `null` for a code Regoria has no name for |
| `merchant_evidence_due_at` | when your evidence is due: 3 business days after the dispute opened |
| `evidence_due_at` | the bank's deadline, the last day evidence can reach the network |
| `over_disputed` | the payment's open and lost disputes add up to more than the payment; Regoria checks it with the processor |

Disputes are **read-only** in the API (`GET /v1/disputes`, `GET /v1/disputes/{dispute}`). Evidence is submitted from the dashboard (**Disputes**), where you attach the fulfilment proof, the receipt and your correspondence; the evidence you recorded with `POST /v1/orders/{order}/fulfil` is already there.

Events: `dispute.opened` when it opens (stop shipping, revoke access: `order.access_revoked` follows for the order), `dispute.closed` with the outcome.

## Money

The disputed amount and the **dispute fee are charged to your balance** when the dispute opens; a won dispute returns the amount, not the fee. Both appear as balance transactions (`category: "dispute"`, `"dispute_fee"`, `"dispute_reversal"`) in [Balance and payouts](http://docs.staging.regoria.com/guides/balance-and-payouts).

A refund or a dispute of a sale that already settled in another currency than the buyer paid in: the buyer gets back the amount of the currency they paid in, and your balance is debited in the currency the sale settled in, at the rate that sale settled at (or the promised rate, when `fx_bearer` on the order is `platform`). With `merchant`, the small difference to what the processor finally takes for the refund is added to or taken from your balance when it settles.

## Keeping disputes rare

- Fulfil promptly and record evidence on the order.
- Use a clear statement descriptor (set in the dashboard) so buyers recognise the payment.
- Answer refund requests quickly; a refund costs less than a chargeback.
- Listen to `charge.declined` and `subscription.past_due` and tell the buyer, rather than retrying blindly.
