# Billing API Changelog

This is the public change record for the Billing API. Billing follows
Fynex's shared public API lifecycle policy: Payments and Billing both support
a public major version for at least 12 months after its successor is generally
available, and both give at least 90 calendar days' notice before removing a
public contract.

## Unreleased

### Added: report business events for your invoicing workflow

`POST /business-events` tells Fynex that billable work happened.
`job.completed` and `service.delivered` (with `reference` and
`sellerCustomerId`) record a completed job, which your approved Fynex invoicing
workflow invoices within a minute at the `job` usage price of the customer's
contract it governs. `contract.period.closed` (with `contractId`) issues a
governed contract's current term now. No `Idempotency-Key`: the job's
`reference` and the contract's term are the keys.

### Added: issue a paid invoice from a settled standalone payment

`POST /invoices` accepts `sourcePaymentId` with `send:false`. Issuance allocates
an official number and applies the existing cash atomically; it creates no new
charge, payment link, email or stored-credit drawdown. Responses expose
`sourcePaymentId`, `paidAt` and `paidVia: existing_payment`. The frozen document
renders the payment date and zero due. Existing payments are not bulk-backfilled.

## 2026-11-10

### Added: payment terms on the dashboard contract

The dashboard contract create (`POST /billing/v1/contracts`) accepts an
optional `paymentTermsDays`, 0–365: days from an invoice's issue date to its
due date, where 0 is due on receipt. The contract response and the dashboard
contract list return it, amendments carry it forward, and invoices the
recurring and usage lanes issue under the contract — the first term and every
continuation — fall due issue date + that many days unless the operator states
a due date. A contract without it keeps the previous behaviour (the prior
invoice's term, else 14 days). The dashboard overview's upcoming invoices show
their due date by the same rule. The public `/billing-api/v1` contract is
unchanged.

### Added: invoice payments Fynex collected, for the merchant

The dashboard billing API adds `GET /billing/v1/collected-payments` with
`sellerAccountUuid`, an optional `limit` (1–100, default 50) and an optional
`beforeId` cursor. It lists, newest first, the invoice payments Fynex collected
on the merchant's behalf: the payment id, `receivedAt`, `amountMinor`,
`currency`, the invoice's id, number and status, the customer's name,
`settlementStatus` and `reversedByCreditNote`. `settlementStatus` is always
`held_by_fynex` today: Fynex holds the money until it is paid out.
`reversedByCreditNote` is true when a credit note that is not voided reverses
the invoice. Refunds and chargebacks of the payment on Fynex's side are not
reflected in this list. While `hasMore` is true, pass
`nextBeforeId` back as `beforeId`. It needs the same dashboard session and
seller access as the invoice list, and is read-only. Payouts and refunds of
these payments are handled by Fynex support. The public `/billing-api/v1`
contract is unchanged.

### Added: `collectedByFynex` on the dashboard billing invoice

The merchant-scoped billing invoice carries a boolean `collectedByFynex`, true
when Fynex collected the invoice's payment on the merchant's behalf. It is
additive and read-only; the public `/billing-api/v1` invoice is unchanged. On
such an invoice, both `GET /billing/v1/invoices/{invoiceId}/applications` and
the public `GET /billing-api/v1/invoices/{invoiceId}/applications` omit
`genericPaymentId` from the payments Fynex's payment link collected, since
that payment is not the merchant's, so those rows carry an empty `reference`;
a payment the merchant applied from its own payments keeps it.

### Changed: documents issued on a merchant's behalf name the merchant

A document the collecting entity issues for a merchant (Fynex-collected
billing) now freezes the merchant's name as the seller's `tradingName`. The
hosted page and the PDF show it as the brand and print "On behalf of
<merchant>" under the issuer, and the invoice email does the same. The issuer
is unchanged. Documents issued before this change keep their frozen payload.

### Changed: contract status changes on the revenue timeline

A contract version that changes the contract's status records
`contract_activated`, `contract_suspended` or `contract_closed` on the
contract's revenue timeline instead of `contract_amended`. A version that keeps
the status still records `contract_amended`. Events already recorded are
unchanged.

### Added: void an unpaid invoice from the dashboard

The dashboard billing API adds `POST /billing/v1/invoices/{invoiceId}/void`
with `sellerAccountUuid` and a required `reason`. It needs the seller's own
dashboard session and the `billingadjustments:write` permission, the same as a
credit note or write-off, and answers 204. Only an issued, sent or overdue
document with no payment applied can be voided; a paid or part-paid document,
a credit note, or a document a credit note already reverses answers 409, and
the correction is a credit note. A void closes the document's payment link,
returns any stored credit drawn into it and records `invoice_voided` on the
revenue timeline, attributed to the user who voided it. A void and a credit
note of the same invoice never both take effect: whichever starts second waits
for the first and is then refused (409). An invoice Fynex collects whose
payment link has already taken a payment not yet applied to it answers 409,
"a payment on this invoice is being settled; try again later or issue a credit
note". `reason` is at most 256 characters; a longer one answers 400. The same
rules now apply to voids made by Fynex support. The public `/billing-api/v1`
contract is unchanged.

### Changed: a paid invoice's checkout returns to the invoice

The hosted checkout of a billing invoice's payment link no longer offers the
merchant's setup page, on the success screen or anywhere else, including for
sandbox merchants. After payment it offers "View your invoice", a link to the
invoice's hosted page (`/i/{token}`), where the paid invoice and its PDF are.
The link is built from the payment link and Fynex's hosted origin, never taken
from the stored `successUrl`, so checkouts opened before this change return
there too. Redirects back from a bank or another payment method return to the
invoice once the payment has succeeded; a payment that is still pending or has
failed shows the payment status page, since the invoice would still offer Pay.
Sandbox billing invoice links no longer store the dashboard's setup page as
their `successUrl`. Other payment links are unchanged.

### Changed: past contract amendments on the revenue timeline

Contract versions written before versions recorded a timeline event now have
one, added once by a data migration: `contract_activated`,
`contract_suspended` or `contract_closed` when the version changed the status,
otherwise `contract_amended`, at the time the version was created. Events
already recorded are unchanged.

### Changed: a billing run's due date follows the contract's payment terms

`POST /billing/v1/hybrid/run` without `dueDate` and without `paymentTerms`
now issues its documents due on the seller's today plus the contract's
`paymentTermsDays`, counted in the seller's billing timezone. An explicit
`dueDate` or `paymentTerms` still wins, and a contract without payment terms
keeps the previous default.

## 2026-11-04

### Changed: the upcoming invoice projects only the subscription billing runs invoice

`GET /contracts/{id}/invoices/upcoming` projected a line for every live
subscription on the contract. The recurring lane and Run billing invoice only
the contract's newest live subscription and skip the others, so a contract
with two live subscriptions showed an older one's open term as due today on
top of the newer one's next term — money no run will invoice. Only the newest
live subscription is projected now; each older one gets a note naming the
subscription that is billed instead.

## 2026-11-03

### Changed: the upcoming invoice skips a term that is already billed

`GET /contracts/{id}/invoices/upcoming` used to project a subscription's
current term even after Run billing or the recurring lane had issued it,
because the term only advances on the subscription at its end. A billed term
is now skipped: the subscription line is the term after it, or there is no
line and a note says so when the billed term was the subscription's last or
the subscription is past due on it (no term opens until it recovers). A claim
whose document never arrived does not count as billed.

The preview now follows the engine's in-advance billing in two more places:
`nextIssueDate` for a subscription term is the day the term opens — today
when it is already open and not yet billed (it was the term's end) — and a
scheduled plan change prices a term only when it is in force by the term's
start (it was by the term's end).

### Changed: period text on new invoice lines names the last day

Subscription, usage and mid-term plan change lines on newly issued documents,
and the matching upcoming-invoice lines, now read `Subscription — 2026-10-30
to 2026-11-29` instead of `… to 2026-11-30`: the period ends the day before
the next one starts. `periodStart`/`periodEnd` are unchanged (still a
half-open span). Documents already issued keep their frozen text.

### Changed: invoice totals on the hosted page, the email and the PDF

All three renditions now print one tax block: a row per rate in the
breakdown, the separate rate row only when there is no breakdown, and the
total row unless exactly one breakdown row already states it. On a document
claiming exemption, a single exempt (or uncategorised) row reads "VAT exempt";
a reverse-charge or zero-rated row keeps its category, now in words ("reverse
charge", not "reverse_charge"). The PDF is rendered from the frozen document,
so an invoice issued earlier shows this tax block when downloaded again; its
figures are unchanged. On the hosted page a
party's country is no longer repeated as a bare code under the address that
already names it.

## 2026-11-02

### Added: payments recorded in QuickBooks reach pushed invoices

While `billing.allocations.from_quickbooks_payments` is on, a payment the
seller records in QuickBooks against an invoice Fynex pushed there is applied
to the Fynex invoice: `paidMinor` and `remainingMinor` move, the status becomes
`partially_paid` (from `issued`/`sent`) or `paid` with `paidVia: quickbooks`,
and the same `InvoicePartiallyPaid` / `InvoicePaid` webhooks fire as for the
other rails. The applications read lists it as `source: quickbooks` with
`reference.quickBooksPaymentId`. QuickBooks' own record of a Fynex payment
(reference `FYNEX-…`) is never counted again, invoices QuickBooks itself
issued are never touched, a part payment on a document collected by payment
link is not applied (the link cannot be shrunk), and nothing is ever written
back to QuickBooks for it. All additive.

### Added: invoice status `partially_paid`, `paidVia: quickbooks`, and the applications read

- **New status `partially_paid`.** A bank transfer that pays part of an
  `issued` or `sent` document now moves it to `partially_paid` (it used to keep
  its status). A further part payment leaves it there; the payment that clears
  the balance makes it `paid`; past its due day it becomes `overdue`, and a part
  payment on an `overdue` document, or on an `issued`/`sent` one already past
  its due day, leaves it for `overdue`. Stored credit drawn at
  issue never moves the status. A `partially_paid` document cannot be sent or
  voided, and can be written off. The status is filterable on
  `GET /invoices` and the export, published in the `Invoice.status` enum, and
  carried by `InvoicePartiallyPaid` (and later) webhook payloads.
  Documents already part-paid by bank transfer when this ships (`issued` or
  `sent`, no payment link, some but not all of the collectible amount paid)
  become `partially_paid` once, **without** an `InvoicePartiallyPaid`
  webhook: their payments were announced when they landed.
  **Clients that switch over `status` must handle the new value** — including
  the Fynex dashboard and backoffice status chips and filters.
- **`paidVia` gains `quickbooks`** (a payment the seller recorded in
  QuickBooks; see the next entry). `paidVia` is now defined as the source of
  the payment that settled the document; existing values are unchanged.
- **`GET /invoices/{invoiceId}/applications`** lists every payment applied to
  a document with its source (`payment_link`, `bank_transfer`, `quickbooks`)
  and the stored credit drawn into it as `kind: credit`.
- `paidMinor` keeps its name; it is the document's amount paid.

**Overview `awaiting` lists part-paid invoices.** The dashboard-only
`GET /billing/v1/overview` now includes `partially_paid` invoices in
`awaiting` (money is still expected on them, at `amountMinor` = what remains),
so its `status` takes a third value beside `sent` and `overdue`.

**Forward-only release.** After migration
`20261103110000_billing_invoice_partially_paid` is applied, rolling the API
image back without rolling the migration back leaves `partially_paid`
documents that an older binary rejects as not collectable, never marks overdue
and omits from AR totals. The migration's Down refuses while any such document
exists, so this release is fixed forward, not rolled back.

## 2026-10-30

### Added: partial payments — `paidMinor`, `remainingMinor`, `InvoicePartiallyPaid`

Invoices carry `paidMinor`, the cash applied so far. A bank transfer may now
pay part of a document: the status stays `issued`, `sent` or `overdue`, and a
new `InvoicePartiallyPaid` webhook fires once per such payment. Invoice
webhook payloads gain `paidMinor` and `remainingMinor` (`collectibleMinor`
less `paidMinor`). All additions are additive; `collectibleMinor` keeps its
meaning. The CSV export appends `paidMinor` and `remainingMinor`. A document
with cash applied can no longer be voided — issue a credit note instead.

## 2026-10-19

### Changed: `includedUnits` on contract usage is the billed allowance

`GET /billing-api/v1/contracts/{contractId}/usage` now reports, as
`includedUnits`, the `allotment.includedUnits` of the metric price effective
for the period — the allowance the period close rates with — instead of the
limit policy's included units. `percentOfPlan` follows it. The backoffice
Connect RPC usage view reports the same value.

What changes for an integration that reads the field:

| Metric | Before | Now |
| --- | --- | --- |
| Priced, allotment 10 000, limit policy 0 | `includedUnits: "0"`, no `percentOfPlan` | `includedUnits: "10000"`, `percentOfPlan` against 10 000 |
| Priced, allotment 0, limit policy 10 000 | `includedUnits: "10000"`, `percentOfPlan` against 10 000 | `includedUnits: "0"`, no `percentOfPlan` — every unit is billed |
| Not priced yet, limit policy 10 000 | `includedUnits: "10000"` | unchanged |

If you compute overage or alerts from `includedUnits`, the new value is the
one your invoices are rated with; the limit policy's cap is still reported as
`capQuantity`.

### Fixed: pausing a subscription needs no body

`POST /billing-api/v1/subscriptions/{subscriptionId}/pause` with no request
body pauses until resumed, as `{}` always did, instead of answering `400`.

## 2026-09-18

### Changed: metering routes under `/billing-api/v1` accept secret keys only

`/billing-api/v1/usage/*` now applies the same credential rule as every other
operation under the Billing prefix: only `sk_test_…` / `sk_live_…` secret keys
authenticate, and any other bearer value answers `401`. Before this date those
routes also accepted the older prefix-less seller token. Nothing changes for
integrations that already send a secret key, which is what every guide has
documented since the prefix was published. The legacy `/usage/v1/*` routes are
unchanged and continue to accept the credentials they always did.

### Fixed: webhook documentation

The Billing webhook pages described the signature as an HMAC over the raw body
and deliveries as "retried until 2xx". The signature has always been computed
over `<X-Fynex-Timestamp>.<raw body>`, only a `200` counts as delivered, and a
delivery is attempted at most 3 times. The documentation now says so; no
delivery behaviour changed.

## 2026-09-13

### Deprecated: `origin=subscription` query alias

`origin=subscription` is a deprecated alias for `origin=recurring` on
`GET /billing-api/v1/invoices`. Notice date: 2026-09-13. The legacy alias is
still accepted and returns the same invoice rows as `origin=recurring`, but it
is no longer produced for newly created invoices. Update integrations to use
`origin=recurring`.

The planned removal date is 2026-12-13, providing 91 calendar days' notice,
which is at least 90 calendar days. This is a **query-value deprecation**, not
an HTTP operation retirement. An OpenAPI `deprecated: true` marker applies to
an operation, parameter, field or schema; this individual enum-like query
value cannot be represented by an operation-level marker. The public changelog
entry is therefore the applicable value-level deprecation signal. Do not mark
the whole `origin` query parameter deprecated, and do not expect
`Deprecation` or `Sunset` response headers for this query value.
