Align avatar recharge plan IDs with WeChat virtual products

This commit is contained in:
stefanfeng
2026-10-19 14:00:06 +08:00
parent 5f27cc93cc
commit 3379d5a1b2
8 changed files with 73 additions and 32 deletions
@@ -49,9 +49,7 @@ def _offer_id() -> str:
def product_id_for_plan(plan) -> str:
configured = str(getattr(plan, "virtual_product_id", "") or "").strip()
if not configured:
configured = os.getenv(f"WECHAT_VIRTUAL_PRODUCT_{plan.id}", "").strip()
configured = str(getattr(plan, "id", "") or "").strip()
if not configured:
raise WechatVirtualPaymentError(f"套餐 {plan.id} 尚未配置微信虚拟支付商品 ID")
if len(configured) > 64 or not all(ch.isalnum() or ch in "_-" for ch in configured):