/// <summary> /// Updates a list of the coupon codes from stripe. /// </summary> /// <returns>true if the list was updated.</returns> private async Task <bool> UpdateCouponCodes() { StripeConfiguration.ApiKey = this.RequestOptions.ApiKey; bool updated; if (DateTime.Now - StripePaymentProcessor.promotionCodesUpdated > TimeSpan.FromMinutes(1)) { PromotionCodeService service = new PromotionCodeService(); StripeList <PromotionCode> codes = await service.ListAsync(new PromotionCodeListOptions() { Limit = 100 });; lock (StripePaymentProcessor.PromotionCodes) { StripePaymentProcessor.PromotionCodes.Clear(); StripePaymentProcessor.PromotionCodes.AddRange(codes.ToList()); } StripePaymentProcessor.promotionCodesUpdated = DateTime.Now; updated = true; } else { updated = false; } return(updated); }
public PaymentService( IUnitOfWork unitOfWork, IOrderService orderService, ICouponService couponService, IEmailService emailService, IShipmentService shipmentService, SessionService stripeSessionService, Stripe.CouponService stripeCouponService, CustomerService customerService, PromotionCodeService promotionCodeService, IOptions <ShippingRate> optionsAccessor, IMapper mapper) { _unitOfWork = unitOfWork; _orderService = orderService; _couponService = couponService; _customerService = customerService; _emailService = emailService; _shipmentService = shipmentService; _stripeSessionService = stripeSessionService; _stripeCouponService = stripeCouponService; _promotionCodeService = promotionCodeService; _shippingRate = optionsAccessor.Value; _mapper = mapper; }
public PromotionCodeServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new PromotionCodeService(this.StripeClient); this.createOptions = new PromotionCodeCreateOptions { Coupon = "co_123", Code = "TESTCODE", }; this.updateOptions = new PromotionCodeUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new PromotionCodeListOptions { Limit = 1, }; }