Fix: Stripe Object to dict conversion

This commit is contained in:
2026-03-27 21:40:23 +01:00
parent faf4ca10c9
commit c7cfaa615d

View File

@@ -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 {}