public CouponServiceTest(
            StripeMockFixture stripeMockFixture,
            MockHttpClientFixture mockHttpClientFixture)
            : base(stripeMockFixture, mockHttpClientFixture)
        {
            this.service = new CouponService(this.StripeClient);

            this.createOptions = new CouponCreateOptions
            {
                PercentOff = 25,
                Duration   = "forever",
            };

            this.updateOptions = new CouponUpdateOptions
            {
                Metadata = new Dictionary <string, string>
                {
                    { "key", "value" },
                },
            };

            this.listOptions = new CouponListOptions
            {
                Limit = 1,
            };
        }
        public CouponServiceTest()
        {
            this.service = new CouponService();

            this.createOptions = new CouponCreateOptions
            {
                PercentOff = 25,
                Duration   = "forever",
            };

            this.updateOptions = new CouponUpdateOptions
            {
                Metadata = new Dictionary <string, string>
                {
                    { "key", "value" },
                },
            };

            this.listOptions = new CouponListOptions
            {
                Limit = 1,
            };
        }
 public virtual IEnumerable <Coupon> ListAutoPaging(CouponListOptions options = null, RequestOptions requestOptions = null)
 {
     return(this.ListEntitiesAutoPaging(options, requestOptions));
 }
 public virtual Task <StripeList <Coupon> > ListAsync(CouponListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(this.ListEntitiesAsync(options, requestOptions, cancellationToken));
 }
 public virtual StripeList <Coupon> List(CouponListOptions options = null, RequestOptions requestOptions = null)
 {
     return(this.ListEntities(options, requestOptions));
 }
        public async Task <PaymentGatewayResult <List <IPaymentCoupon> > > GetAllCouponsAsync()
        {
            try
            {
                var options = new CouponListOptions
                {
                    Limit = 100,
                };
                var coupons = await _couponService.ListAsync(options);

                foreach (var item in coupons.Data)
                {
                    if (item.PercentOff != null)
                    {
                        if (item.Duration == "once")
                        {
                            item.Object = item.PercentOff + "% off " + item.Duration;
                        }
                        else if (item.Duration == "forever")
                        {
                            item.Object = item.PercentOff + "% off " + item.Duration;
                        }

                        else if (item.Duration == "repeating")
                        {
                            if (item.DurationInMonths == 1)
                            {
                                item.Object = item.PercentOff + "% off every Year for 1 month";
                            }
                            else
                            {
                                item.Object = item.PercentOff + "% off every Year for " + item.DurationInMonths + " months";
                            }
                        }
                    }

                    if (item.AmountOff != null)
                    {
                        item.AmountOff = item.AmountOff / 100;
                        if (item.Duration == "once")
                        {
                            item.Object = "$" + item.AmountOff + " off once";
                        }

                        else if (item.Duration == "forever")
                        {
                            item.Object = "$" + item.AmountOff + " off " + item.Duration;
                        }

                        else if (item.Duration == "repeating")
                        {
                            if (item.DurationInMonths == 1)
                            {
                                item.Object = "$" + item.AmountOff + " off every Year for 1 month";
                            }
                            else
                            {
                                item.Object = "$" + item.AmountOff + " off every Year for " + item.DurationInMonths + " months";
                            }
                        }
                    }
                }
                return(PaymentGatewayResult <List <IPaymentCoupon> > .Success(_mapper.Map <List <IPaymentCoupon> >(coupons)));
            }
            catch (StripeException e)
            {
                return(PaymentGatewayResult <List <IPaymentCoupon> > .Failed(e));
            }
        }
Beispiel #7
0
 public virtual IAsyncEnumerable <Coupon> ListAutoPagingAsync(CouponListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
 {
     return(this.ListEntitiesAutoPagingAsync(options, requestOptions, cancellationToken));
 }