public ActionResult Configure(PayPalPlusPaymentSettings settings, int storeScope) { // It's better to also offer inactive methods here but filter them out in frontend. var paymentMethods = _paymentService.LoadAllPaymentMethods(storeScope); var model = new PayPalPlusConfigurationModel(); MiniMapper.Map(settings, model); PrepareConfigurationModel(model, storeScope); model.AvailableThirdPartyPaymentMethods = paymentMethods .Where(x => { if (x.Value.RequiresInteraction) { return(false); } if (x.Metadata.PluginDescriptor.SystemName == Plugin.SystemName) { return(x.Metadata.SystemName == PayPalInstalmentsProvider.SystemName); } return(x.Metadata.PluginDescriptor.SystemName == "SmartStore.OfflinePayment" || x.Value.PaymentMethodType == PaymentMethodType.Redirection); }) .ToSelectListItems(_pluginMediator, model.ThirdPartyPaymentMethods.ToArray()); return(View(model)); }
public ActionResult Configure(PayPalPlusConfigurationModel model, FormCollection form) { var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <PayPalPlusPaymentSettings>(storeScope); var validator = new PayPalPlusConfigValidator(Services.Localization, x => { return(storeScope == 0 || storeDependingSettingHelper.IsOverrideChecked(settings, x, form)); }); validator.Validate(model, ModelState); if (!ModelState.IsValid) { return(Configure()); } ModelState.Clear(); model.Copy(settings, false); storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); Services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false); Services.Settings.ClearCache(); NotifySuccess(T("Admin.Common.DataSuccessfullySaved")); return(Configure()); }
public ActionResult Configure(PayPalPlusConfigurationModel model, FormCollection form) { if (!SaveConfigurationModel(model, form)) { var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <PayPalPlusPaymentSettings>(storeScope); return(Configure(settings, storeScope)); } return(RedirectToConfiguration(PayPalPlusProvider.SystemName, false)); }
public ActionResult Configure(PayPalPlusConfigurationModel model, FormCollection form) { var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <PayPalPlusPaymentSettings>(storeScope); var oldClientId = settings.ClientId; var oldSecret = settings.Secret; var oldProfileId = settings.ExperienceProfileId; var validator = new PayPalPlusConfigValidator(Services.Localization, x => { return(storeScope == 0 || storeDependingSettingHelper.IsOverrideChecked(settings, x, form)); }); validator.Validate(model, ModelState); if (!ModelState.IsValid) { return(Configure(settings, storeScope)); } ModelState.Clear(); model.Copy(settings, false); // Credentials changed: reset profile and webhook id to avoid errors. if (!oldClientId.IsCaseInsensitiveEqual(settings.ClientId) || !oldSecret.IsCaseInsensitiveEqual(settings.Secret)) { if (oldProfileId.IsCaseInsensitiveEqual(settings.ExperienceProfileId)) { settings.ExperienceProfileId = null; } settings.WebhookId = null; } using (Services.Settings.BeginScope()) { storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings); } using (Services.Settings.BeginScope()) { // Multistore context not possible, see IPN handling. Services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false); } NotifySuccess(T("Admin.Common.DataSuccessfullySaved")); return(RedirectToConfiguration(PayPalPlusProvider.SystemName, false)); }
public ActionResult Configure(PayPalPlusPaymentSettings settings, int storeScope) { var model = new PayPalPlusConfigurationModel { ConfigGroups = T("Plugins.SmartStore.PayPal.ConfigGroups").Text.SplitSafe(";") }; // It's better to also offer inactive methods here but filter them out in frontend. var paymentMethods = _paymentService.LoadAllPaymentMethods(storeScope); model.Copy(settings, true); PrepareConfigurationModel(model, storeScope); model.AvailableThirdPartyPaymentMethods = paymentMethods .Where(x => x.Metadata.PluginDescriptor.SystemName != Plugin.SystemName && !x.Value.RequiresInteraction && (x.Metadata.PluginDescriptor.SystemName == "SmartStore.OfflinePayment" || x.Value.PaymentMethodType == PaymentMethodType.Redirection)) .ToSelectListItems(_pluginMediator, model.ThirdPartyPaymentMethods.ToArray()); return(View(model)); }
public ActionResult Configure() { var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext); var settings = Services.Settings.LoadSetting <PayPalPlusPaymentSettings>(storeScope); var model = new PayPalPlusConfigurationModel { ConfigGroups = T("Plugins.SmartStore.PayPal.ConfigGroups").Text.SplitSafe(";") }; model.AvailableSecurityProtocols = PayPal.Services.PayPalService.GetSecurityProtocols() .Select(x => new SelectListItem { Value = ((int)x.Key).ToString(), Text = x.Value }) .ToList(); // it's better to also offer inactive methods here but filter them out in frontend var methods = _paymentService.LoadAllPaymentMethods(storeScope); model.AvailableThirdPartyPaymentMethods = methods .Where(x => x.Metadata.PluginDescriptor.SystemName != Plugin.SystemName && !x.Value.RequiresInteraction && (x.Metadata.PluginDescriptor.SystemName == "SmartStore.OfflinePayment" || x.Value.PaymentMethodType == PaymentMethodType.Redirection)) .Select(x => new SelectListItem { Value = x.Metadata.SystemName, Text = GetPaymentMethodName(x) }) .ToList(); model.Copy(settings, true); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, Services.Settings); return(View(model)); }