Update routes/hello.py
Browse files- routes/hello.py +4 -10
routes/hello.py
CHANGED
@@ -7,23 +7,17 @@ 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 |
-
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",
|
20 |
email=account_data.email,
|
21 |
country="US", # United States
|
22 |
-
business_type="individual", # Ensuring the account is individual, not business
|
23 |
-
individual={
|
24 |
-
"first_name": account_data.name, # Individual's first name
|
25 |
-
"last_name": "", # Optional, leave empty for individual accounts
|
26 |
-
},
|
27 |
capabilities={
|
28 |
"transfers": {"requested": True},
|
29 |
"card_payments": {"requested": True}
|
@@ -42,8 +36,8 @@ def create_account_link(link_data: AccountLinkRequest):
|
|
42 |
try:
|
43 |
account_link = stripe.AccountLink.create(
|
44 |
account=link_data.account_id,
|
45 |
-
return_url="https://yourdomain.com/success",
|
46 |
-
refresh_url="https://yourdomain.com/retry",
|
47 |
type="account_onboarding",
|
48 |
)
|
49 |
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 (DEFAULT SETTINGS)** ###
|
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 |
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}
|