I need to implement in my site a new mode of pay and I chose paypal. In my site I have my cart and only when the user click in finish the products going to the paypal for pay this. I can't use a form with any product with a button buy, I need to send all the products in my cart to paypal after my validations in backend of the .NET.
I try to send the content simulating a form submit with HttpRequest but this return a error, how can I send this with HttpRequest? Is this possible?
There are my code:
Code:
string strNewValue;
string strResponse;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
strNewValue = "upload=1&cmd=_cart&business=teste@teste.com.br&no_shipping=2&return=return.html&cancel_return=cancel.html¤cy_code=USD&item_name_1=Item Name 1&amount_1=1.00&item_name_2=Item Name 2&amount_2=2.00";
req.ContentLength = strNewValue.Length;
StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.Default);
stOut.Write(strNewValue);
stOut.Close();
StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream(), Encoding.Default);
strResponse = stIn.ReadToEnd();
stIn.Close();
Response.Write(strResponse);
Am I commit an error?
Thanks,
Leandro.
[Sorry my poor english]