Billing 0.4.0: Webhooks and Stripe that work, readable errors and an activity log
Billing 0.4.0 makes payment webhooks and Stripe work at all: webhooks failed on every event, and Stripe could never be reached from the admin. Admin errors now read as sentences, and every admin change is written to the activity log.
Webhooks and Stripe
Every incoming provider webhook crashed before it was processed, so the endpoint answered 400 and no event was ever handled. Webhooks are now processed. An event that keeps failing is given up after five attempts and acknowledged, so the provider stops sending it. A repeated delivery is recognised as a duplicate instead of failing. Receipts are now sent after a webhook payment; before, the send always failed.
Stripe read its key from a different setting than the one the admin saved, so it always looked unavailable and checkout failed. It now reads the saved secret key, and still falls back to the old setting name.
Readable errors
Flash messages in the billing admin no longer show raw error codes such as :has_active_subscriptions. Each error has a translatable message, and form errors are shown in words.
Activity logging
Every admin change to orders, invoices, currencies, subscriptions, subscription types and billing profiles, and every payment, refund and send action, is written to PhoenixKit’s activity log. Only ids, statuses, amounts, currency codes and counts are recorded, no personal data, and a logging failure never breaks the action.
Subscriptions and forms
Extending a subscription now adds its own billing period instead of a fixed 30 days, and no longer crashes when the subscription has no period end. Status actions on a subscription update the page in place. The subscription type, billing profile and order forms show their errors inline while typing.
Upgrading
No migration and no configuration. Update the dependency. If your Stripe key only works today because it is saved as billing_stripe_api_key, it keeps working; a key saved from the admin now takes effect.
Full release notes: Billing 0.4.0
0.4.0 · 4 June 2026
Added
- Activity logging (
PhoenixKitBilling.Activity) — a guarded LiveView-layer wrapper aroundPhoenixKit.Activity.log/1, invoked on every admin mutation (orders, invoices, currencies, subscriptions, subscription types, billing profiles, and payment/refund/send actions). Logging failures never crash the caller, and only PII-safe metadata (uuids, status strings, amounts, currency codes, counts) is recorded. - Centralized error messages (
PhoenixKitBilling.Errors) — maps the error atoms returned by contexts, providers, and webhook handlers to gettext-backed, extractable human-readable strings. All admin flash/error messages now route throughErrors.message/1instead ofinspect/1, so users no longer see raw atoms like:has_active_subscriptions. Also formats%Ecto.Changeset{}reasons. - Webhook retry cap —
WebhookProcessornow stops reprocessing an event onceWebhookEvent.max_retries_exceeded?/1is true (≥5 attempts) and the controller acknowledges it with HTTP 200 so providers stop redelivering an intentionally-abandoned event. - Full DB + LiveView test harness (DataCase/LiveCase, test endpoint/router/layouts) and ~230 new tests across schemas, contexts, regressions, activity logging, and LiveView smoke/validation.
Fixed
- Webhook processing crashed on every event.
upsert_webhook_event/1usedAccessbracket syntax on a%Providers.Types.WebhookEventData{}struct (noAccess), raisingUndefinedFunctionErrorso the controller returned 400 and no event was ever processed. Now reads the field viaMap.get/2. - Stripe was unreachable from the admin UI. The UI saves the secret to
billing_stripe_secret_keybutStripe.get_config/0readbilling_stripe_api_key, soavailable?/0was always false and checkout returned:provider_not_available. Now readsbilling_stripe_secret_keywith a fallback to the legacy key, andavailable?/0always returns a boolean. unique_constraintnames didn’t match the DB indexes forwebhook_events,currencies,subscription_types, andpayment_methods, so duplicate inserts raisedEcto.ConstraintErrorinstead of returning{:error, changeset}. ForWebhookEventthis broke idempotency (a duplicate delivery surfaced as:processing_errorinstead of:duplicate_event). Names pinned to the actual indexes.- Receipts were never sent after a webhook payment. The webhook path called
send_receipt/2on an invoice without areceipt_number(the number is stamped only on the struct returned bygenerate_receipt/1), so it always returned{:error, :receipt_not_generated}. The processor now sends from the receipt-bearing struct. extend_subscriptioncrashed (FunctionClauseError) whencurrent_period_endwas nil; it now reports a friendly error instead.extend_subscriptionnow derives the extension from the subscription type’s billing period rather than a hardcoded 30 days;update_subscription/2filters to a non-lifecycle field allowlist (status changes go through cancel/pause/resume); subscription status actions update in place instead of redirecting.
Changed
- Subscription-type, billing-profile, and order forms migrated to core
<.input>/<.select>/<.textarea>components withassign_form/2so inline errors render on validate. SubscriptionType.billing_period_days/1andnext_billing_date/2gained catch-all clauses (fall back to a monthly cadence) instead of raising on an unexpected interval.- Stripe provider moduledoc corrected to document the real
PhoenixKit.Settings-based configuration; the provider talks to the Stripe REST API overReq. - Upgraded locked dependencies; added a test-only
lazy_htmldependency forPhoenix.LiveViewTest.
Billing 0.4.0. Install or update: {:phoenix_kit_billing, "~> 0.4"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.