public ActionResult Configure() { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var googleAnalyticsSettings = _settingService.LoadSetting <GoogleAnalyticsSettings>(storeScope); var model = new ConfigurationModel(); model.GoogleId = googleAnalyticsSettings.GoogleId; model.TrackingScript = googleAnalyticsSettings.TrackingScript; model.EcommerceScript = googleAnalyticsSettings.EcommerceScript; model.EcommerceDetailScript = googleAnalyticsSettings.EcommerceDetailScript; model.ZoneId = googleAnalyticsSettings.WidgetZone; model.AvailableZones.Add(new SelectListItem() { Text = "<head> HTML tag", Value = "head_html_tag" }); model.AvailableZones.Add(new SelectListItem() { Text = "Before <body> end HTML tag", Value = "body_end_html_tag_before" }); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(googleAnalyticsSettings, model, storeScope, _settingService); return(View(model)); }
public ActionResult Configure(ConfigurationModel model, FormCollection form) { if (!HasPermission(false)) { return(Configure()); } if (!ModelState.IsValid) { return(Configure()); } var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); int storeScope = this.GetActiveStoreScopeConfiguration(_services.StoreService, _services.WorkContext); var settings = _services.Settings.LoadSetting <TwitterExternalAuthSettings>(storeScope); settings.ConsumerKey = model.ConsumerKey; settings.ConsumerSecret = model.ConsumerSecret; storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _services.Settings); NotifySuccess(_services.Localization.GetResource("Admin.Common.DataSuccessfullySaved")); return(Configure()); }
public ActionResult Configure(ConfigurationModel model, FormCollection form) { ModelState.Clear(); //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var googleAnalyticsSettings = _settingService.LoadSetting <GoogleAnalyticsSettings>(storeScope); googleAnalyticsSettings.GoogleId = model.GoogleId; googleAnalyticsSettings.TrackingScript = model.TrackingScript; googleAnalyticsSettings.EcommerceScript = model.EcommerceScript; googleAnalyticsSettings.EcommerceDetailScript = model.EcommerceDetailScript; googleAnalyticsSettings.WidgetZone = model.ZoneId; _settingService.SaveSetting(googleAnalyticsSettings, x => x.WidgetZone, 0, false); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.UpdateSettings(googleAnalyticsSettings, form, storeScope, _settingService); //now clear settings cache _settingService.ClearCache(); return(Configure()); }
public ActionResult Configure(PayPalExpressConfigurationModel model, FormCollection form) { if (!ModelState.IsValid) { return(Configure()); } ModelState.Clear(); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); int storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <PayPalExpressPaymentSettings>(storeScope); model.Copy(settings, false); storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); // multistore context not possible, see IPN handling Services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false); Services.Settings.ClearCache(); NotifySuccess(T("Admin.Common.DataSuccessfullySaved")); return(Configure()); }
public ActionResult Configure(PayPalStandardConfigurationModel model, FormCollection form) { if (!ModelState.IsValid) { return(Configure()); } ModelState.Clear(); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext); var settings = _services.Settings.LoadSetting <PayPalStandardPaymentSettings>(storeScope); model.Copy(settings, false); storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _services.Settings); // multistore context not possible, see IPN handling _services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false); _services.Settings.ClearCache(); NotifySuccess(_services.Localization.GetResource("Plugins.Payments.PayPal.ConfigSaveNote")); return(Configure()); }
public ActionResult Configure(PayPalDirectConfigurationModel model, FormCollection form) { var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <PayPalDirectPaymentSettings>(storeScope); if (!ModelState.IsValid) { return(Configure(settings, storeScope)); } ModelState.Clear(); model.Copy(settings, false); using (Services.Settings.BeginScope()) { storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); } using (Services.Settings.BeginScope()) { // Multistore context not possible, see IPN handling. Services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false); } NotifySuccess(T("Admin.Common.DataSuccessfullySaved")); return(RedirectToConfiguration(PayPalDirectProvider.SystemName, false)); }
private void ConfigurePost <TModel, TSetting>(TModel model, FormCollection form, Action <TSetting> fn = null) where TModel : ConfigurationModelBase, new() where TSetting : PaymentSettingsBase, new() { ModelState.Clear(); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); int storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <TSetting>(storeScope); settings.DescriptionText = model.DescriptionText; settings.ThumbnailPictureId = model.PaymentMethodLogo; settings.AdditionalFee = model.AdditionalFee; settings.AdditionalFeePercentage = model.AdditionalFeePercentage; if (fn != null) { fn(settings); } using (Services.Settings.BeginScope()) { storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); } NotifySuccess(T("Admin.Common.DataSuccessfullySaved")); }
private TModel ConfigureGet <TModel, TSetting>(Action <TModel, TSetting> fn = null) where TModel : ConfigurationModelBase, new() where TSetting : PaymentSettingsBase, new() { var model = new TModel(); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <TSetting>(storeScope); var store = storeScope == 0 ? Services.StoreContext.CurrentStore : Services.StoreService.GetStoreById(storeScope); model.PrimaryStoreCurrencyCode = store.PrimaryStoreCurrency.CurrencyCode; model.DescriptionText = settings.DescriptionText; model.PaymentMethodLogo = settings.ThumbnailPictureId; model.AdditionalFee = settings.AdditionalFee; model.AdditionalFeePercentage = settings.AdditionalFeePercentage; if (fn != null) { fn(model, settings); } var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, Services.Settings); return(model); }
public ActionResult Configure(PayPalPlusConfigurationModel model, FormCollection form) { var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <PayPalPlusPaymentSettings>(storeScope); var validator = new PayPalPlusConfigValidator(Services.Localization, x => { return(storeScope == 0 || storeDependingSettingHelper.IsOverrideChecked(settings, x, form)); }); validator.Validate(model, ModelState); if (!ModelState.IsValid) { return(Configure()); } ModelState.Clear(); model.Copy(settings, false); storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); Services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false); Services.Settings.ClearCache(); NotifySuccess(T("Admin.Common.DataSuccessfullySaved")); return(Configure()); }
public ActionResult Configure(ConfigurationModel model, FormCollection form) { if (!ModelState.IsValid) { return(Configure()); } ModelState.Clear(); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext); var settings = _services.Settings.LoadSetting <AmazonPaySettings>(storeScope); model.Copy(settings, false); using (_services.Settings.BeginScope()) { storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _services.Settings); _services.Settings.SaveSetting(settings, x => x.DataFetching, 0, false); _services.Settings.SaveSetting(settings, x => x.PollingMaxOrderCreationDays, 0, false); } _apiService.DataPollingTaskUpdate(settings.DataFetching == AmazonPayDataFetchingType.Polling, model.PollingTaskMinutes * 60); NotifySuccess(_services.Localization.GetResource("Plugins.Payments.AmazonPay.ConfigSaveNote")); return(Configure()); }
public ActionResult Configure() { // load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_services.StoreService, _services.WorkContext); var settings = _services.Settings.LoadSetting <ProfilerSettings>(storeScope); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, settings, storeScope, _services.Settings); return(View(settings)); }
public ActionResult Configure() { // load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var model = _settingService.LoadSetting <GlimpseSettings>(storeScope); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(model, model, storeScope, _settingService); return(View(model)); }
public ActionResult Configure(PayPalPlusConfigurationModel model, FormCollection form) { var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <PayPalPlusPaymentSettings>(storeScope); var oldClientId = settings.ClientId; var oldSecret = settings.Secret; var oldProfileId = settings.ExperienceProfileId; var validator = new PayPalPlusConfigValidator(Services.Localization, x => { return(storeScope == 0 || storeDependingSettingHelper.IsOverrideChecked(settings, x, form)); }); validator.Validate(model, ModelState); if (!ModelState.IsValid) { return(Configure(settings, storeScope)); } ModelState.Clear(); model.Copy(settings, false); // Credentials changed: reset profile and webhook id to avoid errors. if (!oldClientId.IsCaseInsensitiveEqual(settings.ClientId) || !oldSecret.IsCaseInsensitiveEqual(settings.Secret)) { if (oldProfileId.IsCaseInsensitiveEqual(settings.ExperienceProfileId)) { settings.ExperienceProfileId = null; } settings.WebhookId = null; } using (Services.Settings.BeginScope()) { storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); } using (Services.Settings.BeginScope()) { // Multistore context not possible, see IPN handling. Services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false); } NotifySuccess(T("Admin.Common.DataSuccessfullySaved")); return(RedirectToConfiguration(PayPalPlusProvider.SystemName, false)); }
public ActionResult RestoreScripts() { var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <GoogleAnalyticsSettings>(storeScope); settings.TrackingScript = GoogleAnalyticsScriptHelper.GetTrackingScript(); settings.EcommerceScript = GoogleAnalyticsScriptHelper.GetEcommerceScript(); settings.EcommerceDetailScript = GoogleAnalyticsScriptHelper.GetEcommerceDetailScript(); _settingService.SaveSetting(settings, storeScope); return(RedirectToConfiguration("SmartStore.GoogleAnalytics", true)); }
public ActionResult Configure() { var model = new PayPalStandardConfigurationModel(); int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext); var settings = _services.Settings.LoadSetting <PayPalStandardPaymentSettings>(storeScope); model.Copy(settings, true); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, _services.Settings); return(View(model)); }
public ActionResult Configure() { var model = new ConfigurationModel(); int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext); var settings = _settingService.LoadSetting <AmazonPaySettings>(storeScope); model.Copy(settings, true); _apiService.SetupConfiguration(model); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, _settingService); return(View(model)); }
public ActionResult Configure(ProfilerSettings model, FormCollection form) { if (!ModelState.IsValid) { return(Configure()); } // load settings for a chosen store scope var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); storeDependingSettingHelper.UpdateSettings(model /*settings*/, form, storeScope, _settingService); _settingService.ClearCache(); return(Configure()); }
public ActionResult Configure() { var storeScope = this.GetActiveStoreScopeConfiguration(_services.StoreService, _services.WorkContext); var settings = _services.Settings.LoadSetting <ClickatellSettings>(storeScope); var model = new SmsClickatellModel { Enabled = settings.Enabled, PhoneNumber = settings.PhoneNumber, ApiId = settings.ApiId }; var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, _services.Settings); return(View(model)); }
public ActionResult Configure(ConfigurationModel model, FormCollection form) { var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <AmazonPaySettings>(storeScope); if (!ModelState.IsValid) { return(Configure(settings)); } ModelState.Clear(); model.AccessKey = model.AccessKey.TrimSafe(); model.ClientId = model.ClientId.TrimSafe(); model.SecretKey = model.SecretKey.TrimSafe(); model.SellerId = model.SellerId.TrimSafe(); MiniMapper.Map(model, settings); using (Services.Settings.BeginScope()) { storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); } using (Services.Settings.BeginScope()) { Services.Settings.SaveSetting(settings, x => x.DataFetching, 0, false); Services.Settings.SaveSetting(settings, x => x.PollingMaxOrderCreationDays, 0, false); } var task = _scheduleTaskService.Value.GetTaskByType <DataPollingTask>(); if (task != null) { task.Enabled = settings.DataFetching == AmazonPayDataFetchingType.Polling; _scheduleTaskService.Value.UpdateTask(task); } NotifySuccess(T("Plugins.Payments.AmazonPay.ConfigSaveNote")); return(RedirectToConfiguration(AmazonPayPlugin.SystemName)); }
public ActionResult Configure(ConfigurationModel model, FormCollection form) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var trustedShopsSealSettings = _settingService.LoadSetting <TrustedShopsSealSettings>(storeScope); bool trustedShopIdOverride = storeDependingSettingHelper.IsOverrideChecked(trustedShopsSealSettings, "TrustedShopsId", form); bool isTrustedShopIdValid = true; if (trustedShopIdOverride || storeScope == 0) // do validation { isTrustedShopIdValid = IsTrustedShopIdValid(model); if (isTrustedShopIdValid) { NotifySuccess(_localizationService.GetResource("Plugins.Widgets.TrustedShopsSeal.CheckIdSuccess"), true); } else { NotifyError(_localizationService.GetResource("Plugins.Widgets.TrustedShopsSeal.CheckIdError"), true); } } if (isTrustedShopIdValid) //save settings { trustedShopsSealSettings.TrustedShopsId = model.TrustedShopsId; trustedShopsSealSettings.IsTestMode = model.IsTestMode; trustedShopsSealSettings.WidgetZone = model.WidgetZone; trustedShopsSealSettings.ShopName = model.ShopName; trustedShopsSealSettings.ShopText = model.ShopText; storeDependingSettingHelper.UpdateSettings(trustedShopsSealSettings, form, storeScope, _settingService); _settingService.ClearCache(); } return(Configure()); }
public SettingController( SmartDbContext db, ILocalizedEntityService localizedEntityService, StoreDependingSettingHelper storeDependingSettingHelper, IDateTimeHelper dateTimeHelper, ICookieConsentManager cookieManager, Lazy <IMediaTracker> mediaTracker, Lazy <IMenuService> menuService, PrivacySettings privacySettings) { _db = db; _localizedEntityService = localizedEntityService; _storeDependingSettingHelper = storeDependingSettingHelper; _dateTimeHelper = dateTimeHelper; _cookieManager = cookieManager; _mediaTracker = mediaTracker; _menuService = menuService; _privacySettings = privacySettings; }
public ActionResult Configure() { var model = new PayPalDirectConfigurationModel(); int storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting<PayPalDirectPaymentSettings>(storeScope); model.Copy(settings, true); model.TransactModeValues = TransactModeValues(settings.TransactMode); model.AvailableSecurityProtocols = GetSecurityProtocols() .Select(x => new SelectListItem { Value = ((int)x.Key).ToString(), Text = x.Value }) .ToList(); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, Services.Settings); return View(model); }
public ActionResult Configure(SmsClickatellModel model, FormCollection form) { if (ModelState.IsValid) { var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); int storeScope = this.GetActiveStoreScopeConfiguration(_services.StoreService, _services.WorkContext); var settings = _services.Settings.LoadSetting <ClickatellSettings>(storeScope); settings.Enabled = model.Enabled; settings.PhoneNumber = model.PhoneNumber; settings.ApiId = model.ApiId; storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _services.Settings); NotifySuccess(T("Admin.Common.DataSuccessfullySaved")); } return(Configure()); }
public ActionResult Configure() { if (!HasPermission(false)) { return(AccessDeniedPartialView()); } var model = new ConfigurationModel(); int storeScope = this.GetActiveStoreScopeConfiguration(_services.StoreService, _services.WorkContext); var settings = _services.Settings.LoadSetting <TwitterExternalAuthSettings>(storeScope); model.ConsumerKey = settings.ConsumerKey; model.ConsumerSecret = settings.ConsumerSecret; var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, _services.Settings); return(View(model)); }
public ActionResult Configure() { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var trustedShopsSealSettings = _settingService.LoadSetting <TrustedShopsSealSettings>(storeScope); var model = new ConfigurationModel(); model.TrustedShopsId = trustedShopsSealSettings.TrustedShopsId; model.IsTestMode = trustedShopsSealSettings.IsTestMode; model.ShopName = trustedShopsSealSettings.ShopName; model.ShopText = trustedShopsSealSettings.ShopText; model.WidgetZone = trustedShopsSealSettings.WidgetZone; model.AvailableZones.Add(new SelectListItem() { Text = "Before left side column", Value = "left_side_column_before" }); model.AvailableZones.Add(new SelectListItem() { Text = "After left side column", Value = "left_side_column_after" }); model.AvailableZones.Add(new SelectListItem() { Text = "Before right side column", Value = "right_side_column_before" }); model.AvailableZones.Add(new SelectListItem() { Text = "After right side column", Value = "right_side_column_after" }); model.AvailableZones.Add(new SelectListItem() { Text = "Homepage bottom", Value = "home_page_bottom" }); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(trustedShopsSealSettings, model, storeScope, _settingService); return(View("SmartStore.Plugin.Widgets.TrustedShopsSeal.Views.TrustedShopsSeal.Configure", model)); }
public ActionResult Configure() { var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <PayPalPlusPaymentSettings>(storeScope); var model = new PayPalPlusConfigurationModel { ConfigGroups = T("Plugins.SmartStore.PayPal.ConfigGroups").Text.SplitSafe(";") }; model.AvailableSecurityProtocols = PayPal.Services.PayPalService.GetSecurityProtocols() .Select(x => new SelectListItem { Value = ((int)x.Key).ToString(), Text = x.Value }) .ToList(); // it's better to also offer inactive methods here but filter them out in frontend var methods = _paymentService.LoadAllPaymentMethods(storeScope); model.AvailableThirdPartyPaymentMethods = methods .Where(x => x.Metadata.PluginDescriptor.SystemName != Plugin.SystemName && !x.Value.RequiresInteraction && (x.Metadata.PluginDescriptor.SystemName == "SmartStore.OfflinePayment" || x.Value.PaymentMethodType == PaymentMethodType.Redirection)) .Select(x => new SelectListItem { Value = x.Metadata.SystemName, Text = GetPaymentMethodName(x) }) .ToList(); model.Copy(settings, true); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, Services.Settings); return(View(model)); }
public ActionResult Configure(ConfigurationModel model, FormCollection form) { var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <GoogleAnalyticsSettings>(storeScope); ModelState.Clear(); MiniMapper.Map(model, settings); settings.WidgetZone = model.ZoneId; using (Services.Settings.BeginScope()) { storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); } using (Services.Settings.BeginScope()) { _settingService.SaveSetting(settings, x => x.WidgetZone, 0, false); } return(RedirectToConfiguration("SmartStore.GoogleAnalytics")); }
private void ConfigurePost <TModel, TSetting>(TModel model, FormCollection form, Action <TSetting> fn = null) where TModel : ConfigurationModelBase, new() where TSetting : PaymentSettingsBase, new() { ModelState.Clear(); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext); var settings = _services.Settings.LoadSetting <TSetting>(storeScope); settings.DescriptionText = model.DescriptionText; settings.AdditionalFee = model.AdditionalFee; settings.AdditionalFeePercentage = model.AdditionalFeePercentage; if (fn != null) { fn(settings); } storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _services.Settings); _services.Settings.ClearCache(); NotifySuccess(_services.Localization.GetResource("Admin.Common.DataSuccessfullySaved")); }
private TModel ConfigureGet <TModel, TSetting>(Action <TModel, TSetting> fn = null) where TModel : ConfigurationModelBase, new() where TSetting : PaymentSettingsBase, new() { var model = new TModel(); int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext); var settings = _services.Settings.LoadSetting <TSetting>(storeScope); model.DescriptionText = settings.DescriptionText; model.AdditionalFee = settings.AdditionalFee; model.AdditionalFeePercentage = settings.AdditionalFeePercentage; if (fn != null) { fn(model, settings); } var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, _services.Settings); return(model); }
public ActionResult Configure(ConfigurationModel model, FormCollection form) { if (!ModelState.IsValid) { return(Configure()); } ModelState.Clear(); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <AmazonPaySettings>(storeScope); model.Copy(settings, false); using (Services.Settings.BeginScope()) { storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); Services.Settings.SaveSetting(settings, x => x.DataFetching, 0, false); Services.Settings.SaveSetting(settings, x => x.PollingMaxOrderCreationDays, 0, false); } var task = _scheduleTaskService.Value.GetTaskByType <DataPollingTask>(); if (task != null) { task.Enabled = settings.DataFetching == AmazonPayDataFetchingType.Polling; _scheduleTaskService.Value.UpdateTask(task); } NotifySuccess(Services.Localization.GetResource("Plugins.Payments.AmazonPay.ConfigSaveNote")); return(Configure()); }