Unable to connect the hook while initializing project.
lmishra92 opened this issue · comments
I am trying to implement PayPal for my webshop. However, my valid_ipn_signal isn't working the way it should. Below are my files.
signals.py
from django.shortcuts import get_object_or_404
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received
from orders.models import Order
def payment_notification(sender, **kwargs):
print("Hello i am here")
ipn_obj = sender
if ipn_obj.payment_status == ST_PP_COMPLETED:
# payment was successful
order = get_object_or_404(Order, id=ipn_obj.invoice)
# mark the order as paid
order.paid = True
order.save()
valid_ipn_received.connect(payment_notification)
apps.py
from django.apps import AppConfig
class PaymentConfig(AppConfig):
name = 'payment'
verbose_name = 'Payment'
def ready(self):
import payment.signals
__init__.py
default_app_config = 'payment.apps.PaymentConfig'
My PayPal process is going fine. I am able to pay with my test developer account. However, I think the valid_ipn_received.connect(payment_notification)
in signals.py
is not being called. Therefore all my orders in the admin panel show unpaid.
Am I missing out on something or there is a bug in this library ? Please help.
As mentioned in the README/CONTRIBUTING document, I don't provide help with support requests, sorry. Please review the docs, hopefully you will be able to find the bit you missed. If there is something missing in the docs please let us know.
Same here, I followed the docs, I setup the signals properly, and my signal isn't firing either. I copied the docs word for word (even used the same code to test with a print statement like above.). I think either this feature is broken, or the docs are missing something to make this part work.
@ZackPlauche This signal is a critical part of the application, and I have a live app that has been using it for many years, so it is unlikely that it is completely broken. I'm afraid it's impossible for me to debug what's going wrong for you. Have you tested in development using the PayPal sandbox something like ngrok, and ensured that you are actually getting something coming in from PayPal? https://django-paypal.readthedocs.io/en/stable/standard/ipn.html#testing
Ah I see! It could be Ngrok. I found an article explaining how to set it up on a Django project with Django-paypal. I really think it'd be useful to include a small how to guide for Ngrok in the docs though, because you really can't test without it.
Also, when I pushed my project to Heroku, I'm still not able to get the signals to fire (but I didn't see anything saying it should work just because it's in production either).
I did setup my signals properly, and another signal in the same file is working for separate functionality (meaning not with PayPal).
Should it work in production with a normal setup like in the docs?