Example #1
0
        //public static string GetResponse(RequestContext context, decimal price)
        //{
        //    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api-3t.sandbox.paypal.com/nvp");
        //    //HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api-3t.sandbox.paypal.com/nvp");

        //    request.Method = "POST";

        //    UrlHelper url = new UrlHelper(context);
        //    string urlBase = string.Format("{0}://{1}", context.HttpContext.Request.Url.Scheme, context.HttpContext.Request.Url.Authority);

        //    string formContent = "USER="******"paypalUser"] +
        //            "&PWD=" + System.Configuration.ConfigurationManager.AppSettings["paypalPassword"] +
        //            "&SIGNATURE=" + System.Configuration.ConfigurationManager.AppSettings["paypalSignature"] +
        //            "&VERSION=84.0" +
        //            "&PAYMENTREQUEST_0_PAYMENTACTION=Sale" +
        //            "&PAYMENTREQUEST_0_AMT=" + String.Format("{0:0.00}", price) +
        //            "&RETURNURL=" + urlBase + url.Action("Confirm", "Checkout") +
        //            "&CANCELURL=" + urlBase + url.Action("Canceled", "Checkout") +
        //            "&METHOD=SetExpressCheckout";

        //    byte[] byteArray = Encoding.UTF8.GetBytes(formContent);
        //    request.ContentType = "application/x-www-form-urlencoded";
        //    request.ContentLength = byteArray.Length;
        //    Stream dataStream = request.GetRequestStream();
        //    dataStream.Write(byteArray, 0, byteArray.Length);
        //    dataStream.Close();
        //    WebResponse response = request.GetResponse();
        //    dataStream = response.GetResponseStream();
        //    StreamReader reader = new StreamReader(dataStream);
        //    string responseFromServer = HttpUtility.UrlDecode(reader.ReadToEnd());

        //    reader.Close();
        //    dataStream.Close();
        //    response.Close();

        //    return responseFromServer;
        //}

        public ActionResult PostToPayPal(int userid)
        {
            string item               = "test";
            string amount             = "00.55";
            string BusinessAccountKey = "123456789";
            string CurrencyCode       = "USD";

            MealsToGo.Models.Paypal paypal = new Models.Paypal();
            paypal.cmd      = "_xclick";
            paypal.business = "*****@*****.**";

            string useSandbox = ConfigurationManager.AppSettings["PayPalUseSandbox"];

            if (useSandbox == "1")
            {
                ViewBag.actionURl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            }
            else
            {
                ViewBag.actionURl = "https://www.paypal.com/cgi-bin/webscr";
            }

            paypal.cancel_return = System.Configuration.ConfigurationManager.AppSettings["CancelURL"];
            paypal.@return       = ConfigurationManager.AppSettings["ReturnURL"]; //+"&PaymentId=1"; you can append your order Id here
            paypal.notify_url    = ConfigurationManager.AppSettings["ReturnURL"]; // +"?PaymentId=1"; to maintain database logic

            paypal.currency_code = CurrencyCode;

            //paypal.item_name = item;
            //paypal.amount = amount;
            return(View(paypal));
        }
Example #2
0
        public ActionResult PostToPayPal(string item , string amount)
        {
            PaypalMVC.Models.Paypal paypal = new Models.Paypal();
            paypal.cmd = "_xclick";
            paypal.business = ConfigurationManager.AppSettings["BusinessAccountKey"];

            bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSandbox"]);
            if (useSandbox)
                ViewBag.actionURl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            else
                ViewBag.actionURl = "https://www.paypal.com/cgi-bin/webscr";

            paypal.cancel_return = System.Configuration.ConfigurationManager.AppSettings["CancelURL"];
            paypal.@return = ConfigurationManager.AppSettings["ReturnURL"]; //+"&PaymentId=1"; you can append your order Id here
            paypal.notify_url = ConfigurationManager.AppSettings["NotifyURL"];// +"?PaymentId=1"; to maintain database logic

            paypal.currency_code = ConfigurationManager.AppSettings["CurrencyCode"];

            paypal.item_name = item;
            paypal.amount = amount;
            return View(paypal);
        }
        public ActionResult PostToPaypal(int orderId, string amount)
        {
            Models.Paypal paypal = new Models.Paypal();
            paypal.cmd      = "_xclick";
            paypal.business = ConfigurationManager.AppSettings["BusinessAccountKey"];
            //if (useSandbox == "1")
            //    ViewBag.actionURl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            //else
            //    ViewBag.actionURl = "https://www.paypal.com/cgi-bin/webscr";

            bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSandbox"]);

            if (useSandbox)
            {
                //sandbox url
                ViewBag.actionURl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            }
            else
            {
                ViewBag.actionURl = "https://www.paypal.com/cgi-bin/webscr";
            }
            paypal.cancel_return = ConfigurationManager.AppSettings["CancelURL"] + "?orderId=" + orderId + "&";
            paypal.@return       = ConfigurationManager.AppSettings["ReturnURL"] + "?orderId=" + orderId + "&";
            paypal.notify_url    = ConfigurationManager.AppSettings["NotifyURL"] + "?orderId=" + orderId + "&";
            paypal.currency_code = ConfigurationManager.AppSettings["CurrencyCode"];

            paypal.PaypalItems = new List <PaypalItem>();
            foreach (FunOrderDetail od in dbmeals.FunOrderDetails.Where(x => x.OrderID == orderId))
            {
                PaypalItem oPaypalItem = new PaypalItem();
                oPaypalItem.item_name = od.Description;
                oPaypalItem.Quantity  = (od.Quantity).ToString();
                oPaypalItem.amount    = od.Price.ToString();
                paypal.PaypalItems.Add(oPaypalItem);
            }
            return(View(paypal));
        }
        public ActionResult PostToPaypal(int orderId, string amount)
        {
            Models.Paypal paypal = new Models.Paypal();
            paypal.cmd = "_xclick";
            paypal.business = ConfigurationManager.AppSettings["BusinessAccountKey"];
            //if (useSandbox == "1")
            //    ViewBag.actionURl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            //else
            //    ViewBag.actionURl = "https://www.paypal.com/cgi-bin/webscr";

            bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSandbox"]);
            if (useSandbox)
            {
                //sandbox url
                ViewBag.actionURl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            }
            else
            {
                ViewBag.actionURl = "https://www.paypal.com/cgi-bin/webscr";
            }
            paypal.cancel_return = ConfigurationManager.AppSettings["CancelURL"] + "?orderId=" + orderId+"&";
            paypal.@return = ConfigurationManager.AppSettings["ReturnURL"] + "?orderId=" + orderId + "&";
            paypal.notify_url = ConfigurationManager.AppSettings["NotifyURL"] + "?orderId=" + orderId + "&";
            paypal.currency_code = ConfigurationManager.AppSettings["CurrencyCode"];

            paypal.PaypalItems = new List<PaypalItem>();
            foreach (FunOrderDetail od in dbmeals.FunOrderDetails.Where(x => x.OrderID == orderId))
            {
                PaypalItem oPaypalItem = new PaypalItem();
                oPaypalItem.item_name = od.Description;
                oPaypalItem.Quantity = (od.Quantity).ToString();
                oPaypalItem.amount = od.Price.ToString();
                paypal.PaypalItems.Add(oPaypalItem);
            }
            return View(paypal);
        }
        //public static string GetResponse(RequestContext context, decimal price)
        //{
        //    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api-3t.sandbox.paypal.com/nvp");
        //    //HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api-3t.sandbox.paypal.com/nvp");
        //    request.Method = "POST";
        //    UrlHelper url = new UrlHelper(context);
        //    string urlBase = string.Format("{0}://{1}", context.HttpContext.Request.Url.Scheme, context.HttpContext.Request.Url.Authority);
        //    string formContent = "USER="******"paypalUser"] +
        //            "&PWD=" + System.Configuration.ConfigurationManager.AppSettings["paypalPassword"] +
        //            "&SIGNATURE=" + System.Configuration.ConfigurationManager.AppSettings["paypalSignature"] +
        //            "&VERSION=84.0" +
        //            "&PAYMENTREQUEST_0_PAYMENTACTION=Sale" +
        //            "&PAYMENTREQUEST_0_AMT=" + String.Format("{0:0.00}", price) +
        //            "&RETURNURL=" + urlBase + url.Action("Confirm", "Checkout") +
        //            "&CANCELURL=" + urlBase + url.Action("Canceled", "Checkout") +
        //            "&METHOD=SetExpressCheckout";
        //    byte[] byteArray = Encoding.UTF8.GetBytes(formContent);
        //    request.ContentType = "application/x-www-form-urlencoded";
        //    request.ContentLength = byteArray.Length;
        //    Stream dataStream = request.GetRequestStream();
        //    dataStream.Write(byteArray, 0, byteArray.Length);
        //    dataStream.Close();
        //    WebResponse response = request.GetResponse();
        //    dataStream = response.GetResponseStream();
        //    StreamReader reader = new StreamReader(dataStream);
        //    string responseFromServer = HttpUtility.UrlDecode(reader.ReadToEnd());
        //    reader.Close();
        //    dataStream.Close();
        //    response.Close();
        //    return responseFromServer;
        //}
        public ActionResult PostToPayPal(int userid)
        {
            string item = "test";
            string amount = "00.55";
            string BusinessAccountKey = "123456789";
            string CurrencyCode = "USD";

            MealsToGo.Models.Paypal paypal = new Models.Paypal();
            paypal.cmd = "_xclick";
            paypal.business = "*****@*****.**";

            string useSandbox = ConfigurationManager.AppSettings["PayPalUseSandbox"];
            if (useSandbox == "1")
                ViewBag.actionURl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            else
                ViewBag.actionURl = "https://www.paypal.com/cgi-bin/webscr";

            paypal.cancel_return = System.Configuration.ConfigurationManager.AppSettings["CancelURL"];
            paypal.@return = ConfigurationManager.AppSettings["ReturnURL"]; //+"&PaymentId=1"; you can append your order Id here
            paypal.notify_url = ConfigurationManager.AppSettings["ReturnURL"];// +"?PaymentId=1"; to maintain database logic

            paypal.currency_code = CurrencyCode;

            //paypal.item_name = item;
            //paypal.amount = amount;
            return View(paypal);
        }
Example #6
0
        public ActionResult PostToPaypal(string item, string amountval)
        {
            var paypal = new Models.Paypal();
            //paypal.cmd = "_xclick";
            paypal.cmd = "_cart";
            paypal.business = ConfigurationManager.AppSettings["BusinessAccountKey"];

            var useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSandBox"]);
            ViewBag.actionUrl = useSandbox ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr";

            paypal.cancel_return = ConfigurationManager.AppSettings["CancelURL"];
            paypal.@return = ConfigurationManager.AppSettings["ReturnURL"];
            paypal.notify_url = ConfigurationManager.AppSettings["NotifyURL"];
            paypal.currency_code = ConfigurationManager.AppSettings["CurrencyCode"];

            paypal.PaypalItems.Add(new PaypalItem()
                                       {
                                           Amount = amountval,
                                           Name = item,
                                           Quantity = 1
                                       });

            paypal.PaypalItems.Add(new PaypalItem()
                                        {
                                            Amount = "12",
                                            Name = "test",
                                            Quantity = 1
                                        });

            return View(paypal);
        }