Skip to content

feat(customer-portal): plan switching + add-product + terminate - #1

Merged
rrader26 merged 1 commit into
mainfrom
feat/customer-portal-plan-switching
May 22, 2026
Merged

feat(customer-portal): plan switching + add-product + terminate#1
rrader26 merged 1 commit into
mainfrom
feat/customer-portal-plan-switching

Conversation

@rrader26

Copy link
Copy Markdown

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.

…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>
@rrader26
rrader26 merged commit 7a7fee3 into main May 22, 2026
1 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant