YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Send Data With HttpRequest Options
leandroov
#1 Posted : Monday, February 22, 2010 7:59:42 PM
Rank: Starting Member

Groups: Registered

Joined: 2/22/2010
Posts: 1
Location: Brasil
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&currency_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]
Sponsor  
 
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.162 seconds.