public ActionResult Configure()
        {
            //load settings for a chosen store scope
            var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var payPalDirectPaymentSettings = _settingService.LoadSetting<PayPalDirectPaymentSettings>(storeScope);

            var model = new ConfigurationModel();
            model.UseSandbox = payPalDirectPaymentSettings.UseSandbox;
            model.TransactModeId = Convert.ToInt32(payPalDirectPaymentSettings.TransactMode);
            model.ApiAccountName = payPalDirectPaymentSettings.ApiAccountName;
            model.ApiAccountPassword = payPalDirectPaymentSettings.ApiAccountPassword;
            model.Signature = payPalDirectPaymentSettings.Signature;
            model.AdditionalFee = payPalDirectPaymentSettings.AdditionalFee;
            model.AdditionalFeePercentage = payPalDirectPaymentSettings.AdditionalFeePercentage;
            model.TransactModeValues = payPalDirectPaymentSettings.TransactMode.ToSelectList();

            model.ActiveStoreScopeConfiguration = storeScope;
            if (storeScope > 0)
            {
                model.UseSandbox_OverrideForStore = _settingService.SettingExists(payPalDirectPaymentSettings, x => x.UseSandbox, storeScope);
                model.TransactModeId_OverrideForStore = _settingService.SettingExists(payPalDirectPaymentSettings, x => x.TransactMode, storeScope);
                model.ApiAccountName_OverrideForStore = _settingService.SettingExists(payPalDirectPaymentSettings, x => x.ApiAccountName, storeScope);
                model.ApiAccountPassword_OverrideForStore = _settingService.SettingExists(payPalDirectPaymentSettings, x => x.ApiAccountPassword, storeScope);
                model.Signature_OverrideForStore = _settingService.SettingExists(payPalDirectPaymentSettings, x => x.Signature, storeScope);
                model.AdditionalFee_OverrideForStore = _settingService.SettingExists(payPalDirectPaymentSettings, x => x.AdditionalFee, storeScope);
                model.AdditionalFeePercentage_OverrideForStore = _settingService.SettingExists(payPalDirectPaymentSettings, x => x.AdditionalFeePercentage, storeScope);
            }

            return View("~/Plugins/Payments.PayPalDirect/Views/PaymentPayPalDirect/Configure.cshtml", model);
        }
        public ActionResult Configure()
        {
            var model = new ConfigurationModel();
            model.UseSandbox = _paypalDirectPaymentSettings.UseSandbox;
            model.TransactModeId = Convert.ToInt32(_paypalDirectPaymentSettings.TransactMode);
            model.ApiAccountName = _paypalDirectPaymentSettings.ApiAccountName;
            model.ApiAccountPassword = _paypalDirectPaymentSettings.ApiAccountPassword;
            model.Signature = _paypalDirectPaymentSettings.Signature;
            model.AdditionalFee = _paypalDirectPaymentSettings.AdditionalFee;
            model.TransactModeValues = _paypalDirectPaymentSettings.TransactMode.ToSelectList();

            return View("Nop.Plugin.Payments.PayPalDirect.Views.PaymentPayPalDirect.Configure", model);
        }
        public ActionResult Configure(ConfigurationModel model)
        {
            if (!ModelState.IsValid)
                return Configure();

            //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;
            _settingService.SaveSetting(_paypalDirectPaymentSettings);

            model.TransactModeValues = _paypalDirectPaymentSettings.TransactMode.ToSelectList();

            return View("Nop.Plugin.Payments.PayPalDirect.Views.PaymentPayPalDirect.Configure", model);
        }
        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();
        }