habulaj commited on
Commit
32c08f8
·
verified ·
1 Parent(s): f4b70f0

Update routes/hello.py

Browse files
Files changed (1) hide show
  1. routes/hello.py +16 -2
routes/hello.py CHANGED
@@ -151,8 +151,22 @@ def create_customer(
151
 
152
  # 🔹 Atualizar o usuário no Supabase com o stripe_id
153
  update_data = {"stripe_id": stripe_id}
154
- supabase_url = f"{SUPABASE_URL}/rest/v1/User?id=eq.{user_id}"
155
- response = requests.patch(supabase_url, headers=SUPABASE_HEADERS, json=update_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
  if response.status_code not in [200, 204]:
158
  logger.warning(f"⚠️ Rolling back: Deleting Stripe customer {stripe_id} due to Supabase failure.")
 
151
 
152
  # 🔹 Atualizar o usuário no Supabase com o stripe_id
153
  update_data = {"stripe_id": stripe_id}
154
+ supabase_url = f"{SUPABASE_URL}/rest/v1/User"
155
+
156
+ update_headers = {
157
+ "Authorization": f"Bearer {SUPABASE_KEY}",
158
+ "apikey": SUPABASE_KEY,
159
+ "Content-Type": "application/json"
160
+ }
161
+
162
+ # 🔹 Adicionar query params corretamente
163
+ response = requests.patch(
164
+ f"{supabase_url}?id=eq.{user_id}",
165
+ headers=update_headers,
166
+ json=update_data
167
+ )
168
+
169
+ logger.info(f"🔹 Supabase PATCH response: {response.status_code} - {response.text}")
170
 
171
  if response.status_code not in [200, 204]:
172
  logger.warning(f"⚠️ Rolling back: Deleting Stripe customer {stripe_id} due to Supabase failure.")