feat: add callback

This commit is contained in:
yanghao05
2025-04-14 21:15:24 +08:00
parent ea867f7261
commit 6e822e1a1b
7 changed files with 95 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ import (
"quyun/database/schemas/public/model"
"quyun/providers/wepay"
"github.com/go-pay/gopay/wechat/v3"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/log"
"github.com/pkg/errors"
@@ -50,7 +51,7 @@ func (ctl *posts) Mine(ctx fiber.Ctx, pagination *requests.Pagination, query *Li
// Buy
// @Router /buy/:id [get]
// @Bind id path
func (ctl *posts) Buy(ctx fiber.Ctx, id int64) (*wepay.PrepayData, error) {
func (ctl *posts) Buy(ctx fiber.Ctx, id int64) (*wechat.JSAPIPayParams, error) {
var userId int64 = 1
user, err := models.Users.GetByID(ctx.Context(), userId)
@@ -80,5 +81,6 @@ func (ctl *posts) Buy(ctx fiber.Ctx, id int64) (*wepay.PrepayData, error) {
log.Errorf("wepay.V3TransactionJsapi err: %v", err)
return nil, errors.Wrap(err, "微信支付失败")
}
return prePayResp, nil
return prePayResp.PaySignOfJSAPI()
}