A: 

It is hard to judge from what you've given me. Here are a couple of guesses/suggestions:

  1. You may need to encode in utf-8 the key as well as the val.
  2. If it is picky about the order of the keys, you should log the keys as you put them into newparams. Since you are using a dict for f, the order may not be what you are expecting it to be.
Justin Peel
+1  A: 

The order is critical. You must verify in the same order that Paypal specify. The simplest way to achieve this is to use the exact order they were provided in:

def paypal_verify():
    """ Returns false if the current request cannot be verified by paypal """
    # Create verify param string from current query string
    verify_string = "cmd=_notify_validate&" + cherrypy.request.query_string
    req = urllib2.Request("http://www.paypal.com/cgi-bin/webscr", verify_string)
    response = urllib2.urlopen(req)
    result = response.read()
    if response == "VERIFIED":
        # All good
        return True
    # Fail
    return False

If you're not using cherrypy, some other mechanism should be similarly available to get the query string as provided by Paypal.

Richard Clark
That's exactly what I was trying to do, but I couldn't find a mechanism just get the data string without using a FieldStorage instance... Is cherrypy the best option?Thanks for the feedback!
thepeanut
thepeanut, just use `os.environ["QUERY_STRING"]`
Matthew Flaschen
A: 

Make sure you are posting to the sandbox and not the live..

PHP $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

None