Skip to content

Billing 0.24.0: Works with PhoenixKit 3, numbers that never collide

Billing 0.24.0 makes the PhoenixKit billing module ready for PhoenixKit 3: it builds all its own tables, numbers orders and invoices from a counter that cannot collide, and shows each admin page only to staff with the matching permission.

Ready for PhoenixKit 3

The module now accepts PhoenixKit >= 2.65.0 and < 4.0.0. PhoenixKit 3 no longer creates the billing tables, so the module’s own migration chain now builds all eleven of them on an empty database. Where core already created them, nothing changes; the bank transfer, cash on delivery, PayPal and card payment options and the EUR, GBP and USD currencies are only seeded into a table the module creates itself. The module also describes its tables to mix phoenix_kit.doctor and mix phoenix_kit.repair, so they can check and repair them again.

Order and invoice numbers from a counter

Order, invoice, receipt and transaction numbers used to be the number of rows of the year plus one. Deleting a row could make every later create fail on a number already taken, and two creates at the same moment could collide. Numbers now come from a counter table per type and year, seeded from the numbers already in use, so an existing site carries on where it was. A deleted row never frees its number.

Pages follow permissions

The billing dashboard shows order figures only to staff who may manage orders, and invoice and revenue figures only to those who may manage invoices. The order, invoice and subscription detail pages and the forms now check the same permissions themselves, instead of opening for anyone with access to billing.

Upgrading

Update core to 2.65.0 or later first. Run mix phoenix_kit.update to apply the module’s migrations up to V7 before the new code takes traffic: without the counter table every create of an order, invoice or transaction fails. Finish the rollout quickly if several nodes run side by side, as an old node can trip over a number the counter issued. Staff who reached billing pages without the matching permission lose access to them.

Full release notes: Billing 0.24.0

0.24.0 · 27 October 2026

Added

  • The module supplies the manifest of its 11 tables (expected_schema/0, PhoenixKitBilling.ExpectedSchema), so mix phoenix_kit.repair and mix phoenix_kit.doctor check and repair them again, now from the module’s own chain instead of core’s manifest. Generated from PhoenixKitBilling.Migrations by core’s dev_docs/squash/generate_module_manifest.exs, never edited by hand. Core uses it from the first release after 2.64.1; before that nothing reads it. Repair is additive (it creates what is missing and reports the rest) and checks the tables only while the database is at the chain’s current version. No migration.

Changed

  • Core pin widened to >= 2.65.0 and < 4.0.0: works with core 3.x (core 3.0 stops creating the module tables; this module’s own chain builds its tables). The floor is the first core with the file_references/0 and expected_schema/0 callbacks, which now carry @impl PhoenixKit.Module.

  • The migration chain is now V6. V2 and V3 alter phoenix_kit_currencies and phoenix_kit_orders, which V4 creates, so on a database without core’s copy of those tables the chain failed at V2 before adopting anything. V6 emits the base CREATE TABLE IF NOT EXISTS of those two tables between V1 and V2 (a no-op wherever core created them), carrying core’s seed rows (the EUR/GBP/USD currencies and the bank transfer, cash on delivery, PayPal and card payment options) only when it creates the table itself, never over a host’s own rows. Published versions’ statements are untouched, and down/1 never drops a table. With it the chain builds all eleven tables without core (test/phoenix_kit_billing/integration/migrations_build_alone_test.exs, core’s ModuleChainCheck). See core’s dev_docs/plans/2026-10-25-module-table-ownership.md.

Fixed

  • Four subscription tests no longer @tag :skip: subscription_type_uuid exists on a from-scratch build, so the documented “core chain gap” is gone. The matching AGENTS.md landmine and TODO are removed.

Billing 0.24.0. Install or update: {:phoenix_kit_billing, "~> 0.24"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.