добавлен биллинг и тарифы

добавлена интеграция с юкасса
This commit is contained in:
2025-12-24 09:06:19 +03:00
parent b4ce819931
commit 5f35d7a75f
15 changed files with 745 additions and 212 deletions

View File

@@ -0,0 +1,40 @@
package handlers
import (
"net/http"
"rmser/internal/infrastructure/yookassa"
"rmser/internal/services/billing"
"rmser/pkg/logger"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
type BillingHandler struct {
service *billing.Service
}
func NewBillingHandler(s *billing.Service) *BillingHandler {
return &BillingHandler{service: s}
}
func (h *BillingHandler) YooKassaWebhook(c *gin.Context) {
var event yookassa.WebhookEvent
if err := c.ShouldBindJSON(&event); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid json"})
return
}
logger.Log.Info("YooKassa Webhook received",
zap.String("event", event.Event),
zap.String("payment_id", event.Object.ID),
)
if err := h.service.ProcessWebhook(c.Request.Context(), event); err != nil {
logger.Log.Error("Failed to process webhook", zap.Error(err))
c.JSON(http.StatusInternalServerError, gin.H{"status": "error"})
return
}
c.JSON(http.StatusOK, gin.H{"status": "ok"})
}