mirror of
https://github.com/labring/sealos.git
synced 2026-08-28 17:22:42 +08:00
5b2d873bd8
* feat: add workspace subscription card management APIs - Add CreateWorkspaceSubscriptionCardManagePortal for creating Stripe portal sessions - Add GetWorkspaceSubscriptionCardInfo for retrieving payment method details - Add new request structs and route definitions - Update constants for new API endpoints 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: implement subscription-specific card management portal - Add CreateSubscriptionPortalSession method in Stripe service - Modify CreateWorkspaceSubscriptionCardManagePortal to use workspace-specific subscription - Use flow_data to restrict portal to payment method updates only - This ensures users only see the current workspace's subscription in the portal 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: implement subscription upgrade billing cycle reset and discount code support ## Key Changes ### 1. New Billing Logic for Upgrades - Changed from prorated remaining value to current plan remaining value calculation - Formula: Upgrade Fee = New Plan Full Price - Current Plan Remaining Value - Ensures fair pricing based on unused portion of current plan ### 2. Billing Cycle Reset for Upgrades - Upgrade payments now start a new billing cycle from the upgrade date - Next payment date resets to the same day next month - Modified finalizeWorkspaceSubscriptionSuccess to handle upgrade cycle reset ### 3. Discount Code Integration - Added DiscountCode field to WorkspaceSubscriptionOperatorReq - Created CreateWorkspaceSubscriptionSessionWithDiscount method for payment sessions - Enhanced UpdatePlanPricePreviewWithDiscount for accurate discount preview - Discount information stored in transaction.StatusDesc ### 4. API Response Enhancement - Upgrade amount API returns detailed discount information - Supports amount preview with and without discount codes - Frontend can display discount comparison and validation ### 5. Stripe SDK Integration - Used InvoiceCreatePreviewParams.Discounts for discount preview - Used CheckoutSessionParams.Discounts for payment discount - Proper BillingCycleAnchor configuration for upgrade cycles ## Technical Implementation - Maintains backward compatibility for existing operations - Discount codes only apply to upgrade operations - Consistent billing cycle logic across preview and payment - No database schema changes required 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: enhance subscription upgrade package management with proper expiration - Add upgrade-aware traffic and AI quota package management - Implement proper expiration of old packages during upgrades - Add AddTrafficPackageWithUpgrade and AddWorkspaceSubscriptionAIQuotaPackageWithUpgrade functions - Fix stripe subscription cancellation and upgrade logic - Maintain backward compatibility with existing package functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * add redirect url & create subscription setup intent * support get create subscription amount with discount code. * convert the discount code to the promotion code * support cancel workspace subscription invoice * support deleteImmediately --------- Co-authored-by: Claude <noreply@anthropic.com>