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

IPN acknowledgement not working in hosted site Options
meera77c
#1 Posted : Friday, June 25, 2010 10:45:46 AM
Rank: Starting Member

Groups: Registered

Joined: 6/23/2010
Posts: 2
Location: India
Hi,

I am trying to integrate paypal's Simple Pay Standard to my site. I am using the sample code provided by Paypal (shown below)Apart from the sample code I am writing the status to a message file. I have tested the site in my development machine and IPN was working fine. I uploaded the site to the shared web-hosting server and IPN stopped working.
The status in the IPN history shows Failed- HTTP response code 500.

My code is as shown below:

protected void Page_Load(object sender, EventArgs e)
{
try
{
Helper.MsgToFile("Entering PayPal Response Page");
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
string strLive = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);

Helper.MsgToFile("Successfully received req params");
//Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] Param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(Param);
strRequest = strRequest + "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;


//for proxy
//Dim proxy As New WebProxy(New System.Uri("http://url:port#"))
//req.Proxy = proxy

Helper.MsgToFile("Posted back to Paypal for verification");
//Send the request to PayPal and get the response
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();


if (strResponse == "VERIFIED")
{
//check that payment_status is completed
//check that txn_id has not been previously processed
//check that receiver_email is your Primary PayPal email
//check that payment_amount/payment_currency are correct
//process payment

Helper.MsgToFile("Got verified response back from paypal");
}
else if (strResponse == "INVALID")
{
//log for manual investigation
Helper.MsgToFile("Got invalid response back from paypal");
}
else
{
//Response wasn't VERIFIED or INVALID, log for manual investigation
Helper.MsgToFile("Got unknown response back from paypal");
}
}
catch (Exception ex)
{
Helper.ErrorToFile(ex);
}
}

The message file contents are:

[ File writing to log =/PayPalResponse.aspx Date=25/06/2010] Message ===> Entering PayPal Response Page
[ File writing to log =/PayPalResponse.aspx Date=25/06/2010] Message ===> Successfully received req params
[ File writing to log =/PayPalResponse.aspx Date=25/06/2010] Message ===> Posted back to Paypal for verification


The error returned is given below:

[ File Causing Error=/PayPalResponse.aspx Date=25/06/2010] Error Message ===> Unable to connect to the remote server System

Any help as to what is causing this issue is greatly appreciated, since it is a very urgent issue.

Thanks
Meera
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.110 seconds.