The code is really simple to implement, but I don't think the explanation was intuitive enough.
You would need to create a signal like so
#hooks.py
from django.dispatch import Signal
success_signal = Signal(providing_args=[])
#views.py
from .hooks import success_signal
... # after payment
success_signal.connect(handler_function)
success_signal.send(sender=None, **kwargs)
This assumes that you already have a listener waiting for the signal broadcast,
Also replace None with your sender (optional), and replace **kwargs with any kwargs you're sending to your listeners.
Cheers
Hello all,I decided to try and accept payments on my web application. I have chosen the django-paypal application to help me out with this task. I found a decent walkthrough at: how-to-accept-paypal-payments-on-your-django-application. I was able to follow everything until the last step of: "6. Setup a listener to detect successful Paypal payments" I have never really setup any listeners before so I did not know what to do. I decided to read the Django-PayPal ReadTheDocs and I found a file that looked structurally similar to what I found on the original walkthrough I had found. It looks like I needed to make a hooks.py file in my project directory. I have accomplished that, and the ReadTheDocs says: "Remember to ensure that import the hooks file is imported i.e. that you are connecting the signals when your project initializes. The standard way to do this is to create an AppConfig class and add a ready() method, in which you can register your signal handlers or import a module that does this." This is where I am getting lost. I am not quite sure what to do. Does anyone have a better walkthrough or know what I need to do?Thank you.--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d9567663-20fb-4f43-a6c5-131f23497a7bn%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJ4Kmg7mQXtRCh3MCTS-jKVdfoK0ZW5BTc2PLFWTO5142hcyRQ%40mail.gmail.com.
No comments:
Post a Comment