From 9558333c94a7ac6f4095716b157c27dcf1b672f2 Mon Sep 17 00:00:00 2001 From: mguschin Date: Mon, 9 Mar 2026 18:04:13 +0300 Subject: [PATCH] Handle 402 Payment Required from Evotor API gracefully Return empty list for groups/products when Evotor returns 402, instead of crashing the refresh with an unhandled HTTP error. Co-Authored-By: Claude Sonnet 4.6 --- web/evotor_api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/evotor_api.py b/web/evotor_api.py index fd498db..0d220a9 100644 --- a/web/evotor_api.py +++ b/web/evotor_api.py @@ -33,6 +33,8 @@ async def fetch_groups(access_token: str, store_id: str) -> list[dict]: headers={"Authorization": f"Bearer {access_token}"}, timeout=15, ) + if resp.status_code == 402: + return [] resp.raise_for_status() data = resp.json() items = data.get("items", data) if isinstance(data, dict) else data @@ -46,6 +48,8 @@ async def fetch_products(access_token: str, store_id: str) -> list[dict]: headers={"Authorization": f"Bearer {access_token}"}, timeout=15, ) + if resp.status_code == 402: + return [] resp.raise_for_status() data = resp.json() items = data.get("items", data) if isinstance(data, dict) else data