feat(server): Implement payment routes and handler initialization
- Add payment routes with placeholders for CreatePaymentIntent, ConfirmPayment, and HandleWebhook - Introduce initializeServices method to set up payment service and handler - Update Server struct to include paymentHandler - Prepare infrastructure for payment-related functionality - Enhance server initialization process with service setup
This commit is contained in:
parent
a45b22afd0
commit
d0117e6ac7
@ -6,6 +6,8 @@ import (
|
|||||||
|
|
||||||
"attune-heart-therapy/internal/config"
|
"attune-heart-therapy/internal/config"
|
||||||
"attune-heart-therapy/internal/database"
|
"attune-heart-therapy/internal/database"
|
||||||
|
"attune-heart-therapy/internal/handlers"
|
||||||
|
"attune-heart-therapy/internal/services"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -14,6 +16,7 @@ type Server struct {
|
|||||||
config *config.Config
|
config *config.Config
|
||||||
db *database.DB
|
db *database.DB
|
||||||
router *gin.Engine
|
router *gin.Engine
|
||||||
|
paymentHandler *handlers.PaymentHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(cfg *config.Config) *Server {
|
func New(cfg *config.Config) *Server {
|
||||||
@ -51,6 +54,9 @@ func (s *Server) Initialize() error {
|
|||||||
return fmt.Errorf("failed to seed database: %w", err)
|
return fmt.Errorf("failed to seed database: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize services and handlers
|
||||||
|
s.initializeServices()
|
||||||
|
|
||||||
log.Println("Server initialization completed successfully")
|
log.Println("Server initialization completed successfully")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -117,18 +123,12 @@ func (s *Server) setupRoutes() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Payment routes (will be implemented in later tasks)
|
// Payment routes
|
||||||
payments := v1.Group("/payments")
|
payments := v1.Group("/payments")
|
||||||
{
|
{
|
||||||
payments.POST("/intent", func(c *gin.Context) {
|
payments.POST("/intent", s.paymentHandler.CreatePaymentIntent)
|
||||||
c.JSON(501, gin.H{"message": "Not implemented yet"})
|
payments.POST("/confirm", s.paymentHandler.ConfirmPayment)
|
||||||
})
|
payments.POST("/webhook", s.paymentHandler.HandleWebhook)
|
||||||
payments.POST("/confirm", func(c *gin.Context) {
|
|
||||||
c.JSON(501, gin.H{"message": "Not implemented yet"})
|
|
||||||
})
|
|
||||||
payments.POST("/webhook", func(c *gin.Context) {
|
|
||||||
c.JSON(501, gin.H{"message": "Not implemented yet"})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Admin routes (will be implemented in later tasks)
|
// Admin routes (will be implemented in later tasks)
|
||||||
@ -141,6 +141,15 @@ func (s *Server) setupRoutes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initializeServices sets up all services and handlers
|
||||||
|
func (s *Server) initializeServices() {
|
||||||
|
// Initialize payment service
|
||||||
|
paymentService := services.NewPaymentService(s.config)
|
||||||
|
|
||||||
|
// Initialize payment handler
|
||||||
|
s.paymentHandler = handlers.NewPaymentHandler(paymentService)
|
||||||
|
}
|
||||||
|
|
||||||
// healthCheck handles the health check endpoint
|
// healthCheck handles the health check endpoint
|
||||||
func (s *Server) healthCheck(c *gin.Context) {
|
func (s *Server) healthCheck(c *gin.Context) {
|
||||||
response := gin.H{
|
response := gin.H{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user