GetPaySettingByType gets a payment setting by type @Summary Get payment setting by type @Description Get a payment setting by payment type @Tags PaySetting @Accept json @Produce json @Param type path int true "Payment type (1: WeChat Pay, 2: Manual Transfer, 3: PayPal)" @Success 200 {object} model.C
(c *gin.Context)
| 264 | // @Success 200 {object} model.CommonResponse{data=model.PaySetting} |
| 265 | // @Router /api/pay_settings/type/{type} [get] |
| 266 | func GetPaySettingByType(c *gin.Context) { |
| 267 | typeStr := c.Param("type") |
| 268 | payType, err := strconv.Atoi(typeStr) |
| 269 | if err != nil { |
| 270 | c.JSON(http.StatusBadRequest, model.ParamError.ToResponse("Invalid payment type")) |
| 271 | return |
| 272 | } |
| 273 | |
| 274 | // Validate payment type |
| 275 | if !isValidPayType(payType) { |
| 276 | c.JSON(http.StatusBadRequest, model.ParamError.ToResponse("Invalid payment type")) |
| 277 | return |
| 278 | } |
| 279 | |
| 280 | paySetting, err := model.GetPaySettingByType(config.GetEID(c), payType) |
| 281 | if err != nil { |
| 282 | c.JSON(http.StatusNotFound, model.NotFound.ToResponse(nil)) |
| 283 | return |
| 284 | } |
| 285 | |
| 286 | c.JSON(http.StatusOK, model.Success.ToResponse(paySetting)) |
| 287 | } |
| 288 | |
| 289 | // PayConfigRequest represents the request for updating payment configuration |
| 290 | type PayConfigRequest struct { |
nothing calls this directly
no test coverage detected