(c *gin.Context, req *StripePayRequest)
| 34 | } |
| 35 | |
| 36 | func (*StripeAdaptor) RequestAmount(c *gin.Context, req *StripePayRequest) { |
| 37 | if req.Amount < getStripeMinTopup() { |
| 38 | c.JSON(200, gin.H{"message": "error", "data": fmt.Sprintf("充值数量不能小于 %d", getStripeMinTopup())}) |
| 39 | return |
| 40 | } |
| 41 | id := c.GetInt("id") |
| 42 | group, err := model.GetUserGroup(id, true) |
| 43 | if err != nil { |
| 44 | c.JSON(200, gin.H{"message": "error", "data": "获取用户分组失败"}) |
| 45 | return |
| 46 | } |
| 47 | payMoney := getStripePayMoney(float64(req.Amount), group) |
| 48 | if payMoney <= 0.01 { |
| 49 | c.JSON(200, gin.H{"message": "error", "data": "充值金额过低"}) |
| 50 | return |
| 51 | } |
| 52 | c.JSON(200, gin.H{"message": "success", "data": strconv.FormatFloat(payMoney, 'f', 2, 64)}) |
| 53 | } |
| 54 | |
| 55 | func (*StripeAdaptor) RequestPay(c *gin.Context, req *StripePayRequest) { |
| 56 | if req.PaymentMethod != PaymentMethodStripe { |
no test coverage detected