PayPal Instant Payment Notification(IPN) Issue..
-
Hi i m using paypal IPN for payment notifications. I am using the same code provided by Paypal however i m having issues. Here is the code 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); //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); Dictionary nvs = new Dictionary(); string[] items = strRequest.Split("&".ToCharArray()); foreach (string item in items) { string[] parts = item.Split("=".ToCharArray()); nvs.Add(parts[0], HttpUtility.UrlDecode(parts[1])); } strRequest += "&cmd=_notify-validate"; req.ContentLength = strRequest.Length; //for proxy //Hook up 1&1 proxy server //WebProxy proxy = new WebProxy("ntproxyus.lxa.perfora.net:3128",false); //req.Proxy = proxy; //Send transaction detail with the flag back to PayPal StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII); streamOut.Write(strRequest); streamOut.Close(); //DataLayer dl3 = new DataLayer(); //dl3.executeQuery("Update petOwner set orderStatus = 'Afterproxy(Invalid Card)' where orderId = '" + Request.Form["item_name"] + "'"); //Get validation status from PayPal StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()); string strResponse = streamIn.ReadToEnd(); streamIn.Close(); //DataLayer dl4 = new DataLayer(); //dl4.executeQuery("Update petOwner set orderStatus = 'Afterproxy2(Invalid Card)' where orderId = '" + Request.Form["item_name"] + "'"); if (strResponse == "VERIFIED") { //check the payment_status is Completed if (nvs["payment_status"] == "Completed") { //check that txn_id has not been previously processed //check that receiver_email is your Primary PayPal email
-
Hi i m using paypal IPN for payment notifications. I am using the same code provided by Paypal however i m having issues. Here is the code 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); //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); Dictionary nvs = new Dictionary(); string[] items = strRequest.Split("&".ToCharArray()); foreach (string item in items) { string[] parts = item.Split("=".ToCharArray()); nvs.Add(parts[0], HttpUtility.UrlDecode(parts[1])); } strRequest += "&cmd=_notify-validate"; req.ContentLength = strRequest.Length; //for proxy //Hook up 1&1 proxy server //WebProxy proxy = new WebProxy("ntproxyus.lxa.perfora.net:3128",false); //req.Proxy = proxy; //Send transaction detail with the flag back to PayPal StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII); streamOut.Write(strRequest); streamOut.Close(); //DataLayer dl3 = new DataLayer(); //dl3.executeQuery("Update petOwner set orderStatus = 'Afterproxy(Invalid Card)' where orderId = '" + Request.Form["item_name"] + "'"); //Get validation status from PayPal StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()); string strResponse = streamIn.ReadToEnd(); streamIn.Close(); //DataLayer dl4 = new DataLayer(); //dl4.executeQuery("Update petOwner set orderStatus = 'Afterproxy2(Invalid Card)' where orderId = '" + Request.Form["item_name"] + "'"); if (strResponse == "VERIFIED") { //check the payment_status is Completed if (nvs["payment_status"] == "Completed") { //check that txn_id has not been previously processed //check that receiver_email is your Primary PayPal email
Please put your code in <pre> tags so that it's readable. (Use the "code" formatting.)
The difficult we do right away... ...the impossible takes slightly longer.
-
Hi i m using paypal IPN for payment notifications. I am using the same code provided by Paypal however i m having issues. Here is the code 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); //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); Dictionary nvs = new Dictionary(); string[] items = strRequest.Split("&".ToCharArray()); foreach (string item in items) { string[] parts = item.Split("=".ToCharArray()); nvs.Add(parts[0], HttpUtility.UrlDecode(parts[1])); } strRequest += "&cmd=_notify-validate"; req.ContentLength = strRequest.Length; //for proxy //Hook up 1&1 proxy server //WebProxy proxy = new WebProxy("ntproxyus.lxa.perfora.net:3128",false); //req.Proxy = proxy; //Send transaction detail with the flag back to PayPal StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII); streamOut.Write(strRequest); streamOut.Close(); //DataLayer dl3 = new DataLayer(); //dl3.executeQuery("Update petOwner set orderStatus = 'Afterproxy(Invalid Card)' where orderId = '" + Request.Form["item_name"] + "'"); //Get validation status from PayPal StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()); string strResponse = streamIn.ReadToEnd(); streamIn.Close(); //DataLayer dl4 = new DataLayer(); //dl4.executeQuery("Update petOwner set orderStatus = 'Afterproxy2(Invalid Card)' where orderId = '" + Request.Form["item_name"] + "'"); if (strResponse == "VERIFIED") { //check the payment_status is Completed if (nvs["payment_status"] == "Completed") { //check that txn_id has not been previously processed //check that receiver_email is your Primary PayPal email
Please refer this link: https://cms.paypal.com/cgi-bin/marketingweb?cmd=_render-content&content_ID=developer/library_code_ipn_code_samples[^] http://www.phpwebcommerce.com/shop-checkout-process/handling-paypal-ipn.php[^]
Maulik Dusara Sr. Sofware Engineer