feat: complete charge
This commit is contained in:
@@ -1,14 +1,35 @@
|
||||
package users
|
||||
|
||||
import "github.com/gofiber/fiber/v3"
|
||||
import (
|
||||
"backend/pkg/consts"
|
||||
"backend/providers/jwt"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
hashids "github.com/speps/go-hashids/v2"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Controller struct {
|
||||
svc *Service
|
||||
svc *Service
|
||||
hashIds *hashids.HashID
|
||||
}
|
||||
|
||||
// List
|
||||
func (c *Controller) List(ctx fiber.Ctx) error {
|
||||
return ctx.SendString(ctx.Params("tenant", "no user"))
|
||||
return ctx.JSON(nil)
|
||||
}
|
||||
|
||||
// Charge
|
||||
func (c *Controller) Charge(ctx fiber.Ctx) error {
|
||||
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
|
||||
log.Debug(claim)
|
||||
|
||||
// [tenantId, chargeAmount, timestamp]
|
||||
code := ctx.Params("code")
|
||||
if err := c.svc.Charge(ctx.Context(), claim, code); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ctx.JSON(nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user