# Disputes and buyer protection — v0.1

**Status:** descriptive. It describes `release/0.545.0`. The code is in `collector/routes/disputes.py`
(routes) and `collector/store/disputes.py` (the read-model). The buyer journey is in
`docs/buyer-protection.md`. Gaps are listed under §7 *Open*.

## 1. What you can do

If something is wrong with a marketplace item you have access to, you can report it. The seller
can answer, and the platform decides the outcome. Every step is recorded as an event, so the result
can be traced:

- a refund;
- a corrected version;
- a takedown;
- no action.

## 2. Opening a dispute — `POST /memory/disputes` (`open_dispute`)

Body: `{kind: memory|session|collection, id, tenant?, reason, detail}`. You must be signed in
(401 `not_logged_in`).

- `reason` is one of `refund`, `inaccurate`, `copied`, `unsafe` or `other` (`store/disputes.py:REASONS`).
  `detail` must be at least 10 characters (400 `bad_dispute`).
- The item must be on the marketplace, meaning it is in the discovery index. Otherwise the answer is 404.
- For `refund`, `inaccurate` and `other` you must **have access** to the item: you bought it, imported it,
  were granted it, or are a member of its tenant. Otherwise the answer is 403 `no_access`. **Takedown
  reports** (`copied`, `unsafe`) do not need access.
- You can have one open dispute per item (409 `dispute_open`).
- The record says whether you **paid** (a fulfilled one-time purchase exists, `billing.paid_intent_for`)
  and whether the report is **within the refund window**. The window is 14 days by default
  (`REFUND_WINDOW_DAYS`) and is counted from the purchase's checkout creation.
- Opening a dispute is **not** blocked by a pending Terms update (`accounts.require_terms_current`
  is deliberately not applied here).

Anyone, including someone without an account, can also report a listing through the public notice
form (`POST /support/report`, DSA Art. 16, see `specs/support`). When the listing exists, that
report opens a dispute with `by: "report:<id>"`.

## 3. Conversation — `POST /memory/disputes/{id}/reply {text}` (`reply`)

The buyer, the seller (matched by the listing owner's handle) and admins may reply. Text is capped
at 2000 characters. A seller's first reply moves the status `open → answered`
(`store/disputes.py:Disputes.fold`).

`GET /memory/disputes` (`list_disputes`):

- a signed-in user sees `mine` (disputes they opened) and `selling` (disputes on their listings);
- a global admin sees all, optionally filtered by `?status=open|answered|resolved`.

## 4. Resolution — `POST /memory/disputes/{id}/resolve {outcome, note?, version?}` (`resolve`)

Only a **global admin** resolves (403 otherwise). A resolved dispute cannot be resolved again (409).

| Outcome | What happens |
|---|---|
| `refunded` | A **full** Stripe refund of your purchase (`billing.refund_intent`). If Stripe fails, the answer is 502, your access is kept and the dispute stays open for a retry. On success your access is **revoked** (`entitlement.revoked` carrying the dispute id). A **credit note** is issued, and the seller's revenue is reversed through the same reversal path the Stripe webhook uses (`billing._emit_item_reversal`), so the refund is booked once. A private library copy you made from the item stops working with 410 `license_revoked` (`specs/session-library` §4). If no purchase is on file, the refund is `not_applicable`, and access is still revoked. |
| `corrected` | The seller shipped a fixed version, which may be linked (`version`). Access is unchanged. |
| `taken_down` | The item leaves the marketplace: its `latest` channel is cleared, reversibly, and its history is kept. This must be resolved from the item's own tenant (409 `wrong_tenant` otherwise). A DSA Art. 17 **statement of reasons** is queued by mail to the seller (`_send_statement_of_reasons`). |
| `dismissed` | No action. |

A refund **always** revokes access. There is no "refund and keep" outcome. Terms § 9 reserves keeping
access for a correction.

## 5. Subscription withdrawals

A § 356a withdrawal from a **subscription** (`specs/marketplace-billing` §7) opens a dispute
with `kind: "subscription"` and `reason: "withdrawal"`. That dispute carries the suggested refund
quote. It can only be resolved `refunded` or `dismissed` (400 `bad_outcome` otherwise):

- `refunded` ends the subscription now if that has not already happened. It then refunds the
  suggested amount, or `amount_cents` when the admin sets it (0 up to what was paid). The Stripe webhook books
  the reversal, and access ends when Stripe ends the subscription.
- The refund must be approved within the 14 days § 357 (1) BGB allows. The code records the
  declaration time. It does **not** enforce or alert on that deadline (§7).

## 6. Records and retention

Disputes are events: `marketplace.dispute.opened | replied | resolved`. They are kept **3 years**
from the end of the year they arose in, implemented as 1461 days
(`collector/retention_policy.py:DISPUTE_DAYS`, owner decision D16). The credit note of a refunded
dispute stays in the invoice register for the tax period (10 years), because billing documents are
never pruned (`specs/gobd-verfahrensdokumentation`).

## 7. Open

1. The refund window counts from the checkout **creation** time (`open_dispute` uses the intent's
   `created_at`), not from payment or delivery. A slow payment method (SEPA) shortens it.
2. An item refund is always **full** (`refund_intent` has no amount). Partial refunds exist only
   through the Stripe dashboard (`charge.refunded`) and the withdrawal path.
3. Nothing enforces or alerts on the § 357 (1) 14-day approval deadline for withdrawal disputes.
4. Replies are accepted on a resolved dispute (`reply` does not check the status).
5. Q2 / OQ9 (an uncollectable seller balance after a refund) affects payouts, not the buyer.
