refactor: replace direct WeChat/Alipay with unified pay-api gateway
Switch from direct WeChat Pay / Alipay integrations to the unified
宇之然 pay-api gateway (HMAC-SHA256 auth). Removes wechat_pay.py,
keeps PaymentGateway abstraction, adds UnifiedPayService. Simplifies
payment.py create_order to {plan, pay_type} params. Single webhook
endpoint replaces separate WeChat/Alipay notify handlers.
This commit is contained in:
@@ -8,6 +8,7 @@ from app.services.admin import AdminService
|
||||
from app.services.translation_quota import TranslationQuotaService
|
||||
from app.services.certification import CertificationService
|
||||
from app.services.invoice import InvoiceService
|
||||
from app.services.payment import PaymentService
|
||||
from app.api.v1.deps import get_current_user
|
||||
|
||||
router = APIRouter()
|
||||
@@ -274,3 +275,41 @@ async def admin_process_invoice(
|
||||
if not result:
|
||||
raise HTTPException(status_code=404, detail="Invoice not found")
|
||||
return result
|
||||
|
||||
|
||||
@router.get("/payments")
|
||||
async def admin_list_payments(
|
||||
page: int = Query(1, ge=1),
|
||||
size: int = Query(20, ge=1, le=100),
|
||||
gateway: str = Query(default=""),
|
||||
status: str = Query(default=""),
|
||||
user_id: str = Query(default=""),
|
||||
_: dict = Depends(require_admin),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
svc = PaymentService(db)
|
||||
return await svc.admin_list_payments(page, size, gateway, status, user_id)
|
||||
|
||||
|
||||
@router.get("/payments/stats")
|
||||
async def admin_payment_stats(
|
||||
_: dict = Depends(require_admin),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
svc = PaymentService(db)
|
||||
return await svc.admin_payment_stats()
|
||||
|
||||
|
||||
@router.post("/payments/refund")
|
||||
async def admin_refund(
|
||||
data: dict,
|
||||
_: dict = Depends(require_admin),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
order_no = data.get("order_no", "")
|
||||
reason = data.get("reason", "")
|
||||
svc = PaymentService(db)
|
||||
try:
|
||||
return await svc.admin_refund(order_no, reason)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
Reference in New Issue
Block a user