Final Fix: Use json.loads for webhook event
This commit is contained in:
@@ -316,11 +316,11 @@ async def stripe_webhook(
|
|||||||
|
|
||||||
body = await request.body()
|
body = await request.body()
|
||||||
try:
|
try:
|
||||||
event = stripe.Webhook.construct_event(payload=body, sig_header=stripe_signature, secret=STRIPE_WEBHOOK_SECRET)
|
stripe.Webhook.construct_event(payload=body, sig_header=stripe_signature, secret=STRIPE_WEBHOOK_SECRET)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=400, detail=f"Webhook signature verification failed: {e}")
|
raise HTTPException(status_code=400, detail=f"Webhook signature verification failed: {e}")
|
||||||
|
|
||||||
event = event.to_dict_recursive()
|
event = json.loads(body)
|
||||||
event_id = event.get("id", "")
|
event_id = event.get("id", "")
|
||||||
if event_id and _already_processed(event_id):
|
if event_id and _already_processed(event_id):
|
||||||
return JSONResponse({"ok": True, "duplicate": True})
|
return JSONResponse({"ok": True, "duplicate": True})
|
||||||
|
|||||||
Reference in New Issue
Block a user