Update routes/subscription.py
Browse files- routes/subscription.py +9 -2
routes/subscription.py
CHANGED
@@ -167,14 +167,21 @@ async def create_price(
|
|
167 |
logger.info(f"🔹 Subscription {sub.id} set to cancel at period end.")
|
168 |
|
169 |
# 🔹 5. Atualizar Supabase com o novo price_id
|
170 |
-
update_data = {"price_id":
|
|
|
|
|
|
|
|
|
|
|
171 |
update_response = requests.patch(supabase_url, headers=headers, json=update_data)
|
|
|
|
|
172 |
logger.info(f"🔹 Supabase PATCH response: {update_response.status_code} - {update_response.text}")
|
173 |
|
174 |
if update_response.status_code not in [200, 204]:
|
175 |
raise HTTPException(status_code=500, detail=f"Failed to update Supabase: {update_response.text}")
|
176 |
|
177 |
-
logger.info(f"✅ Successfully updated user {user_id} with new price_id {
|
178 |
return {"message": "Price created successfully!", "price_id": new_price_id}
|
179 |
|
180 |
except Exception as e:
|
|
|
167 |
logger.info(f"🔹 Subscription {sub.id} set to cancel at period end.")
|
168 |
|
169 |
# 🔹 5. Atualizar Supabase com o novo price_id
|
170 |
+
update_data = {"price_id": updated_price_id}
|
171 |
+
headers = {
|
172 |
+
"Authorization": f"Bearer {user_token}", # Adicionando o token no header
|
173 |
+
"Content-Type": "application/json"
|
174 |
+
}
|
175 |
+
|
176 |
update_response = requests.patch(supabase_url, headers=headers, json=update_data)
|
177 |
+
|
178 |
+
# Log detalhado para verificar a resposta
|
179 |
logger.info(f"🔹 Supabase PATCH response: {update_response.status_code} - {update_response.text}")
|
180 |
|
181 |
if update_response.status_code not in [200, 204]:
|
182 |
raise HTTPException(status_code=500, detail=f"Failed to update Supabase: {update_response.text}")
|
183 |
|
184 |
+
logger.info(f"✅ Successfully updated user {user_id} with new price_id {updated_price_id}")
|
185 |
return {"message": "Price created successfully!", "price_id": new_price_id}
|
186 |
|
187 |
except Exception as e:
|