Spaces:
Running
Running
Update subscriptions.py
Browse files- subscriptions.py +5 -7
subscriptions.py
CHANGED
|
@@ -10,11 +10,9 @@ async def fetch_subscription(jwt: str):
|
|
| 10 |
if auth_res.user is None:
|
| 11 |
return {"error": "Invalid or expired session"}
|
| 12 |
|
| 13 |
-
email = auth_res.user.email
|
| 14 |
-
|
| 15 |
user = auth_res.user
|
|
|
|
| 16 |
|
| 17 |
-
# 3. Fetch customer
|
| 18 |
cust_res = (
|
| 19 |
supabase.schema("stripe").table("customers")
|
| 20 |
.select("*")
|
|
@@ -25,13 +23,13 @@ async def fetch_subscription(jwt: str):
|
|
| 25 |
if not cust_res.data:
|
| 26 |
return {
|
| 27 |
"email": email,
|
| 28 |
-
"signed_up": user
|
| 29 |
"subscription": None
|
| 30 |
}
|
| 31 |
|
| 32 |
customer = cust_res.data[0]
|
| 33 |
|
| 34 |
-
#
|
| 35 |
sub_res = (
|
| 36 |
supabase.schema("stripe").table("subscriptions")
|
| 37 |
.select("*")
|
|
@@ -43,7 +41,7 @@ async def fetch_subscription(jwt: str):
|
|
| 43 |
if not sub_res.data:
|
| 44 |
return {
|
| 45 |
"email": email,
|
| 46 |
-
"signed_up": user
|
| 47 |
"subscription": None
|
| 48 |
}
|
| 49 |
|
|
@@ -92,6 +90,6 @@ async def fetch_subscription(jwt: str):
|
|
| 92 |
|
| 93 |
return {
|
| 94 |
"email": email,
|
| 95 |
-
"signed_up": user
|
| 96 |
"subscription": subscriptions
|
| 97 |
}
|
|
|
|
| 10 |
if auth_res.user is None:
|
| 11 |
return {"error": "Invalid or expired session"}
|
| 12 |
|
|
|
|
|
|
|
| 13 |
user = auth_res.user
|
| 14 |
+
email = user.email
|
| 15 |
|
|
|
|
| 16 |
cust_res = (
|
| 17 |
supabase.schema("stripe").table("customers")
|
| 18 |
.select("*")
|
|
|
|
| 23 |
if not cust_res.data:
|
| 24 |
return {
|
| 25 |
"email": email,
|
| 26 |
+
"signed_up": signed_up = user.created_at.isoformat() if hasattr(user.created_at, "isoformat") else user.created_at,
|
| 27 |
"subscription": None
|
| 28 |
}
|
| 29 |
|
| 30 |
customer = cust_res.data[0]
|
| 31 |
|
| 32 |
+
# Fetch subscriptions
|
| 33 |
sub_res = (
|
| 34 |
supabase.schema("stripe").table("subscriptions")
|
| 35 |
.select("*")
|
|
|
|
| 41 |
if not sub_res.data:
|
| 42 |
return {
|
| 43 |
"email": email,
|
| 44 |
+
"signed_up": signed_up = user.created_at.isoformat() if hasattr(user.created_at, "isoformat") else user.created_at,
|
| 45 |
"subscription": None
|
| 46 |
}
|
| 47 |
|
|
|
|
| 90 |
|
| 91 |
return {
|
| 92 |
"email": email,
|
| 93 |
+
"signed_up": signed_up = user.created_at.isoformat() if hasattr(user.created_at, "isoformat") else user.created_at,
|
| 94 |
"subscription": subscriptions
|
| 95 |
}
|