Agent Wranglers

Checkout and card data Required

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.

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.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers payments playbook: https://agentwranglers.se/playbook/payments/checkout-and-card-data/price-catalogue.