public static List <Charge> GetPaymentHistory(int itemLimit, string accountId = null) { var charges = new List <Charge>(); #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 stripeCharges = stripeManager.GetCharges(itemLimit, stripeCustomerId); if (stripeCharges != null) { foreach (var stripeCharge in stripeCharges) { charges.Add(Transformations.TransformStripeChargeToCharge(stripeCharge, addAccountDetails)); } } #endregion return(charges); }