78 lines
2.2 KiB
Python
Executable File
78 lines
2.2 KiB
Python
Executable File
"""
|
||
支付 API 主入口
|
||
支持多支付渠道(XorPay、ZPAY),通过 PAYMENT_PROVIDER 环境变量切换
|
||
|
||
路由模块化,按项目拆分:
|
||
- nomadvip: /nomadvip/* - 固定 ZPAY
|
||
- digital: /digital/* - 使用 PAYMENT_PROVIDER
|
||
- cnomadcna: /cnomadcna/* - 使用 PAYMENT_PROVIDER
|
||
- nomadlms: /nomadlms/* - 使用 PAYMENT_PROVIDER
|
||
- legacy: /payh5、/zpay_notify 等(向后兼容)
|
||
- common: /submit_meetup_application、/create_user
|
||
|
||
本地调试:BASE_URL 需为 ZPAY 可访问地址(如 ngrok)
|
||
线上部署:https://api.hackrobot.cn
|
||
"""
|
||
import logging
|
||
|
||
from fastapi import FastAPI
|
||
from fastapi.middleware.cors import CORSMiddleware
|
||
|
||
from .routers import (
|
||
nomadvip_router,
|
||
digital_router,
|
||
cnomadcna_router,
|
||
nomadlms_router,
|
||
legacy_router,
|
||
common_router,
|
||
)
|
||
|
||
app = FastAPI(
|
||
title="PayJS API",
|
||
description="nomadvip / digital / cnomadcna / nomadlms 支付接口",
|
||
version="2.0",
|
||
)
|
||
|
||
app.add_middleware(
|
||
CORSMiddleware,
|
||
allow_origins=["*"],
|
||
allow_credentials=False,
|
||
allow_methods=["*"],
|
||
allow_headers=["*"],
|
||
)
|
||
|
||
# 日志
|
||
logging.basicConfig(
|
||
level=logging.INFO,
|
||
format="%(asctime)s - %(message)s",
|
||
handlers=[
|
||
logging.FileHandler("payment_notify.log"),
|
||
logging.StreamHandler(),
|
||
],
|
||
)
|
||
|
||
# 挂载路由
|
||
app.include_router(nomadvip_router)
|
||
app.include_router(digital_router)
|
||
app.include_router(cnomadcna_router)
|
||
app.include_router(nomadlms_router)
|
||
app.include_router(legacy_router)
|
||
app.include_router(common_router)
|
||
|
||
|
||
@app.get("/")
|
||
async def root():
|
||
"""健康检查"""
|
||
return {
|
||
"status": "ok",
|
||
"service": "payjsapi",
|
||
"routes": {
|
||
"nomadvip": "/nomadvip/payh5, /nomadvip/payh5/redirect, /nomadvip/zpay_order_status, /nomadvip/zpay_notify",
|
||
"digital": "/digital/payh5, /digital/payh5/redirect, /digital/zpay_order_status, /digital/zpay_notify, /digital/xorpay_notify",
|
||
"cnomadcna": "/cnomadcna/payh5, ...",
|
||
"nomadlms": "/nomadlms/payh5, ...",
|
||
"legacy": "/payh5, /payh5/redirect, /zpay_notify, /xorpay_notify, /zpay_order_status",
|
||
"common": "/submit_meetup_application, /create_user",
|
||
},
|
||
}
|