feat(subscriptions): à-la-carte add-ons — attach/detach fixed charges per subscription - #21
Merged
Merged
Conversation
… per subscription Lago's stock API can only *override* fixed charges that already exist on the shared plan (subscriptions/fixed_charges is index/show/update). There is no way to add an add-on to a single subscription, which is what self-serve à-la-carte billing needs. This adds that, on the open-core license (Option B): - Subscriptions::AddFixedChargeService — ensures the subscription has its own overridden plan (reusing PlanOverrideConcern), then creates the fixed charge on that override so the base plan and every other subscriber is untouched. Idempotent on the add-on code. - Subscriptions::RemoveFixedChargeService — discards an à-la-carte charge from the subscription's own override plan; refuses to touch charges on a shared plan. - subscriptions/fixed_charges#create + #destroy wired to those services, route extended to create/destroy. - Plans::OverrideService: allow the empty-params plan clone (what à-la-carte needs) on the open-core license; real overrides (custom pricing, commitments, trials) stay premium-only. Service specs assert the add/remove behavior works without a premium key and that the shared base plan is never mutated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds subscriptions/fixed_charges create + destroy so an add-on (fixed charge) can be attached to a single subscription — the primitive EngageIt's self-serve à-la-carte billing needs. Stock Lago only supports index/show/update there.
Subscriptions::AddFixedChargeService— ensures a per-subscription plan override (reuses PlanOverrideConcern), creates the fixed charge on it; base plan untouched; idempotent on code.Subscriptions::RemoveFixedChargeService— discards the charge; refuses to touch shared (non-override) plans.Plans::OverrideService— allows the empty-params plan clone (what à-la-carte needs) on the open-core license; real overrides (custom pricing/commitments) stay premium.Ruby 4 syntax-clean. Additive — no migration, no change to existing billing behavior. 🤖 Generated with Claude Code