# Sales orders and card payments

If your system takes orders and is paid online, let ReconSmiths raise the invoice at the right moment instead of posting invoices yourself.

## Orders come before invoices

`POST /v1/sales-orders` records an order. An order is not in the ledger yet: no journal, no tax invoice number. That is why it can be deleted (`DELETE /v1/sales-orders/{externalRef}`) and why order numbers may have gaps. Send your own `order_no`, or leave it out and ReconSmiths numbers it.

An order becomes an invoice on whichever happens first:

1. **It is paid.** `POST /v1/sales-orders/{externalRef}/payment-confirmation` when your payment provider says paid. The invoice is raised from the order's lines, the payment is posted and allocated.
2. **It is fulfilled.** `POST /v1/sales-orders/{externalRef}/fulfil` when the goods or service are delivered. The invoice is raised from the order's lines.

Both are safe to repeat: an order that already has its invoice returns that invoice. Once an order is invoiced, it can no longer be deleted; a credit note is the answer.

`GET /v1/sales-orders` lists orders with whether each is paid (`payment_status`, `amount_paid`, `outstanding`, `paid_at`, `invoice_no`). Filter by `status`, `paymentStatus` or `since`.

## Card money is in transit

A payment provider saying "paid" is not money in the bank. ReconSmiths books a card confirmation into the provider's **clearing account**, not the bank, and moves it to the bank only when the provider pays out. This keeps the bank reconciliation exact.

| Step | Call | In the books |
|---|---|---|
| Customer pays by card | `POST /v1/sales-orders/{ref}/payment-confirmation` | Invoice paid; money in the provider's clearing account |
| Provider pays out, less its fee | `POST /v1/gateway-settlements` naming the payment refs | Bank receives the net; the fee is an expense; clearing goes to zero |

`GET /v1/gateway-payments` lists what is confirmed but not yet in the bank, and what is overdue against the provider's settlement window. Its total equals the clearing account's balance.

Instead of calling `/v1/gateway-settlements`, the company can upload the provider's settlement report in the office; it matches the payout's bank line to the payments in the file.

## Remittances

A payment covering several orders or invoices at once, under one number: see [Payments and allocations](06-payments-and-allocations.md#one-payment-for-several-invoices).
