Files
resolutionflow/backend/app/core/stripe_handlers.py
chihlasm 4ccb93ee31 feat: add account-based subscription model with migrations
Transition from team-based to account-based multi-tenancy (Free/Pro/Team).
Migrations 016-020 create accounts, subscriptions, plan_limits, and
account_invites tables, then migrate existing users and content FKs.

New models: Account, Subscription, PlanLimits, AccountInvite.
Updated models add account_id alongside existing team_id (coexistence
for safe two-PR deployment). Permissions and deps refactored for
account_role instead of is_team_admin.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 02:38:47 -05:00

38 lines
1.3 KiB
Python

"""Stripe webhook event handlers (stub implementations).
These handlers log events but don't process them until Stripe is fully configured.
"""
import logging
from sqlalchemy.ext.asyncio import AsyncSession
logger = logging.getLogger(__name__)
async def handle_checkout_completed(event: dict, db: AsyncSession) -> None:
logger.info("Stripe: checkout.session.completed — %s", event.get("id"))
async def handle_invoice_paid(event: dict, db: AsyncSession) -> None:
logger.info("Stripe: invoice.paid — %s", event.get("id"))
async def handle_invoice_payment_failed(event: dict, db: AsyncSession) -> None:
logger.warning("Stripe: invoice.payment_failed — %s", event.get("id"))
async def handle_subscription_updated(event: dict, db: AsyncSession) -> None:
logger.info("Stripe: customer.subscription.updated — %s", event.get("id"))
async def handle_subscription_deleted(event: dict, db: AsyncSession) -> None:
logger.info("Stripe: customer.subscription.deleted — %s", event.get("id"))
WEBHOOK_HANDLERS = {
"checkout.session.completed": handle_checkout_completed,
"invoice.paid": handle_invoice_paid,
"invoice.payment_failed": handle_invoice_payment_failed,
"customer.subscription.updated": handle_subscription_updated,
"customer.subscription.deleted": handle_subscription_deleted,
}