Files
life-echo/api/app/features/payment/deps.py

29 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from fastapi import Depends
from sqlalchemy.ext.asyncio import AsyncSession
from app.core.db import get_async_db
from app.features.payment.order_service import PaymentOrderService
from app.features.payment.payment_config import PaymentConfig
from app.features.payment.payment_facade import PaymentService
from app.features.plan.deps import get_plan_service
from app.features.plan.service import PlanService
_payment_service = None
def get_payment_service() -> PaymentService:
"""统一支付门面wechat/alipay供 PaymentOrderService 与 startup 使用。"""
global _payment_service
if _payment_service is None:
config = PaymentConfig.from_env()
_payment_service = PaymentService(config)
return _payment_service
def get_payment_order_service(
db: AsyncSession = Depends(get_async_db),
plan_service: PlanService = Depends(get_plan_service),
) -> PaymentOrderService:
"""Payment order facade: create_order, callbacks, list/status."""
return PaymentOrderService(db=db, plan_service=plan_service)