private static string PaypalURL(PayPalOrderData ord, bool isTestMode)
        {
            System.Text.StringBuilder sbr = new System.Text.StringBuilder();
            if (isTestMode)
            {
                sbr.AppendFormat("{0}business={1}", ord.PaypalSandoxUrl, HTTPPOSTEncode(ord.PayPalRecpientID));
            }
            else
            {
                sbr.AppendFormat("{0}business={1}", ord.PayPalLiveUrl, HTTPPOSTEncode(ord.PayPalRecpientID));
            }

            if (ord.IsShoppingCart && null != ord.OrderedData && ord.OrderedData.Rows.Count > 0)
            {
                sbr.Append("&upload=1");
                int intI = 1;
                foreach (DataRow objRow in ord.OrderedData.Rows)
                {
                    sbr.Append(string.Format("&item_name_{0}={1}", intI, HTTPPOSTEncode(objRow["ProductName"].ToString())));
                    sbr.Append(string.Format("&amount_{0}={1}", intI, ((decimal)objRow["Price"] * (decimal)objRow["Qty"])));
                    intI++;
                }
            }
            else
            {
                sbr.Append("&item_name=" + HTTPPOSTEncode(ord.Name));
                sbr.Append("&item_number=" + HTTPPOSTEncode(ord.ItemNumber));
            }


            sbr.Append("&cmd=" + HTTPPOSTEncode("_xclick"));

            sbr.Append("&custom=" + HTTPPOSTEncode(ord.Custom));
            sbr.Append("&invoice=" + HTTPPOSTEncode(ord.Invoice));
            string amount = Convert.ToString(ord.Amount, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

            sbr.Append("&amount=" + HTTPPOSTEncode(amount));
            sbr.Append("&currency_code=" + HTTPPOSTEncode(ord.CurrencyCode));
            sbr.Append("&return=" + HTTPPOSTEncode(ord.ReturnUrl));
            sbr.Append("&cancel_return=" + HTTPPOSTEncode(ord.CancelUrl));
            sbr.Append("&notify_url=" + HTTPPOSTEncode(ord.NotifyUrl));
            sbr.Append("&undefined_quantity=&no_note=1&no_shipping=1");

            return(sbr.ToString());
        }
 public static string GetPaypalUrl(PayPalOrderData ord, bool isTestMode)
 {
     return(PaypalURL(ord, isTestMode));
 }
 //General Redirect Params
 public static void SetRedirect(PayPalOrderData order, bool isTestMode)
 {
     System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
     System.Web.HttpContext.Current.Response.RedirectPermanent(PaypalURL(order, isTestMode));
 }