feat(customer-portal): plan switching + add-product + terminate - #1
Merged
Conversation
…ription
Adds 4 customer-portal-scoped GraphQL operations so end users can manage
their subscriptions self-service from the hosted portal, without needing
admin intervention:
Resolver:
- customerPortalAvailablePlans(productKey?, excludeCurrent?) — lists plans
visible to the authenticated portal user. Filters by product prefix
(aistack-*, growth-*, memory-*, etc.) when productKey is set. When
excludeCurrent=true, omits plans the customer already has, which powers
the "Add a Product" cross-sell.
Mutations:
- changeCustomerPortalSubscriptionPlan(subscriptionId, planCode) — switches
an existing subscription to a different plan within the same product.
Calls Subscriptions::PlanUpgradeService which handles proration + Stripe
invoice generation automatically.
- createCustomerPortalSubscription(planCode) — adds a NEW subscription for
a product the customer doesn't yet have. External_id follows the
parent-app bridge convention: ${customer.external_id}-${productKey}.
- terminateCustomerPortalSubscription(subscriptionId) — cancels a single
subscription within a multi-product account; other products unchanged.
All four are scoped to the AuthenticableCustomerPortalUser context, so a
customer can only act on subscriptions they own. Errors normalize via the
existing result_error helper.
Powers Phase 2 of the ThinkFleet billing integration: unified Lago portal
as the single place customers manage all their cross-product subscriptions.
Co-Authored-By: Claude Opus 4.7 (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.
Companion PR: https://github.com/ThinkfleetAI/lago-front (Phase 2B). Adds 4 customer-portal GraphQL ops: customerPortalAvailablePlans query + change/create/terminate subscription mutations. Scoped to AuthenticableCustomerPortalUser. See PHASE_2_DESIGN.md in companion app repo. 🤖 Generated with Claude Code.