Billing 0.5.0: Subscriptions only take the customer's own payment methods
Billing 0.5.0 makes sure a subscription can only be charged to one of its customer’s own active payment methods, and lets admins change a subscription’s payment method when editing it.
Payment methods that belong to the customer
Creating or updating a subscription now checks that the chosen payment method belongs to the subscription’s user and is active. Before, only the admin subscription form checked this; any other code could attach another user’s card, or one that had been removed. Such a request now fails with “This payment method cannot be used.” The form keeps its own quick check as well.
Editing a subscription’s payment method
The payment method selector was hidden on the subscription edit form, so a subscription’s payment method could not be changed after it was created. It now shows when editing, and a changed payment method is saved. Changing the plan still goes through its own step, so its notifications still fire.
Smaller fixes
- Listing payment methods by status now really filters by that status.
- On the Transactions list, a row without an invoice is no longer clickable and no longer leads to a broken invoice address.
- The billing permission now uses the same banknotes icon as the billing tabs.
Upgrading
No migration and no configuration. Update the dependency. Code that calls format_company_address/1 must now pass the company info.
Full release notes: Billing 0.5.0
0.5.0 · 5 June 2026
Security
- Payment-method ownership is now enforced in the context.
create_subscription/2andupdate_subscription/2reject apayment_method_uuidthat isn’t one of the subscription user’s own active methods ({:error, :payment_method_not_usable}), instead of relying on the changeset’s foreign-key check alone (which only proves the row exists). Previously the guard lived only in the adminSubscriptionForm, so any other caller could attach another user’s or an inactive/removed payment method. The form retains a fast UX pre-check.
Fixed
- Subscription edit-save dropped payment-method changes. Edit mode only ran
change_subscription_type/2, and the payment-method selector was hidden behind@live_action != :editso the field couldn’t be changed at all. The selector now renders in edit mode and a changedpayment_method_uuidis persisted viaupdate_subscription/2(type changes still route throughchange_subscription_type/2so its broadcast fires). list_payment_methods/2silently ignored thestatus:option. Callers passingstatus: "active"worked only by theactive_onlydefault;status:was never inspected. It now honours an explicitstatus:(exact-status filter) withactive_only(defaulttrue) as the fallback.- Invoice-less transaction rows were
cursor-pointerand navigated to a broken/invoices/URL; rows are now clickable only when an invoice exists.
Changed
format_company_address/1made pure — dropped the deadcompany_info \\ nilimpure default (the argument is now required); the compat delegate’s arity matches.permission_metadatabilling icon💰→hero-banknotesto match the billing tabs.- DRY’d the 13
Tab.new!calls behind a privatebilling_tab!/1helper.
Tests
- Added
compat_delegate_test(asserts everycompat/*.exdelegate isfunction_exported?on its target at the same arity),list_payment_methods/2scoping andstatus:-filtering tests, and context-level payment-method guard reject-path tests (these short-circuit before any insert, so they run without the coresubscription_type_uuidskip).
Billing 0.5.0. Install or update: {:phoenix_kit_billing, "~> 0.5"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.