From c7cfaa615d95bde14042c3a8ff6daab166d9973f Mon Sep 17 00:00:00 2001 From: suro Date: Fri, 27 Mar 2026 21:40:23 +0100 Subject: [PATCH] Fix: Stripe Object to dict conversion --- AzA march 2026/stripe_routes.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/AzA march 2026/stripe_routes.py b/AzA march 2026/stripe_routes.py index 1195636..1c3c90f 100644 --- a/AzA march 2026/stripe_routes.py +++ b/AzA march 2026/stripe_routes.py @@ -273,14 +273,11 @@ async def sync_subscription() -> Dict[str, Any]: raise HTTPException(status_code=404, detail="No active license found") subscription_id = str(row[0]) - sub = stripe.Subscription.retrieve(subscription_id) + sub = stripe.Subscription.retrieve(subscription_id).to_dict_recursive() status = (sub.get("status") or "").strip() - current_period_end = None + current_period_end = sub.get("current_period_end") - if "current_period_end" in sub and sub["current_period_end"]: - current_period_end = sub["current_period_end"] - else: - # Fallback für neuere API-Versionen + if not current_period_end: try: current_period_end = sub["items"]["data"][0]["current_period_end"] except Exception: @@ -323,6 +320,7 @@ async def stripe_webhook( except Exception as e: raise HTTPException(status_code=400, detail=f"Webhook signature verification failed: {e}") + event = event.to_dict_recursive() event_id = event.get("id", "") if event_id and _already_processed(event_id): return JSONResponse({"ok": True, "duplicate": True}) @@ -347,7 +345,7 @@ async def stripe_webhook( customer_email = obj.get("customer_email") or None if subscription_id and customer_id: - sub = stripe.Subscription.retrieve(subscription_id, expand=["items.data.price"]) + sub = stripe.Subscription.retrieve(subscription_id, expand=["items.data.price"]).to_dict_recursive() status = sub.get("status", "") or "" current_period_end = sub.get("current_period_end") md = sub.get("metadata") or {}