public void SaveInfo() { if (Page.IsValid) { try { PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods(null, false); foreach (GridViewRow row in gvPaymentMethodCountryMap.Rows) { foreach (PaymentMethod paymentMethod in paymentMethodCollection) { CheckBox cbRestrict = row.FindControl(String.Format("cbRestrict_{0}", paymentMethod.PaymentMethodId)) as CheckBox; HiddenField hfCountryId = row.FindControl(String.Format("hfCountryId_{0}", paymentMethod.PaymentMethodId)) as HiddenField; int countryId = Int32.Parse(hfCountryId.Value); if (cbRestrict.Checked) { PaymentMethodManager.CreatePaymentMethodCountryMapping(paymentMethod.PaymentMethodId, countryId); } else { PaymentMethodManager.DeletePaymentMethodCountryMapping(paymentMethod.PaymentMethodId, countryId); } } } Response.Redirect("PaymentMethods.aspx"); } catch (Exception exc) { ProcessException(exc); } } }
private void CreateChildControlsTree() { PaymentMethod paymentMethod = null; if (NopContext.Current.User != null) { PaymentMethodCollection paymentMethods = PaymentMethodManager.GetAllPaymentMethods(); if (paymentMethods.Count == 1) { paymentMethod = paymentMethods[0]; } else { paymentMethod = NopContext.Current.User.LastPaymentMethod; } } if (paymentMethod != null) { Control child = null; child = base.LoadControl(paymentMethod.UserTemplatePath); this.PaymentInfoPlaceHolder.Controls.Add(child); } else { Response.Redirect("~/CheckoutPaymentMethod.aspx"); } }
public PaymentMethodCollection GetAllPaymentMethodsDynamicCollection(string whereExpression, string orderBy) { IDBManager dbm = new DBManager(); PaymentMethodCollection cols = new PaymentMethodCollection(); try { dbm.CreateParameters(2); dbm.AddParameters(0, "@WhereCondition", whereExpression); dbm.AddParameters(1, "@OrderByExpression", orderBy); IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectPaymentMethodsDynamic"); while (reader.Read()) { PaymentMethod paymentMethod = new PaymentMethod(); paymentMethod.PaymentMethodID = Int32.Parse(reader["PaymentMethodID"].ToString()); paymentMethod.Name = reader["Name"].ToString(); cols.Add(paymentMethod); } } catch (Exception ex) { log.Write(ex.Message, "GetAllPaymentMethodsDynamicCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
protected void BindGrid() { CountryCollection countryCollection = CountryManager.GetAllCountries(); PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods(null, false); if (countryCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoCountryDefined"); } if (paymentMethodCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoPaymentMethodDefined"); } List <PaymentMethodCountryMappingHelperClass> dt = new List <PaymentMethodCountryMappingHelperClass>(); foreach (Country country in countryCollection) { PaymentMethodCountryMappingHelperClass map1 = new PaymentMethodCountryMappingHelperClass(); map1.CountryId = country.CountryId; map1.CountryName = country.Name; map1.Restrict = new Dictionary <int, bool>(); foreach (PaymentMethod paymentMethod in paymentMethodCollection) { map1.Restrict.Add(paymentMethod.PaymentMethodId, PaymentMethodManager.DoesPaymentMethodCountryMappingExist(paymentMethod.PaymentMethodId, country.CountryId)); } dt.Add(map1); } gvPaymentMethodCountryMap.DataSource = dt; gvPaymentMethodCountryMap.DataBind(); }
void BindGrid() { PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods(); gvPaymentMethods.DataSource = paymentMethodCollection; gvPaymentMethods.DataBind(); }
public PaymentMethodCollection GetAllPaymentMethodsCollection() { IDBManager dbm = new DBManager(); PaymentMethodCollection cols = new PaymentMethodCollection(); try { IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectPaymentMethodsAll"); while (reader.Read()) { PaymentMethod paymenyMethod = new PaymentMethod(); paymenyMethod.PaymentMethodID = Int32.Parse(reader["PaymentMethodID"].ToString()); paymenyMethod.Name = reader["Name"].ToString(); cols.Add(paymenyMethod); } } catch (Exception ex) { log.Write(ex.Message, "GetAllPaymentMethodsCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
private static PaymentMethodCollection DBMapping(DBPaymentMethodCollection dbCollection) { if (dbCollection == null) return null; PaymentMethodCollection collection = new PaymentMethodCollection(); foreach (DBPaymentMethod dbItem in dbCollection) { PaymentMethod item = DBMapping(dbItem); collection.Add(item); } return collection; }
private static PaymentMethodCollection DBMapping(DBPaymentMethodCollection dbCollection) { if (dbCollection == null) { return(null); } var collection = new PaymentMethodCollection(); foreach (var dbItem in dbCollection) { var item = DBMapping(dbItem); collection.Add(item); } return(collection); }
public static int GetGCPaymentMethodId(GoogleCheckout gatewayInstance) { PaymentMethodCollection gcPayMethods = PaymentMethodDataSource.LoadForPaymentGateway(gatewayInstance.PaymentGatewayId); if (gcPayMethods == null || gcPayMethods.Count == 0) { PaymentMethod gcPayMethod = new PaymentMethod(); gcPayMethod.Name = "GoogleCheckout"; gcPayMethod.PaymentGatewayId = gatewayInstance.PaymentGatewayId; gcPayMethod.PaymentInstrument = PaymentInstrument.GoogleCheckout; gcPayMethod.Save(); return(gcPayMethod.PaymentMethodId); } else { return(gcPayMethods[0].PaymentMethodId); } }
protected void BuildColumnsDynamically() { gvPaymentMethodCountryMap.Columns.Clear(); TemplateField tfAction = new TemplateField(); tfAction.ItemTemplate = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "CountryName", "String"); tfAction.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, GetLocaleResourceString("Admin.PaymentMethodsFilterControl.Grid.CountryName"), "String"); gvPaymentMethodCountryMap.Columns.Add(tfAction); PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods(null, false); foreach (PaymentMethod paymentMethod in paymentMethodCollection) { TemplateField tf = new TemplateField(); tf.ItemTemplate = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "Restrict", "Checkbox", paymentMethod.PaymentMethodId); tf.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, paymentMethod.Name, "String"); gvPaymentMethodCountryMap.Columns.Add(tf); } }
/// <summary> /// Gets all payment methods /// </summary> /// <returns>Payment method collection</returns> public static PaymentMethodCollection GetAllPaymentMethods() { bool showHidden = NopContext.Current.IsAdmin; string key = string.Format(PAYMENTMETHODS_ALL_KEY, showHidden); object obj2 = NopCache.Get(key); if (PaymentMethodManager.CacheEnabled && (obj2 != null)) { return((PaymentMethodCollection)obj2); } DBPaymentMethodCollection dbCollection = DBProviderManager <DBPaymentMethodProvider> .Provider.GetAllPaymentMethods(showHidden); PaymentMethodCollection paymentMethodCollection = DBMapping(dbCollection); if (PaymentMethodManager.CacheEnabled) { NopCache.Max(key, paymentMethodCollection); } return(paymentMethodCollection); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } if (!Page.IsPostBack) { PaymentMethodCollection paymentMethods = PaymentMethodManager.GetAllPaymentMethods(); PaymentMethod paypalExpressPaymentMethod = null; foreach (PaymentMethod pm in paymentMethods) { if (pm.SystemKeyword == "PayPalExpress") { paypalExpressPaymentMethod = pm; } } PaymentMethod googleCheckoutPaymentMethod = null; foreach (PaymentMethod pm in paymentMethods) { if (pm.SystemKeyword == "GoogleCheckout") { googleCheckoutPaymentMethod = pm; } } bool hasButtonMethods = false; if (paypalExpressPaymentMethod != null && paypalExpressPaymentMethod.IsActive) { hasButtonMethods = true; } PaymentMethodCollection boundPaymentMethods = new PaymentMethodCollection(); foreach (PaymentMethod pm in paymentMethods) { if (pm != paypalExpressPaymentMethod && pm != googleCheckoutPaymentMethod) { boundPaymentMethods.Add(pm); } } if (boundPaymentMethods.Count == 0) { if (hasButtonMethods) { phSelectPaymentMethod.Visible = false; phNoPaymentMethods.Visible = false; } else { phSelectPaymentMethod.Visible = false; phNoPaymentMethods.Visible = true; } } else if (boundPaymentMethods.Count == 1) { if (hasButtonMethods) { phSelectPaymentMethod.Visible = true; phNoPaymentMethods.Visible = false; dlPaymentMethod.DataSource = boundPaymentMethods; dlPaymentMethod.DataBind(); } else { phSelectPaymentMethod.Visible = false; phNoPaymentMethods.Visible = false; NopContext.Current.User = CustomerManager.SetLastPaymentMethodID(NopContext.Current.User.CustomerID, paymentMethods[0].PaymentMethodID); Response.Redirect("~/CheckoutConfirm.aspx"); } } else { phSelectPaymentMethod.Visible = true; phNoPaymentMethods.Visible = false; dlPaymentMethod.DataSource = boundPaymentMethods; dlPaymentMethod.DataBind(); } } divAdditionalPaymentInfo.Visible = Request["OrderId"] != null; }
public void BindData() { //reward points if (OrderManager.RewardPointsEnabled && !this.Cart.IsRecurring) { int rewardPointsBalance = NopContext.Current.User.RewardPointsBalance; decimal rewardPointsAmountBase = OrderManager.ConvertRewardPointsToAmount(rewardPointsBalance); decimal rewardPointsAmount = CurrencyManager.ConvertCurrency(rewardPointsAmountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (rewardPointsAmount > decimal.Zero) { string rewardPointsAmountStr = PriceHelper.FormatPrice(rewardPointsAmount, true, false); cbUseRewardPoints.Text = GetLocaleResourceString("Checkout.UseRewardPoints", rewardPointsBalance, rewardPointsAmountStr); pnlRewardPoints.Visible = true; } else { pnlRewardPoints.Visible = false; } } else { pnlRewardPoints.Visible = false; } //payment methods int?filterByCountryId = null; if (NopContext.Current.User.BillingAddress != null && NopContext.Current.User.BillingAddress.Country != null) { filterByCountryId = NopContext.Current.User.BillingAddress.CountryId; } bool hasButtonMethods = false; var boundPaymentMethods = new PaymentMethodCollection(); var paymentMethods = PaymentMethodManager.GetAllPaymentMethods(filterByCountryId); foreach (var pm in paymentMethods) { switch (pm.PaymentMethodType) { case PaymentMethodTypeEnum.Unknown: case PaymentMethodTypeEnum.Standard: { if (!Cart.IsRecurring || PaymentManager.SupportRecurringPayments(pm.PaymentMethodId) != RecurringPaymentTypeEnum.NotSupported) { boundPaymentMethods.Add(pm); } } break; case PaymentMethodTypeEnum.Button: { //PayPal Express is placed here as button if (pm.SystemKeyword == "PayPalExpress") { if (!Cart.IsRecurring || PaymentManager.SupportRecurringPayments(pm.PaymentMethodId) != RecurringPaymentTypeEnum.NotSupported) { hasButtonMethods = true; } } } break; default: break; } } if (boundPaymentMethods.Count == 0) { if (hasButtonMethods) { phSelectPaymentMethod.Visible = false; pnlPaymentMethodsError.Visible = false; //no reward points in this case pnlRewardPoints.Visible = false; } else { phSelectPaymentMethod.Visible = false; pnlPaymentMethodsError.Visible = true; lPaymentMethodsError.Text = GetLocaleResourceString("Checkout.NoPaymentMethods"); //no reward points in this case pnlRewardPoints.Visible = false; } } else if (boundPaymentMethods.Count == 1) { phSelectPaymentMethod.Visible = true; pnlPaymentMethodsError.Visible = false; dlPaymentMethod.DataSource = boundPaymentMethods; dlPaymentMethod.DataBind(); } else { phSelectPaymentMethod.Visible = true; pnlPaymentMethodsError.Visible = false; dlPaymentMethod.DataSource = boundPaymentMethods; dlPaymentMethod.DataBind(); } }