Update routes/hello.py
Browse files- routes/hello.py +11 -4
routes/hello.py
CHANGED
@@ -7,17 +7,24 @@ router = APIRouter()
|
|
7 |
stripe.api_key = "sk_test_51QtyIUPwiMKKxiyaqRrDh4e3JdpE2Ket5p7idABq7dBYhpImMftf4N1IXTWB9yPxoTfb9CxhoBX7a96Sds7CQ9As00E2yf3dyW"
|
8 |
stripe.api_version = "2023-10-16"
|
9 |
|
10 |
-
### **1️⃣ CREATE CONNECTED ACCOUNT
|
11 |
class AccountRequest(BaseModel):
|
12 |
email: str
|
|
|
13 |
|
14 |
@router.post("/create_account")
|
15 |
def create_account(account_data: AccountRequest):
|
16 |
try:
|
17 |
account = stripe.Account.create(
|
18 |
-
type="express",
|
19 |
email=account_data.email,
|
20 |
country="US", # United States
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
capabilities={
|
22 |
"transfers": {"requested": True},
|
23 |
"card_payments": {"requested": True}
|
@@ -36,8 +43,8 @@ def create_account_link(link_data: AccountLinkRequest):
|
|
36 |
try:
|
37 |
account_link = stripe.AccountLink.create(
|
38 |
account=link_data.account_id,
|
39 |
-
return_url="https://yourdomain.com/success",
|
40 |
-
refresh_url="https://yourdomain.com/retry",
|
41 |
type="account_onboarding",
|
42 |
)
|
43 |
return {"url": account_link.url}
|
|
|
7 |
stripe.api_key = "sk_test_51QtyIUPwiMKKxiyaqRrDh4e3JdpE2Ket5p7idABq7dBYhpImMftf4N1IXTWB9yPxoTfb9CxhoBX7a96Sds7CQ9As00E2yf3dyW"
|
8 |
stripe.api_version = "2023-10-16"
|
9 |
|
10 |
+
### **1️⃣ CREATE CONNECTED ACCOUNT** ###
|
11 |
class AccountRequest(BaseModel):
|
12 |
email: str
|
13 |
+
name: str # Now including name in the request body
|
14 |
|
15 |
@router.post("/create_account")
|
16 |
def create_account(account_data: AccountRequest):
|
17 |
try:
|
18 |
account = stripe.Account.create(
|
19 |
+
type="express", # Express account type for individual accounts
|
20 |
email=account_data.email,
|
21 |
country="US", # United States
|
22 |
+
business_type="individual", # Ensuring the account is individual, not business
|
23 |
+
business_profile={
|
24 |
+
"name": account_data.name, # Using the name from the request body
|
25 |
+
"product_description": "We connect U.S. stylists with clients through subscription services.",
|
26 |
+
"support_email": "[email protected]"
|
27 |
+
},
|
28 |
capabilities={
|
29 |
"transfers": {"requested": True},
|
30 |
"card_payments": {"requested": True}
|
|
|
43 |
try:
|
44 |
account_link = stripe.AccountLink.create(
|
45 |
account=link_data.account_id,
|
46 |
+
return_url="https://yourdomain.com/success", # Updated return URL
|
47 |
+
refresh_url="https://yourdomain.com/retry", # Updated refresh URL
|
48 |
type="account_onboarding",
|
49 |
)
|
50 |
return {"url": account_link.url}
|