Update payment micro-service
This commit is contained in:
parent
45df1e97fd
commit
d47823124f
@ -18,8 +18,8 @@ class PaymentHub:
|
|||||||
async def create_stripe_account(self) -> Optional[str]:
|
async def create_stripe_account(self) -> Optional[str]:
|
||||||
return await self.stripe_manager.create_stripe_account()
|
return await self.stripe_manager.create_stripe_account()
|
||||||
|
|
||||||
async def create_account_link(self, account_id: str) -> Optional[str]:
|
async def create_account_link(self, account_id: str, link_type: str = "account_onboarding") -> Optional[str]:
|
||||||
return await self.stripe_manager.create_account_link(account_id)
|
return await self.stripe_manager.create_account_link(account_id, link_type)
|
||||||
|
|
||||||
async def can_account_receive_payments(self, account_id: str) -> bool:
|
async def can_account_receive_payments(self, account_id: str) -> bool:
|
||||||
return await self.stripe_manager.can_account_receive_payments(account_id)
|
return await self.stripe_manager.can_account_receive_payments(account_id)
|
||||||
|
|||||||
@ -22,12 +22,22 @@ class StripeManager:
|
|||||||
account = stripe.Account.create(type="standard")
|
account = stripe.Account.create(type="standard")
|
||||||
return account.id
|
return account.id
|
||||||
|
|
||||||
async def create_account_link(self, account_id: str) -> Optional[str]:
|
async def create_account_link(self, account_id: str, link_type: str = "account_onboarding") -> Optional[str]:
|
||||||
|
account = stripe.Account.retrieve(account_id)
|
||||||
|
|
||||||
|
# For account_update, try to show dashboard if TOS is accepted
|
||||||
|
if link_type == "account_update" and account.tos_acceptance.date:
|
||||||
|
login_link = stripe.Account.create_login_link(
|
||||||
|
account_id,
|
||||||
|
redirect_url="{}/work".format(self.site_url_root)
|
||||||
|
)
|
||||||
|
return login_link.url
|
||||||
|
|
||||||
|
# Otherwise show onboarding
|
||||||
account_link = stripe.AccountLink.create(
|
account_link = stripe.AccountLink.create(
|
||||||
account=account_id,
|
account=account_id,
|
||||||
refresh_url="{}/front-door".format(self.site_url_root),
|
refresh_url="{}/front-door".format(self.site_url_root),
|
||||||
return_url="{}/user-profile".format(self.site_url_root),
|
return_url="{}/work".format(self.site_url_root),
|
||||||
type="account_onboarding",
|
type="account_onboarding",
|
||||||
)
|
)
|
||||||
return account_link.url
|
return account_link.url
|
||||||
|
|||||||
@ -29,8 +29,8 @@ async def create_stripe_account():
|
|||||||
summary="Create account link",
|
summary="Create account link",
|
||||||
description="Create account link",
|
description="Create account link",
|
||||||
)
|
)
|
||||||
async def create_account_link(account_id: str):
|
async def create_account_link(account_id: str, link_type: str = "account_onboarding"):
|
||||||
return await payment_hub.create_account_link(account_id)
|
return await payment_hub.create_account_link(account_id, link_type)
|
||||||
|
|
||||||
|
|
||||||
# Web API
|
# Web API
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user