public object Create(object parent, object configContext, XmlNode section) { PaypalConfig cfg = new PaypalConfig(); // Get Test Data bool test = Convert.ToBoolean(section.SelectSingleNode("test").Attributes["enabled"].Value); XmlNode root; if (test) { root = section.SelectSingleNode("test"); } else { root = section.SelectSingleNode("default"); } cfg.Business = root.SelectSingleNode("business").InnerText; cfg.UrlProcessor = root.SelectSingleNode("urlProcessor").InnerText; cfg.UrlNotify = root.SelectSingleNode("urlNotify").InnerText; cfg.UrlReturn = root.SelectSingleNode("urlReturn").InnerText; cfg.UrlCancelled = root.SelectSingleNode("urlCancel").InnerText; cfg.CurrencyCode = root.SelectSingleNode("currencyCode").InnerText; cfg.Shipping = root.SelectSingleNode("shipping").InnerText; cfg.ReturnText = root.SelectSingleNode("returnText").InnerText; return(cfg); }
/// <summary> /// CheckOut al the items included in the <see cref="Items"/> property. /// </summary> public void CheckOutOnPaypal() { int itemNumber = 1; // Obtengo configuracion PaypalConfig cfg = (PaypalConfig)ConfigurationManager.GetSection("paypal"); string strPaypal = cfg.UrlProcessor; strPaypal += "?cmd=_cart&upload=1"; strPaypal += "&business=" + HttpContext.Current.Server.UrlEncode(cfg.Business); strPaypal += "¬ify_url=" + HttpContext.Current.Server.UrlEncode(cfg.UrlNotify); strPaypal += "&cancel_url=" + HttpContext.Current.Server.UrlEncode(cfg.UrlCancelled); strPaypal += "&return=" + HttpContext.Current.Server.UrlEncode(cfg.UrlReturn); strPaypal += "&invoice=" + invoice; // To configure // currency_code // no_shipping (0: optional, 1: No, 2: Required) // cbt (text for button to return page) // Customer Fields // address1, address2, city, country (code), first_name, last_name, state, zip foreach (PaypalItem pi in items) { string cartProduct; int cartQuantity; decimal cartCost; cartProduct = HttpContext.Current.Server.UrlEncode(pi.Product); cartQuantity = pi.Quantity; cartCost = pi.UnitPrice; strPaypal += "&item_name_" + itemNumber + "=" + cartProduct; strPaypal += "&item_number_" + itemNumber + "=" + cartQuantity; strPaypal += "&amount_" + itemNumber + "=" + Decimal.Round(cartQuantity * cartCost, 2); itemNumber++; } strPaypal += "&add_" + "=" + 1; HttpContext.Current.Response.Redirect(strPaypal); }