On-demand charges
On-demand charges
Charge selected one-off product items on top of an existing subscription whenever you need to: a one-time setup fee, an extra package, or an add-on bought at the click of a button.
Why this matters
Some product items aren’t billed on a recurring schedule; they’re charged when the customer asks for them. Flagging a one-off product item pricing as on-demand (the on_demand flag on its pricing item config) lets you retrieve the on-demand items available for a subscription and charge one or more of them on a separate invoice, with an optional preview first.
Listing the available on-demand items
To know which on-demand items can be charged for a subscription, fetch them per pricing plan schedule with GET /v1/pricing-plan-schedules/{id}/on-demand-pricing-items. Pass the optional timestamp query parameter to evaluate the schedule’s pricing at a specific point in time; it defaults to now.
The response mirrors a pricing plan version, filtered to the product item pricings that are ONE_OFF and flagged on-demand:
The same endpoint is available in the Customer Portal API, so you can present on-demand items to your customers and let them buy directly from the portal.
Charging an on-demand item
Charge one or more on-demand items with POST /v1/invoices/charge-on-demand-pricing-items:
The response is an invoice containing the charged on-demand lines:
Use preview: true to show the customer what the charge will look like before they confirm. A preview is never persisted and never finalized, regardless of finalize_immediately.
Typical flow
List the available items
Call GET /v1/pricing-plan-schedules/{id}/on-demand-pricing-items and show the available items to the customer.
See also: One-off pricing, Add-ons, Invoices and One-off invoices.