problem with paypal and the PDTHandler

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
Hi, I have successfully deployed nopCommerce to azure using a shared hosting plan.
All was going ok until I came to attempting to test the paypal payments integration using sandbox

I have connected up my site to paypal using a test seller account, and a test buyer account in the sandbox environment, and have managed to successfully send the buyer to paypal to complete payment for an item, however the problem occurs on the return

when paypal tries to redirect to my site, I get an error like this :

"We're sorry, an internal error occurred.
Our supporting staff has been notified of this error and will address the issue shortly"

now, I have followed the instructions on the configure paypal section in the admin of nopCommerce to the letter.

in paypal, auto return is on, the return url is set to   http://xxxxxxxx.azurewebsites.net/Plugins/PaymentPayPalStandard/PDTHandler

PDT transfer is on and I have the token copied over to my admin config

I also tried enabling IPN as I was unsure if this was required for this to all work.

the notification URL is set to
http://xxxxxxxx.azurewebsites.net/Plugins/PaymentPayPalStandard/IPNHandler

back in nopCommerce admin, ihave the following configured :

use sandbox - yes
correct business email
PDT identity token is entered correctly
IPN Handler is as above, although I suspect you can leave blank to default and it would be same as above

and yet... seemingly, I stil receive an error when Paypal attempts to send the sandbox test user back to my site.

Anyone have any suggestions or faced something similar?

thanks in advance
9 years ago
btw I have managed to grab what PAYPAL is setting as the return URL

the href is as follows :


http://xxxxxxxxxxxxxx.azurewebsites.net/Plugins/PaymentPayPalStandard/PDTHandler?tx=9ND66961R7349752G&st=Completed&amt=4%2e50&cc=GBP&cm=5f5e95d2%2d07dd%2d4172%2daa56%2d191e21c13aa3&item_number=

if any of that seems badly configured?
9 years ago
Just a remark - sandboxes can be the problem sometimes - try a live purchase first if you can...
9 years ago
i`m considering doing just that, but before i did, i attempted to do some remote debugging and had a little success.
the code falls over on the following which is in bold/underline.

this is in PaypalSandardPaymentProcessor.cs


public bool GetPdtDetails(string tx, out Dictionary<string, string> values, out string response)
        {
            var req = (HttpWebRequest)WebRequest.Create(GetPaypalUrl());
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            //now PayPal requires user-agent. otherwise, we can get 403 error
            req.UserAgent = HttpContext.Current.Request.UserAgent;

            string formContent = string.Format("cmd=_notify-synch&at={0}&tx={1}", _paypalStandardPaymentSettings.PdtToken, tx);
            req.ContentLength = formContent.Length;

            using (var sw = new StreamWriter(req.GetRequestStream(), Encoding.ASCII))
                sw.Write(formContent);


the values ...

UserAgent is : "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
formConent ends up as : "cmd=_notify-synch&at=YzoNvoJSCPgYnV9D8HGT9E7YsLjBic80jD6VjMxG7Jw11tyNgBCB4gcxG4u&tx=4FP31080P1847721M"


anyone think of a reason why the code could fall over on GetRequestStream of HttpWebRequest ?

the paypal URL is https://www.sandbox.paypal.com/us/cgi-bin/webscr
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.