Update routes/stylist.py
Browse files- routes/stylist.py +25 -0
routes/stylist.py
CHANGED
@@ -240,6 +240,31 @@ def get_total_subscribers(user_id: str) -> int:
|
|
240 |
return len(subscribers)
|
241 |
return 0
|
242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
@router.get("/dashboard")
|
244 |
def get_dashboard(user_token: str = Header(None, alias="User-key"), page: int = Query(0, ge=0)):
|
245 |
try:
|
|
|
240 |
return len(subscribers)
|
241 |
return 0
|
242 |
|
243 |
+
@router.post("/bank_account_dashboard_link")
|
244 |
+
async def generate_bank_account_dashboard_link(data: UserIDRequest):
|
245 |
+
try:
|
246 |
+
user_id = data.user_id # O ID do estilista no Stripe (deve começar com "acct_")
|
247 |
+
|
248 |
+
if not user_id.startswith("acct_"):
|
249 |
+
raise HTTPException(status_code=400, detail="Invalid user ID format. Must be a Stripe connected account (acct_).")
|
250 |
+
|
251 |
+
try:
|
252 |
+
# Criar o login link para a conta do estilista no Stripe
|
253 |
+
login_link = stripe.Account.create_login_link(user_id)
|
254 |
+
|
255 |
+
return {
|
256 |
+
"status": "success",
|
257 |
+
"dashboard_link": login_link.url # URL do painel do Stripe para edição
|
258 |
+
}
|
259 |
+
|
260 |
+
except stripe.error.StripeError as e:
|
261 |
+
logger.error(f"❌ Error creating login link: {str(e)}")
|
262 |
+
raise HTTPException(status_code=500, detail="Error creating login link for stylist account.")
|
263 |
+
|
264 |
+
except Exception as e:
|
265 |
+
logger.error(f"❌ Error generating bank account dashboard link: {str(e)}")
|
266 |
+
raise HTTPException(status_code=500, detail="Error generating bank account dashboard link.")
|
267 |
+
|
268 |
@router.get("/dashboard")
|
269 |
def get_dashboard(user_token: str = Header(None, alias="User-key"), page: int = Query(0, ge=0)):
|
270 |
try:
|