Signals
There is a signal sent for every webhook event. You can access them by doing the following:
# receivers.py
from django.dispatch import receiver
from pinax.stripe.signals import WEBHOOK_SIGNALS
@receiver(WEBHOOK_SIGNALS["invoice.payment_succeeded"])
def handle_payment_succeeded(sender, event, **kwargs):
pass # do what it is you want to do here
If you make sure that receivers.py
is imported at startup
then this code example above will execute the handle_payment_succeeded
function
everytime the invoice.payment_succeeded
event is sent by Stripe and processed by your
webhook endpoint.
The event
object is a processed and verified Event model instance
which gives you access to all the raw data of the event.