mirror of
https://github.com/GMWalletApp/epusdt.git
synced 2026-07-07 10:16:15 +00:00
update payment ui and change api route path
This commit is contained in:
+43
-11
@@ -1,6 +1,9 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/assimon/luuu/controller/comm"
|
||||
@@ -13,16 +16,45 @@ func RegisterRoute(e *echo.Echo) {
|
||||
e.Any("/", func(c echo.Context) error {
|
||||
return c.String(http.StatusOK, "hello epusdt, https://github.com/GMwalletApp/epusdt")
|
||||
})
|
||||
// ==== 支付相关=====
|
||||
payRoute := e.Group("/legacy/pay")
|
||||
// 收银台
|
||||
payRoute.GET("/checkout-counter/:trade_id", comm.Ctrl.LegecyCheckoutCounter)
|
||||
// 状态检测
|
||||
payRoute.GET("/check-status/:trade_id", comm.Ctrl.LegecyCheckStatus)
|
||||
|
||||
apiV1Route := e.Group("/legacy/api/v1")
|
||||
// ====订单相关====
|
||||
orderRoute := apiV1Route.Group("/order", middleware.LegecyCheckApiSign())
|
||||
// 创建订单
|
||||
orderRoute.POST("/create-transaction", comm.Ctrl.LegecyCreateTransaction)
|
||||
payRoute := e.Group("/pay")
|
||||
payRoute.GET("/checkout-counter/:trade_id", comm.Ctrl.CheckoutCounter)
|
||||
payRoute.GET("/check-status/:trade_id", comm.Ctrl.CheckStatus)
|
||||
|
||||
// payment routes
|
||||
paymentRoute := e.Group("/payments")
|
||||
|
||||
// for epusdt
|
||||
epusdtV1 := paymentRoute.Group("/epusdt/v1")
|
||||
epusdtV1.POST("/order/create-transaction", func(ctx echo.Context) error {
|
||||
// add default token and currency for old plugin
|
||||
|
||||
body := make(map[string]interface{})
|
||||
if err := ctx.Bind(&body); err != nil {
|
||||
return comm.Ctrl.FailJson(ctx, err)
|
||||
}
|
||||
if _, ok := body["token"]; !ok {
|
||||
body["token"] = "usdt"
|
||||
}
|
||||
if _, ok := body["currency"]; !ok {
|
||||
body["currency"] = "cny"
|
||||
}
|
||||
if _, ok := body["network"]; !ok {
|
||||
body["network"] = "TRON"
|
||||
}
|
||||
ctx.Set("request_body", body)
|
||||
|
||||
jsonBytes, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
return comm.Ctrl.FailJson(ctx, err)
|
||||
}
|
||||
ctx.Request().Body = io.NopCloser(bytes.NewBuffer(jsonBytes))
|
||||
|
||||
return comm.Ctrl.CreateTransaction(ctx)
|
||||
}, middleware.CheckApiSign())
|
||||
|
||||
// gmpay v1 routes
|
||||
gmpayV1 := paymentRoute.Group("/gmpay/v1")
|
||||
gmpayV1.POST("/order/create-transaction", comm.Ctrl.CreateTransaction, middleware.CheckApiSign())
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user