Agent Wranglers

PRC-1Recommended

Keep prices in a versioned catalogue

Keep every price in one server-side catalogue with a stable ID, and create a new price instead of changing the amount of one in use.

How to do it

The browser sends only product or price IDs, as server-side business rules requires. Store each price with its amount in minor units, currency, interval and tax behaviour. To change an amount, create a new price and archive the old one. Orders and subscriptions keep pointing at the old price, so history and invoices stay true. Move subscribers to a new price on purpose, with notice.

Examples

SQL example

CREATE TABLE prices (
  id               text PRIMARY KEY,
  product_id       text NOT NULL,
  amount_minor     bigint NOT NULL CHECK (amount_minor >= 0),
  currency         char(3) NOT NULL,
  billing_interval text CHECK (billing_interval IN ('month', 'year')),
  tax_behaviour    text NOT NULL CHECK (tax_behaviour IN ('inclusive', 'exclusive')),
  archived_at      timestamptz
);
GRANT SELECT, INSERT ON prices TO app_role;
GRANT UPDATE (archived_at) ON prices TO app_role;

How to check

The app's database role cannot update the amount or currency of a price. Search the client code for amounts sent to the checkout endpoint. None are sent.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/pricing/plans-and-prices/price-catalogue">Agent Wranglers pricing, plans and entitlements playbook</a>. In code you write, add a comment next to it with the same link.