44 lines
1.5 KiB
Go
44 lines
1.5 KiB
Go
package handlers
|
|
|
|
import (
|
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
// CreateSantimPayPaymentHandler initializes a payment session with SantimPay.
|
|
//
|
|
// @Summary Create SantimPay Payment Session
|
|
// @Description Generates a payment URL using SantimPay and returns it to the client.
|
|
// @Tags SantimPay
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param request body domain.GeneratePaymentURLInput true "SantimPay payment request payload"
|
|
// @Success 200 {object} domain.Response
|
|
// @Failure 400 {object} domain.ErrorResponse
|
|
// @Failure 500 {object} domain.ErrorResponse
|
|
// @Router /api/v1/santimpay/payment [post]
|
|
func (h *Handler) CreateSantimPayPaymentHandler(c *fiber.Ctx) error {
|
|
var req domain.GeneratePaymentURLInput
|
|
if err := c.BodyParser(&req); err != nil {
|
|
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
|
Error: err.Error(),
|
|
Message: "Failed to process your request",
|
|
})
|
|
}
|
|
|
|
paymentURL, err := h.santimpaySvc.GeneratePaymentURL(req)
|
|
if err != nil {
|
|
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
|
Error: err.Error(),
|
|
Message: "Failed to initiate SantimPay payment session",
|
|
})
|
|
}
|
|
|
|
return c.Status(fiber.StatusOK).JSON(domain.Response{
|
|
Message: "SantimPay payment URL generated successfully",
|
|
Data: paymentURL,
|
|
Success: true,
|
|
StatusCode: fiber.StatusOK,
|
|
})
|
|
}
|