Hi,
I started having trouble with paypal IPN on Sept. 4 (a week ago), but
didn't know it until they notified me yesterday that my endpoint url
was failing. Well, I had just upgraded to Django 1.2.1 and figured it
had to be that or some code refactoring I had done.

However, as far as I can tell, the problems were due to a change in
paypal's mechanism. What I did was change my endpoint to accept data
from either a POST or a GET. Previously it only accepted POST data.
When I made that change the IPN started coming through again.  Just
for completeness, here's my endpoint code. Note that yes, I'm not
doing anything special with the data now, just writing it to a file so
I can see the last transaction's data:

@csrf_exempt
def endpoint(request):
    def verify(data):
        newparams={}
        for key in data.keys():
            newparams[key]=data[key]

        newparams["cmd"]="_notify-validate"
        params=urllib.urlencode(newparams)
        req = urllib2.Request(verify_url)
        req.add_header("Content-type", "application/x-www-form-
urlencoded")
        fo = urllib2.urlopen(verify_url, params)
        return fo.read()

    def process(data):
        f = open('/home/myuser/mydata.txt','wb')
        f.write('%r valid' % data)
        f.close()
        return HttpResponse('Ok')

    def process_invalid(data):
        f = open('/home/myuser/myerrors.txt','wb')
        f.write('%r error' % data)
        f.close()
        return HttpResponse('NOT Ok')

    default_response_text = 'Nothing to see here'
    verify_url = "https://www.paypal.com/cgi-bin/webscr";
    if request.method == 'POST':
        data = request.POST
    elif request.method == 'GET':
        data = request.GET
    if verify(data):
        process(data)
    else:
        process_invalid(data)
    return HttpResponse(default_response_text)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to