MCPcopy Create free account
hub / github.com/53AI/53AIHub / GetPaySettingByType

Function GetPaySettingByType

api/controller/pay_setting.go:266–287  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

264// @Success 200 {object} model.CommonResponse{data=model.PaySetting}
265// @Router /api/pay_settings/type/{type} [get]
266func 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
290type PayConfigRequest struct {

Callers

nothing calls this directly

Calls 3

isValidPayTypeFunction · 0.85
ToResponseMethod · 0.80
GetEIDMethod · 0.80

Tested by

no test coverage detected