(c *gin.Context)
| 519 | } |
| 520 | |
| 521 | func 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 | |
| 557 | func RefunTradeOrder(c *gin.Context) { |
| 558 | orderId := c.Param("order_id") |
nothing calls this directly
no test coverage detected