# UJ-104 Refund PayPal payment and issue credit note

Audience: AI coding agents first.

- Actor + entry point: Authorized finance staff; `/plugins/{plugin}/payments`.
- Priority: MUST-HAVE.
- Preconditions: Create customer/subscription through public APIs; settle PayPal payment through webhook API; issue invoice. Never insert transaction directly.
- Test layer: L3.

## Steps

1. Open payments → `Payments`, `View and manage all payment transactions`, and settled payment render (`admin-panel/src/pages/PaymentsPage.tsx:214-228`).
2. Open refund control for payment → modal shows refundable amount and reason input (old-panel `RefundModal` import: `admin-panel/src/pages/PaymentsPage.tsx:6-7`).
3. Submit refund once → row status/amount updates to refunded; success notice renders.
4. Open account invoices → one credit note linked to original invoice renders; reload preserves both refund and credit note.

## Failure branches

- Auth failure/insufficient staff role → `401/403`; no PayPal call, ledger write, or credit note.
- Duplicate submit → same refund result; exactly one provider refund and one credit note.
- Provider failure/429 → visible failure; original payment remains settled; no credit note.

## Backend touchpoints

`GET /v1/admin/transactions/payments`; locked-v1 `POST` refund endpoint; PayPal refund; invoicing credit-note operation.

