package api import ( "github.com/gin-gonic/gin" "veza-backend-api/internal/core/subscription" "veza-backend-api/internal/handlers" ) // setupSubscriptionRoutes configures routes for subscription plans management (v0.12.1) func (r *APIRouter) setupSubscriptionRoutes(router *gin.RouterGroup) { svc := subscription.NewService(r.db.GormDB, r.logger) handler := handlers.NewSubscriptionHandler(svc, r.logger) group := router.Group("/subscriptions") // Public: list available plans group.GET("/plans", handler.ListPlans) group.GET("/plans/:id", handler.GetPlan) // Protected: user subscription management if r.config.AuthMiddleware != nil { protected := group.Group("") protected.Use(r.config.AuthMiddleware.RequireAuth()) r.applyCSRFProtection(protected) protected.GET("/me", handler.GetMySubscription) protected.POST("/subscribe", handler.Subscribe) protected.POST("/cancel", handler.CancelSubscription) protected.POST("/reactivate", handler.ReactivateSubscription) protected.PUT("/billing-cycle", handler.ChangeBillingCycle) protected.GET("/invoices", handler.GetInvoices) protected.GET("/history", handler.GetSubscriptionHistory) } }