feat: complete wechat pay
This commit is contained in:
@@ -23,7 +23,7 @@ type pays struct {
|
||||
|
||||
// Callback
|
||||
//
|
||||
// @Router /pay/callback/:channel [get]
|
||||
// @Router /pay/callback/:channel [post]
|
||||
// @Bind channel path
|
||||
func (ctl *pays) Callback(ctx fiber.Ctx, channel string) error {
|
||||
log := log.WithField("method", "pays.Callback")
|
||||
|
||||
@@ -241,7 +241,7 @@ func (ctl *posts) Mine(ctx fiber.Ctx, pagination *requests.Pagination, query *Li
|
||||
|
||||
// Buy
|
||||
//
|
||||
// @Router /posts/:id/buy [get]
|
||||
// @Router /posts/:id/buy [post]
|
||||
// @Bind id path
|
||||
// @Bind user local
|
||||
func (ctl *posts) Buy(ctx fiber.Ctx, id int64, user *model.Users) (*wechat.JSAPIPayParams, error) {
|
||||
|
||||
@@ -46,7 +46,7 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
))
|
||||
|
||||
// 注册路由组: pays
|
||||
router.Get("/pay/callback/:channel", Func1(
|
||||
router.Post("/pay/callback/:channel", Func1(
|
||||
r.pays.Callback,
|
||||
PathParam[string]("channel"),
|
||||
))
|
||||
@@ -78,7 +78,7 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
Local[*model.Users]("user"),
|
||||
))
|
||||
|
||||
router.Get("/posts/:id/buy", DataFunc2(
|
||||
router.Post("/posts/:id/buy", DataFunc2(
|
||||
r.posts.Buy,
|
||||
PathParam[int64]("id"),
|
||||
Local[*model.Users]("user"),
|
||||
|
||||
@@ -21,7 +21,7 @@ type wechats struct {
|
||||
// @Bind url query
|
||||
// @Bind user local
|
||||
func (ctl *wechats) GetJsSDK(ctx fiber.Ctx, url string, user *model.Users) (*wechat.JsSDK, error) {
|
||||
if user.AuthToken.Data.StableExpiresAt.After(time.Now()) {
|
||||
if user.AuthToken.Data.StableExpiresAt.Before(time.Now()) {
|
||||
token, err := ctl.wechat.RefreshAccessToken(user.AuthToken.Data.RefreshToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user