dj-stripe / dj-stripe

dj-stripe automatically syncs your Stripe Data to your local database as pre-implemented Django Models allowing you to use the Django ORM, in your code, to work with the data making it easier and faster.
https://dj-stripe.dev
MIT License
1.56k stars 476 forks source link

1.0.0 not triggering webhooks? #419

Closed tkwon closed 3 years ago

tkwon commented 7 years ago

I'm on django 1.10.4.

I have used this code to test the reception of webhooks:

@receiver(WEBHOOK_SIGNALS['customer.subscription.created'])
def subscription_created(sender, **kwargs):
    print('subscription created')

When I create the subscription, I see the event created in the db and an invoice is sent. So all seems well. However, this webhook signal never triggers.

kavdev commented 7 years ago

Hi @tkwon, sorry our docs aren't quite up to speed yet. You might be better off using our Event Handlers paradigm (See here):

from djstripe import webhooks

@webhooks.handler("customer.subscription.created")
def subscription_created(event, event_data, event_type, event_subtype):
    print('subscription created')
kavdev commented 7 years ago

(closing this, but feel free to reopen if need be)

kavdev commented 7 years ago

I realized I'll have to confirm that the signals do still work. Leaving open and setting as bug (unconfirmed for now)

tkwon commented 7 years ago

No success. I'll try to debug.

tkwon commented 7 years ago

I have been unable to track down the problem with webhooks. Hopefully someone else can chime in.

kavdev commented 7 years ago

@tkwon: I'd suggest posting on Stack Overflow with your configuration. Closing as Cannot Reproduce.

kccheung commented 6 years ago

I am having the same problem and tried to hook plan.created, but not succeed

@webhooks.handler('plan.created')
def plan_created(sender, **kwargs):
    log_info("plan_created")

I am using Django 1.11.8

kccheung commented 6 years ago

I figured out the reason why... I saw there is code statements in djstripe/models.py which does the registrations:

# Much like registering signal handlers. We import this module so that its registrations get picked up
# the NO QA directive tells flake8 to not complain about the unused import
from . import event_handlers  # NOQA, isort:skip

I have put this in my app's models.py and it did the trick.

kavdev commented 6 years ago

@lskillen are you experiencing this? I don't think I've run into it yet; we might need a docs update.

cameronepstein commented 4 years ago

Did anyone find a fix to this? Tried kccheung's method and no fix. Still not getting any triggers from @webhooks.handler('plan.created')

kavdev commented 4 years ago

@cameronepstein what version of dj-stripe are you running?

tarsil commented 3 years ago

I have the same issue and my custom webhooks are not working at all. The documentation is a mess and this product cannot be used whatsoever since we can't even understand how this works properly.

kavdev commented 3 years ago

@tiagoarasilva please provide a bit more info. What version are you running and which events are you looking to hook into? If you can please post a snippet of your code.

I understand you might be frustrated, but know that this project is maintained by a group of volunteers in their free time. Functionality and keeping up with stripe api changes have been prioritized over detailed documentation. Browsing the reference sections of the docs should get you a decent understanding of the available functionality. PRs are always welcome for the higher-level docs.

cc @jleclanche

tarsil commented 3 years ago

@kavdev I'm using the latest with Django 3.1 which is fantastic with the webhooks. I found a way to make it work but took me a lot of time to understand it and reverse engineering it where simple documentation would explain with some examples, I would say.

I think dj-stripe is fantastic as it does a lot of heavy lifting for us but the lack of examples and documentation, for instance, for invoices and so on make us wonder if is actually what we need at the moment

kavdev commented 3 years ago

@tiagoarasilva I should clarify that I totally agree the documentation is lacking 🙂 We'll be sharing some news shortly that will allow us to take steps to focus on more aspects of the library, including documentation.

tarsil commented 3 years ago

@kavdev I would be more than happy to help if you want. I did a lot of reverse engineering and I'm still doing as we speak since I want to implement features such as collecting invoices, generate them by logged in user and guest checkout.

I liked the REST side of things but again, it would be great to have that documented and with more features since REST is becoming the new norm, this way dj-stripe will become a massive reference for the django world and widely used (even more).

Looking forward to the news :)

kavdev commented 3 years ago

@tiagoarasilva go ahead and hop on our discord; @jleclanche or I will ping you once we have an updated roadmap

tarsil commented 3 years ago

@kavdev I've joined discord and thank you for the invite :). Let me know how can be helpful somehow

kavdev commented 3 years ago

related: #483

kavdev commented 3 years ago

@tiagoarasilva #1221

LordXyTh commented 3 years ago

Did this ever get resolved? @tiagoarasilva how were you able to move forward?

jleclanche commented 3 years ago

Closing this in favour of #483.

Alihassanc5 commented 7 months ago

@tarsil @kavdev how did you solve the problem? I have seen the objects are saved in my DB, but when It's not triggering the webhook. @webhooks.handler('plan.created')

I am using the latest version of djstripe