Skip to content

feat: auto-apply referral coupon to active Pro subscriptions - #83

Merged
thomasluizon merged 1 commit into
mainfrom
feat/referral-coupon-auto-apply
Mar 28, 2026
Merged

feat: auto-apply referral coupon to active Pro subscriptions#83
thomasluizon merged 1 commit into
mainfrom
feat/referral-coupon-auto-apply

Conversation

@thomasluizon

Copy link
Copy Markdown
Owner

Summary

  • Pro users with active subscription: coupon applied directly to next invoice (no cancel needed)
  • Free/Trial users: coupon stored for checkout as before
  • Fixed notification not saving (DbContext disposed between two SaveChangesAsync calls -- now single save)
  • Notification messages adapt: "applied to next invoice" for Pro, "earned a coupon" for Free

Scenarios

  • Refer 1, buy Pro with discount, renews full price
  • Buy Pro, refer 1, next renewal gets discount automatically
  • Refer 2, buy Pro with first discount, next renewal uses second discount, then full price

Test Plan

  • Referral completion for Free user -- coupon stored, shows at checkout
  • Referral completion for Pro user -- coupon applied to subscription directly
  • Notification received by both users

🤖 Generated with Claude Code

- Pro users with active subscription: coupon applied to next invoice
  via Stripe Subscription.Update (no cancel/resubscribe needed)
- Free/Trial users: coupon stored for checkout
- Fixed notification not saving: single SaveChangesAsync for both
  coupon + notification (DbContext was being disposed between saves)
- Cleaned up into GrantCoupon/SendNotification helper methods
- Notification messages adapt for Pro users ("applied to next invoice"
  vs "earned a coupon")

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thomasluizon
thomasluizon merged commit 574ad36 into main Mar 28, 2026
2 checks passed
@thomasluizon
thomasluizon deleted the feat/referral-coupon-auto-apply branch March 28, 2026 17:49
thomasluizon added a commit that referenced this pull request Jun 5, 2026
…ve ordering (#185)

Bundles four correlated chat-agent changes:

- #83: tag chat tools (list/create/update/delete_tag) delegating to existing
  MediatR handlers, registered in DI and catalogued under tags.read/write/delete.
- #89: ReorderGoalsTool (mirrors ReorderHabitsTool) + unit tests for the new/write
  tag and goal tools; reorder_goals added to GoalsWrite.chatTools.
- #88: full executor routing — every mutating MCP method (GoalTools, TagTools,
  ProfileTools, NotificationTools, UserFactTools, SubscriptionTools) now routes
  through McpExecutorBridge → IAgentOperationExecutor for shared policy + audit,
  mapping mismatched methods to their consolidated chat ops. Hard cases routed too:
  assign_tags via a new tag_ids id-path on AssignTagsTool (id-based, replace-all,
  no auto-create; MCP id contract unchanged) and get_referral_code via a new
  GetReferralCodeTool + ReferralsWrite capability + WriteReferrals scope (added to
  ClaudeDefaultScopes). Destructive routed deletes (goal/tag/notification/user-fact)
  accept and forward a confirmation token. No mutating MCP method remains on direct
  MediatR. update_goal_progress widened to accept goal_id so its MCP method can route.
- #87: tool ordering is now data — int Order default-interface member on IAiTool
  (create_habit=0, create_sub_habit=1, assign_tags=2, default int.MaxValue); the
  hardcoded switch in ProcessUserChatCommand is replaced by the registry lookup.
  Adds Chat/Tools/README.md documenting the contract, Order, catalog invariant, and
  MCP-routing relationship.

Existing MCP toolset unit tests migrated to the executor-routed pattern.

Refs thomasluizon/orbit-ui-mobile#83, thomasluizon/orbit-ui-mobile#89,
thomasluizon/orbit-ui-mobile#88, thomasluizon/orbit-ui-mobile#87

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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