habulaj commited on
Commit
9a274ef
·
verified ·
1 Parent(s): 5f45a50

Update routes/hello.py

Browse files
Files changed (1) hide show
  1. routes/hello.py +8 -12
routes/hello.py CHANGED
@@ -1,26 +1,22 @@
1
  import stripe
2
- from fastapi import FastAPI, HTTPException
3
- from routes.hello import router as hello_router
4
  from pydantic import BaseModel
5
 
6
- app = FastAPI()
7
 
8
- # Incluindo a rota separada
9
- app.include_router(hello_router)
10
-
11
- stripe.api_key = "sk_test_51N6K5JB9VMe0qzbOjlJvMEsfdQyrFgV49vRaeErtmhrzHV3Cu3f5jMDJmrhKdI5uqvpHubjkmwDQgMOtCEmz19t800AouH7W6g"
12
  stripe.api_version = "2023-10-16"
13
 
14
  class AccountRequest(BaseModel):
15
  email: str
16
 
17
- @app.post("/create_account")
18
  def create_account(account_data: AccountRequest):
19
  try:
20
  account = stripe.Account.create(
21
  type="express",
22
  email=account_data.email,
23
- country="BR", # Ajuste para o país correto
24
  capabilities={"transfers": {"requested": True}},
25
  )
26
  return {"account_id": account.id}
@@ -30,13 +26,13 @@ def create_account(account_data: AccountRequest):
30
  class AccountLinkRequest(BaseModel):
31
  account_id: str
32
 
33
- @app.post("/account_link")
34
  def create_account_link(link_data: AccountLinkRequest):
35
  try:
36
  account_link = stripe.AccountLink.create(
37
  account=link_data.account_id,
38
- return_url=f"http://localhost:4242/success",
39
- refresh_url=f"http://localhost:4242/retry",
40
  type="account_onboarding",
41
  )
42
  return {"url": account_link.url}
 
1
  import stripe
2
+ from fastapi import APIRouter, HTTPException
 
3
  from pydantic import BaseModel
4
 
5
+ router = APIRouter()
6
 
7
+ stripe.api_key = "sk_test_SUA_SECRET_KEY"
 
 
 
8
  stripe.api_version = "2023-10-16"
9
 
10
  class AccountRequest(BaseModel):
11
  email: str
12
 
13
+ @router.post("/create_account")
14
  def create_account(account_data: AccountRequest):
15
  try:
16
  account = stripe.Account.create(
17
  type="express",
18
  email=account_data.email,
19
+ country="BR",
20
  capabilities={"transfers": {"requested": True}},
21
  )
22
  return {"account_id": account.id}
 
26
  class AccountLinkRequest(BaseModel):
27
  account_id: str
28
 
29
+ @router.post("/account_link")
30
  def create_account_link(link_data: AccountLinkRequest):
31
  try:
32
  account_link = stripe.AccountLink.create(
33
  account=link_data.account_id,
34
+ return_url="http://localhost:4242/success",
35
+ refresh_url="http://localhost:4242/retry",
36
  type="account_onboarding",
37
  )
38
  return {"url": account_link.url}