private void LoadPaymentMethods() { try { var paymentMethods = _paymentMethodService.GetAll(); cboPaymentMethod.Items.Clear(); cboPaymentMethod.Items.Add("-Select Payment Method-"); foreach (var item in paymentMethods) { cboPaymentMethod.Items.Add(new ItemX(item.Name, item.PaymentMethodID.ToString())); } } catch (Exception ex) { MetroMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected CheckoutPaymentMethodModel PreparePaymentMethodModel(IOrderedEnumerable <ShoppingCartItem> cart) { var model = new CheckoutPaymentMethodModel(); var payment = _paymentMethodService.GetAll(); if (payment.IsAny()) { model.PaymentMethods = (from x in payment select new CheckoutPaymentMethodModel.PaymentMethodModel { Id = x.Id, PaymentMethodSystemName = x.PaymentMethodSystemName, FullDescription = x.Description }).ToList(); } var selectedPaymentMethodSystemName = _workContext.CurrentCustomer.GetAttribute("Customer", Contains.SelectedPaymentMethod, _genericAttributeService); var selected = false; if (selectedPaymentMethodSystemName.HasValue()) { var paymentMethodToSelect = model.PaymentMethods.Find(pm => pm.PaymentMethodSystemName.IsCaseInsensitiveEqual(selectedPaymentMethodSystemName)); if (paymentMethodToSelect != null) { paymentMethodToSelect.Selected = true; selected = true; } } // if no option has been selected, let's do it for the first one if (!selected) { var paymentMethodToSelect = model.PaymentMethods.FirstOrDefault(); if (paymentMethodToSelect != null) { paymentMethodToSelect.Selected = true; } } return(model); }
public async Task <IActionResult> GetPaymentMethods() { const string loggerHeader = "GetPaymentMethods -"; _logService.Info($"{loggerHeader} Start"); var result = new ApiJsonResult(); try { var userLogin = await _userService.GetCurrentUserLogin(HttpContext); _logService.Info($"{loggerHeader} with tenantId {userLogin?.TenantId}"); result.Data = await _paymentMethodService.GetAll(userLogin?.TenantId); } catch (Exception ex) { _logService.Error($"{loggerHeader} Throw error {ex.Message}"); result.Code = CodeModel.Fail; result.Message = ex.Message; } return(Ok(result)); }
public void InstallOrUpdate() { _persistenceInstaller.InstallOrUpdate(); Database database = _databaseFactory.Get(); int currentVersion = database.ExecuteScalar <int>("SELECT SpecialActionsVersion FROM TeaCommerce_Version"); int newVersion = 5; while (currentVersion < newVersion) { try { #region 2.1.0 if (currentVersion + 1 == 1) { #region Auto set current cart and order number for all stores foreach (Store store in _storeService.GetAll()) { store.CurrentCartNumber = database.ExecuteScalar <long>("SELECT COUNT(Id) FROM TeaCommerce_Order WHERE StoreId=@0", store.Id); store.CurrentOrderNumber = database.ExecuteScalar <long>("SELECT COUNT(Id) FROM TeaCommerce_Order WHERE StoreId=@0 AND DateFinalized IS NOT NULL", store.Id); store.Save(); } #endregion } #endregion #region 2.1.1 if (currentVersion + 1 == 2) { #region Correct wrong order properties for sage pay orders foreach (Store store in _storeService.GetAll()) { List <long> sagePayPaymentMethodIds = _paymentMethodService.GetAll(store.Id).Where(p => p.PaymentProviderAlias == "SagePay").Select(p => p.Id).ToList(); if (sagePayPaymentMethodIds.Any()) { IEnumerable <Order> orders = _orderService.Get(store.Id, database.Fetch <Guid>("SELECT Id FROM TeaCommerce_Order WHERE StoreId=@0 AND PaymentMethodId IN (" + string.Join(",", sagePayPaymentMethodIds) + ")", store.Id)); foreach (Order order in orders) { CustomProperty vendorTxCode = order.Properties.Get("VendorTxCode"); CustomProperty txAuthNo = order.Properties.Get("TxAuthNo"); if (vendorTxCode == null && txAuthNo == null) { continue; } if (vendorTxCode != null) { vendorTxCode.Alias = "vendorTxCode"; } if (txAuthNo != null) { txAuthNo.Alias = "txAuthNo"; } order.Save(); } } } #endregion } #endregion #region 2.2 if (currentVersion + 1 == 3) { //Had to remove the deletion of TeaCommerce.PaymentProviders.dll and TeaCommerce.PaymentProviders.XmlSerializers.dll } #endregion #region 2.3.2 if (currentVersion + 1 == 3) { #region Remove order xml cache because properties was wrongly serialized string teaCommerceAppDataPath = HostingEnvironment.MapPath("~/App_Data/tea-commerce"); if (teaCommerceAppDataPath != null) { DirectoryInfo teaCommerceAppDataFolder = new DirectoryInfo(teaCommerceAppDataPath); if (teaCommerceAppDataFolder.Exists) { foreach (FileInfo orderXmlCache in teaCommerceAppDataFolder.GetFiles("finalized-orders-xml-cache*")) { orderXmlCache.Delete(); } } } #endregion } #endregion #region 3.0.0 if (currentVersion + 1 == 4) { #region Remove old javascript API file string javaScriptApiFile = HostingEnvironment.MapPath("~/scripts/tea-commerce.min.js"); if (javaScriptApiFile != null && File.Exists(javaScriptApiFile)) { File.Delete(javaScriptApiFile); } #endregion #region Remove old Tea Commerce folder in Umbraco plugins string oldTeaCommercePluginPath = HostingEnvironment.MapPath("~/umbraco/plugins/tea-commerce"); if (oldTeaCommercePluginPath != null && Directory.Exists(oldTeaCommercePluginPath)) { Directory.Delete(oldTeaCommercePluginPath, true); } oldTeaCommercePluginPath = HostingEnvironment.MapPath("~/App_Plugins/tea-commerce"); if (oldTeaCommercePluginPath != null && Directory.Exists(oldTeaCommercePluginPath)) { Directory.Delete(oldTeaCommercePluginPath, true); } #endregion #region Create default gift card settings foreach (Store store in _storeService.GetAll()) { store.GiftCardSettings.Length = 10; store.GiftCardSettings.DaysValid = 1095; store.Save(); } #endregion } #endregion currentVersion++; database.Execute("UPDATE TeaCommerce_Version SET SpecialActionsVersion=@0", currentVersion); } catch (Exception exp) { LoggingService.Instance.Log(exp); break; } } }
public async Task <IActionResult> GetAll() { var payment = await _paymentService.GetAll(); return(Ok(payment)); }
private IEnumerable <PaymentMethodViewModel> PreparePaymentMethod() { var paymentMethods = _paymentMethodService.GetAll(); return(paymentMethods.Select(x => x.ToModel())); }
public IEnumerable <PaymentMethod> Get() { return(service.GetAll().OrderBy(c => c.Name)); }
public ActionResult AddressAndPayment() { ViewBag.PaymentMethods = Mapper.Map <IEnumerable <PaymentMethodViewModel> >(_paymentMethodService.GetAll()); return(View()); }
// GET: Admin/PaymentMethod public ActionResult Index() { return(View(AutoMapper.Mapper.Map <List <PaymentMethodViewModel> >(_paymentMethodService.GetAll().ToList()))); }
public void InstallOrUpdate() { _persistenceInstaller.InstallOrUpdate(); Database database = _databaseFactory.Get(); int currentVersion = database.ExecuteScalar <int>("SELECT SpecialActionsVersion FROM TeaCommerce_Version"); int stepTargetVersion = 0; int targetVersion = 5; // Loop from the current version to the target version // one step at a time, performing any upgrade steps. // At each step we also update the SpecialActionsVersion // in the TeaCommerce_Version database table. // If any step fails, we log the failure, but carry on // to the next step. while (currentVersion < targetVersion) { try { stepTargetVersion = currentVersion + 1; #region Initial install if (currentVersion == 0) { foreach (IInstallTask installTask in _installTasks) { installTask.Install(); } } #endregion #region 2.1.0 if (stepTargetVersion == 1) { #region Auto set current cart and order number for all stores foreach (Store store in _storeService.GetAll()) { store.CurrentCartNumber = database.ExecuteScalar <long>("SELECT COUNT(Id) FROM TeaCommerce_Order WHERE StoreId=@0", store.Id); store.CurrentOrderNumber = database.ExecuteScalar <long>("SELECT COUNT(Id) FROM TeaCommerce_Order WHERE StoreId=@0 AND DateFinalized IS NOT NULL", store.Id); store.Save(); } #endregion } #endregion #region 2.1.1 if (stepTargetVersion == 2) { #region Correct wrong order properties for sage pay orders foreach (Store store in _storeService.GetAll()) { List <long> sagePayPaymentMethodIds = _paymentMethodService.GetAll(store.Id).Where(p => p.PaymentProviderAlias == "SagePay").Select(p => p.Id).ToList(); if (sagePayPaymentMethodIds.Any()) { IEnumerable <Order> orders = _orderService.Get(store.Id, database.Fetch <Guid>("SELECT Id FROM TeaCommerce_Order WHERE StoreId=@0 AND PaymentMethodId IN (" + string.Join(",", sagePayPaymentMethodIds) + ")", store.Id)); foreach (Order order in orders) { CustomProperty vendorTxCode = order.Properties.Get("VendorTxCode"); CustomProperty txAuthNo = order.Properties.Get("TxAuthNo"); if (vendorTxCode == null && txAuthNo == null) { continue; } if (vendorTxCode != null) { vendorTxCode.Alias = "vendorTxCode"; } if (txAuthNo != null) { txAuthNo.Alias = "txAuthNo"; } order.Save(); } } } #endregion } #endregion #region 2.2 if (stepTargetVersion == 3) { //Had to remove the deletion of TeaCommerce.PaymentProviders.dll and TeaCommerce.PaymentProviders.XmlSerializers.dll } #endregion #region 2.3.2 if (stepTargetVersion == 3) { #region Remove order xml cache because properties was wrongly serialized string teaCommerceAppDataPath = HostingEnvironment.MapPath("~/App_Data/tea-commerce"); if (teaCommerceAppDataPath != null) { DirectoryInfo teaCommerceAppDataFolder = new DirectoryInfo(teaCommerceAppDataPath); if (teaCommerceAppDataFolder.Exists) { foreach (FileInfo orderXmlCache in teaCommerceAppDataFolder.GetFiles("finalized-orders-xml-cache*")) { orderXmlCache.Delete(); } } } #endregion } #endregion #region 3.0.0 if (stepTargetVersion == 4) { #region Remove old javascript API file string javaScriptApiFile = HostingEnvironment.MapPath("~/scripts/tea-commerce.min.js"); if (javaScriptApiFile != null && File.Exists(javaScriptApiFile)) { File.Delete(javaScriptApiFile); } #endregion #region Remove old Tea Commerce folder in Umbraco plugins string oldTeaCommercePluginPath = HostingEnvironment.MapPath("~/umbraco/plugins/tea-commerce"); if (oldTeaCommercePluginPath != null && Directory.Exists(oldTeaCommercePluginPath)) { Directory.Delete(oldTeaCommercePluginPath, true); } oldTeaCommercePluginPath = HostingEnvironment.MapPath("~/App_Plugins/tea-commerce"); if (oldTeaCommercePluginPath != null && Directory.Exists(oldTeaCommercePluginPath)) { Directory.Delete(oldTeaCommercePluginPath, true); } #endregion #region Create default gift card settings foreach (Store store in _storeService.GetAll()) { store.GiftCardSettings.Length = 10; store.GiftCardSettings.DaysValid = 1095; store.Save(); } #endregion } #endregion #region 3.3.0 // We were going to attempt to delete payment provider 3rd party DLL's // but on second thoughs, we decided to leave them and add nodes in the // changelog as it's not detramental if they remain, but could cause // problems if the app pool recycles mid delete // //if ( stepTargetVersion == 6 ) //{ // #region Remove old payment provider dependencies // // The latest payment provider build merges 3rd party dependencies // // into the core payment providers DLL in order to prevent conflicts // var oldPaymentProvider3rdPartyDlls = new string [] { // "Klarna.Checkout.dll", // "Paynova.Api.Client.dll", // "Stripe.net.dll" // }; // foreach (var dll in oldPaymentProvider3rdPartyDlls) // { // var dllPath = HostingEnvironment.MapPath("~/bin/" + dll); // if (dllPath != null && File.Exists(dllPath)) // { // File.Delete(dllPath); // } // } // #endregion //} #endregion database.Execute("UPDATE TeaCommerce_Version SET SpecialActionsVersion=@0", stepTargetVersion); } catch (Exception exp) { LoggingService.Instance.Error <Installer>($"Tea Commerce upgrade step {stepTargetVersion} failed", exp); break; } finally { // Update current version whether a step succeeds or fails currentVersion = stepTargetVersion; } } //Language files new LanguageFileInstallTask("TeaCommerce.Umbraco.Install.Content.Resources.da.xml", "~/umbraco/config/lang/da.xml").Install(); new LanguageFileInstallTask("TeaCommerce.Umbraco.Install.Content.Resources.en.xml", "~/umbraco/config/lang/en.xml").Install(); new LanguageFileInstallTask("TeaCommerce.Umbraco.Install.Content.Resources.en_us.xml", "~/umbraco/config/lang/en_us.xml").Install(); new LanguageFileInstallTask("TeaCommerce.Umbraco.Install.Content.Resources.se.xml", "~/umbraco/config/lang/se.xml").Install(); new UIFileInstallTask("TeaCommerce.Umbraco.Install.Content.XML.UI.xml", "~/umbraco/config/create/UI.xml").Install(); //Fix package file new RemoveOldPackageInstallTask().Install(); }