troubleshooting Question

PayPal PDT integration ASP.NET

Avatar of nedlogan
nedloganFlag for United Kingdom of Great Britain and Northern Ireland asked on
ASP.NETWeb Development
5 Comments1 Solution1812 ViewsLast Modified:
I'm going round in circles trying to integrate PayPal with my C# code. All I want to do is send the value of the shopping cart, e.g. £25.99 to paypal, have the client pay then send a response to PDT and update my database with SUCCESS, or FAIL response and return to my site.

I've set up Website Payments Standard code to send the form to paypal but nothing seems to be coming back to the PDT page in sandbox. There is so much documentation on the PayPal website that it I'm not sure where to look.

Does someone have some example code or know of a tutorial to get this done? It only needs to be really simple!

The code I tried to use is below, but I'm unsure where to go from here?
String strTransactionID = Request.QueryString["tx"].ToString();
    string sOut = "";
    string MyIDToken = "MyIdentityToken";
    string transactionID = Request.QueryString["tx"].ToString();
    string sCmd = "_notify-synch";
    string serverURL = "https: //www. paypal. com/cgi-bin/webscr";
        string strFormValues = Request.Form.ToString();
        string strPassValue;
        string strResponse;
        // Create the request back
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serverURL);
        // Set values for the request back
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        //Append the transaction ID, ID Token, and command
        //to the form
        strPassValue = strFormValues + "&cmd = _notify-synch&at = " + MyIDToken + "&tx = " + transactionID;
        req.ContentLength = strPassValue.Length;
        // Write the request back IPN strings
        StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
        // Do the request to PayPal and get the response
        StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
        strResponse = stIn.ReadToEnd();
        sOut = Server.UrlDecode(strResponse);
    catch (Exception x)

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros