payment-history: /{id} lists the order's payments, logs move to /{id}/logs
GET /payment-history/{id} now returns one row per payment of the order
(paid, card, time, period, amounts), newest first - the per-order payment
table the frontend already calls. The step-by-step logs it used to return
are kept at GET /payment-history/{id}/logs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a715cd23ea
commit
c209f338c2
7 files changed
+319
-14
No files matched your search
@@ -31,7 +31,8 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
||||
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Cards))
|
||||
group.GET("", h.list)
|
||||
group.GET("/payments/:id", h.get)
|
||||
group.GET("/:id", h.logs)
|
||||
group.GET("/:id", h.orderPayments)
|
||||
group.GET("/:id/logs", h.logs)
|
||||
}
|
||||
|
||||
// list godoc
|
||||
@@ -108,19 +109,53 @@ func (h *handler) get(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||
}
|
||||
|
||||
// logs godoc
|
||||
// @Summary Get payment logs for an order
|
||||
// @Description Returns the full step-by-step audit trail (visa_master_payment_logs) recorded while processing an order's payout - evidence of what actually happened, independent of the summary rows returned by the list endpoint
|
||||
// orderPayments godoc
|
||||
// @Summary List an order's payments
|
||||
// @Description Returns every visa/master/sber payout attempt of one order, newest first - one row per payment with whether it was paid (paid/gatewayStatus), the card it was paid from (cardholderName/maskedPan, once GBÜS reports them), its time (createdAt) and period (paymentPeriod). The raw GBÜS response of a row is at /payment-history/payments/{id}; the step-by-step logs are at /payment-history/{id}/logs.
|
||||
// @Tags payment-history
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "Order ID"
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Success 200 {array} PaymentHistoryItemDTO
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 403 {object} appresult.AppError
|
||||
// @Failure 404 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /payment-history/{id} [get]
|
||||
func (h *handler) orderPayments(c *gin.Context) {
|
||||
orderID, ok := shared.ParseID(c.Param("id"))
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
if !h.guardOrder(c, orderID) {
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.repository.OrderPayments(c.Request.Context(), orderID)
|
||||
if err != nil {
|
||||
h.logger.Errorf("list order payments failed (order %d): %v", orderID, err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||
}
|
||||
|
||||
// logs godoc
|
||||
// @Summary Get payment logs for an order
|
||||
// @Description Returns the full step-by-step audit trail (visa_master_payment_logs) recorded while processing an order's payout, newest first - evidence of what actually happened, independent of the summary rows returned by /payment-history/{id}
|
||||
// @Tags payment-history
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "Order ID"
|
||||
// @Success 200 {array} PaymentLogDTO
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 403 {object} appresult.AppError
|
||||
// @Failure 404 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /payment-history/{id}/logs [get]
|
||||
func (h *handler) logs(c *gin.Context) {
|
||||
orderID, ok := shared.ParseID(c.Param("id"))
|
||||
if !ok {
|
||||
|
||||
Reference in new issue
Block a user