Skip to content

Commit 3352c3c

Browse files
committed
Update djstripe handlers (webhook.handler was deleted)
Related #12148
1 parent 080fdf0 commit 3352c3c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

readthedocs/subscriptions/event_handlers.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from django.contrib.humanize.templatetags import humanize
1111
from django.db.models import Sum
1212
from django.utils import timezone
13+
from djstripe import event_handlers
1314
from djstripe import models as djstripe
14-
from djstripe import webhooks
1515
from djstripe.enums import ChargeStatus
1616
from djstripe.enums import SubscriptionStatus
1717

@@ -26,23 +26,23 @@
2626
log = structlog.get_logger(__name__)
2727

2828

29-
def handler(*args, **kwargs):
29+
def djstripe_receiver(*args, **kwargs):
3030
"""
3131
Register handlers only if organizations are enabled.
3232
33-
Wrapper around the djstripe's webhooks.handler decorator,
33+
Wrapper around the djstripe's ``event_handlers.djstripe_receiver`` decorator,
3434
to register the handler only if organizations are enabled.
3535
"""
3636

3737
def decorator(func):
3838
if settings.RTD_ALLOW_ORGANIZATIONS:
39-
return webhooks.handler(*args, **kwargs)(func)
39+
return event_handlers.djstripe_receiver(*args, **kwargs)(func)
4040
return func
4141

4242
return decorator
4343

4444

45-
@handler("customer.subscription.created")
45+
@djstripe_receiver("customer.subscription.created")
4646
def subscription_created_event(event):
4747
"""
4848
Handle the creation of a new subscription.
@@ -82,7 +82,7 @@ def subscription_created_event(event):
8282
organization.save()
8383

8484

85-
@handler("customer.subscription.updated", "customer.subscription.deleted")
85+
@djstripe_receiver("customer.subscription.updated", "customer.subscription.deleted")
8686
def subscription_updated_event(event):
8787
"""
8888
Handle subscription updates.
@@ -155,7 +155,7 @@ def subscription_updated_event(event):
155155
organization.save()
156156

157157

158-
@handler("customer.subscription.deleted")
158+
@djstripe_receiver("customer.subscription.deleted")
159159
def subscription_canceled(event):
160160
"""
161161
Send a notification to all owners if the subscription has ended.
@@ -283,7 +283,7 @@ def subscription_canceled(event):
283283
log.warning("Timeout sending a message to Slack webhook")
284284

285285

286-
@handler("customer.updated")
286+
@djstripe_receiver("customer.updated")
287287
def customer_updated_event(event):
288288
"""Update the organization with the new information from the stripe customer."""
289289
stripe_customer = event.data["object"]

0 commit comments

Comments
 (0)