Update routes/subscription.py
Browse files- routes/subscription.py +10 -7
routes/subscription.py
CHANGED
@@ -120,19 +120,21 @@ async def subscription_details(data: SubscriptionRequest):
|
|
120 |
payment_info = "No default payment method found"
|
121 |
|
122 |
# Pegando o stylist_id dos metadados
|
123 |
-
stylist_id = subscription["metadata"].get("stylist_id",
|
124 |
|
125 |
-
# Buscar avatar do stylist no Supabase
|
126 |
stylist_avatar = None
|
127 |
-
|
|
|
128 |
response = requests.get(
|
129 |
-
f"{SUPABASE_URL}/rest/v1/User?id=eq.{stylist_id}&select=avatar",
|
130 |
headers=SUPABASE_HEADERS
|
131 |
)
|
132 |
if response.status_code == 200:
|
133 |
data = response.json()
|
134 |
-
if data
|
135 |
-
stylist_avatar = data[0]
|
|
|
136 |
|
137 |
return {
|
138 |
"status": subscription_status,
|
@@ -142,7 +144,8 @@ async def subscription_details(data: SubscriptionRequest):
|
|
142 |
"next_billing_date": next_billing_date,
|
143 |
"payment_method": payment_info,
|
144 |
"stylist_id": stylist_id,
|
145 |
-
"stylist_avatar": stylist_avatar
|
|
|
146 |
}
|
147 |
|
148 |
except stripe.error.StripeError as e:
|
|
|
120 |
payment_info = "No default payment method found"
|
121 |
|
122 |
# Pegando o stylist_id dos metadados
|
123 |
+
stylist_id = subscription["metadata"].get("stylist_id", "N/A")
|
124 |
|
125 |
+
# Buscar avatar e nome do stylist no Supabase
|
126 |
stylist_avatar = None
|
127 |
+
stylist_name = None
|
128 |
+
if stylist_id != "N/A":
|
129 |
response = requests.get(
|
130 |
+
f"{SUPABASE_URL}/rest/v1/User?id=eq.{stylist_id}&select=avatar,name",
|
131 |
headers=SUPABASE_HEADERS
|
132 |
)
|
133 |
if response.status_code == 200:
|
134 |
data = response.json()
|
135 |
+
if data:
|
136 |
+
stylist_avatar = data[0].get("avatar")
|
137 |
+
stylist_name = data[0].get("name")
|
138 |
|
139 |
return {
|
140 |
"status": subscription_status,
|
|
|
144 |
"next_billing_date": next_billing_date,
|
145 |
"payment_method": payment_info,
|
146 |
"stylist_id": stylist_id,
|
147 |
+
"stylist_avatar": stylist_avatar,
|
148 |
+
"stylist_name": stylist_name
|
149 |
}
|
150 |
|
151 |
except stripe.error.StripeError as e:
|