Align avatar recharge plan IDs with WeChat virtual products
This commit is contained in:
@@ -46,6 +46,13 @@ router = APIRouter(tags=["Token"])
|
||||
|
||||
PAYMENT_METHODS = {"wechat": "WECHAT", "alipay": "ALIPAY"}
|
||||
PAYMENT_SCENES = {"APP", "H5", "LITE", "JSAPI"}
|
||||
LEGACY_PLAN_IDS = {"1": "Basic", "2": "Standard", "3": "Professional", "4": "Enterprise"}
|
||||
|
||||
|
||||
def _selected_plan(db: Session, plan_id):
|
||||
return db.query(TokenPlan).filter(TokenPlan.id == LEGACY_PLAN_IDS.get(str(plan_id), plan_id)).first()
|
||||
|
||||
|
||||
SUCCESS_STATUSES = {"SUCCESS", "SUCCEEDED", "PAID", "COMPLETED", "TRADE_SUCCESS"}
|
||||
FAILED_STATUSES = {"FAIL", "FAILED", "CLOSED", "CANCELLED", "CANCELED", "EXPIRED"}
|
||||
|
||||
@@ -307,7 +314,7 @@ def plans(authorization: str = Header(None), db: Session = Depends(get_db)):
|
||||
@router.post("/token/charge")
|
||||
def charge(payload: dict = Body(...), authorization: str = Header(None), db: Session = Depends(get_db)):
|
||||
user = _require_user(authorization, db)
|
||||
plan = db.query(TokenPlan).filter(TokenPlan.id == payload.get("planId")).first()
|
||||
plan = _selected_plan(db, payload.get("planId"))
|
||||
if not plan:
|
||||
return fail("套餐不存在", 404)
|
||||
|
||||
@@ -410,7 +417,7 @@ def charge(payload: dict = Body(...), authorization: str = Header(None), db: Ses
|
||||
@router.post("/token/charge/org")
|
||||
def charge_via_huihui_org(payload: dict = Body(...), authorization: str = Header(None), db: Session = Depends(get_db)):
|
||||
user = _require_user(authorization, db)
|
||||
plan = db.query(TokenPlan).filter(TokenPlan.id == payload.get("planId")).first()
|
||||
plan = _selected_plan(db, payload.get("planId"))
|
||||
if not plan:
|
||||
return fail("套餐不存在", 404)
|
||||
method = str(payload.get("paymentMethod") or "").lower()
|
||||
|
||||
Reference in New Issue
Block a user