getting webhook events into database 2
This commit is contained in:
@@ -176,6 +176,7 @@ class StripeWebhookTest(APIView):
|
||||
try:
|
||||
event = stripe.Event.construct_from(json.loads(payload), stripe.api_key)
|
||||
event_id = event["id"]
|
||||
event_type = event["type"]
|
||||
# Check if the event has been processed already
|
||||
if WebhookEvent.objects.filter(event_id=event_id, status="processed").exists():
|
||||
return ApiResponse.success(
|
||||
@@ -186,6 +187,7 @@ class StripeWebhookTest(APIView):
|
||||
# Log event processing
|
||||
WebhookEvent.objects.create(
|
||||
event_id=event_id,
|
||||
event_type=event_type,
|
||||
event_payload=json.loads(payload), # optional
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user