private List <CardInfo> GetCardsList()
        {
            var        result = new List <CardInfo>();
            FileStream f      = null;

            try
            {
                string           orderType    = "RSO";
                MyHLShoppingCart shoppingCart = (Page as ProductsBase).ShoppingCart;

                if (_enableInstallments)
                {
                    if (shoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.ETO)
                    {
                        orderType = "ETO";
                    }

                    if (APFDueProvider.containsOnlyAPFSku(shoppingCart.ShoppingCartItems))
                    {
                        orderType = "APF";
                    }

                    _installmentsConfiguration = InstallmentsProvider.GetInstallmentsConfiguration((Page as ProductsBase).CountryCode, DateTime.Today, orderType);

                    // Check the source for installments config
                    if (!_paymentsConfig.LocalInstallmentsSource)
                    {
                        _cards = _installmentsConfiguration.Cards;
                    }
                    else
                    {
                        var serial = new XmlSerializer(typeof(Cards));
                        //f = System.IO.File.OpenRead(Server.MapPath("~/Ordering/Controls/Payments/PaymentGateways/CardData_es-AR.xml"));
                        f      = File.OpenRead(Server.MapPath("~/App_Data/Configuration/CardData_es-AR.xml"));
                        _cards = serial.Deserialize(f) as Cards;
                    }
                }

                result = _cards != null ? _cards.Card : null;
            }
            catch (Exception ex)
            {
                //string errorMessage =
                //    "Cannot find Credit Card CardData_es-AR.xml. Cannot calculate fees for Payment Installments";
                LoggerHelper.Error(string.Format("\r\nException: {0}", ex.Message));
                //throw new ApplicationException(errorMessage, ex);
            }
            finally
            {
                if (null != f)
                {
                    f.Close();
                }
            }
            return(result);
        }
 // **********************************************************************************************
 private static void SaveInstallmentConfigurationInfoToCache(string cacheKey,
                                                             InstallmentConfiguration configuration,
                                                             HttpSessionState session)
 {
     if (configuration != null)
     {
         if (null != HttpContext.Current)
         {
             var thisSession = session ?? HttpContext.Current.Session;
             thisSession[cacheKey] = configuration;
         }
     }
 }
        public static InstallmentConfiguration GetInstallmentsConfiguration(string CountryCode,
                                                                            DateTime applicationDate,
                                                                            string orderType)
        {
            if (string.IsNullOrEmpty(CountryCode))
            {
                return(null);
            }

            string cacheKey = GetCacheKey(CountryCode, applicationDate, orderType);

            var installmentConfiguration = GetInstallmentsConfigurationInfoFromCache(cacheKey);

            if (installmentConfiguration == null || installmentConfiguration.Month != applicationDate.Month)
            {
                installmentConfiguration = new InstallmentConfiguration();

                var results = LoadInstallmentsConfigurationInfoFromService(CountryCode, applicationDate);

                if (results != null)
                {
                    var result     = results.Find(r => r.OrderType == orderType);
                    var serializer = new XmlSerializer(typeof(Cards));

                    if (result != null && !string.IsNullOrEmpty(result.ConfigurationData))
                    {
                        var creditCardsInstallmentsConfiguration =
                            (Cards)serializer.Deserialize(new StringReader(result.ConfigurationData));

                        installmentConfiguration.Cards = creditCardsInstallmentsConfiguration;
                    }

                    if (result != null)
                    {
                        if (result.DraftExclusionDateTime != null)
                        {
                            installmentConfiguration.DraftExclusionDateTime = (DateTime)result.DraftExclusionDateTime;
                        }
                        if (result.LastDateTimeToPlaceOrders != null)
                        {
                            installmentConfiguration.LastDateTimeToPlaceOrders =
                                (DateTime)result.LastDateTimeToPlaceOrders;
                        }
                        if (result.LastPaymentDateTime != null)
                        {
                            installmentConfiguration.LastPaymentDateTime = (DateTime)result.LastPaymentDateTime;
                        }
                        if (result.TicketDueDate != null)
                        {
                            installmentConfiguration.TicketDueDate = (DateTime)result.TicketDueDate;
                        }

                        installmentConfiguration.Month = (byte)result.ApplyDate.Month;
                        installmentConfiguration.Year  = result.ApplyDate.Year;
                    }
                }
                else
                {
                    installmentConfiguration.Month = (byte)applicationDate.Month;
                    installmentConfiguration.Year  = applicationDate.Year;
                }

                SaveInstallmentConfigurationInfoToCache(cacheKey, installmentConfiguration);
            }

            return(installmentConfiguration);
        }
 // **********************************************************************************************
 private static void SaveInstallmentConfigurationInfoToCache(string cacheKey,
                                                             InstallmentConfiguration configuration)
 {
     SaveInstallmentConfigurationInfoToCache(cacheKey, configuration, null);
 }