public ActionResult Configure() { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); Log("Configure storeScope " + storeScope); var simplifyPaymentSettings = _settingService.LoadSetting <SimplifyPaymentSettings>(storeScope); Log("Configure settings " + simplifyPaymentSettings.ToString()); var model = new ConfigurationModel(); model.HostedMode = simplifyPaymentSettings.HostedMode; model.LiveMode = simplifyPaymentSettings.LiveMode; model.SandboxPublicKey = simplifyPaymentSettings.SandboxPublicKey; model.SandboxPrivateKey = _encryptionService.DecryptText(simplifyPaymentSettings.SandboxPrivateKey); model.LivePublicKey = simplifyPaymentSettings.LivePublicKey; model.LivePrivateKey = _encryptionService.DecryptText(simplifyPaymentSettings.LivePrivateKey); model.DebugEnabled = simplifyPaymentSettings.DebugEnabled; model.ActiveStoreScopeConfiguration = storeScope; if (storeScope > 0) { _logger.Information("Configure checking store scope overrides"); model.HostedMode_OverrideForStore = _settingService.SettingExists(simplifyPaymentSettings, x => x.HostedMode, storeScope); model.LiveMode_OverrideForStore = _settingService.SettingExists(simplifyPaymentSettings, x => x.LiveMode, storeScope); model.SandboxPublicKey_OverrideForStore = _settingService.SettingExists(simplifyPaymentSettings, x => x.SandboxPublicKey, storeScope); model.SandboxPrivateKey_OverrideForStore = _settingService.SettingExists(simplifyPaymentSettings, x => x.SandboxPrivateKey, storeScope); model.LivePublicKey_OverrideForStore = _settingService.SettingExists(simplifyPaymentSettings, x => x.LivePublicKey, storeScope); model.LivePrivateKey_OverrideForStore = _settingService.SettingExists(simplifyPaymentSettings, x => x.LivePrivateKey, storeScope); model.DebugEnabled_OverrideForStore = _settingService.SettingExists(simplifyPaymentSettings, x => x.DebugEnabled, storeScope); } Log("Configure model " + model.ToString()); return(View("~/Plugins/Payments.Simplify/Views/PaymentSimplify/Configure.cshtml", model)); }
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()); }