public ActionResult Configure(MailChimpModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeId = GetActiveStoreScopeConfiguration(_storeService, _workContext); var mailChimpSettings = _settingService.LoadSetting <MailChimpSettings>(storeId); //update stores if the list was changed if (model.ListId != null && !model.ListId.Equals("0") && !model.ListId.Equals(mailChimpSettings.ListId)) { if (storeId > 0) { _synchronizationRecordService.CreateOrUpdateRecord(EntityType.Store, storeId, ActionType.Update); } else { foreach (var store in _storeService.GetAllStores()) { _synchronizationRecordService.CreateOrUpdateRecord(EntityType.Store, store.Id, ActionType.Update); } } } //webhook if (!string.IsNullOrEmpty(model.ListId)) { //delete current webhook if (!model.ListId.Equals(mailChimpSettings.ListId)) { _mailChimpManager.DeleteWebhook(mailChimpSettings.ListId, mailChimpSettings.WebhookId); mailChimpSettings.WebhookId = string.Empty; } //and create new one if (!model.ListId.Equals("0")) { //we use Task.Run() because child actions cannot be run asynchronously mailChimpSettings.WebhookId = tasks.Task.Run(() => _mailChimpManager.CreateWebhook(model.ListId, mailChimpSettings.WebhookId)).Result; if (string.IsNullOrEmpty(mailChimpSettings.WebhookId)) { ErrorNotification(_localizationService.GetResource("Plugins.Misc.MailChimp.WebhookError")); } } } //settings mailChimpSettings.ApiKey = model.ApiKey; mailChimpSettings.UseEcommerceApi = model.UseEcommerceApi; mailChimpSettings.ListId = model.ListId; _settingService.SaveSetting(mailChimpSettings, x => x.ApiKey, 0, false); _settingService.SaveSetting(mailChimpSettings, x => x.UseEcommerceApi, 0, false); _settingService.SaveSettingOverridablePerStore(mailChimpSettings, x => x.ListId, model.ListId_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(mailChimpSettings, x => x.WebhookId, true, storeId, false); //now clear settings cache _settingService.ClearCache(); //create or update synchronization task var task = FindScheduledTask(); if (task != null) { //task parameters was changed if (task.Enabled != model.AutoSync || task.Seconds != model.AutoSyncEachMinutes * 60) { task.Enabled = model.AutoSync; task.Seconds = model.AutoSyncEachMinutes * 60; _scheduleTaskService.UpdateTask(task); SuccessNotification(_localizationService.GetResource("Plugins.Misc.MailChimp.AutoSyncRestart")); } else { SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); } } else { _scheduleTaskService.InsertTask(new ScheduleTask { Name = "MailChimp synchronization", Seconds = model.AutoSyncEachMinutes * 60, Enabled = model.AutoSync, Type = "Nop.Plugin.Misc.MailChimp.Services.MailChimpSynchronizationTask, Nop.Plugin.Misc.MailChimp", }); SuccessNotification(_localizationService.GetResource("Plugins.Misc.MailChimp.AutoSyncRestart")); } return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { //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.IncludingTax = model.IncludingTax; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.GoogleId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(googleAnalyticsSettings, x => x.GoogleId, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(googleAnalyticsSettings, x => x.GoogleId, storeScope); } if (model.TrackingScript_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(googleAnalyticsSettings, x => x.TrackingScript, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(googleAnalyticsSettings, x => x.TrackingScript, storeScope); } if (model.EcommerceScript_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(googleAnalyticsSettings, x => x.EcommerceScript, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(googleAnalyticsSettings, x => x.EcommerceScript, storeScope); } if (model.EcommerceDetailScript_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(googleAnalyticsSettings, x => x.EcommerceDetailScript, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(googleAnalyticsSettings, x => x.EcommerceDetailScript, storeScope); } if (model.IncludingTax_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(googleAnalyticsSettings, x => x.IncludingTax, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(googleAnalyticsSettings, x => x.IncludingTax, storeScope); } //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var stripePaymentSettings = _settingService.LoadSetting <StripePaymentSettings>(storeScope); //save settings stripePaymentSettings.TransactMode = TransactMode.Authorize; stripePaymentSettings.AdditionalFee = model.AdditionalFee; stripePaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; stripePaymentSettings.ApiKey = model.ApiKey; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.TransactModeId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(stripePaymentSettings, x => x.TransactMode, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(stripePaymentSettings, x => x.TransactMode, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(stripePaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(stripePaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(stripePaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(stripePaymentSettings, x => x.AdditionalFeePercentage, storeScope); } if (model.ApiKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(stripePaymentSettings, x => x.ApiKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(stripePaymentSettings, x => x.ApiKey, storeScope); } //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public ActionResult ConfigureAD(ConfigurationModel model) { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var ADSettings = _settingService.LoadSetting <ADSettings>(storeScope); ADSettings.Picture1Id = model.Picture1Id; ADSettings.Text1 = model.Text1; ADSettings.Link1 = model.Link1; ADSettings.Picture2Id = model.Picture2Id; ADSettings.Text2 = model.Text2; ADSettings.Link2 = model.Link2; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.Picture1Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ADSettings, x => x.Picture1Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ADSettings, x => x.Picture1Id, storeScope); } if (model.Text1_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ADSettings, x => x.Text1, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ADSettings, x => x.Text1, storeScope); } if (model.Link1_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ADSettings, x => x.Link1, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ADSettings, x => x.Link1, storeScope); } if (model.Picture2Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ADSettings, x => x.Picture2Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ADSettings, x => x.Picture2Id, storeScope); } if (model.Text2_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ADSettings, x => x.Text2, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ADSettings, x => x.Text2, storeScope); } if (model.Link2_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ADSettings, x => x.Link2, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ADSettings, x => x.Link2, storeScope); } //now clear settings cache _settingService.ClearCache(); Response.Redirect("/Admin/Widget/ConfigureWidget?systemName=Widgets.AD"); return(null); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var cardComPaymentSettings = _settingService.LoadSetting <CardComPaymentSettings>(storeScope); //save settings cardComPaymentSettings.Operation = model.Operation; cardComPaymentSettings.TerminalNumber = model.TerminalNumber; cardComPaymentSettings.UserName = model.UserName; cardComPaymentSettings.AddReturnButtonToSecurePage = model.AddReturnButtonToSecurePage; cardComPaymentSettings.AdditionalFee = model.AdditionalFee; cardComPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; cardComPaymentSettings.CreateToken = model.CreateToken; cardComPaymentSettings.CreateInvoice = model.CreateInvoice; cardComPaymentSettings.MaxPayments = model.MaxPayments; cardComPaymentSettings.MinPayments = model.MinPayments; cardComPaymentSettings.UseIframe = model.UseIframe; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.Operation_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.Operation, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.Operation, storeScope); } if (model.TerminalNumber_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.TerminalNumber, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.TerminalNumber, storeScope); } if (model.UserName_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.UserName, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.UserName, storeScope); } if (model.AddReturnButtonToSecurePage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.AddReturnButtonToSecurePage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.AddReturnButtonToSecurePage, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } if (model.CreateToken_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.CreateToken, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.CreateToken, storeScope); } if (model.CreateInvoice_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.CreateInvoice, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.CreateInvoice, storeScope); } if (model.MaxPayments_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.MaxPayments, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.MaxPayments, storeScope); } if (model.MinPayments_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.MinPayments, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.MinPayments, storeScope); } if (model.UseIframe_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(cardComPaymentSettings, x => x.UseIframe, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(cardComPaymentSettings, x => x.UseIframe, storeScope); } //now clear settings cache _settingService.ClearCache(); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var sagePayServerPaymentSettings = _settingService.LoadSetting <SagePayServerPaymentSettings>(storeScope); //save settings sagePayServerPaymentSettings.ConnectTo = (ConnectToValues)model.ConnectToId; sagePayServerPaymentSettings.TransactType = (TransactTypeValues)model.TransactTypeId; sagePayServerPaymentSettings.Profile = (ProfileValues)model.ProfileId; sagePayServerPaymentSettings.VendorName = model.VendorName; sagePayServerPaymentSettings.PartnerId = model.PartnerId; sagePayServerPaymentSettings.AdditionalFee = model.AdditionalFee; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.ConnectToId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(sagePayServerPaymentSettings, x => x.ConnectTo, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(sagePayServerPaymentSettings, x => x.ConnectTo, storeScope); } if (model.TransactTypeId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(sagePayServerPaymentSettings, x => x.TransactType, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(sagePayServerPaymentSettings, x => x.TransactType, storeScope); } if (model.ProfileId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(sagePayServerPaymentSettings, x => x.Profile, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(sagePayServerPaymentSettings, x => x.Profile, storeScope); } if (model.VendorName_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(sagePayServerPaymentSettings, x => x.VendorName, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(sagePayServerPaymentSettings, x => x.VendorName, storeScope); } if (model.PartnerId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(sagePayServerPaymentSettings, x => x.PartnerId, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(sagePayServerPaymentSettings, x => x.PartnerId, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(sagePayServerPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(sagePayServerPaymentSettings, x => x.AdditionalFee, storeScope); } //now clear settings cache _settingService.ClearCache(); return(Configure()); }
public IActionResult Configure(ConfigurationModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) { return(AccessDeniedView()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var nivoSliderSettings = _settingService.LoadSetting <NivoSliderSettings>(storeScope); //get previous picture identifiers var previousPictureIds = new[] { nivoSliderSettings.Picture1Id, nivoSliderSettings.Picture2Id, nivoSliderSettings.Picture3Id, nivoSliderSettings.Picture4Id, nivoSliderSettings.Picture5Id }; nivoSliderSettings.Picture1Id = model.Picture1Id; nivoSliderSettings.Text1 = model.Text1; nivoSliderSettings.Link1 = model.Link1; nivoSliderSettings.Picture2Id = model.Picture2Id; nivoSliderSettings.Text2 = model.Text2; nivoSliderSettings.Link2 = model.Link2; nivoSliderSettings.Picture3Id = model.Picture3Id; nivoSliderSettings.Text3 = model.Text3; nivoSliderSettings.Link3 = model.Link3; nivoSliderSettings.Picture4Id = model.Picture4Id; nivoSliderSettings.Text4 = model.Text4; nivoSliderSettings.Link4 = model.Link4; nivoSliderSettings.Picture5Id = model.Picture5Id; nivoSliderSettings.Text5 = model.Text5; nivoSliderSettings.Link5 = model.Link5; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Picture1Id, model.Picture1Id_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Text1, model.Text1_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Link1, model.Link1_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Picture2Id, model.Picture2Id_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Text2, model.Text2_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Link2, model.Link2_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Picture3Id, model.Picture3Id_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Text3, model.Text3_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Link3, model.Link3_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Picture4Id, model.Picture4Id_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Text4, model.Text4_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Link4, model.Link4_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Picture5Id, model.Picture5Id_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Text5, model.Text5_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(nivoSliderSettings, x => x.Link5, model.Link5_OverrideForStore, storeScope, false); //now clear settings cache _settingService.ClearCache(); //get current picture identifiers var currentPictureIds = new[] { nivoSliderSettings.Picture1Id, nivoSliderSettings.Picture2Id, nivoSliderSettings.Picture3Id, nivoSliderSettings.Picture4Id, nivoSliderSettings.Picture5Id }; //delete an old picture (if deleted or updated) foreach (var pictureId in previousPictureIds.Except(currentPictureIds)) { var previousPicture = _pictureService.GetPictureById(pictureId); if (previousPicture != null) { _pictureService.DeletePicture(previousPicture); } } SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public ActionResult GeneralCommon(GeneralCommonSettingsModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } //store information settings var storeInformationSettings = _settingService.LoadSetting <StoreInformationSettings>(); var commonSettings = _settingService.LoadSetting <CommonSettings>(); storeInformationSettings.StoreClosed = model.StoreInformationSettings.StoreClosed; storeInformationSettings.DefaultStoreTheme = model.StoreInformationSettings.DefaultStoreTheme; storeInformationSettings.AllowCustomerToSelectTheme = model.StoreInformationSettings.AllowCustomerToSelectTheme; storeInformationSettings.Name = model.StoreInformationSettings.Name; storeInformationSettings.Url = model.StoreInformationSettings.Url; if (!string.IsNullOrWhiteSpace(storeInformationSettings.Url) && !storeInformationSettings.Url.EndsWith("/")) { storeInformationSettings.Url += "/"; } storeInformationSettings.SslEnabled = model.StoreInformationSettings.SslEnabled; storeInformationSettings.Hosts = model.StoreInformationSettings.Hosts; //social var socialSettings = _settingService.LoadSetting <SocialSettings>(); socialSettings.FacebookAppId = model.SocialSettings.FacebookAppId; socialSettings.FacebookAppSecret = model.SocialSettings.FacebookAppSecret; _settingService.SaveSetting(socialSettings); //EU Cookie law storeInformationSettings.DisplayEuCookieLawWarning = model.StoreInformationSettings.DisplayEuCookieLawWarning; //social pages storeInformationSettings.FacebookLink = model.StoreInformationSettings.FacebookLink; storeInformationSettings.TwitterLink = model.StoreInformationSettings.TwitterLink; storeInformationSettings.YoutubeLink = model.StoreInformationSettings.YoutubeLink; storeInformationSettings.GooglePlusLink = model.StoreInformationSettings.GooglePlusLink; //contact us commonSettings.SubjectFieldOnContactUsForm = model.StoreInformationSettings.SubjectFieldOnContactUsForm; commonSettings.UseSystemEmailForContactUsForm = model.StoreInformationSettings.UseSystemEmailForContactUsForm; _settingService.SaveSetting(storeInformationSettings, x => x.StoreClosed, false); _settingService.SaveSetting(storeInformationSettings, x => x.DefaultStoreTheme, false); _settingService.SaveSetting(storeInformationSettings, x => x.AllowCustomerToSelectTheme, false); _settingService.SaveSetting(storeInformationSettings, x => x.DisplayEuCookieLawWarning, false); _settingService.SaveSetting(storeInformationSettings, x => x.FacebookLink, false); _settingService.SaveSetting(storeInformationSettings, x => x.TwitterLink, false); _settingService.SaveSetting(storeInformationSettings, x => x.YoutubeLink, false); _settingService.SaveSetting(storeInformationSettings, x => x.GooglePlusLink, false); _settingService.SaveSetting(commonSettings, x => x.SubjectFieldOnContactUsForm, false); _settingService.SaveSetting(commonSettings, x => x.UseSystemEmailForContactUsForm, false); _settingService.SaveSetting(storeInformationSettings); _settingService.SaveSetting(commonSettings); //seo settings var seoSettings = _settingService.LoadSetting <SeoSettings>(); seoSettings.PageTitleSeparator = model.SeoSettings.PageTitleSeparator; seoSettings.PageTitleSeoAdjustment = (PageTitleSeoAdjustment)model.SeoSettings.PageTitleSeoAdjustment; seoSettings.DefaultTitle = model.SeoSettings.DefaultTitle; seoSettings.DefaultMetaKeywords = model.SeoSettings.DefaultMetaKeywords; seoSettings.DefaultMetaDescription = model.SeoSettings.DefaultMetaDescription; seoSettings.GeneratePostMetaDescription = model.SeoSettings.GeneratePostMetaDescription; seoSettings.ConvertNonWesternChars = model.SeoSettings.ConvertNonWesternChars; seoSettings.CanonicalUrlsEnabled = model.SeoSettings.CanonicalUrlsEnabled; seoSettings.WwwRequirement = (WwwRequirement)model.SeoSettings.WwwRequirement; seoSettings.EnableJsBundling = model.SeoSettings.EnableJsBundling; seoSettings.EnableCssBundling = model.SeoSettings.EnableCssBundling; seoSettings.TwitterMetaTags = model.SeoSettings.TwitterMetaTags; seoSettings.OpenGraphMetaTags = model.SeoSettings.OpenGraphMetaTags; _settingService.SaveSetting(seoSettings, x => x.PageTitleSeparator, false); _settingService.SaveSetting(seoSettings, x => x.PageTitleSeoAdjustment, false); _settingService.SaveSetting(seoSettings, x => x.DefaultTitle, false); _settingService.SaveSetting(seoSettings, x => x.DefaultMetaKeywords, false); _settingService.SaveSetting(seoSettings, x => x.DefaultMetaDescription, false); _settingService.SaveSetting(seoSettings, x => x.GeneratePostMetaDescription, false); _settingService.SaveSetting(seoSettings, x => x.ConvertNonWesternChars, false); _settingService.SaveSetting(seoSettings, x => x.CanonicalUrlsEnabled, false); _settingService.SaveSetting(seoSettings, x => x.WwwRequirement, false); _settingService.SaveSetting(seoSettings, x => x.EnableJsBundling, false); _settingService.SaveSetting(seoSettings, x => x.EnableCssBundling, false); _settingService.SaveSetting(seoSettings, x => x.TwitterMetaTags, false); _settingService.SaveSetting(seoSettings, x => x.OpenGraphMetaTags, false); //security settings var securitySettings = _settingService.LoadSetting <SecuritySettings>(); var captchaSettings = _settingService.LoadSetting <CaptchaSettings>(); if (securitySettings.AdminAreaAllowedIpAddresses == null) { securitySettings.AdminAreaAllowedIpAddresses = new List <string>(); } securitySettings.AdminAreaAllowedIpAddresses.Clear(); if (!String.IsNullOrEmpty(model.SecuritySettings.AdminAreaAllowedIpAddresses)) { foreach ( var s in model.SecuritySettings.AdminAreaAllowedIpAddresses.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (!String.IsNullOrWhiteSpace(s)) { securitySettings.AdminAreaAllowedIpAddresses.Add(s.Trim()); } } } securitySettings.ForceSslForAllPages = model.SecuritySettings.ForceSslForAllPages; securitySettings.EnableXsrfProtectionForAdminArea = model.SecuritySettings.EnableXsrfProtectionForAdminArea; securitySettings.EnableXsrfProtectionForPublicStore = model.SecuritySettings.EnableXsrfProtectionForPublicStore; securitySettings.HoneypotEnabled = model.SecuritySettings.HoneypotEnabled; _settingService.SaveSetting(securitySettings); captchaSettings.Enabled = model.SecuritySettings.CaptchaEnabled; captchaSettings.ShowOnLoginPage = model.SecuritySettings.CaptchaShowOnLoginPage; captchaSettings.ShowOnRegistrationPage = model.SecuritySettings.CaptchaShowOnRegistrationPage; captchaSettings.ShowOnContactUsPage = model.SecuritySettings.CaptchaShowOnContactUsPage; captchaSettings.ShowOnEmailWishlistToFriendPage = model.SecuritySettings.CaptchaShowOnEmailWishlistToFriendPage; captchaSettings.ShowOnEmailPostToFriendPage = model.SecuritySettings.CaptchaShowOnEmailPostToFriendPage; captchaSettings.ShowOnBlogCommentPage = model.SecuritySettings.CaptchaShowOnBlogCommentPage; captchaSettings.ShowOnNewsCommentPage = model.SecuritySettings.CaptchaShowOnNewsCommentPage; captchaSettings.ShowOnPostReviewPage = model.SecuritySettings.CaptchaShowOnPostReviewPage; captchaSettings.ShowOnApplyVendorPage = model.SecuritySettings.CaptchaShowOnApplyVendorPage; captchaSettings.ReCaptchaPublicKey = model.SecuritySettings.ReCaptchaPublicKey; captchaSettings.ReCaptchaPrivateKey = model.SecuritySettings.ReCaptchaPrivateKey; _settingService.SaveSetting(captchaSettings); if (captchaSettings.Enabled && (String.IsNullOrWhiteSpace(captchaSettings.ReCaptchaPublicKey) || String.IsNullOrWhiteSpace(captchaSettings.ReCaptchaPrivateKey))) { //captcha is enabled but the keys are not entered ErrorNotification("Captcha is enabled but the appropriate keys are not entered"); } //localization settings var localizationSettings = _settingService.LoadSetting <LocalizationSettings>(); localizationSettings.UseImagesForLanguageSelection = model.LocalizationSettings.UseImagesForLanguageSelection; if (localizationSettings.SeoFriendlyUrlsForLanguagesEnabled != model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled) { localizationSettings.SeoFriendlyUrlsForLanguagesEnabled = model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled; //clear cached values of routes RouteTable.Routes.ClearSeoFriendlyUrlsCachedValueForRoutes(); } localizationSettings.AutomaticallyDetectLanguage = model.LocalizationSettings.AutomaticallyDetectLanguage; localizationSettings.LoadAllLocaleRecordsOnStartup = model.LocalizationSettings.LoadAllLocaleRecordsOnStartup; localizationSettings.LoadAllLocalizedPropertiesOnStartup = model.LocalizationSettings.LoadAllLocalizedPropertiesOnStartup; localizationSettings.LoadAllUrlRecordsOnStartup = model.LocalizationSettings.LoadAllUrlRecordsOnStartup; _settingService.SaveSetting(localizationSettings); //full-text commonSettings.FullTextMode = (FulltextSearchMode)model.FullTextSettings.SearchMode; _settingService.SaveSetting(commonSettings); _settingService.ClearCache(); //activity log _customerActivityService.InsertActivity("EditSettings", _localizationService.GetResource("ActivityLog.EditSettings")); SuccessNotification(_localizationService.GetResource("Admin.Configuration.Updated")); //selected tab SaveSelectedTabIndex(); return(RedirectToAction("GeneralCommon")); }
public IActionResult Configure(ConfigurationModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePaymentMethods)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var fawryPaymentSettings = _settingService.LoadSetting <FawryPaymentSettings>(storeScope); //save settings fawryPaymentSettings.UseSandbox = model.UseSandbox; fawryPaymentSettings.BusinessEmail = model.BusinessEmail; fawryPaymentSettings.PdtToken = model.PdtToken; fawryPaymentSettings.PassProductNamesAndTotals = model.PassProductNamesAndTotals; fawryPaymentSettings.AdditionalFee = model.AdditionalFee; fawryPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; //edit here by amal fawryPaymentSettings.PdtValidateOrderTotal = model.PdtValidateOrderTotal; fawryPaymentSettings.EnableIpn = model.EnableIpn; fawryPaymentSettings.IpnUrl = model.IpnUrl; fawryPaymentSettings.AddressOverride = model.AddressOverride; fawryPaymentSettings.ReturnFromPayPalWithoutPaymentRedirectsToOrderDetailsPage = model.ReturnFromPayPalWithoutPaymentRedirectsToOrderDetailsPage; //amal 23/9/2018 fawryPaymentSettings.AdminName = model.AdminName; fawryPaymentSettings.AdminEmail = model.AdminEmail; fawryPaymentSettings.OrderExpiry = model.OrderExpiry; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.UseSandbox, model.UseSandbox_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.BusinessEmail, model.BusinessEmail_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.PdtToken, model.PdtToken_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.PassProductNamesAndTotals, model.PassProductNamesAndTotals_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.AdditionalFee, model.AdditionalFee_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.AdditionalFeePercentage, model.AdditionalFeePercentage_OverrideForStore, storeScope, false); //edit here by amal _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.PdtValidateOrderTotal, model.PdtValidateOrderTotal_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.EnableIpn, model.EnableIpn_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.IpnUrl, model.IpnUrl_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.AddressOverride, model.AddressOverride_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.ReturnFromPayPalWithoutPaymentRedirectsToOrderDetailsPage, model.ReturnFromPayPalWithoutPaymentRedirectsToOrderDetailsPage_OverrideForStore, storeScope, false); //amal 23/9/2018 _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.AdminName, model.AdminName_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.AdminEmail, model.AdminEmail_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(fawryPaymentSettings, x => x.OrderExpiry, model.OrderExpiry_OverrideForStore, storeScope, false); //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageExternalAuthenticationMethods)) { return(Content("Access denied")); } if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var weiXinExternalAuthSettings = _settingService.LoadSetting <WeiXinExternalAuthSettings>(storeScope); //save settings weiXinExternalAuthSettings.AppId = model.AppId; weiXinExternalAuthSettings.AppSecret = model.AppSecret; weiXinExternalAuthSettings.WebAppId = model.WebAppId; weiXinExternalAuthSettings.WebAppSecret = model.WebAppSecret; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.AppId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(weiXinExternalAuthSettings, x => x.AppId, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(weiXinExternalAuthSettings, x => x.AppId, storeScope); } if (model.AppSecret_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(weiXinExternalAuthSettings, x => x.AppSecret, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(weiXinExternalAuthSettings, x => x.AppSecret, storeScope); } if (model.WebAppId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(weiXinExternalAuthSettings, x => x.WebAppId, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(weiXinExternalAuthSettings, x => x.WebAppId, storeScope); } if (model.WebAppSecret_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(weiXinExternalAuthSettings, x => x.WebAppSecret, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(weiXinExternalAuthSettings, x => x.WebAppSecret, storeScope); } //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public IActionResult Configure(ConfigurationModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePaymentMethods)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeId = _storeContext.ActiveStoreScopeConfiguration; var settings = _settingService.LoadSetting <QualpaySettings>(storeId); //ensure that webhook is already exists and create the new one if does not (required for recurring billing) if (model.UseRecurringBilling) { var webhook = _qualpayManager.CreateWebhook(settings.WebhookId); if (webhook?.WebhookId != null) { settings.WebhookId = webhook.WebhookId.ToString(); settings.WebhookSecretKey = webhook.Secret; _settingService.SaveSetting(settings, x => x.WebhookId, storeId, false); _settingService.SaveSetting(settings, x => x.WebhookSecretKey, storeId, false); } else { _notificationService.WarningNotification(_localizationService.GetResource("Plugins.Payments.Qualpay.Fields.Webhook.Warning")); } } //save settings settings.MerchantId = model.MerchantId; settings.SecurityKey = model.SecurityKey; settings.ProfileId = model.ProfileId; settings.UseSandbox = model.UseSandbox; settings.UseEmbeddedFields = model.UseEmbeddedFields; settings.UseCustomerVault = model.UseCustomerVault; settings.UseRecurringBilling = model.UseRecurringBilling; settings.PaymentTransactionType = (TransactionType)model.PaymentTransactionTypeId; settings.AdditionalFee = model.AdditionalFee; settings.AdditionalFeePercentage = model.AdditionalFeePercentage; _settingService.SaveSetting(settings, x => x.MerchantId, storeId, false); _settingService.SaveSetting(settings, x => x.SecurityKey, storeId, false); _settingService.SaveSetting(settings, x => x.ProfileId, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.UseSandbox, model.UseSandbox_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.UseEmbeddedFields, model.UseEmbeddedFields_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.UseCustomerVault, model.UseCustomerVault_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.UseRecurringBilling, model.UseRecurringBilling_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.PaymentTransactionType, model.PaymentTransactionTypeId_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.AdditionalFee, model.AdditionalFee_OverrideForStore, storeId, false); _settingService.SaveSettingOverridablePerStore(settings, x => x.AdditionalFeePercentage, model.AdditionalFeePercentage_OverrideForStore, storeId, false); _settingService.ClearCache(); //display notification _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
/// <summary> /// Prepare SendinBlueModel /// </summary> /// <param name="model">Model</param> private void PrepareModel(ConfigurationModel model) { //load settings for active store scope var storeId = _storeContext.ActiveStoreScopeConfiguration; var sendinBlueSettings = _settingService.LoadSetting <SendinBlueSettings>(storeId); //whether plugin is configured if (string.IsNullOrEmpty(sendinBlueSettings.ApiKey)) { return; } //prepare common properties model.ActiveStoreScopeConfiguration = storeId; model.ApiKey = sendinBlueSettings.ApiKey; model.ListId = sendinBlueSettings.ListId; model.SmtpKey = sendinBlueSettings.SmtpKey; model.SenderId = sendinBlueSettings.SenderId; model.UseSmsNotifications = sendinBlueSettings.UseSmsNotifications; model.SmsSenderName = sendinBlueSettings.SmsSenderName; model.StoreOwnerPhoneNumber = sendinBlueSettings.StoreOwnerPhoneNumber; model.UseMarketingAutomation = sendinBlueSettings.UseMarketingAutomation; model.TrackingScript = sendinBlueSettings.TrackingScript; model.HideGeneralBlock = _genericAttributeService.GetAttribute <bool>(_workContext.CurrentCustomer, SendinBlueDefaults.HideGeneralBlock); model.HideSynchronizationBlock = _genericAttributeService.GetAttribute <bool>(_workContext.CurrentCustomer, SendinBlueDefaults.HideSynchronizationBlock); model.HideTransactionalBlock = _genericAttributeService.GetAttribute <bool>(_workContext.CurrentCustomer, SendinBlueDefaults.HideTransactionalBlock); model.HideSmsBlock = _genericAttributeService.GetAttribute <bool>(_workContext.CurrentCustomer, SendinBlueDefaults.HideSmsBlock); model.HideMarketingAutomationBlock = _genericAttributeService.GetAttribute <bool>(_workContext.CurrentCustomer, SendinBlueDefaults.HideMarketingAutomationBlock); //prepare nested search models model.MessageTemplateSearchModel.SetGridPageSize(); model.SmsSearchModel.SetGridPageSize(); //prepare add SMS model model.AddSms.AvailablePhoneTypes.Add(new SelectListItem(_localizationService.GetResource("Plugins.Misc.SendinBlue.MyPhone"), "0")); model.AddSms.AvailablePhoneTypes.Add(new SelectListItem(_localizationService.GetResource("Plugins.Misc.SendinBlue.CustomerPhone"), "1")); model.AddSms.AvailablePhoneTypes.Add(new SelectListItem(_localizationService.GetResource("Plugins.Misc.SendinBlue.BillingAddressPhone"), "2")); model.AddSms.DefaultSelectedPhoneTypeId = model.AddSms.AvailablePhoneTypes.First().Value; model.AddSms.AvailableMessages = _messageTemplateService.GetAllMessageTemplates(storeId).Select(messageTemplate => { var name = messageTemplate.Name; if (storeId == 0 && messageTemplate.LimitedToStores) { var storeIds = _storeMappingService.GetStoresIdsWithAccess(messageTemplate); var storeNames = _storeService.GetAllStores().Where(store => storeIds.Contains(store.Id)).Select(store => store.Name); name = $"{name} ({string.Join(',', storeNames)})"; } return(new SelectListItem(name, messageTemplate.Id.ToString())); }).ToList(); var defaultSelectedMessage = model.AddSms.AvailableMessages.FirstOrDefault(); model.AddSms.DefaultSelectedMessageId = defaultSelectedMessage?.Value ?? "0"; //check whether email account exists if (sendinBlueSettings.UseSmtp && _emailAccountService.GetEmailAccountById(sendinBlueSettings.EmailAccountId) != null) { model.UseSmtp = sendinBlueSettings.UseSmtp; } //get account info var(accountInfo, marketingAutomationEnabled, maKey, accountErrors) = _sendinBlueEmailManager.GetAccountInfo(); model.AccountInfo = accountInfo; model.MarketingAutomationKey = maKey; model.MarketingAutomationDisabled = !marketingAutomationEnabled; if (!string.IsNullOrEmpty(accountErrors)) { _notificationService.ErrorNotification($"{SendinBlueDefaults.NotificationMessage} {accountErrors}"); } //prepare overridable settings if (storeId > 0) { model.ListId_OverrideForStore = _settingService.SettingExists(sendinBlueSettings, settings => settings.ListId, storeId); model.UseSmtp_OverrideForStore = _settingService.SettingExists(sendinBlueSettings, settings => settings.UseSmtp, storeId); model.SenderId_OverrideForStore = _settingService.SettingExists(sendinBlueSettings, settings => settings.SenderId, storeId); model.UseSmsNotifications_OverrideForStore = _settingService.SettingExists(sendinBlueSettings, settings => settings.UseSmsNotifications, storeId); model.SmsSenderName_OverrideForStore = _settingService.SettingExists(sendinBlueSettings, settings => settings.SmsSenderName, storeId); model.UseMarketingAutomation_OverrideForStore = _settingService.SettingExists(sendinBlueSettings, settings => settings.UseMarketingAutomation, storeId); } //check SMTP status var(smtpEnabled, smtpErrors) = _sendinBlueEmailManager.SmtpIsEnabled(); if (!string.IsNullOrEmpty(smtpErrors)) { _notificationService.ErrorNotification($"{SendinBlueDefaults.NotificationMessage} {smtpErrors}"); } //get available contact lists to synchronize var(lists, listsErrors) = _sendinBlueEmailManager.GetLists(); model.AvailableLists = lists.Select(list => new SelectListItem(list.Name, list.Id)).ToList(); model.AvailableLists.Insert(0, new SelectListItem("Select list", "0")); if (!string.IsNullOrEmpty(listsErrors)) { _notificationService.ErrorNotification($"{SendinBlueDefaults.NotificationMessage} {listsErrors}"); } //get available senders of emails from account var(senders, sendersErrors) = _sendinBlueEmailManager.GetSenders(); model.AvailableSenders = senders.Select(list => new SelectListItem(list.Name, list.Id)).ToList(); model.AvailableSenders.Insert(0, new SelectListItem("Select sender", "0")); if (!string.IsNullOrEmpty(sendersErrors)) { _notificationService.ErrorNotification($"{SendinBlueDefaults.NotificationMessage} {sendersErrors}"); } //get allowed tokens model.AllowedTokens = string.Join(", ", _messageTokenProvider.GetListOfAllowedTokens()); //create attributes in account var attributesErrors = _sendinBlueEmailManager.PrepareAttributes(); if (!string.IsNullOrEmpty(attributesErrors)) { _notificationService.ErrorNotification($"{SendinBlueDefaults.NotificationMessage} {attributesErrors}"); } //try to set account partner if (!sendinBlueSettings.PartnerValueSet) { var partnerSet = _sendinBlueEmailManager.SetPartner(); if (partnerSet) { sendinBlueSettings.PartnerValueSet = true; _settingService.SaveSetting(sendinBlueSettings, settings => settings.PartnerValueSet, clearCache: false); _settingService.ClearCache(); } } }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var wePayPaymentSettings = _settingService.LoadSetting <WePayPaymentSettings>(storeScope); //save settings wePayPaymentSettings.UseSandbox = model.UseSandbox; wePayPaymentSettings.TransactMode = (TransactMode)model.TransactModeId; wePayPaymentSettings.AccessToken = model.AccessToken; wePayPaymentSettings.AccountId = model.AccountId; wePayPaymentSettings.ClientSecret = model.ClientSecret; wePayPaymentSettings.AdditionalFee = model.AdditionalFee; wePayPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; wePayPaymentSettings.ClientId = model.ClientId; wePayPaymentSettings.PdtValidateOrderTotal = model.PdtValidateOrderTotal; wePayPaymentSettings.CheckoutType = model.CheckoutType; wePayPaymentSettings.FundingSources = model.FundingSources; wePayPaymentSettings.RequireShipping = model.RequireShipping; wePayPaymentSettings.FeePayer = model.FeePayer; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.UseSandbox_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.UseSandbox, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.UseSandbox, storeScope); } if (model.TransactModeId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.TransactMode, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.TransactMode, storeScope); } if (model.AccessToken_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.AccessToken, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.AccessToken, storeScope); } if (model.AccountId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.AccountId, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.AccountId, storeScope); } if (model.ClientSecret_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.ClientSecret, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.ClientSecret, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } if (model.ClientId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.ClientId, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.ClientId, storeScope); } if (model.PdtValidateOrderTotal_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.PdtValidateOrderTotal, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.PdtValidateOrderTotal, storeScope); } if (model.FeePayer_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.FeePayer, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.FeePayer, storeScope); } if (model.RequireShipping_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.RequireShipping, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.RequireShipping, storeScope); } if (model.FundingSources_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.FundingSources, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.FundingSources, storeScope); } if (model.CheckoutType_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(wePayPaymentSettings, x => x.CheckoutType, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(wePayPaymentSettings, x => x.CheckoutType, storeScope); } //now clear settings cache _settingService.ClearCache(); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = _storeContext.ActiveStoreScopeConfiguration; var ePayPaymentSettings = _settingService.LoadSetting <EPayPaymentSettings>(storeScope); //save settings ePayPaymentSettings.UseSandbox = model.UseSandbox; ePayPaymentSettings.CustomerNumber = model.CustomerNumber; ePayPaymentSettings.DealerEmail = model.DealerEmail; ePayPaymentSettings.SecretKey = model.SecretKey; ePayPaymentSettings.ExpirationTimeDays = model.ExpirationTimeDays; ePayPaymentSettings.AdditionalFee = model.AdditionalFee; ePayPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; ePayPaymentSettings.EnableEpay = model.EnableEpay; ePayPaymentSettings.EnableEasyPay = model.EnableEasyPay; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.UseSandbox_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ePayPaymentSettings, x => x.UseSandbox, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ePayPaymentSettings, x => x.UseSandbox, storeScope); } if (model.CustomerNumber_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ePayPaymentSettings, x => x.CustomerNumber, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ePayPaymentSettings, x => x.CustomerNumber, storeScope); } if (model.DealerEmail_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ePayPaymentSettings, x => x.DealerEmail, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ePayPaymentSettings, x => x.DealerEmail, storeScope); } if (model.SecretKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ePayPaymentSettings, x => x.SecretKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ePayPaymentSettings, x => x.SecretKey, storeScope); } if (model.ExpirationTimeDays_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ePayPaymentSettings, x => x.ExpirationTimeDays, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ePayPaymentSettings, x => x.ExpirationTimeDays, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ePayPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ePayPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ePayPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ePayPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } if (model.EnableEasyPay_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ePayPaymentSettings, x => x.EnableEasyPay, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ePayPaymentSettings, x => x.EnableEasyPay, storeScope); } if (model.EnableEpay_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ePayPaymentSettings, x => x.EnableEpay, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ePayPaymentSettings, x => x.EnableEpay, storeScope); } //now clear settings cache _settingService.ClearCache(); _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var todoPagoPaymentSettings = _settingService.LoadSetting <TodoPagoPaymentSettings>(storeScope); //save settings todoPagoPaymentSettings.Titulo = model.Titulo; todoPagoPaymentSettings.Descripcion = model.Descripcion; todoPagoPaymentSettings.Ambiente = (Ambiente)model.AmbienteId; todoPagoPaymentSettings.Segmento = (Segmento)model.SegmentoId; //todoPagoPaymentSettings.DeadLine = model.DeadLine; //todoPagoPaymentSettings.Formulario = (Formulario)model.FormularioId; todoPagoPaymentSettings.SetCuotas = model.SetCuotas; todoPagoPaymentSettings.MaxCuotas = (MaxCuotas)model.MaxCuotasId; todoPagoPaymentSettings.SetTimeout = model.SetTimeout; if (todoPagoPaymentSettings.SetTimeout) { if (!String.IsNullOrEmpty(model.Timeout)) { long n; if (Int64.TryParse(model.Timeout, out n)) { // It's a number! todoPagoPaymentSettings.Timeout = model.Timeout; } else { todoPagoPaymentSettings.Timeout = String.Empty; todoPagoPaymentSettings.SetTimeout = false; } } else { todoPagoPaymentSettings.Timeout = String.Empty; todoPagoPaymentSettings.SetTimeout = false; } } else { todoPagoPaymentSettings.Timeout = String.Empty; } todoPagoPaymentSettings.Chart = model.Chart; todoPagoPaymentSettings.GoogleMaps = model.GoogleMaps; todoPagoPaymentSettings.Hibrido = model.Hibrido; todoPagoPaymentSettings.UrlBannerBilletera = model.UrlBannerBilletera; todoPagoPaymentSettings.User = model.User; todoPagoPaymentSettings.Password = model.Password; todoPagoPaymentSettings.ApiKeyDeveloper = model.ApiKeyDeveloper; todoPagoPaymentSettings.SecurityDeveloper = model.SecurityDeveloper; todoPagoPaymentSettings.MerchantDeveloper = model.MerchantDeveloper; todoPagoPaymentSettings.ApiKeyProduction = model.ApiKeyProduction; todoPagoPaymentSettings.SecurityProduction = model.SecurityProduction; todoPagoPaymentSettings.MerchantProduction = model.MerchantProduction; todoPagoPaymentSettings.TransaccionIniciada = (OrderStatus)model.TransaccionIniciadaId; todoPagoPaymentSettings.TransaccionAprobada = (OrderStatus)model.TransaccionAprobadaId; todoPagoPaymentSettings.TransaccionRechazada = (OrderStatus)model.TransaccionRechazadaId; todoPagoPaymentSettings.TransaccionOffline = (OrderStatus)model.TransaccionOfflineId; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.Titulo_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.Titulo, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.Titulo, storeScope); } if (model.Descripcion_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.Descripcion, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.Descripcion, storeScope); } if (model.AmbienteId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.Ambiente, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.Ambiente, storeScope); } if (model.SegmentoId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.Segmento, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.Segmento, storeScope); } // if (model.DeadLine_OverrideForStore || storeScope == 0) // _settingService.SaveSetting(todoPagoPaymentSettings, x => x.DeadLine, storeScope, false); //else if (storeScope > 0) //_settingService.DeleteSetting(todoPagoPaymentSettings, x => x.DeadLine, storeScope); //if (model.FormularioId_OverrideForStore || storeScope == 0) //_settingService.SaveSetting(todoPagoPaymentSettings, x => x.Formulario, storeScope, false); //else if (storeScope > 0) //_settingService.DeleteSetting(todoPagoPaymentSettings, x => x.Formulario, storeScope); if (model.SetCuotas_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.SetCuotas, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.SetCuotas, storeScope); } if (model.MaxCuotasId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.MaxCuotas, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.MaxCuotas, storeScope); } if (model.SetTimeout_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.SetTimeout, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.SetTimeout, storeScope); } if (model.Timeout_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.Timeout, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.Timeout, storeScope); } if (model.SetTimeout_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.Chart, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.Chart, storeScope); } if (model.SetTimeout_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.GoogleMaps, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.GoogleMaps, storeScope); } if (model.SetTimeout_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.Hibrido, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.Hibrido, storeScope); } if (model.UrlBannerBilletera_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.UrlBannerBilletera, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.UrlBannerBilletera, storeScope); } if (model.User_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.User, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.User, storeScope); } if (model.Password_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.Password, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.Password, storeScope); } if (model.ApiKeyDeveloper_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.ApiKeyDeveloper, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.ApiKeyDeveloper, storeScope); } if (model.SecurityDeveloper_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.SecurityDeveloper, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.SecurityDeveloper, storeScope); } if (model.MerchantDeveloper_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.MerchantDeveloper, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.MerchantDeveloper, storeScope); } if (model.ApiKeyProduction_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.ApiKeyProduction, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.ApiKeyProduction, storeScope); } if (model.SecurityProduction_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.SecurityProduction, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.SecurityProduction, storeScope); } if (model.MerchantProduction_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.MerchantProduction, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.MerchantProduction, storeScope); } if (model.TransaccionIniciadaId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.TransaccionIniciada, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.TransaccionIniciada, storeScope); } if (model.TransaccionAprobadaId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.TransaccionAprobada, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.TransaccionAprobada, storeScope); } if (model.TransaccionRechazadaId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.TransaccionRechazada, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.TransaccionRechazada, storeScope); } if (model.TransaccionOfflineId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(todoPagoPaymentSettings, x => x.TransaccionOffline, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(todoPagoPaymentSettings, x => x.TransaccionOffline, storeScope); } //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var payPalDirectPaymentSettings = _settingService.LoadSetting <PayPalDirectPaymentSettings>(storeScope); //save settings payPalDirectPaymentSettings.UseSandbox = model.UseSandbox; payPalDirectPaymentSettings.TransactMode = (TransactMode)model.TransactModeId; payPalDirectPaymentSettings.ApiAccountName = model.ApiAccountName; payPalDirectPaymentSettings.ApiAccountPassword = model.ApiAccountPassword; payPalDirectPaymentSettings.Signature = model.Signature; payPalDirectPaymentSettings.AdditionalFee = model.AdditionalFee; payPalDirectPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.UseSandbox_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalDirectPaymentSettings, x => x.UseSandbox, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalDirectPaymentSettings, x => x.UseSandbox, storeScope); } if (model.TransactModeId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalDirectPaymentSettings, x => x.TransactMode, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalDirectPaymentSettings, x => x.TransactMode, storeScope); } if (model.ApiAccountName_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalDirectPaymentSettings, x => x.ApiAccountName, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalDirectPaymentSettings, x => x.ApiAccountName, storeScope); } if (model.ApiAccountPassword_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalDirectPaymentSettings, x => x.ApiAccountPassword, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalDirectPaymentSettings, x => x.ApiAccountPassword, storeScope); } if (model.Signature_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalDirectPaymentSettings, x => x.Signature, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalDirectPaymentSettings, x => x.Signature, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalDirectPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalDirectPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalDirectPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalDirectPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public async Task <IActionResult> Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(await Configure()); } //load settings for a chosen store scope var storeId = GetActiveStoreScopeConfiguration(_storeService, _workContext); var mailChimpSettings = _settingService.LoadSetting <MailChimpSettings>(storeId); //update stores if the list was changed if (!string.IsNullOrEmpty(model.ListId) && !model.ListId.Equals(Guid.Empty.ToString()) && !model.ListId.Equals(mailChimpSettings.ListId)) { (storeId > 0 ? new[] { storeId } : _storeService.GetAllStores().Select(store => store.Id)).ToList() .ForEach(id => _synchronizationRecordService.CreateOrUpdateRecord(EntityType.Store, id, OperationType.Update)); } //prepare webhook if (!string.IsNullOrEmpty(mailChimpSettings.ApiKey)) { var listId = !string.IsNullOrEmpty(model.ListId) && !model.ListId.Equals(Guid.Empty.ToString()) ? model.ListId : string.Empty; var webhookPrepared = await _mailChimpManager.PrepareWebhook(listId); //display warning if webhook is not prepared if (!webhookPrepared && !string.IsNullOrEmpty(listId)) { WarningNotification(_localizationService.GetResource("Plugins.Misc.MailChimp.Webhook.Warning")); } } //save settings mailChimpSettings.ApiKey = model.ApiKey; mailChimpSettings.PassEcommerceData = model.PassEcommerceData; mailChimpSettings.ListId = model.ListId; _settingService.SaveSetting(mailChimpSettings, x => x.ApiKey, clearCache: false); _settingService.SaveSetting(mailChimpSettings, x => x.PassEcommerceData, clearCache: false); _settingService.SaveSettingOverridablePerStore(mailChimpSettings, x => x.ListId, model.ListId_OverrideForStore, storeId, false); _settingService.ClearCache(); //create or update synchronization task var task = _scheduleTaskService.GetTaskByType(MailChimpDefaults.SynchronizationTask); if (task == null) { task = new ScheduleTask { Type = MailChimpDefaults.SynchronizationTask, Name = MailChimpDefaults.SynchronizationTaskName, Seconds = MailChimpDefaults.DefaultSynchronizationPeriod * 60 * 60 }; _scheduleTaskService.InsertTask(task); } var synchronizationPeriodInSeconds = model.SynchronizationPeriod * 60 * 60; var synchronizationEnabled = model.AutoSynchronization; if (task.Enabled != synchronizationEnabled || task.Seconds != synchronizationPeriodInSeconds) { //task parameters was changed task.Enabled = synchronizationEnabled; task.Seconds = synchronizationPeriodInSeconds; _scheduleTaskService.UpdateTask(task); WarningNotification(_localizationService.GetResource("Plugins.Misc.MailChimp.Fields.AutoSynchronization.Restart")); } SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(await Configure()); }
public ActionResult Configure(ConfigurationModel model) { Log("Configure [post]"); if (!ModelState.IsValid) { Log("Configure [post] model state invalid"); return(Configure()); } Log("Configure model " + model.ToString()); //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var simplifyPaymentSettings = _settingService.LoadSetting <SimplifyPaymentSettings>(storeScope); Log("Configure storeScope " + storeScope); Log("Configure settings " + simplifyPaymentSettings.ToString()); //save settings simplifyPaymentSettings.HostedMode = model.HostedMode; simplifyPaymentSettings.LiveMode = model.LiveMode; simplifyPaymentSettings.SandboxPublicKey = model.SandboxPublicKey; simplifyPaymentSettings.SandboxPrivateKey = _encryptionService.EncryptText(model.SandboxPrivateKey); simplifyPaymentSettings.LivePublicKey = model.LivePublicKey; simplifyPaymentSettings.LivePrivateKey = _encryptionService.EncryptText(model.LivePrivateKey); simplifyPaymentSettings.DebugEnabled = model.DebugEnabled; if (model.HostedMode_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(simplifyPaymentSettings, x => x.HostedMode, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(simplifyPaymentSettings, x => x.HostedMode, storeScope); } if (model.LiveMode_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(simplifyPaymentSettings, x => x.LiveMode, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(simplifyPaymentSettings, x => x.LiveMode, storeScope); } if (model.SandboxPublicKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(simplifyPaymentSettings, x => x.SandboxPublicKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(simplifyPaymentSettings, x => x.SandboxPublicKey, storeScope); } if (model.SandboxPrivateKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(simplifyPaymentSettings, x => x.SandboxPrivateKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(simplifyPaymentSettings, x => x.SandboxPrivateKey, storeScope); } if (model.LivePublicKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(simplifyPaymentSettings, x => x.LivePublicKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(simplifyPaymentSettings, x => x.LivePublicKey, storeScope); } if (model.LivePrivateKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(simplifyPaymentSettings, x => x.LivePrivateKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(simplifyPaymentSettings, x => x.LivePrivateKey, storeScope); } if (model.DebugEnabled_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(simplifyPaymentSettings, x => x.DebugEnabled, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(simplifyPaymentSettings, x => x.DebugEnabled, storeScope); } //now clear settings cache Log("Configure clearing cache"); _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var checkMoneyOrderPaymentSettings = _settingService.LoadSetting <CheckMoneyOrderPaymentSettings>(storeScope); //save settings checkMoneyOrderPaymentSettings.DescriptionText = model.DescriptionText; checkMoneyOrderPaymentSettings.AdditionalFee = model.AdditionalFee; checkMoneyOrderPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; checkMoneyOrderPaymentSettings.ShippableProductRequired = model.ShippableProductRequired; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.DescriptionText_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(checkMoneyOrderPaymentSettings, x => x.DescriptionText, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(checkMoneyOrderPaymentSettings, x => x.DescriptionText, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(checkMoneyOrderPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(checkMoneyOrderPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(checkMoneyOrderPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(checkMoneyOrderPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } if (model.ShippableProductRequired_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(checkMoneyOrderPaymentSettings, x => x.ShippableProductRequired, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(checkMoneyOrderPaymentSettings, x => x.ShippableProductRequired, storeScope); } //now clear settings cache _settingService.ClearCache(); //localization. no multi-store support for localization yet. //foreach (var localized in model.Locales) //{ // checkMoneyOrderPaymentSettings.SaveLocalizedSetting(x => x.DescriptionText, // localized.LanguageId, // localized.DescriptionText); //} SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var nivoSliderSettings = _settingService.LoadSetting <NivoSliderSettings>(storeScope); nivoSliderSettings.Picture1Id = model.Picture1Id; nivoSliderSettings.Text1 = model.Text1; nivoSliderSettings.Link1 = model.Link1; nivoSliderSettings.Picture2Id = model.Picture2Id; nivoSliderSettings.Text2 = model.Text2; nivoSliderSettings.Link2 = model.Link2; nivoSliderSettings.Picture3Id = model.Picture3Id; nivoSliderSettings.Text3 = model.Text3; nivoSliderSettings.Link3 = model.Link3; nivoSliderSettings.Picture4Id = model.Picture4Id; nivoSliderSettings.Text4 = model.Text4; nivoSliderSettings.Link4 = model.Link4; //Customized nivoSliderSettings.Picture5Id = model.Picture5Id; nivoSliderSettings.Text5 = model.Text5; nivoSliderSettings.Link5 = model.Link5; nivoSliderSettings.Picture6Id = model.Picture6Id; nivoSliderSettings.Text6 = model.Text6; nivoSliderSettings.Link6 = model.Link6; nivoSliderSettings.Picture7Id = model.Picture7Id; nivoSliderSettings.Text7 = model.Text7; nivoSliderSettings.Link7 = model.Link7; nivoSliderSettings.Picture8Id = model.Picture8Id; nivoSliderSettings.Text8 = model.Text8; nivoSliderSettings.Link8 = model.Link8; //End Customization /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.Picture1Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Picture1Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Picture1Id, storeScope); } if (model.Text1_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Text1, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Text1, storeScope); } if (model.Link1_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Link1, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Link1, storeScope); } if (model.Picture2Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Picture2Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Picture2Id, storeScope); } if (model.Text2_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Text2, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Text2, storeScope); } if (model.Link2_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Link2, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Link2, storeScope); } if (model.Picture3Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Picture3Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Picture3Id, storeScope); } if (model.Text3_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Text3, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Text3, storeScope); } if (model.Link3_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Link3, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Link3, storeScope); } if (model.Picture4Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Picture4Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Picture4Id, storeScope); } if (model.Text4_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Text4, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Text4, storeScope); } if (model.Link4_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Link4, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Link4, storeScope); } //Customized if (model.Picture5Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Picture5Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Picture5Id, storeScope); } if (model.Text5_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Text5, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Text5, storeScope); } if (model.Link5_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Link5, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Link5, storeScope); } if (model.Picture6Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Picture6Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Picture6Id, storeScope); } if (model.Text6_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Text6, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Text6, storeScope); } if (model.Link6_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Link6, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Link6, storeScope); } if (model.Picture7Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Picture7Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Picture7Id, storeScope); } if (model.Text7_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Text7, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Text7, storeScope); } if (model.Link7_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Link7, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Link7, storeScope); } if (model.Picture8Id_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Picture8Id, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Picture8Id, storeScope); } if (model.Text8_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Text8, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Text8, storeScope); } if (model.Link8_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(nivoSliderSettings, x => x.Link8, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(nivoSliderSettings, x => x.Link8, storeScope); } //End Csutomization //now clear settings cache _settingService.ClearCache(); return(Configure()); }
public IActionResult Configure(ConfigurationModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePaymentMethods)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = _storeContext.ActiveStoreScopeConfiguration; var settings = _settingService.LoadSetting <PayPalSmartPaymentButtonsSettings>(storeScope); //first delete the unused webhook on a previous client, if changed if ((!model.ClientId?.Equals(settings.ClientId) ?? true) && !string.IsNullOrEmpty(settings.ClientId) && !string.IsNullOrEmpty(settings.SecretKey)) { _serviceManager.DeleteWebhook(settings); } //set new settings values settings.ClientId = model.ClientId; settings.SecretKey = model.SecretKey; settings.UseSandbox = model.UseSandbox; settings.PaymentType = (PaymentType)model.PaymentTypeId; settings.DisplayButtonsOnShoppingCart = model.DisplayButtonsOnShoppingCart; settings.DisplayButtonsOnProductDetails = model.DisplayButtonsOnProductDetails; settings.DisplayLogoInHeaderLinks = model.DisplayLogoInHeaderLinks; settings.LogoInHeaderLinks = model.LogoInHeaderLinks; settings.DisplayLogoInFooter = model.DisplayLogoInFooter; settings.LogoInFooter = model.LogoInFooter; //ensure that webhook created, display warning in case of fail if (!string.IsNullOrEmpty(settings.ClientId) && !string.IsNullOrEmpty(settings.SecretKey)) { var webhookUrl = Url.RouteUrl(Defaults.WebhookRouteName, null, _webHelper.CurrentRequestProtocol); var(webhook, webhookError) = _serviceManager.CreateWebHook(settings, webhookUrl); settings.WebhookId = webhook?.Id; if (string.IsNullOrEmpty(settings.WebhookId)) { var url = Url.Action("List", "Log"); var warning = string.Format(_localizationService.GetResource("Plugins.Payments.PayPalSmartPaymentButtons.WebhookWarning"), url); _notificationService.WarningNotification(warning, false); } } //save settings _settingService.SaveSettingOverridablePerStore(settings, setting => setting.WebhookId, true, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.ClientId, model.ClientId_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.SecretKey, model.SecretKey_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.UseSandbox, model.UseSandbox_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.PaymentType, model.PaymentTypeId_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.DisplayButtonsOnShoppingCart, model.DisplayButtonsOnShoppingCart_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.DisplayButtonsOnProductDetails, model.DisplayButtonsOnProductDetails_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.DisplayLogoInHeaderLinks, model.DisplayLogoInHeaderLinks_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.LogoInHeaderLinks, model.LogoInHeaderLinks_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.DisplayLogoInFooter, model.DisplayLogoInFooter_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.LogoInFooter, model.LogoInFooter_OverrideForStore, storeScope, false); _settingService.ClearCache(); //ensure credentials are valid if (!string.IsNullOrEmpty(settings.ClientId) && !string.IsNullOrEmpty(settings.SecretKey)) { var(_, errorMessage) = _serviceManager.GetAccessToken(settings); if (!string.IsNullOrEmpty(errorMessage)) { var url = Url.Action("List", "Log"); var error = string.Format(_localizationService.GetResource("Plugins.Payments.PayPalSmartPaymentButtons.Credentials.Invalid"), url); _notificationService.ErrorNotification(error, false); } else { _notificationService.SuccessNotification(_localizationService.GetResource("Plugins.Payments.PayPalSmartPaymentButtons.Credentials.Valid")); } } _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public IActionResult Configure(ConfigurationModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePaymentMethods)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = _storeContext.ActiveStoreScopeConfiguration; var settings = _settingService.LoadSetting <PayPalSmartPaymentButtonsSettings>(storeScope); //first delete the unused webhook on a previous client, if changed if (!model.ClientId.Equals(settings.ClientId)) { _serviceManager.DeleteWebhook(settings); } //set new settings values settings.ClientId = model.ClientId; settings.SecretKey = model.SecretKey; settings.UseSandbox = model.UseSandbox; settings.PaymentType = (PaymentType)model.PaymentTypeId; settings.ButtonsWidgetZones = model.ButtonsWidgetZones.Select(id => Defaults.AvailableButtonsWidgetZones[id]).ToList(); //ensure that webhook created, display warning in case of fail var webhookUrl = Url.RouteUrl(Defaults.WebhookRouteName, null, _webHelper.CurrentRequestProtocol); var(webhook, webhookError) = _serviceManager.CreateWebHook(settings, webhookUrl); settings.WebhookId = webhook?.Id; if (string.IsNullOrEmpty(settings.WebhookId)) { var url = Url.Action("List", "Log"); var warning = string.Format(_localizationService.GetResource("Plugins.Payments.PayPalSmartPaymentButtons.WebhookWarning"), url); _notificationService.WarningNotification(warning, false); } //save settings _settingService.SaveSettingOverridablePerStore(settings, setting => setting.WebhookId, true, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.ClientId, model.ClientId_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.SecretKey, model.SecretKey_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.UseSandbox, model.UseSandbox_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.PaymentType, model.PaymentTypeId_OverrideForStore, storeScope, false); _settingService.SaveSettingOverridablePerStore(settings, setting => setting.ButtonsWidgetZones, model.ButtonsWidgetZones_OverrideForStore, storeScope, false); _settingService.ClearCache(); _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); //check credentials var credentialsError = _serviceManager.CheckCredentials(settings); if (!string.IsNullOrEmpty(credentialsError)) { _notificationService.ErrorNotification(credentialsError); } else { _notificationService.SuccessNotification(_localizationService.GetResource("Plugins.Payments.PayPalSmartPaymentButtons.Credentials.Valid")); } return(Configure()); }
public async Task <IActionResult> Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(await Configure()); } //load settings for a chosen store scope var storeScope = await this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var payPalStandardPaymentSettings = _settingService.LoadSetting <PayPalStandardPaymentSettings>(storeScope); //save settings payPalStandardPaymentSettings.UseSandbox = model.UseSandbox; payPalStandardPaymentSettings.BusinessEmail = model.BusinessEmail; payPalStandardPaymentSettings.PdtToken = model.PdtToken; payPalStandardPaymentSettings.PdtValidateOrderTotal = model.PdtValidateOrderTotal; payPalStandardPaymentSettings.AdditionalFee = model.AdditionalFee; payPalStandardPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; payPalStandardPaymentSettings.PassProductNamesAndTotals = model.PassProductNamesAndTotals; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.UseSandbox_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.UseSandbox, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.UseSandbox, storeScope); } if (model.BusinessEmail_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.BusinessEmail, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.BusinessEmail, storeScope); } if (model.PdtToken_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.PdtToken, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.PdtToken, storeScope); } if (model.PdtValidateOrderTotal_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.PdtValidateOrderTotal, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.PdtValidateOrderTotal, storeScope); } if (model.AdditionalFee_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } if (model.PassProductNamesAndTotals_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.PassProductNamesAndTotals, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.PassProductNamesAndTotals, storeScope); } //now clear settings cache await _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(await Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var secureSubmitPaymentSettings = _settingService.LoadSetting <SecureSubmitPaymentSettings>(storeScope); //save settings secureSubmitPaymentSettings.TransactMode = (TransactMode)model.TransactModeId; secureSubmitPaymentSettings.PublicApiKey = model.PublicApiKey; secureSubmitPaymentSettings.SecretApiKey = model.SecretApiKey; secureSubmitPaymentSettings.AdditionalFee = model.AdditionalFee; secureSubmitPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; if (model.TransactModeId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(secureSubmitPaymentSettings, x => x.TransactMode, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(secureSubmitPaymentSettings, x => x.TransactMode, storeScope); } if (model.PublicApiKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(secureSubmitPaymentSettings, x => x.PublicApiKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(secureSubmitPaymentSettings, x => x.PublicApiKey, storeScope); } if (model.SecretApiKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(secureSubmitPaymentSettings, x => x.SecretApiKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(secureSubmitPaymentSettings, x => x.SecretApiKey, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(secureSubmitPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(secureSubmitPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(secureSubmitPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(secureSubmitPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } _settingService.ClearCache(); return(Configure()); }
public async Task <IActionResult> Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(await Configure()); } //load settings for a chosen store scope var storeScope = await this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var checkMoneyOrderPaymentSettings = _settingService.LoadSetting <CheckMoneyOrderPaymentSettings>(storeScope); //save settings checkMoneyOrderPaymentSettings.DescriptionText = model.DescriptionText; checkMoneyOrderPaymentSettings.AdditionalFee = model.AdditionalFee; checkMoneyOrderPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; checkMoneyOrderPaymentSettings.ShippableProductRequired = model.ShippableProductRequired; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.DescriptionText_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(checkMoneyOrderPaymentSettings, x => x.DescriptionText, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(checkMoneyOrderPaymentSettings, x => x.DescriptionText, storeScope); } if (model.AdditionalFee_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(checkMoneyOrderPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(checkMoneyOrderPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(checkMoneyOrderPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(checkMoneyOrderPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } if (model.ShippableProductRequired_OverrideForStore || String.IsNullOrEmpty(storeScope)) { await _settingService.SaveSetting(checkMoneyOrderPaymentSettings, x => x.ShippableProductRequired, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { await _settingService.DeleteSetting(checkMoneyOrderPaymentSettings, x => x.ShippableProductRequired, storeScope); } //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(await Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var ogonePaymentSettings = _settingService.LoadSetting <OgonePaymentSettings>(storeScope); //save settings ogonePaymentSettings.PSPId = model.PSPId; ogonePaymentSettings.SHAInPassPhrase = _encryptionService.EncryptText(model.SHAInPassPhrase); ogonePaymentSettings.SHAOutPassPhrase = _encryptionService.EncryptText(model.SHAOutPassPhrase); ogonePaymentSettings.AdditionalFee = model.AdditionalFee; ogonePaymentSettings.HashAllParameters = model.HashAllParameters; ogonePaymentSettings.HashingAlgorithm = (HashingAlgorithm)model.HashingAlgorithmId; ogonePaymentSettings.OgoneGatewayUrl = model.OgoneGatewayUrl; ogonePaymentSettings.TemplateUrl = model.TemplateUrl; ogonePaymentSettings.TemplateTitle = model.TemplateTitle; ogonePaymentSettings.BackgroundColor = model.BackgroundColor; ogonePaymentSettings.TextColor = model.TextColor; ogonePaymentSettings.TableBackgroundColor = model.TableBackgroundColor; ogonePaymentSettings.TableTextColor = model.TableTextColor; ogonePaymentSettings.ButtonBackgroundColor = model.ButtonBackgroundColor; ogonePaymentSettings.ButtonTextColor = model.ButtonTextColor; ogonePaymentSettings.FontFamily = model.FontFamily; ogonePaymentSettings.LogoUrl = model.LogoUrl; ogonePaymentSettings.ParamVar = model.ParamVar; ogonePaymentSettings.OrderIdPrefix = model.OrderIdPrefix; ogonePaymentSettings.PmList = model.PmList; ogonePaymentSettings.ExclPmList = model.ExclPmList; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.PSPId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.PSPId, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.PSPId, storeScope); } if (model.SHAInPassPhrase_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.SHAInPassPhrase, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.SHAInPassPhrase, storeScope); } if (model.SHAOutPassPhrase_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.SHAOutPassPhrase, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.SHAOutPassPhrase, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.AdditionalFee, storeScope); } if (model.HashAllParameters_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.HashAllParameters, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.HashAllParameters, storeScope); } if (model.HashingAlgorithmId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.HashingAlgorithm, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.HashingAlgorithm, storeScope); } if (model.OgoneGatewayUrl_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.OgoneGatewayUrl, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.OgoneGatewayUrl, storeScope); } if (model.TemplateUrl_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.TemplateUrl, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.TemplateUrl, storeScope); } if (model.TemplateTitle_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.TemplateTitle, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.TemplateTitle, storeScope); } if (model.BackgroundColor_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.BackgroundColor, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.BackgroundColor, storeScope); } if (model.TextColor_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.TextColor, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.TextColor, storeScope); } if (model.TableBackgroundColor_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.TableBackgroundColor, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.TableBackgroundColor, storeScope); } if (model.TableTextColor_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.TableTextColor, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.TableTextColor, storeScope); } if (model.ButtonBackgroundColor_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.ButtonBackgroundColor, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.ButtonBackgroundColor, storeScope); } if (model.ButtonTextColor_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.ButtonTextColor, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.ButtonTextColor, storeScope); } if (model.FontFamily_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.FontFamily, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.FontFamily, storeScope); } if (model.LogoUrl_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.LogoUrl, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.LogoUrl, storeScope); } if (model.ParamVar_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.ParamVar, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.LogoUrl, storeScope); } if (model.OrderIdPrefix_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.OrderIdPrefix, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.OrderIdPrefix, storeScope); } if (model.PmList_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.PmList, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.PmList, storeScope); } if (model.ExclPmList_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(ogonePaymentSettings, x => x.ExclPmList, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(ogonePaymentSettings, x => x.ExclPmList, storeScope); } //now clear settings cache _settingService.ClearCache(); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var authorizeNetPaymentSettings = _settingService.LoadSetting <AuthorizeNetPaymentSettings>(storeScope); //save settings authorizeNetPaymentSettings.UseSandbox = model.UseSandbox; authorizeNetPaymentSettings.TransactMode = (TransactMode)model.TransactModeId; authorizeNetPaymentSettings.TransactionKey = model.TransactionKey; authorizeNetPaymentSettings.LoginId = model.LoginId; authorizeNetPaymentSettings.AdditionalFee = model.AdditionalFee; authorizeNetPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.UseSandbox_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(authorizeNetPaymentSettings, x => x.UseSandbox, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(authorizeNetPaymentSettings, x => x.UseSandbox, storeScope); } if (model.TransactModeId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(authorizeNetPaymentSettings, x => x.TransactMode, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(authorizeNetPaymentSettings, x => x.TransactMode, storeScope); } if (model.TransactionKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(authorizeNetPaymentSettings, x => x.TransactionKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(authorizeNetPaymentSettings, x => x.TransactionKey, storeScope); } if (model.LoginId_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(authorizeNetPaymentSettings, x => x.LoginId, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(authorizeNetPaymentSettings, x => x.LoginId, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(authorizeNetPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(authorizeNetPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(authorizeNetPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(authorizeNetPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } //now clear settings cache _settingService.ClearCache(); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var sliderSettings = _settingService.LoadSetting <SliderSettings>(storeScope); sliderSettings.Picture1Id = model.Picture1Id; sliderSettings.Text1 = model.Text1; sliderSettings.Link1 = model.Link1; sliderSettings.Picture2Id = model.Picture2Id; sliderSettings.Text2 = model.Text2; sliderSettings.Link2 = model.Link2; sliderSettings.Picture3Id = model.Picture3Id; sliderSettings.Text3 = model.Text3; sliderSettings.Link3 = model.Link3; sliderSettings.Picture4Id = model.Picture4Id; sliderSettings.Text4 = model.Text4; sliderSettings.Link4 = model.Link4; sliderSettings.Picture5Id = model.Picture5Id; sliderSettings.Text5 = model.Text5; sliderSettings.Link5 = model.Link5; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.Picture1Id_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Picture1Id, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Picture1Id, storeScope); } if (model.Text1_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Text1, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Text1, storeScope); } if (model.Link1_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Link1, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Link1, storeScope); } if (model.Picture2Id_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Picture2Id, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Picture2Id, storeScope); } if (model.Text2_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Text2, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Text2, storeScope); } if (model.Link2_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Link2, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Link2, storeScope); } if (model.Picture3Id_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Picture3Id, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Picture3Id, storeScope); } if (model.Text3_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Text3, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Text3, storeScope); } if (model.Link3_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Link3, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Link3, storeScope); } if (model.Picture4Id_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Picture4Id, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Picture4Id, storeScope); } if (model.Text4_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Text4, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Text4, storeScope); } if (model.Link4_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Link4, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Link4, storeScope); } if (model.Picture5Id_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Picture5Id, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Picture5Id, storeScope); } if (model.Text5_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Text5, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Text5, storeScope); } if (model.Link5_OverrideForStore || String.IsNullOrEmpty(storeScope)) { _settingService.SaveSetting(sliderSettings, x => x.Link5, storeScope, false); } else if (!String.IsNullOrEmpty(storeScope)) { _settingService.DeleteSetting(sliderSettings, x => x.Link5, storeScope); } //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public ActionResult Configure(ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var payPalStandardPaymentSettings = _settingService.LoadSetting <OnepayPaymentSettings>(storeScope); //save settings payPalStandardPaymentSettings.UseSandbox = model.UseSandbox; payPalStandardPaymentSettings.BusinessEmail = model.BusinessEmail; payPalStandardPaymentSettings.PdtToken = model.PdtToken; payPalStandardPaymentSettings.PdtValidateOrderTotal = model.PdtValidateOrderTotal; payPalStandardPaymentSettings.AdditionalFee = model.AdditionalFee; payPalStandardPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; payPalStandardPaymentSettings.PassProductNamesAndTotals = model.PassProductNamesAndTotals; payPalStandardPaymentSettings.EnableIpn = model.EnableIpn; payPalStandardPaymentSettings.IpnUrl = model.IpnUrl; payPalStandardPaymentSettings.AddressOverride = model.AddressOverride; payPalStandardPaymentSettings.ReturnFromPayPalWithoutPaymentRedirectsToOrderDetailsPage = model.ReturnFromPayPalWithoutPaymentRedirectsToOrderDetailsPage; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.UseSandbox_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.UseSandbox, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.UseSandbox, storeScope); } if (model.BusinessEmail_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.BusinessEmail, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.BusinessEmail, storeScope); } if (model.PdtToken_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.PdtToken, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.PdtToken, storeScope); } if (model.PdtValidateOrderTotal_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.PdtValidateOrderTotal, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.PdtValidateOrderTotal, storeScope); } if (model.AdditionalFee_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.AdditionalFee, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.AdditionalFee, storeScope); } if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.AdditionalFeePercentage, storeScope); } if (model.PassProductNamesAndTotals_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.PassProductNamesAndTotals, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.PassProductNamesAndTotals, storeScope); } if (model.EnableIpn_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.EnableIpn, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.EnableIpn, storeScope); } if (model.IpnUrl_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.IpnUrl, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.IpnUrl, storeScope); } if (model.AddressOverride_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.AddressOverride, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.AddressOverride, storeScope); } if (model.ReturnFromPayPalWithoutPaymentRedirectsToOrderDetailsPage_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payPalStandardPaymentSettings, x => x.ReturnFromPayPalWithoutPaymentRedirectsToOrderDetailsPage, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payPalStandardPaymentSettings, x => x.ReturnFromPayPalWithoutPaymentRedirectsToOrderDetailsPage, storeScope); } //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
public IActionResult Configure(ConfigurationModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePaymentMethods)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Configure()); } //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var payGatePaymentSettings = _settingService.LoadSetting <PayGatePaymentSettings>(storeScope); //save settings payGatePaymentSettings.UseSandbox = model.UseSandbox; payGatePaymentSettings.PayGateID = model.PayGateID; payGatePaymentSettings.EncryptionKey = model.EncryptionKey; payGatePaymentSettings.EnableIpn = model.EnableIpn; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.UseSandbox_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payGatePaymentSettings, x => x.UseSandbox, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payGatePaymentSettings, x => x.UseSandbox, storeScope); } if (model.PayGateID_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payGatePaymentSettings, x => x.PayGateID, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payGatePaymentSettings, x => x.PayGateID, storeScope); } if (model.EncryptionKey_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payGatePaymentSettings, x => x.EncryptionKey, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payGatePaymentSettings, x => x.EncryptionKey, storeScope); } if (model.EnableIpn_OverrideForStore || storeScope == 0) { _settingService.SaveSetting(payGatePaymentSettings, x => x.EnableIpn, storeScope, false); } else if (storeScope > 0) { _settingService.DeleteSetting(payGatePaymentSettings, x => x.EnableIpn, storeScope); } //now clear settings cache _settingService.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }