Handle presence of HTTP_STRIPE_SIGNATURE header in META
This commit is contained in:
parent
d71bf87470
commit
3b84d6f646
1 changed files with 6 additions and 1 deletions
|
@ -17,10 +17,15 @@ logger = logging.getLogger(__name__)
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def handle_invoice_webhook(request):
|
def handle_invoice_webhook(request):
|
||||||
payload = request.body
|
payload = request.body
|
||||||
sig_header = request.META['HTTP_STRIPE_SIGNATURE']
|
|
||||||
event = None
|
event = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if 'HTTP_STRIPE_SIGNATURE' in request.META:
|
||||||
|
sig_header = request.META['HTTP_STRIPE_SIGNATURE']
|
||||||
|
else:
|
||||||
|
logger.error("No HTTP_STRIPE_SIGNATURE header")
|
||||||
|
# Invalid payload
|
||||||
|
return HttpResponse(status=400)
|
||||||
event = stripe.Webhook.construct_event(
|
event = stripe.Webhook.construct_event(
|
||||||
payload, sig_header, settings.INVOICE_WEBHOOK_SECRET
|
payload, sig_header, settings.INVOICE_WEBHOOK_SECRET
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue