Billing 0.25.0: A trash for orders and invoices, void reasons and Stripe refund fixes
Billing 0.25.0 gives the PhoenixKit billing module a trash for orders and draft invoices, asks for a reason when an invoice is voided or an order cancelled, and fixes Stripe Checkout refunds and amounts.
A trash for orders and draft invoices
The Orders and Invoices lists get a Trash tab, and the detail pages get Move to trash and Restore. Only a draft or cancelled order without an open invoice, or a draft invoice that was never sent, can be moved to the trash. Its status does not change and its number stays used. The trash tab shows when each record was trashed and by whom. Nothing empties the trash, and a trashed record cannot be changed until it is restored. Listings, counts and the dashboard leave trashed records out.
Reasons on void and cancel
Void on an invoice and Cancel on an order now open a dialog with an optional Reason (optional) field. The reason, the person and the time are stored with the invoice or order. A cancel reason is added to the order’s internal notes as a dated line instead of replacing them. A void invoice shows a VOID mark, also on the printout, which leaves the reason out because a printout can reach the customer.
Stripe and payments
A refund made in the Stripe dashboard was acknowledged and never applied; it is now matched to its payment. A second refund on one charge is no longer recorded as the running total. Stripe Checkout charged the line items alone for an invoice with tax, a discount or a part payment; such a session is now one line for the amount due. A webhook payment for a void invoice is no longer retried to the limit: it is kept on the invoice’s void trail and the admins are told.
Other modules can now learn reliably that an order was paid, refunded or cancelled, through jobs on the billing queue. A new call opens an order’s invoice and checkout session together, so a double click cannot create two invoices. Billing profile forms can make the phone number required. 87 strings that showed in English in every language are now translated into Estonian, Russian and Ukrainian.
Upgrading
Run mix phoenix_kit.update and apply migration V8 before the new code takes traffic: every read of an order or invoice needs its new columns. The module now declares its billing Oban queue (billing: 10); without it, renewals, dunning and events wait forever. ecto_sql is now ~> 3.13. Code that cancels orders through Order.changeset/2, changes invoice status through update_invoice/2, or deletes orders with invoices now gets an error: read “Changes that can break a caller” in the changelog. A host that records its own Stripe refunds should pass payment_method: "stripe" to record_refund/3, or the refund is counted twice.
Full release notes: Billing 0.25.0
0.25.0 · 5 November 2026
Durable order events (issue #68), one call to start an order’s payment (PR #64),
a trash for orders and draft invoices (PR #66), a void and cancel trail with
changes decided on the locked row (PR #65), Stripe Checkout refunds and amounts
(PRs #62 and #64), a require_phone option (PR #63) and the migration chain on
a fresh core 3.x database (PR #67).
Upgrading. Run mix phoenix_kit.update and apply migration V8 before the new
code takes traffic: every read of an order or invoice needs its columns. The same
task adds the billing queue to a host that does not list it, and
mix phoenix_kit.doctor confirms it. ecto_sql is now ~> 3.13. Read “Changes
that can break a caller” below.
Added
- Durable order events.
PhoenixKitBilling.OrderEventsdelivers:paid,:refundedand:cancelledto other modules, mirroringInvoiceEvents, so an order paid without an invoice no longer reaches them only by a PubSub broadcast. One Oban job per event and handler is enqueued in the transaction that changes the status and delivered at least once, with the order re-read. A handler implementshandle_order_event/2, returning:okor{:error, term()}, and is found throughbilling_order_event_handlers/0on a module or the:order_event_handlersconfig. It is not handed an event id: key idempotency on the order’s uuid and the event, as an order reaches each status once. An order paid through its invoice fires both:paidevents, and a partial refund fires no order event. (#68) oban_queues/0declares thebillingqueue (billing: 10). It was only a manual install step, and Oban never runs a queue the node does not list, so renewals, dunning and the durable events could wait forever with no error. (#68)PhoenixKitBilling.start_order_payment/2opens an order’s invoice and checkout session in one call under a per-order lock, so a double click cannot create two invoices, and returns{:ok, %{invoice: invoice, url: url}}. It reuses a recent session for the same provider and amount, must be called outside a transaction, and needs session pooling (no PgBouncer transaction mode). An open invoice that no longer matches its order is refused with:invoice_out_of_date: void it, and the next start makes a new one. (PR #64)- A trash for orders and draft invoices (migration V8):
trash_order/2,restore_order/2,trash_invoice/2andrestore_invoice/2, with a Trash tab on the lists and Move to trash and Restore on the detail pages. Only adraftorcancelledorder without an open invoice, or adraftinvoice that was never sent, can be trashed. The status does not change, the number stays used, and nothing purges the trash. A trashed record refuses every change with:order_trashedor:invoice_trashed. (PR #66) - A void and cancel trail.
void_invoice/3stores reason, actor and time undermetadata["void"], andcancel_order/3recordsmetadata["cancelled_from"]andmetadata["cancelled_by_uuid"]. Void and Cancel open a modal for an optional reason, and a void invoice shows a VOID mark, on the printout without the reason. (PR #65) require_phoneonBillingProfile.fields_changeset/3andbilling_profile_fields/1, defaultfalse, next torequire_emailandrequire_address. (PR #63)
Changed
Changes that can break a caller:
Order.changeset/2no longer cancels an order and moves a stored order forward only. Onlycancel_order/3writes the cancellation trail. (PR #65)update_order/2decides on the stored row under its lock, so a stale struct cannot undo a cancellation::order_not_editable, or:not_foundfor an order that is gone. (PR #65)update_invoice/2andInvoice.changeset/2no longer change the status of a stored invoice. (PR #65)delete_order/1refuses an order that has an invoice (:order_has_invoices), and returns:not_foundfor an order that is gone. (PR #65)void_invoice/3leavesnotesalone, so the reason no longer prints on the invoice and is capped at 500 characters, as is a cancel reason. It returns and broadcasts the invoice with:orderand:userloaded. (PR #65)cancel_order/3appends its reason tointernal_notesas a dated line instead of replacing them. (PR #65)record_payment/3andmark_invoice_paid/2re-check that the invoice is payable under its lock, returning:not_payableand:invoice_not_payable. (PR #65)- Refusals found on the locked row are returned as values, not rolled back, so a
transaction the caller holds stays usable.
:invoice_not_foundreplaces a raise for a deleted invoice. (PR #65) - Listings, counts, the dashboard, a customer’s orders and
get_order_by_uuid/2leave the trash out;trashed: :only | :includebrings it back on the listings. (PR #66) - The order and invoice topics carry
{:order_trashed, order},{:order_restored, order},{:invoice_trashed, invoice}and{:invoice_restored, invoice}: a subscriber with a stricthandle_info/2needs a catch-all clause. (PR #66) ecto_sqlraised to~> 3.13.
Other changes:
- A host that records its own Stripe refund should pass
payment_method: "stripe"torecord_refund/3. The webhook that follows counts only refunds of the payment’s own method, so one left on the default"bank"is recorded twice. (PR #62) - Free-text void and cancel reasons no longer reach the activity log, as its PII rule requires; they stay on the invoice and the order.
Fixed
- Stripe Checkout refunds. A refund made in the Stripe dashboard was
acknowledged and never applied, because the payment is recorded under its
PaymentIntent id while
charge.refundednames the charge. It is now found by either id, and rows already stored match without a data migration. A second refund on one charge is no longer recorded as the running total, a refund without an id no longer borrows the charge id, andStripe.create_refund/3sends api_…id aspayment_intent. A refund that matches no payment is logged and noted on the webhook event. (PR #62) - Stripe Checkout charged the wrong amount for an invoice with tax, a discount or a part payment, as the session was built from the line items alone. A session that does not match the amount due is now a single line for that amount. (PR #64)
- A webhook payment for a void invoice was retried to the limit and visible only in a log line. Nothing is booked now: the charge is kept on the invoice’s void trail, the admins are told, and the retries stop. (PR #65)
send_invoice/2,update_invoice/2,delete_order/1,void_invoice/3andcreate_checkout_session/3decide on the locked row, so a void committed in between is no longer overwritten. (PR #65)- The chain no longer fails on a fresh core 3.x database for a host migration file
pinned below V6, and
Migrations.up/1never lowers the marker. (PR #67) - A blank number on
update_order/2orupdate_invoice/2returns a changeset instead of raisingnot_null_violation. - The legacy
PhoenixKit.Modules.Billingnamespace has delegates for the trash and void functions. - 87 strings that rendered in English in every locale, mostly the
Errorscatalogue and invoice flashes, are in the.potand translated intoet,ruanduk. The trial badge on the subscription types page uses the right plural form.
Billing 0.25.0. Install or update: {:phoenix_kit_billing, "~> 0.25"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.