protected virtual void AddPaymentMethods(Result <BillingModel> result, Cart cart) { var paymentOption = new PaymentOption { PaymentOptionType = PaymentOptionType.PayCard }; var paymentMethods = this.PaymentManager.GetPaymentMethods(cart, paymentOption); if (paymentMethods.ServiceProviderResult.Success && (paymentMethods.Result != null)) { result.Data.PaymentMethods = new List <PaymentMethodModel>(); foreach (var paymentMethod in paymentMethods.Result) { var model = new PaymentMethodModel(); model.Description = paymentMethod.Description; model.ExternalId = paymentMethod.PaymentOptionId; result.Data.PaymentMethods.Add(model); } } else { result.SetErrors(paymentMethods.ServiceProviderResult); } }
public int InsertPaymentMethod(PaymentMethodModel PaymentMethodModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("PaymentMethod", "PaymentMethodName", PaymentMethodModel.PaymentMethodName, PaymentMethodModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("PaymentMethod"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO PaymentMethod (Id,PaymentMethodName,IsBank,IsIntegration,IsActive)" + "VALUES (" + MaxId + ",@PaymentMethodName, @IsBank,@IsIntegration,@IsActive); SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, PaymentMethodModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("PaymentMethod"); } else { sqltrans.Rollback(); } } return(result); }
public ActionResult PaymentMethod(PaymentMethodModel paymentMethodModel, string submitButton) { if (!ModelState.IsValid) { string errorString = this.ValidationPaymentMethod(paymentMethodModel); if (!string.IsNullOrEmpty(errorString)) { ViewBag.Validate = errorString; return(View(paymentMethodModel)); } } if (paymentMethodModel.Id > 0) { var result = _iPaymentMethodService.UpdatePaymentMethod(paymentMethodModel); if (result == -1) { ModelState.AddModelError("PaymentMethodName", "Payment method name already exists"); return(View(paymentMethodModel)); } ViewBag.Result = _locService.GetLocalizedHtmlString("EditSuccss"); } else { var result = _iPaymentMethodService.InsertPaymentMethod(paymentMethodModel); if (result == -1) { ModelState.AddModelError("PaymentMethodName", "Payment method name already exists"); return(View(paymentMethodModel)); } ViewBag.Result = _locService.GetLocalizedHtmlString("SaveSuccess"); } return(RedirectToAction("Index", "PaymentMethod")); }
public int UpdatePaymentMethod(PaymentMethodModel PaymentMethodModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("PaymentMethod", "PaymentMethodName", PaymentMethodModel.PaymentMethodName, PaymentMethodModel.Id.ToString()); if (result > 0) { return(-1); } con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "UPDATE PaymentMethod SET PaymentMethodName =@PaymentMethodName, IsBank=@IsBank,IsIntegration=@IsIntegration," + "IsActive = @IsActive " + "WHERE Id = @Id;"; result = con.Execute(query, PaymentMethodModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("PaymentMethod"); } else { sqltrans.Rollback(); } } return(result); }
public async Task <IActionResult> PutPaymentMethod(int id, PaymentMethodModel paymentMethodModel) { if (id != paymentMethodModel.Id) { return(BadRequest()); } var paymentMethod = await _context.PaymentMethods.FindAsync(id); _mapper.Map(paymentMethodModel, paymentMethod); //Note the way that we use to map here. //_context.Entry(paymentMethod).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentMethodExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult MethodUpdate(PaymentMethodModel model, GridCommand command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePaymentMethods)) { return(AccessDeniedView()); } var pm = _paymentService.LoadPaymentMethodBySystemName(model.SystemName); if (pm.IsPaymentMethodActive(_paymentSettings)) { if (!model.IsActive) { //mark as disabled _paymentSettings.ActivePaymentMethodSystemNames.Remove(pm.PluginDescriptor.SystemName); _settingService.SaveSetting(_paymentSettings); } } else { if (model.IsActive) { //mark as active _paymentSettings.ActivePaymentMethodSystemNames.Add(pm.PluginDescriptor.SystemName); _settingService.SaveSetting(_paymentSettings); } } var pluginDescriptor = pm.PluginDescriptor; //display order pluginDescriptor.DisplayOrder = model.DisplayOrder; PluginFileParser.SavePluginDescriptionFile(pluginDescriptor); return(Methods(command)); }
public async Task <IActionResult> MethodUpdate(PaymentMethodModel model) { var _paymentSettings = _settingService.LoadSetting <PaymentSettings>(); var pm = _paymentService.LoadPaymentMethodBySystemName(model.SystemName); if (pm.IsPaymentMethodActive(_paymentSettings)) { if (!model.IsActive) { //mark as disabled _paymentSettings.ActivePaymentProviderSystemNames.Remove(pm.SystemName); await _settingService.SaveSetting(_paymentSettings); } } else { if (model.IsActive) { //mark as active _paymentSettings.ActivePaymentProviderSystemNames.Add(pm.SystemName); await _settingService.SaveSetting(_paymentSettings); } } return(new JsonResult("")); }
public IActionResult PaymentMethods() { IWorkContext _workContext = EngineContext.Current.Resolve <IWorkContext>(); var customer = _workContext.CurrentCustomer; var model = new CustomerPaymentProfilesModel(); DBManager dbmanager = new DBManager(); Dictionary <string, string> paramDic = new Dictionary <string, string>(); paramDic.Add("@CustomerID", customer.Id.ToString()); string select = "SELECT * FROM Profiles WHERE CustomerID = " + customer.Id + ""; DataView dView = dbmanager.GetParameterizedDataView(select, paramDic); //dbmanager.GetDataView(select); if (dView != null && dView.Count > 0) { foreach (DataRow dRow in dView.Table.Rows) { PaymentMethodModel getProfile = new PaymentMethodModel(); getProfile.profileID = (int)dRow["ProfileID"]; getProfile.NickName = dRow["NickName"].ToString(); getProfile.Last4Digits = dRow["Last4Digits"].ToString(); getProfile.CardType = dRow["CardType"].ToString(); getProfile.ExpMonth = (int)dRow["ExpMonth"]; getProfile.ExpYear = (int)dRow["ExpYear"]; model.SavedProfiles.Add(getProfile); } } return(View(model)); }
public async Task <bool> ValidatePrices(FullOrderModel order, DeliveryMethodsProvider deliveryMethodsProvider, PaymentMethodsProvider paymentMethodsProvider) { decimal priceAccuracy = 0.1m; Task <DeliveryMethodModel> getDeliveryMethodTask = deliveryMethodsProvider.GetDeliveryMethodById(order.DeliveryMethodId.Value); Task <PaymentMethodModel> getPaymentMethodTask = paymentMethodsProvider.GetPaymentMethodById(order.PaymentMethodId.Value); decimal itemsPrice = order.Items.Sum(i => i.Quantity.Value * i.Price.Value); if (Math.Abs(itemsPrice - order.Total.Order.Value) > priceAccuracy) { return(false); } DeliveryMethodModel deliveryMethod = await getDeliveryMethodTask; PaymentMethodModel paymentMethod = await getPaymentMethodTask; decimal shippingPrice = deliveryMethod.DeliveryPrice; if (paymentMethod.ApplyDeliveryTax) { shippingPrice += ((decimal)deliveryMethod.CODTax * order.Total.Order.Value) / 100m; } if (Math.Abs(shippingPrice - order.Total.Shipping.Value) > priceAccuracy) { return(false); } decimal orderNonDiscountedPrice = order.Items.Where(i => !i.HasDiscount.Value).Sum(i => i.Quantity.Value * i.Price.Value); decimal couponesDiscount = 0m; if (order.Coupones != null) { foreach (CouponeModel coupone in order.Coupones) { if (coupone.ValueType.Value == CouponeValueType.Percent) { couponesDiscount += (orderNonDiscountedPrice * coupone.Value.Value) / 100; } else if (coupone.ValueType.Value == CouponeValueType.Absolute) { couponesDiscount += coupone.Value.Value; } } } if (Math.Abs(couponesDiscount - order.Total.CouponesDiscount.Value) > priceAccuracy) { return(false); } decimal totalPrice = shippingPrice + itemsPrice - couponesDiscount; if (Math.Abs(totalPrice - order.Total.Full.Value) > priceAccuracy) { return(false); } return(true); }
public async Task <IActionResult> MethodUpdate(PaymentMethodModel model) { var pm = _paymentService.LoadPaymentMethodBySystemName(model.SystemName); if (pm.IsPaymentMethodActive(_paymentSettings)) { if (!model.IsActive) { //mark as disabled _paymentSettings.ActivePaymentMethodSystemNames.Remove(pm.PluginDescriptor.SystemName); await _settingService.SaveSetting(_paymentSettings); } } else { if (model.IsActive) { //mark as active _paymentSettings.ActivePaymentMethodSystemNames.Add(pm.PluginDescriptor.SystemName); await _settingService.SaveSetting(_paymentSettings); } } var pluginDescriptor = pm.PluginDescriptor; pluginDescriptor.FriendlyName = model.FriendlyName; pluginDescriptor.DisplayOrder = model.DisplayOrder; PluginFileParser.SavePluginDescriptionFile(pluginDescriptor); //reset plugin cache _pluginFinder.ReloadPlugins(); return(new NullJsonResult()); }
public ActionResult MethodUpdate(PaymentMethodModel model, GridCommand command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePaymentMethods)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(RedirectToAction("Methods")); } var pm = _paymentService.LoadPaymentMethodBySystemName(model.SystemName); if (pm.IsPaymentMethodActive(_paymentSettings)) { if (!model.IsActive) { //mark as disabled _paymentSettings.ActivePaymentMethodSystemNames.Remove(pm.PluginDescriptor.SystemName); _settingService.SaveSetting(_paymentSettings); } } else { if (model.IsActive) { //mark as active _paymentSettings.ActivePaymentMethodSystemNames.Add(pm.PluginDescriptor.SystemName); _settingService.SaveSetting(_paymentSettings); } } return(Methods(command)); }
public ActionResult Index() { PaymentMethodModel model = new PaymentMethodModel(); model.paymentMethodList = PaymentMethodModel.List(); return(View("Index", model)); }
public IViewComponentResult Invoke() { var model = new CustomerPaymentProfilesModel(); IWorkContext _workContext = EngineContext.Current.Resolve <IWorkContext>(); model.customerID = _workContext.CurrentCustomer.Id; DBManager dbmanager = new DBManager(); Dictionary <string, string> paramDic = new Dictionary <string, string>(); paramDic.Add("@CustomerID", model.customerID.ToString()); string select = "SELECT * FROM Profiles WHERE CustomerID = " + model.customerID + ""; DataView dView = dbmanager.GetParameterizedDataView(select, paramDic); //dbmanager.GetDataView(select); if (dView != null) { if (dView.Count > 0) { foreach (DataRow dRow in dView.Table.Rows) { PaymentMethodModel getProfile = new PaymentMethodModel(); getProfile.profileID = (int)dRow["ProfileID"]; getProfile.NickName = dRow["NickName"].ToString(); getProfile.Last4Digits = dRow["Last4Digits"].ToString(); getProfile.CardType = dRow["CardType"].ToString(); getProfile.ExpMonth = (int)dRow["ExpMonth"]; getProfile.ExpYear = (int)dRow["ExpYear"]; model.SavedProfiles.Add(getProfile); } } } return(View("~/Plugins/Payments.GBS/Views/PaymentGBS/SaveCreditCard.cshtml", model)); }
public override ActionResult MethodUpdate([Bind(Exclude = "ConfigurationRouteValues")] PaymentMethodModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePaymentMethods)) { return(AccessDeniedView()); } var pm = _paymentService.LoadPaymentMethodBySystemName(model.SystemName); if (pm.IsPaymentMethodActive(_paymentSettings)) { if (!model.IsActive) { //mark as disabled _paymentSettings.ActivePaymentMethodSystemNames.Remove(pm.PluginDescriptor.SystemName); _settingService.SaveSetting(_paymentSettings); //accordingly update widgets of Square plugin if (model.SystemName.Equals(SquarePaymentDefaults.SystemName)) { if (_widgetSettings.ActiveWidgetSystemNames.Contains(SquarePaymentDefaults.SystemName)) { _widgetSettings.ActiveWidgetSystemNames.Remove(SquarePaymentDefaults.SystemName); } _settingService.SaveSetting(_widgetSettings); } } } else { if (model.IsActive) { //mark as active _paymentSettings.ActivePaymentMethodSystemNames.Add(pm.PluginDescriptor.SystemName); _settingService.SaveSetting(_paymentSettings); //accordingly update widgets of Square plugin if (model.SystemName.Equals(SquarePaymentDefaults.SystemName)) { if (!_widgetSettings.ActiveWidgetSystemNames.Contains(SquarePaymentDefaults.SystemName)) { _widgetSettings.ActiveWidgetSystemNames.Add(SquarePaymentDefaults.SystemName); } _settingService.SaveSetting(_widgetSettings); } } } var pluginDescriptor = pm.PluginDescriptor; pluginDescriptor.FriendlyName = model.FriendlyName; pluginDescriptor.DisplayOrder = model.DisplayOrder; PluginFileParser.SavePluginDescriptionFile(pluginDescriptor); //reset plugin cache _pluginFinder.ReloadPlugins(); return(new NullJsonResult()); }
public ActionResult DeleteConfirmed(int id) { PaymentMethodModel paymentmethodmodel = db.PaymentMethodModel.Find(id); db.PaymentMethodModel.Remove(paymentmethodmodel); db.SaveChanges(); return(RedirectToAction("Index")); }
public int Insert(PaymentMethodModel model) { string sqlInsert = "INSERT INTO PaymentMethod (Id, Name) Values (@Id, @Name)"; using (_connection) { return(_connection.Execute(sqlInsert, model)); } }
public ActionResult Index(string msg) { BuyingSessionModel model = BuyingSessionModel.GetBuyingSession(); model.disponibleProductsList = ProductModel.List(); ViewBag.PaymentMethodModel = new SelectList(PaymentMethodModel.List(), "paymentMethodId", "paymentMethodDescription"); ViewBag.Script = msg; return(View("Index", model)); }
public int Update(PaymentMethodModel model) { string sqlUpdate = "UPDATE PaymentMethod SET Name = @Name WHERE Id = @Id"; using (_connection) { return(_connection.Execute(sqlUpdate, model)); } }
public async Task <ActionResult <PaymentMethod> > PostPaymentMethod(PaymentMethodModel paymentMethodModel) { var paymentMethod = _mapper.Map <PaymentMethod>(paymentMethodModel); _context.PaymentMethods.Add(paymentMethod); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPaymentMethod", new { id = paymentMethod.Id }, paymentMethodModel)); }
public int Delete(PaymentMethodModel model) { string sqlDelete = "DELETE FROM PaymentMethod WHERE Id = @Id"; using (_connection) { return(_connection.Execute(sqlDelete, model)); } }
public static PaymentMethodModel PaymentMethodToPaymentMethodModelMapper(this PaymentMethod paymentmethod) { PaymentMethodModel paymentmethodmodel = new PaymentMethodModel() { PaymentMethodID = paymentmethod.PaymentMethodID, Description = paymentmethod.Description }; return(paymentmethodmodel); }
public static PaymentMethod PaymentMethodModelToPaymentMethodMapper(this PaymentMethodModel paymentmethodmodel) { PaymentMethod paymentmethod = new PaymentMethod() { PaymentMethodID = paymentmethodmodel.PaymentMethodID, Description = paymentmethodmodel.Description }; return(paymentmethod); }
public ActionResult Delete(int id = 0) { PaymentMethodModel paymentmethodmodel = db.PaymentMethodModel.Find(id); if (paymentmethodmodel == null) { return(HttpNotFound()); } return(View(paymentmethodmodel)); }
public ActionResult Edit(PaymentMethodModel paymentmethodmodel) { if (ModelState.IsValid) { db.Entry(paymentmethodmodel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(paymentmethodmodel)); }
public void UpdatePaymentMethod(PaymentMethodModel paymentMethodModel) { Models.DBObjects.PaymentMethod existingPaymentMethod = dbContext.PaymentMethods.FirstOrDefault(x => x.PaymentMethodID == paymentMethodModel.PaymentMethodID); if (existingPaymentMethod != null) { existingPaymentMethod.PaymentMethodID = paymentMethodModel.PaymentMethodID; existingPaymentMethod.Name = paymentMethodModel.Name; existingPaymentMethod.Description = paymentMethodModel.Description; dbContext.SubmitChanges(); } }
public HttpResponseMessage AddAPaymentMethod(PaymentMethodModel paymentMethodModel) { //TODO: Validate payment method. _settingsValueService.Create(new SettingsValue { UserId = RequestContext.Principal.Identity.GetUserId(), ValueTypeId = 5, //Using Magic numbers like a scrub. Really should have done this with an enumerable. Or maybe as a config value? Not really sure. Value = paymentMethodModel.NotACCNumber.ToString() }); return(Request.CreateResponse(HttpStatusCode.Created)); }
public ActionResult Save(PaymentMethodModel paymentMethodObj) { if (PaymentMethodModel.Save(paymentMethodObj)) { return(Index()); } else { return(Edit(paymentMethodObj.paymentMethodId)); } }
public ActionResult Create(PaymentMethodModel paymentmethodmodel) { if (ModelState.IsValid) { db.PaymentMethodModel.Add(paymentmethodmodel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(paymentmethodmodel)); }
public static PostProcessPaymentResponse PostProcessPayment(this PaymentMethodModel paymentMethod, PostProcessPaymentRequest postProcessPaymentRequest) { var resp = new PostProcessPaymentResponse(); IPaymentMethod paymentProcess = null; paymentProcess = GetPaymentProcessor(paymentMethod.SystemName); if (paymentProcess != null) { paymentProcess.Settings = paymentMethod; resp = paymentProcess.PostProcessPayment(postProcessPaymentRequest); } return(resp); }
private Models.DBObjects.PaymentMethod MapModelToDbObject(PaymentMethodModel paymentMethodModel) { Models.DBObjects.PaymentMethod dbpaymentMethodModel = new Models.DBObjects.PaymentMethod(); if (paymentMethodModel != null) { dbpaymentMethodModel.PaymentMethodID = paymentMethodModel.PaymentMethodID; dbpaymentMethodModel.Name = paymentMethodModel.Name; dbpaymentMethodModel.Description = paymentMethodModel.Description; return(dbpaymentMethodModel); } return(null); }
public PaymentMethodModel Put(string id, PaymentMethodModel model) { var retorno = PutAsync<PaymentMethodModel>(id, model).Result; return retorno; }