G
Guest
Hi,
I'm trying to use PayPal and its Instant Payment Notification. In short,
when a payment is made, PayPal send a post to my server and I post it back to
PayPal.
I'm using WebRequest to do this. I receive the PayPal post, but I can't post
it back. It's always giving me a Time out.
Here's my code:
// Setup Web request
objRequest = System.Net.WebRequest.Create(url);
objRequest.Timeout = timeoutSeconds * 1000;
objRequest.ContentType="application/x-www-form-urlencoded";
objRequest.Method = "POST";
// Create a copy of the http post received
// to post it back to paypal
NameValueCollection form = new NameValueCollection(Request.Form);
string hdrs = "";
foreach ( string var in form )
{
if (form[var] != null)
objRequest.Headers.Add(var,form[var]);
}
// Adds the Paypal validation field to the request
objRequest.Headers.Add("cmd","_notify-validate");
// Retrieve data from request
objResponse = objRequest.GetResponse();
....Then, nothing happens here and I receive a timeout webException.
I'm using this in other class where it's working really well. Also, I made a
HTML form to test the post from my server and it's working too. The PayPal
url exists and I don't understand why I can't reach it via webRequest.
Any idea?
Thanks,
Stephane
I'm trying to use PayPal and its Instant Payment Notification. In short,
when a payment is made, PayPal send a post to my server and I post it back to
PayPal.
I'm using WebRequest to do this. I receive the PayPal post, but I can't post
it back. It's always giving me a Time out.
Here's my code:
// Setup Web request
objRequest = System.Net.WebRequest.Create(url);
objRequest.Timeout = timeoutSeconds * 1000;
objRequest.ContentType="application/x-www-form-urlencoded";
objRequest.Method = "POST";
// Create a copy of the http post received
// to post it back to paypal
NameValueCollection form = new NameValueCollection(Request.Form);
string hdrs = "";
foreach ( string var in form )
{
if (form[var] != null)
objRequest.Headers.Add(var,form[var]);
}
// Adds the Paypal validation field to the request
objRequest.Headers.Add("cmd","_notify-validate");
// Retrieve data from request
objResponse = objRequest.GetResponse();
....Then, nothing happens here and I receive a timeout webException.
I'm using this in other class where it's working really well. Also, I made a
HTML form to test the post from my server and it's working too. The PayPal
url exists and I don't understand why I can't reach it via webRequest.
Any idea?
Thanks,
Stephane