Charging up to a maximum
Declare the ceiling withmaxQuantity instead of quantity:
quantity and maxQuantity before any network call.
You can also declare neither: the item then defers to the meter’s configured Max usage per request (defaultMaxQuantity on the plan’s meter price). That keeps the ceiling in your catalog instead of your code. If the meter has no configured maximum, the allowance check denies with meter_not_priced.
On the buyer’s side, a ceiling is payable only on the reserve payment rails: the agent authorizes the maximum and pays the actual amount you settle. An exact quantity lets ZeroClick offer the immediate-settle scheme more clients can pay today, so when you know the size, prefer fixed charges. See payment protocols.
Settle at the actual amount
A ceiling has no settled quantity until you report one. On a pay-per-call payment, report it on the response: that is the only place the payment settles, so know the actual by the end of the handler. Only a buyer on a credit, subscription, or free-trial plan can be billed asynchronously for work that finishes later.202 counts as delivered. A report sent later cannot reopen the payment, so the header on the response is what turns the work into revenue. See settle usage for the header rules (2xx only, stripped by ZeroClick).
Go: Meter takes fixed quantities only
Go’sMeter middleware settles exactly what it declares, so it accepts fixed quantities only. Handed an UpTo item, it panics at wire-up: a ceiling has no settled quantity, and the middleware would otherwise bill zero, silently, on a delivered 200. You have two working shapes: call Guard yourself and settle explicitly on the response, or keep Meter for a fixed per-request charge and report the variable part after responding. The second shape bills the variable part only to buyers on a credit, subscription, or free-trial plan. For a pay-per-call buyer the report fails with 404 access_not_found, and they pay the fixed part alone.