Reputation: 1551
I've been picking my way though django-paypal documentation and have got a signal connecting when I send a IPN from the sandbox simulator.
I can do:
UserProfile.objects.update(has_paid=True)
I can also do:
UserProfile.objects.update(middle_name=sender.custom) # sender.custom set to "Lyndon" on IPN
and everyone gets a year free. Not what I want... What I'd like to do is
up = UserProfile.objects.get(user=ipn_obj.custom)
up.has_paid = False
up.save()
but on such occasions I get a server error (500) message on the Instant Payment Notification (IPN) simulator.
IPN delivery failed. HTTP error code 500: Internal Server Error
I still get a Paypal IPN in my database and it will show up not flagged and with a payment status of "Completed". However, the signal is not connecting.
I'm just not getting something (or multiple things!) here. Any pointers much appreciated.
T
Upvotes: 0
Views: 349
Reputation: 1551
It would help if I paid attention...
up = UserProfile.objects.get(user.username=ipn_obj.custom)
user.username...
Upvotes: 1
Reputation: 310
Try to use that,
UserProfile.objects.filter(user=ipn_obj.custom).update(has_paid=False)
For that kind of bugs, which you can not understand what is the problem use ipdb:
you should install ipdb,
$ pip install ipdb
and to run go to your code which doesn't work and add,
import ipdb; ipdb.set_trace()
when you run on your local (I mean with runserver) and make request to make that code pieces run, you will see the trace after the above line.
Note that to go next use "n" and to continue use "c" on ipdb.
Upvotes: 2