public static Invoice GetUpcomingInvoice(string accountId) { var invoice = new Invoice(); #region (Plan A) Check Redis Cache First #endregion #region (Plan B) Call Stripe API, Transform Data & Store in Redis Cache var stripeManager = new StripeManager(); string stripeCustomerId = null; bool addAccountDetails = false; if (!String.IsNullOrEmpty(accountId)) { stripeCustomerId = AccountManager.GetAccount(accountId, true, AccountManager.AccountIdentificationType.AccountID).StripeCustomerID; } else { addAccountDetails = true; } //var stripeCustomerId = AccountManager.GetAccount(accountId, false, AccountManager.AccountIdentificationType.AccountID).StripeCustomerID; if (!String.IsNullOrEmpty(stripeCustomerId)) { var stripeInvoice = stripeManager.GetUpcomingInvoice(stripeCustomerId); if (stripeInvoice != null) { invoice = Transformations.TransformStripeInvoiceToInvoice(stripeInvoice, addAccountDetails); } } #endregion return(invoice); }