Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer @require_POST over explicit check #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions zebra/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from zebra.conf import options
from zebra.signals import *
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST

import logging
log = logging.getLogger("zebra.%s" % __name__)
Expand All @@ -25,15 +26,13 @@ def _try_to_get_customer_from_customer_id(stripe_customer_id):
return None

@csrf_exempt
@require_POST
def webhooks(request):
"""
Handles all known webhooks from stripe, and calls signals.
Plug in as you need.
"""

if request.method != "POST":
return HttpResponse("Invalid Request.", status=400)

json = simplejson.loads(request.POST["json"])

if json["event"] == "recurring_payment_failed":
Expand All @@ -60,13 +59,12 @@ def webhooks(request):
return HttpResponse(status=200)

@csrf_exempt
@require_POST
def webhooks_v2(request):
"""
Handles all known webhooks from stripe, and calls signals.
Plug in as you need.
"""
if request.method != "POST":
return HttpResponse("Invalid Request.", status=400)

try:
event_json = simplejson.loads(request.body)
Expand Down