static void Main(string[] args) { // Set Stripe Api Key StripeConfiguration.SetApiKey(AppConfiguration.StripeApiKey); using (var subscriptionBookingRepository = new SubscriptionBookingRepository()) { var subscriptionBookingList = subscriptionBookingRepository.SubscriptionBookingsList.Where(sb => ids.Contains(sb.Id)).ToList(); // Each Subscription Bookings subscriptionBookingList.ForEach(subscriptionBookings => { var customerInfos = subscriptionBookingRepository.CustomerInfoList .FirstOrDefault(ci => ci.CustomerId == subscriptionBookings.CustomerId); // Customer Infos if (customerInfos != null) { var subscriptionService = new StripeSubscriptionService(); StripeSubscription subscription = subscriptionService.Get(subscriptionBookings.StripeSubscriptionId); DateTime?canceledDate = subscription.CanceledAt; if (canceledDate.HasValue) { subscriptionBookings.CancelDate = canceledDate; } } }); subscriptionBookingRepository.UpdateSubscriptionBookingCanceledDate(subscriptionBookingList); Console.WriteLine("Done!!!"); Console.ReadLine(); } }
static void Main(string[] args) { // Set Stripe Api Key StripeConfiguration.SetApiKey(AppConfiguration.StripeApiKey); using (var subscriptionBookingRepository = new SubscriptionBookingRepository()) { var subscriptionBookingList = subscriptionBookingRepository.SubscriptionBookingsList.Where(sb => ids.Contains(sb.Id)).ToList(); // Each Subscription Bookings subscriptionBookingList.ForEach(subscriptionBookings => { var customerInfos = subscriptionBookingRepository.CustomerInfoList .FirstOrDefault(ci => ci.CustomerId == subscriptionBookings.CustomerId); // Customer Infos if (customerInfos != null) { var subscriptionService = new StripeSubscriptionService(); StripeSubscription subscription = subscriptionService.Get(subscriptionBookings.StripeSubscriptionId); DateTime?canceledDate = subscription.CanceledAt; if (canceledDate.HasValue) { subscriptionBookings.CancelDate = canceledDate; } switch (subscription.Status) { case "past_due": case "unpaid": subscriptionBookings.Status = (int)Enums.SubscriptionBookingStatus.Suspended; break; case "active": // Set Date of Discounts //subscriptionBookings.Status = (int)Enums.SubscriptionBookingStatus.Active; break; case "canceled": //subscriptionBookings.Status = (int)Enums.SubscriptionBookingStatus.End; break; default: //trialing break; } } }); subscriptionBookingRepository.UpdateSubscriptionBookingCanceledDate(subscriptionBookingList); Console.WriteLine("Done!!!"); Console.ReadLine(); } }