Fix account signup webhook

This commit is contained in:
Jet Li 2025-01-28 08:08:56 +00:00
parent f96ec74176
commit 0b4a4a6173

View File

@ -189,30 +189,22 @@ async def invoke_checkout_session_webhook(event: dict):
@router.post( @router.post(
"/webhook/account", "/webhook/account_signup",
operation_id="stripe_account_webhook", operation_id="stripe_account_webhook",
summary="Handle Stripe account webhook events", summary="Handle Stripe account webhook events",
) )
async def handle_account_webhook( async def handle_account_webhook(
request: Request, request: Request,
stripe_signature: str = Header(None) event: dict
): ):
payload = await request.body()
try: try:
event = stripe.Webhook.construct_event( if event["type"] == 'account.updated':
payload, session = event["data"]["object"]
stripe_signature,
app_settings.STRIPE_WEBHOOK_SECRET
)
# Handle account.updated event
if event.type == 'account.updated':
account = event.data.object
return await payment_hub.handle_account_update( return await payment_hub.handle_account_update(
account_id=account.id, account_id=session["id"],
details_submitted=account.details_submitted, details_submitted=session["details_submitted"],
payouts_enabled=account.payouts_enabled, payouts_enabled=session["payouts_enabled"],
charges_enabled=account.charges_enabled charges_enabled=session["charges_enabled"]
) )
except Exception as e: except Exception as e: