public async Task <PaymentGatewayResult <IPaymentCoupon> > CreateCouponAsync(CreateCouponViewModel model) { try { var options = new CouponCreateOptions(); if (model.Duration != "repeating") { model.DurationInMonths = null; } model.Currency = "usd"; model.MaxRedemptions = model.MaxRedemptions > 0 ? model.MaxRedemptions : null; model.PercentOff = model.PercentOff > 0 ? model.PercentOff : null; model.AmountOff = model.AmountOff > 0 ? model.AmountOff * 100 : null; options = _mapper.Map <CouponCreateOptions>(model); var coupon = await _couponService.CreateAsync(options); if (coupon.PercentOff != null) { if (coupon.Duration == "once") { coupon.Object = coupon.PercentOff + "% off " + coupon.Duration; } else if (coupon.Duration == "forever") { coupon.Object = coupon.PercentOff + "% off " + coupon.Duration; } else if (coupon.Duration == "repeating") { if (coupon.DurationInMonths == 1) { coupon.Object = coupon.PercentOff + "% off every Year for 1 month"; } else { coupon.Object = coupon.PercentOff + "% off every Year for " + coupon.DurationInMonths + " months"; } } } if (coupon.AmountOff != null) { if (coupon.Duration == "once") { coupon.Object = "$" + coupon.AmountOff + " off once"; } else if (coupon.Duration == "forever") { coupon.Object = "$" + coupon.AmountOff + " off " + coupon.Duration; } else if (coupon.Duration == "repeating") { if (coupon.DurationInMonths == 1) { coupon.Object = coupon.Currency.ToUpper() + coupon.AmountOff + " off every Year for 1 month"; } else { coupon.Object = "$" + coupon.AmountOff + " off every Year for " + coupon.DurationInMonths + " months"; } } } return(PaymentGatewayResult <IPaymentCoupon> .Success(_mapper.Map <IPaymentCoupon>(coupon))); } catch (StripeException e) { return(PaymentGatewayResult <IPaymentCoupon> .Failed(e)); } }