private void CreatePlanAndSubscription(RecurringGift gift, StripeAccount account, MinistryPlatformContext mpDB, StripeOnboardingContext stripeDB)
        {
            var plan = _paymentService.CreatePlan(MapToRecurringGiftDto(gift), MapToContactDonor(gift));
            var subscription = _paymentService.CreateSubscription(plan.Id, account.StripeCustomer.CustomerId, GetStartDate(gift));
            UpdateRecurringGiftAndDonorAccount(gift, account, subscription, mpDB, stripeDB);

        }
 private IEnumerable<RecurringGift> GetActiveNoneProcessedRecurringGifts(MinistryPlatformContext db)
 {
     return
         (from r in db.RecurringGifts
             where r.End_Date == null && r.DonorAccount.Processor_Account_ID == null
             select r).ToList();
 }
 private void CreatePlanAndSubscriptions(MinistryPlatformContext mpDB, StripeOnboardingContext stripeDB)
 {
     foreach (var gift in GetActiveNoneProcessedRecurringGifts(mpDB))
     {
         var account = GetStripeAccount(stripeDB, gift.Donor.C__ExternalPersonID, gift.DonorAccount.Account_Number);
         CreatePlanAndSubscription(gift, account, mpDB, stripeDB);
     }
 }
 public Messages generate()
 {
     using (var stripeDB = new StripeOnboardingContext())
     using (var mpDB = new MinistryPlatformContext())
     {
         CreatePlanAndSubscriptions(mpDB, stripeDB);
         return Messages.PlansAndSubscriptionsSuccess;
     }
 }
        private void UpdateRecurringGiftAndDonorAccount(RecurringGift gift, StripeAccount account, StripeSubscription subscription,
            MinistryPlatformContext mpDB, StripeOnboardingContext stripeDB)
        {
            gift.Subscription_ID = subscription.Id;
            gift.DonorAccount.Processor_Account_ID = account.NewCardId;
            gift.DonorAccount.Processor_ID = account.StripeCustomer.CustomerId;
            mpDB.SaveChanges();

            account.StripeCustomer.Imported = true;
            stripeDB.SaveChanges();
        }
 public VerifyStripeSubscriptions(MinistryPlatformContext mpContext, IPaymentService paymentService)
 {
     _mpContext = mpContext;
     _paymentService = paymentService;
 }