Files
epusdt/src/controller/comm/pay_controller.go
T
line-6000 9c533a7ff8 feat(pay): switch checkout counter to SPA redirect + JSON API
- redirect `/pay/checkout-counter/:trade_id` to `/cashier/:trade_id`
- add `/pay/checkout-counter-resp/:trade_id` for checkout JSON payload
- remove embedded `static` release and keep `www` as the web bundle source
- regenerate PWA/www assets and move chain icons to `/www/images/chains`
2026-04-29 00:34:58 +08:00

56 lines
1.8 KiB
Go

package comm
import (
"net/http"
"github.com/GMWalletApp/epusdt/model/response"
"github.com/GMWalletApp/epusdt/model/service"
"github.com/labstack/echo/v4"
)
// CheckoutCounter 收银台
// @Summary Checkout counter page
// @Description Render the payment checkout counter JSON response for a given trade
// @Tags Payment
// @Produce json
// @Param trade_id path string true "Trade ID"
// @Success 200 {object} response.CheckoutCounterResponse
// @Router /pay/checkout-counter-resp/{trade_id} [get]
func (c *BaseCommController) CheckoutCounter(ctx echo.Context) (err error) {
tradeId := ctx.Param("trade_id")
resp, err := service.GetCheckoutCounterByTradeId(tradeId)
if err != nil {
if err == service.ErrOrder {
// Unknown trade id: render the page with empty payload
// (client side shows a friendly "order not found" screen).
emptyResp := response.CheckoutCounterResponse{}
return c.SucJson(ctx, emptyResp)
}
return ctx.String(http.StatusInternalServerError, err.Error())
}
return c.SucJson(ctx, resp)
}
// CheckStatus 支付状态检测
// @Summary Check payment status
// @Description Check the payment status of an order by trade ID
// @Tags Payment
// @Produce json
// @Param trade_id path string true "Trade ID"
// @Success 200 {object} response.ApiResponse{data=response.CheckStatusResponse}
// @Failure 400 {object} response.ApiResponse
// @Router /pay/check-status/{trade_id} [get]
func (c *BaseCommController) CheckStatus(ctx echo.Context) (err error) {
tradeId := ctx.Param("trade_id")
order, err := service.GetOrderInfoByTradeId(tradeId)
if err != nil {
return c.FailJson(ctx, err)
}
resp := response.CheckStatusResponse{
TradeId: order.TradeId,
Status: order.Status,
}
return c.SucJson(ctx, resp)
}