I am using django-paypal for django 1.7 project. Now I am testing on a paypal sandbox.
Whenever I made a payment, the process at paypal was successful. I can see the buyer account amount deducted, and in the business account accept the money.
Basically, when user make a successful payment , some objects will be updated. But, during my test payment, the object was not updated, seem like the payment signal was not called at all.
Another weird thing is, when I check on the ipn at the admin, i see there were two records for single transaction. One is flagged but no error message and another one is not flagged but give an error message 'Duplicate txn_id xxxxx'. Both records shows that the payment status was 'Completed'.
I really don't know what is going wrong, the documentation doesn't shows how to debug the problem.
On the bottom of the models.py from paypal.standard.ipn.signals import payment_was_successful
def Paypal_comfirm(sender, **kwargs):
ipn_obj = sender
if ipn_obj.payment_status == "Completed":
orderid = ipn_obj.invoice
theorder = get_object_or_404(Order, pk=orderid)
theorder.status = 'complete'
theorder.txn_id = ipn_obj.txn_id
theorder.date_pay = timezone.now()
theorder.save()
payment_was_successful.connect(Paypal_comfirm)
I noticed that you can also use payment_was_flagged
signal, but I don't know what to do with it.
Has anyone know how to debug this kind of problem?
Turns out, it's my signal function that got problems. If your set debug = False (which normally you will do when deployed on a live server) on the settings.py, then you will not get the error logs (on heroku). All I can see is a bad 500 error request, this is very hard to tell what are the problem.
Just in case for who want have the similar problem, you can add the ADMINS to the settings.py.
So whenever there is error in your site, you will get the error sending to your email. Of course , you'll need to add your email details in the settings.py as well.