add epay route support

This commit is contained in:
line-6000
2026-04-12 18:14:40 +08:00
parent 730ff983f8
commit 32ca778735
9 changed files with 216 additions and 29 deletions
+29
View File
@@ -1,6 +1,9 @@
package comm
import (
"fmt"
"log"
"github.com/assimon/luuu/model/request"
"github.com/assimon/luuu/model/service"
"github.com/assimon/luuu/util/constant"
@@ -22,3 +25,29 @@ func (c *BaseCommController) CreateTransaction(ctx echo.Context) (err error) {
}
return c.SucJson(ctx, resp)
}
func (c *BaseCommController) CreateTransactionAndRedirect(ctx echo.Context) (err error) {
req := new(request.CreateTransactionRequest)
if err = ctx.Bind(req); err != nil {
log.Println("bind request error:", err)
return c.FailJson(ctx, constant.ParamsMarshalErr)
}
if err = c.ValidateStruct(ctx, req); err != nil {
log.Println("validate request error:", err)
return c.FailJson(ctx, err)
}
resp, err := service.CreateTransaction(req)
if err != nil {
log.Println("create transaction error:", err)
return c.FailJson(ctx, err)
}
fmt.Printf("create transaction response: %+v\n", resp)
tradeID := resp.TradeId
ctx.Redirect(302, "/pay/checkout-counter/"+tradeID)
return nil
}