sharktide commited on
Commit
1dd8760
·
verified ·
1 Parent(s): da31625

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -1437,5 +1437,23 @@ async def tiers():
1437
  )
1438
 
1439
  @app.get("/portal")
1440
- def a():
1441
- return RedirectResponse(url="https://billing.stripe.com/p/login/test_6oUcN5g665rp7nLgaq8bS00", status_code=status.HTTP_302_FOUND)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1437
  )
1438
 
1439
  @app.get("/portal")
1440
+ @app.post("/portal")
1441
+ def a(request: Request):
1442
+ email = None
1443
+
1444
+ if request.method == "POST":
1445
+ try:
1446
+ body = await request.json()
1447
+ email = body.get("email")
1448
+ except:
1449
+ email = None
1450
+
1451
+ base_url = "https://billing.stripe.com/p/login/test_6oUcN5g665rp7nLgaq8bS00"
1452
+
1453
+ if not email:
1454
+ return RedirectResponse(url=base_url, status_code=status.HTTP_302_FOUND)
1455
+
1456
+ return RedirectResponse(
1457
+ url=f"{base_url}?prefilled_email={email}",
1458
+ status_code=status.HTTP_302_FOUND
1459
+ )