nedlogan
asked on
PayPal PDT integration ASP.NET
Hi,
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?
Thanks,
NL
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";
try
{
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);
stOut.Write(strPassValue);
stOut.Close();
// Do the request to PayPal and get the response
StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
strResponse = stIn.ReadToEnd();
stIn.Close();
sOut = Server.UrlDecode(strResponse);
}
catch (Exception x)
{
}
Thanks,
NL
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your response.
I tried the IPN code you linked to yet regardless of the response I send from the sandbox ipn tester interperates it as SUCCESS?
Any ideas?
I tried the IPN code you linked to yet regardless of the response I send from the sandbox ipn tester interperates it as SUCCESS?
Any ideas?
ASKER
Never mind I found the other part of the puzzle here:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro#id091F0M006Y4
Further to my earlier post it should always be SUCCESS.
Thanks for the push.
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro#id091F0M006Y4
Further to my earlier post it should always be SUCCESS.
Thanks for the push.
ASKER
Thanks for your help.
string serverURL = "https: //www. paypal. com/cgi-bin/webscr";
remove space between https: and //