MCPcopy Index your code
hub / github.com/53AI/53AIHub / QueryTradeOrder

Function QueryTradeOrder

api/controller/order.go:521–555  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

519}
520
521func QueryTradeOrder(c *gin.Context) {
522 orderId := c.Param("order_id")
523 if orderId == "" {
524 c.JSON(http.StatusBadRequest, model.ParamError.ToResponse("Order ID is required"))
525 return
526 }
527
528 eid := config.GetEID(c)
529 // Try to get order from database
530 order, err := model.GetOrderByOrderId(eid, orderId)
531 if err != nil {
532 c.JSON(http.StatusNotFound, model.NotFound.ToNewErrorResponse(model.OrderNotFound))
533 return
534 }
535
536 paySetting, err := model.GetPaySettingByType(eid, order.PayType)
537 if err != nil {
538 c.JSON(http.StatusBadRequest, model.ParamError.ToResponse("Payment method not configured"))
539 return
540 }
541
542 factory := &payment.PaymentFactory{}
543 newPayment, err := factory.NewPayment(order.PayType)
544 if err != nil {
545 c.JSON(http.StatusBadRequest, model.ParamError.ToResponse(err))
546 return
547 }
548 rsp, err := newPayment.QueryPaymentStatus(order, paySetting)
549 if err != nil {
550 c.JSON(http.StatusInternalServerError, model.ParamError.ToResponse(err))
551 return
552 }
553
554 c.JSON(http.StatusOK, model.Success.ToResponse(rsp))
555}
556
557func RefunTradeOrder(c *gin.Context) {
558 orderId := c.Param("order_id")

Callers

nothing calls this directly

Calls 5

NewPaymentMethod · 0.95
ToResponseMethod · 0.80
GetEIDMethod · 0.80
ToNewErrorResponseMethod · 0.80
QueryPaymentStatusMethod · 0.65

Tested by

no test coverage detected