29 lines
2.6 KiB
Markdown
29 lines
2.6 KiB
Markdown
# B2B partner partial payments (Phase 3H)
|
|
|
|
Staff can record externally received payments against a partner purchase order. The order's frozen `merchandiseTotal` and `currency` are the balance basis. These are manual receipt records: this API does not call a gateway, capture money, issue tax invoices, calculate shipping, or consume credit. Staff must verify the external receipt before recording it. A reversal corrects an erroneous record; it does not send a refund.
|
|
|
|
All paths are under `/api/v1/b2b/partner-orders/:orderId/payments` and require a bearer session. Access is organization scoped.
|
|
|
|
| Method | Suffix | Permission | Purpose |
|
|
| ------ | --------------------- | -------------------- | ---------------------------------------------------------------------------- |
|
|
| GET | `/` | `b2b.payment.read` | List records and exact paid/outstanding totals; accepts `limit` and `offset` |
|
|
| GET | `/:paymentId` | `b2b.payment.read` | Read one record and its optional reversal |
|
|
| POST | `/` | `b2b.payment.manage` | Record an external receipt |
|
|
| POST | `/:paymentId/reverse` | `b2b.payment.manage` | Append one reasoned reversal |
|
|
|
|
Example receipt:
|
|
|
|
```json
|
|
{
|
|
"idempotencyKey": "901a9906-cec5-4eaa-b6d5-d6ac7e23c6d2",
|
|
"reference": "UTR-123456",
|
|
"method": "BANK_TRANSFER",
|
|
"amount": "100.25",
|
|
"receivedOn": "2026-10-03"
|
|
}
|
|
```
|
|
|
|
`amount` must be positive, have exactly two decimal places, and fit the remaining order balance. Methods are `BANK_TRANSFER`, `UPI`, `CHEQUE`, `CASH`, or `OTHER`. The server normalizes the reference to uppercase and requires it to be unique across the organization, including reversed records. A retry with the same key and payload returns the original record; a changed payload returns a specific 409 error. The list reports `merchandiseTotal`, `paidTotal`, and `outstandingTotal` as two-decimal strings and includes reversed records for audit, but excludes their amounts from the paid total.
|
|
|
|
To reverse, send `{ "reason": "Recorded against the wrong bank entry", "idempotencyKey": "<uuid>" }`. Reversals are append-only and idempotent. An order with an active receipt cannot be cancelled; reverse all receipts first. A cancelled order cannot accept new receipts. Database guards enforce these balance and cancellation rules even for writes outside the API. Credit exposure, refunds, fulfillment, tax, and freight remain separate milestones.
|