mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Stripe: Robust webhook recognition
This commit is contained in:
@@ -173,6 +173,17 @@ def webhook(request, *args, **kwargs):
|
|||||||
if hasattr(request, 'event'):
|
if hasattr(request, 'event'):
|
||||||
return func(request.event, event_json, objid, None)
|
return func(request.event, event_json, objid, None)
|
||||||
else:
|
else:
|
||||||
|
# If we receive a charge webhook *before* the payment intent webhook, we don't know the charge ID yet
|
||||||
|
# and can't match it -- but we know the payment intent ID!
|
||||||
|
if event_json['data']['object']['object'] == "charge" and event_json['data']['object']['payment_intent']:
|
||||||
|
try:
|
||||||
|
rso = ReferencedStripeObject.objects.select_related('order', 'order__event').get(
|
||||||
|
reference=event_json['data']['object']['payment_intent']
|
||||||
|
)
|
||||||
|
return func(rso.order.event, event_json, objid, rso)
|
||||||
|
except ReferencedStripeObject.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
return HttpResponse("Unable to detect event", status=200)
|
return HttpResponse("Unable to detect event", status=200)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user