public StripeCoupon CreateCoupon(StripeCouponInfo coupon) { if (coupon == null) { throw new ArgumentNullException("coupon"); } if (coupon.PercentOff < 1 || coupon.PercentOff > 100) { throw new ArgumentOutOfRangeException("coupon.PercentOff"); } if (coupon.Duration == StripeCouponDuration.Repeating && coupon.MonthsForDuration < 1) { throw new ArgumentException("MonthsForDuration must be greater than 1 when Duration = Repeating"); } StringBuilder str = UrlEncode(coupon); string ep = string.Format("{0}/coupons", api_endpoint); return(DoRequest <StripeCoupon> (ep, "POST", str.ToString())); }
public StripeCoupon CreateCoupon(StripeCouponInfo coupon) { if (coupon == null) throw new ArgumentNullException ("coupon"); if (coupon.PercentOff < 1 || coupon.PercentOff > 100) throw new ArgumentOutOfRangeException ("coupon.PercentOff"); if (coupon.Duration == StripeCouponDuration.Repeating && coupon.MonthsForDuration < 1) throw new ArgumentException ("MonthsForDuration must be greater than 1 when Duration = Repeating"); StringBuilder str = UrlEncode (coupon); string ep = string.Format ("{0}/coupons", api_endpoint); string json = DoRequest (ep, "POST", str.ToString ()); return JsonConvert.DeserializeObject<StripeCoupon> (json); }