Update WeChat virtual pay OfferID and AppKeys; document miniprogram props.
Switch pay signing to sandbox/live AppKey by WX_PAY_ENV and record the product catalog. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
525fbf7766
commit
b845d0bcea
16
.env.example
16
.env.example
@ -14,12 +14,16 @@ NOMADRO_ADMIN_SESSION_SECRET=change-me-session
|
|||||||
|
|
||||||
# WeChat miniprogram virtual pay (apps/api)
|
# WeChat miniprogram virtual pay (apps/api)
|
||||||
WX_APPID=wx11f6afc44ea1532f
|
WX_APPID=wx11f6afc44ea1532f
|
||||||
WX_APPSECRET=04214ecc910dca4526781c90bae94da1
|
WX_SECRET=04214ecc910dca4526781c90bae94da1
|
||||||
WX_OFFER_ID=1450642200
|
WX_OFFER_ID=1450705308
|
||||||
WX_SANDBOX_APPKEY=0wB3HV3sfKVTEgomZ6BIbgsN8Mlbv5Bn
|
WX_APP_KEY=JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY
|
||||||
WX_LIVE_APPKEY=CBi5tdkkSWuvkDvWJNnSjrGmeYE3xlsg
|
WX_SANDBOX_APP_KEY=BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi
|
||||||
# 1=sandbox 0=live
|
# 0=现网 1=沙箱
|
||||||
WX_PAY_ENV=1
|
WX_PAY_ENV=0
|
||||||
|
|
||||||
|
# 公众号 userid 档案:读 vip.hackrobot.cn wechat-profile;可选 VIP 运营 token 拉全量列表
|
||||||
|
# VIP_WEB_API_BASE=https://vip.hackrobot.cn
|
||||||
|
# VIP_OPS_TOKEN=
|
||||||
|
|
||||||
# Observability (production)
|
# Observability (production)
|
||||||
# NOMADRO_PUBLIC_ORIGIN=https://nomadro.com
|
# NOMADRO_PUBLIC_ORIGIN=https://nomadro.com
|
||||||
|
|||||||
@ -115,9 +115,9 @@ def main() -> None:
|
|||||||
|
|
||||||
env_content = """WX_APPID=wx11f6afc44ea1532f
|
env_content = """WX_APPID=wx11f6afc44ea1532f
|
||||||
WX_SECRET=04214ecc910dca4526781c90bae94da1
|
WX_SECRET=04214ecc910dca4526781c90bae94da1
|
||||||
WX_OFFER_ID=1450642200
|
WX_OFFER_ID=1450705308
|
||||||
WX_APP_KEY=CBi5tdkkSWuvkDvWJNnSjrGmeYE3xlsg
|
WX_APP_KEY=JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY
|
||||||
WX_SANDBOX_APP_KEY=0wB3HV3sfKVTEgomZ6BIbgsN8Mlbv5Bn
|
WX_SANDBOX_APP_KEY=BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi
|
||||||
WX_PAY_ENV=0
|
WX_PAY_ENV=0
|
||||||
JWT_SECRET=nomadro-jwt-prod-2026
|
JWT_SECRET=nomadro-jwt-prod-2026
|
||||||
ADMIN_USERNAME=hackrobot
|
ADMIN_USERNAME=hackrobot
|
||||||
|
|||||||
@ -23,12 +23,12 @@ class Settings(BaseSettings):
|
|||||||
"http://localhost:5173,http://127.0.0.1:5173,http://localhost:3000,http://127.0.0.1:3000"
|
"http://localhost:5173,http://127.0.0.1:5173,http://localhost:3000,http://127.0.0.1:3000"
|
||||||
)
|
)
|
||||||
|
|
||||||
# WeChat
|
# WeChat 虚拟支付(AppID wx11f6afc44ea1532f · OfferID 1450705308)
|
||||||
wx_appid: str = "wx11f6afc44ea1532f"
|
wx_appid: str = "wx11f6afc44ea1532f"
|
||||||
wx_secret: str = "04214ecc910dca4526781c90bae94da1"
|
wx_secret: str = "04214ecc910dca4526781c90bae94da1"
|
||||||
wx_offer_id: str = "1450642200"
|
wx_offer_id: str = "1450705308"
|
||||||
wx_app_key: str = "CBi5tdkkSWuvkDvWJNnSjrGmeYE3xlsg"
|
wx_app_key: str = "JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY" # 现网
|
||||||
wx_sandbox_app_key: str = "0wB3HV3sfKVTEgomZ6BIbgsN8Mlbv5Bn"
|
wx_sandbox_app_key: str = "BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi" # 沙箱
|
||||||
wx_pay_env: int = 0 # 0 现网 / 1 沙箱
|
wx_pay_env: int = 0 # 0 现网 / 1 沙箱
|
||||||
|
|
||||||
# JWT / Admin
|
# JWT / Admin
|
||||||
@ -48,6 +48,11 @@ class Settings(BaseSettings):
|
|||||||
# 开启:环境变量 VIP_WEB_BRIDGE_ENABLED=true
|
# 开启:环境变量 VIP_WEB_BRIDGE_ENABLED=true
|
||||||
vip_web_bridge_enabled: bool = False
|
vip_web_bridge_enabled: bool = False
|
||||||
vip_web_api_base: str = "https://vip.hackrobot.cn"
|
vip_web_api_base: str = "https://vip.hackrobot.cn"
|
||||||
|
# 可选:代理 vip.hackrobot.cn/api/wechat-users(运营台 token);空则自动登录 ops
|
||||||
|
vip_ops_token: str = ""
|
||||||
|
vip_ops_login_url: str = "https://admin.hackrobot.cn/api/ops/login"
|
||||||
|
vip_ops_username: str = "hackrobot"
|
||||||
|
vip_ops_password: str = "Xiao4669805@"
|
||||||
|
|
||||||
# 抖音 platforms.tt 写入路径(默认自动探测门户 remote-config.json)
|
# 抖音 platforms.tt 写入路径(默认自动探测门户 remote-config.json)
|
||||||
tt_remote_config_path: str = ""
|
tt_remote_config_path: str = ""
|
||||||
|
|||||||
@ -18,7 +18,7 @@ from ebook_svc.services.shop_store import shop_store
|
|||||||
from ebook_svc.services.store import store
|
from ebook_svc.services.store import store
|
||||||
from ebook_svc.services.social_join_config import SOCIAL_JOIN_BOOK_ID, read_social_join_config
|
from ebook_svc.services.social_join_config import SOCIAL_JOIN_BOOK_ID, read_social_join_config
|
||||||
from ebook_svc.services.vip_config import read_vip_config
|
from ebook_svc.services.vip_config import read_vip_config
|
||||||
from ebook_svc.services.wxpay import build_sign_data, calc_pay_sig, calc_signature, query_order
|
from ebook_svc.services.wxpay import active_wx_app_key, build_sign_data, calc_pay_sig, calc_signature, query_order
|
||||||
|
|
||||||
router = APIRouter(prefix="/pay", tags=["pay"])
|
router = APIRouter(prefix="/pay", tags=["pay"])
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ def _build_vip_order_payload(openid: str) -> dict[str, Any]:
|
|||||||
out_trade_no=out_trade_no,
|
out_trade_no=out_trade_no,
|
||||||
attach=attach,
|
attach=attach,
|
||||||
)
|
)
|
||||||
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, settings.wx_app_key)
|
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, active_wx_app_key())
|
||||||
signature = calc_signature(sign_data, user["session_key"])
|
signature = calc_signature(sign_data, user["session_key"])
|
||||||
return {
|
return {
|
||||||
"signData": sign_data,
|
"signData": sign_data,
|
||||||
@ -216,7 +216,7 @@ def _build_social_join_order_payload(openid: str) -> dict[str, Any]:
|
|||||||
out_trade_no=out_trade_no,
|
out_trade_no=out_trade_no,
|
||||||
attach=attach,
|
attach=attach,
|
||||||
)
|
)
|
||||||
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, settings.wx_app_key)
|
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, active_wx_app_key())
|
||||||
signature = calc_signature(sign_data, user["session_key"])
|
signature = calc_signature(sign_data, user["session_key"])
|
||||||
return {
|
return {
|
||||||
"signData": sign_data,
|
"signData": sign_data,
|
||||||
@ -369,7 +369,7 @@ async def create_shop_pay_order(
|
|||||||
out_trade_no=out_trade_no,
|
out_trade_no=out_trade_no,
|
||||||
attach=attach,
|
attach=attach,
|
||||||
)
|
)
|
||||||
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, settings.wx_app_key)
|
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, active_wx_app_key())
|
||||||
signature = calc_signature(sign_data, user["session_key"])
|
signature = calc_signature(sign_data, user["session_key"])
|
||||||
return {
|
return {
|
||||||
"signData": sign_data,
|
"signData": sign_data,
|
||||||
@ -428,7 +428,7 @@ async def create_pay_order(
|
|||||||
out_trade_no=out_trade_no,
|
out_trade_no=out_trade_no,
|
||||||
attach=attach,
|
attach=attach,
|
||||||
)
|
)
|
||||||
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, settings.wx_app_key)
|
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, active_wx_app_key())
|
||||||
signature = calc_signature(sign_data, user["session_key"])
|
signature = calc_signature(sign_data, user["session_key"])
|
||||||
try:
|
try:
|
||||||
from ebook_svc.services.track import ingest_events
|
from ebook_svc.services.track import ingest_events
|
||||||
|
|||||||
@ -10,6 +10,14 @@ import httpx
|
|||||||
from ebook_svc.config import settings
|
from ebook_svc.config import settings
|
||||||
|
|
||||||
|
|
||||||
|
def active_wx_app_key(*, env: int | None = None) -> str:
|
||||||
|
"""按 WX_PAY_ENV 选用现网 / 沙箱 AppKey。"""
|
||||||
|
use_env = settings.wx_pay_env if env is None else env
|
||||||
|
if int(use_env) == 1:
|
||||||
|
return (settings.wx_sandbox_app_key or settings.wx_app_key or "").strip()
|
||||||
|
return (settings.wx_app_key or "").strip()
|
||||||
|
|
||||||
|
|
||||||
def calc_pay_sig(uri: str, post_body: str, appkey: str) -> str:
|
def calc_pay_sig(uri: str, post_body: str, appkey: str) -> str:
|
||||||
"""uri 不带问号参数。C 端固定 requestVirtualPayment;B 端为 /xpay/* 路径。"""
|
"""uri 不带问号参数。C 端固定 requestVirtualPayment;B 端为 /xpay/* 路径。"""
|
||||||
msg = f"{uri}&{post_body}"
|
msg = f"{uri}&{post_body}"
|
||||||
@ -112,7 +120,7 @@ async def query_order(openid: str, out_trade_no: str) -> dict[str, Any]:
|
|||||||
"""POST /xpay/query_order,带 pay_sig。"""
|
"""POST /xpay/query_order,带 pay_sig。"""
|
||||||
body_obj = {"openid": openid, "env": settings.wx_pay_env, "order_id": out_trade_no}
|
body_obj = {"openid": openid, "env": settings.wx_pay_env, "order_id": out_trade_no}
|
||||||
post_body = json.dumps(body_obj, ensure_ascii=False, separators=(",", ":"))
|
post_body = json.dumps(body_obj, ensure_ascii=False, separators=(",", ":"))
|
||||||
pay_sig = calc_pay_sig("/xpay/query_order", post_body, settings.wx_app_key)
|
pay_sig = calc_pay_sig("/xpay/query_order", post_body, active_wx_app_key())
|
||||||
token = await get_access_token()
|
token = await get_access_token()
|
||||||
url = f"https://api.weixin.qq.com/xpay/query_order?access_token={token}&pay_sig={pay_sig}"
|
url = f"https://api.weixin.qq.com/xpay/query_order?access_token={token}&pay_sig={pay_sig}"
|
||||||
async with httpx.AsyncClient(timeout=20) as client:
|
async with httpx.AsyncClient(timeout=20) as client:
|
||||||
|
|||||||
@ -1,25 +1,14 @@
|
|||||||
WX_APPID=wxa55815dd741a540d
|
WX_APPID=wx11f6afc44ea1532f
|
||||||
WX_SECRET=bf71025c209e7567d49268bc427ba22b
|
WX_SECRET=04214ecc910dca4526781c90bae94da1
|
||||||
WX_OFFER_ID=1450642200
|
WX_OFFER_ID=1450705308
|
||||||
WX_APP_KEY=CBi5tdkkSWuvkDvWJNnSjrGmeYE3xlsg
|
WX_APP_KEY=JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY
|
||||||
WX_SANDBOX_APP_KEY=0wB3HV3sfKVTEgomZ6BIbgsN8Mlbv5Bn
|
WX_SANDBOX_APP_KEY=BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi
|
||||||
WX_PAY_ENV=0
|
WX_PAY_ENV=0
|
||||||
JWT_SECRET=nomadro-jwt-local-dev-2026
|
JWT_SECRET=change-me
|
||||||
ADMIN_USERNAME=admin
|
ADMIN_USERNAME=hackrobot
|
||||||
ADMIN_PASSWORD=Xiao4669805
|
ADMIN_PASSWORD=change-me
|
||||||
PB_URL=http://127.0.0.1:8090
|
PB_URL=http://127.0.0.1:8090
|
||||||
PB_ADMIN_EMAIL=admin@nomadro.cn
|
|
||||||
PB_ADMIN_PASSWORD=Xiao4669805
|
|
||||||
USE_POCKETBASE=false
|
USE_POCKETBASE=false
|
||||||
|
DEBUG=false
|
||||||
PUBLIC_API_BASE=https://api.nomadro.cn
|
PUBLIC_API_BASE=https://api.nomadro.cn
|
||||||
ADMIN_ORIGIN=https://admin.nomadro.cn
|
ADMIN_ORIGIN=https://admin.nomadro.cn
|
||||||
CORS_ORIGINS=https://admin.nomadro.cn,http://localhost:5173,http://127.0.0.1:5173,http://localhost:8000
|
|
||||||
DEFAULT_PRODUCT_ID=ebook_unlock_default
|
|
||||||
DEFAULT_PRICE_FEN=18800
|
|
||||||
DEFAULT_UNLOCK_PERCENT=30
|
|
||||||
SQLITE_PATH=../data/nomadmini.db
|
|
||||||
WX_PUSH_TOKEN=hackrobot
|
|
||||||
WX_PUSH_ENCODING_AES_KEY=ulnyydH8LF4uWmdpzSgUiWS6hVXp1V3wp26MhEYeHkI
|
|
||||||
WX_ALLOW_DEVTOOLS_LOGIN=true
|
|
||||||
DEBUG=true
|
|
||||||
API_PORT=8000
|
|
||||||
|
|||||||
@ -12,12 +12,12 @@ class Settings(BaseSettings):
|
|||||||
admin_origin: str = "https://admin.nomadro.cn"
|
admin_origin: str = "https://admin.nomadro.cn"
|
||||||
cors_origins: str = "https://admin.nomadro.cn,http://localhost:5173,http://127.0.0.1:5173"
|
cors_origins: str = "https://admin.nomadro.cn,http://localhost:5173,http://127.0.0.1:5173"
|
||||||
|
|
||||||
# WeChat
|
# WeChat 虚拟支付(与 Nomadro 小程序对齐)
|
||||||
wx_appid: str = "wxa55815dd741a540d"
|
wx_appid: str = "wx11f6afc44ea1532f"
|
||||||
wx_secret: str = "bf71025c209e7567d49268bc427ba22b"
|
wx_secret: str = "04214ecc910dca4526781c90bae94da1"
|
||||||
wx_offer_id: str = "1450642200"
|
wx_offer_id: str = "1450705308"
|
||||||
wx_app_key: str = "CBi5tdkkSWuvkDvWJNnSjrGmeYE3xlsg"
|
wx_app_key: str = "JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY" # 现网
|
||||||
wx_sandbox_app_key: str = "0wB3HV3sfKVTEgomZ6BIbgsN8Mlbv5Bn"
|
wx_sandbox_app_key: str = "BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi" # 沙箱
|
||||||
wx_pay_env: int = 0 # 0 现网 / 1 沙箱
|
wx_pay_env: int = 0 # 0 现网 / 1 沙箱
|
||||||
|
|
||||||
# JWT / Admin
|
# JWT / Admin
|
||||||
|
|||||||
@ -18,7 +18,7 @@ from app.services.shop_store import shop_store
|
|||||||
from app.services.store import store
|
from app.services.store import store
|
||||||
from app.services.social_join_config import SOCIAL_JOIN_BOOK_ID, read_social_join_config
|
from app.services.social_join_config import SOCIAL_JOIN_BOOK_ID, read_social_join_config
|
||||||
from app.services.vip_config import read_vip_config
|
from app.services.vip_config import read_vip_config
|
||||||
from app.services.wxpay import build_sign_data, calc_pay_sig, calc_signature, query_order
|
from app.services.wxpay import active_wx_app_key, build_sign_data, calc_pay_sig, calc_signature, query_order
|
||||||
|
|
||||||
router = APIRouter(prefix="/pay", tags=["pay"])
|
router = APIRouter(prefix="/pay", tags=["pay"])
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ def _build_vip_order_payload(openid: str) -> dict[str, Any]:
|
|||||||
out_trade_no=out_trade_no,
|
out_trade_no=out_trade_no,
|
||||||
attach=attach,
|
attach=attach,
|
||||||
)
|
)
|
||||||
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, settings.wx_app_key)
|
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, active_wx_app_key())
|
||||||
signature = calc_signature(sign_data, user["session_key"])
|
signature = calc_signature(sign_data, user["session_key"])
|
||||||
return {
|
return {
|
||||||
"signData": sign_data,
|
"signData": sign_data,
|
||||||
@ -216,7 +216,7 @@ def _build_social_join_order_payload(openid: str) -> dict[str, Any]:
|
|||||||
out_trade_no=out_trade_no,
|
out_trade_no=out_trade_no,
|
||||||
attach=attach,
|
attach=attach,
|
||||||
)
|
)
|
||||||
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, settings.wx_app_key)
|
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, active_wx_app_key())
|
||||||
signature = calc_signature(sign_data, user["session_key"])
|
signature = calc_signature(sign_data, user["session_key"])
|
||||||
return {
|
return {
|
||||||
"signData": sign_data,
|
"signData": sign_data,
|
||||||
@ -369,7 +369,7 @@ async def create_shop_pay_order(
|
|||||||
out_trade_no=out_trade_no,
|
out_trade_no=out_trade_no,
|
||||||
attach=attach,
|
attach=attach,
|
||||||
)
|
)
|
||||||
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, settings.wx_app_key)
|
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, active_wx_app_key())
|
||||||
signature = calc_signature(sign_data, user["session_key"])
|
signature = calc_signature(sign_data, user["session_key"])
|
||||||
return {
|
return {
|
||||||
"signData": sign_data,
|
"signData": sign_data,
|
||||||
@ -428,7 +428,7 @@ async def create_pay_order(
|
|||||||
out_trade_no=out_trade_no,
|
out_trade_no=out_trade_no,
|
||||||
attach=attach,
|
attach=attach,
|
||||||
)
|
)
|
||||||
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, settings.wx_app_key)
|
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, active_wx_app_key())
|
||||||
signature = calc_signature(sign_data, user["session_key"])
|
signature = calc_signature(sign_data, user["session_key"])
|
||||||
try:
|
try:
|
||||||
from app.services.track import ingest_events
|
from app.services.track import ingest_events
|
||||||
|
|||||||
@ -10,6 +10,14 @@ import httpx
|
|||||||
from app.config import settings
|
from app.config import settings
|
||||||
|
|
||||||
|
|
||||||
|
def active_wx_app_key(*, env: int | None = None) -> str:
|
||||||
|
"""按 WX_PAY_ENV 选用现网 / 沙箱 AppKey。"""
|
||||||
|
use_env = settings.wx_pay_env if env is None else env
|
||||||
|
if int(use_env) == 1:
|
||||||
|
return (settings.wx_sandbox_app_key or settings.wx_app_key or "").strip()
|
||||||
|
return (settings.wx_app_key or "").strip()
|
||||||
|
|
||||||
|
|
||||||
def calc_pay_sig(uri: str, post_body: str, appkey: str) -> str:
|
def calc_pay_sig(uri: str, post_body: str, appkey: str) -> str:
|
||||||
"""uri 不带问号参数。C 端固定 requestVirtualPayment;B 端为 /xpay/* 路径。"""
|
"""uri 不带问号参数。C 端固定 requestVirtualPayment;B 端为 /xpay/* 路径。"""
|
||||||
msg = f"{uri}&{post_body}"
|
msg = f"{uri}&{post_body}"
|
||||||
@ -112,7 +120,7 @@ async def query_order(openid: str, out_trade_no: str) -> dict[str, Any]:
|
|||||||
"""POST /xpay/query_order,带 pay_sig。"""
|
"""POST /xpay/query_order,带 pay_sig。"""
|
||||||
body_obj = {"openid": openid, "env": settings.wx_pay_env, "order_id": out_trade_no}
|
body_obj = {"openid": openid, "env": settings.wx_pay_env, "order_id": out_trade_no}
|
||||||
post_body = json.dumps(body_obj, ensure_ascii=False, separators=(",", ":"))
|
post_body = json.dumps(body_obj, ensure_ascii=False, separators=(",", ":"))
|
||||||
pay_sig = calc_pay_sig("/xpay/query_order", post_body, settings.wx_app_key)
|
pay_sig = calc_pay_sig("/xpay/query_order", post_body, active_wx_app_key())
|
||||||
token = await get_access_token()
|
token = await get_access_token()
|
||||||
url = f"https://api.weixin.qq.com/xpay/query_order?access_token={token}&pay_sig={pay_sig}"
|
url = f"https://api.weixin.qq.com/xpay/query_order?access_token={token}&pay_sig={pay_sig}"
|
||||||
async with httpx.AsyncClient(timeout=20) as client:
|
async with httpx.AsyncClient(timeout=20) as client:
|
||||||
|
|||||||
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
业务 API:`apps/api`。管理后台:`apps/admin`。
|
业务 API:`apps/api`。管理后台:`apps/admin`。
|
||||||
|
|
||||||
|
微信虚拟支付 / 道具目录:[`docs/wechat-virtual-pay-props.md`](docs/wechat-virtual-pay-props.md)。
|
||||||
|
|
||||||
**全端禁止 web-view 承载业务内容**(VIP / 电子书 / 视频课等须原生页)。微信 VIP 说明见 `weapp/README.md`。
|
**全端禁止 web-view 承载业务内容**(VIP / 电子书 / 视频课等须原生页)。微信 VIP 说明见 `weapp/README.md`。
|
||||||
|
|
||||||
H5 游戏模块冷冻,默认勿改。
|
H5 游戏模块冷冻,默认勿改。
|
||||||
|
|||||||
55
apps/miniprogram/docs/wechat-virtual-pay-props.md
Normal file
55
apps/miniprogram/docs/wechat-virtual-pay-props.md
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# 微信小程序虚拟支付 · 账号与道具
|
||||||
|
|
||||||
|
SoT 代码:`apps/api/services/ebook_svc/domains/books/products.py`
|
||||||
|
支付签名:`apps/api/services/ebook_svc/services/wxpay.py`(`WX_PAY_ENV=0` 现网 / `1` 沙箱自动选 AppKey)
|
||||||
|
|
||||||
|
## 账号
|
||||||
|
|
||||||
|
| 项 | 值 |
|
||||||
|
|---|---|
|
||||||
|
| AppID(小程序) | `wx11f6afc44ea1532f` |
|
||||||
|
| OfferID(支付应用) | `1450705308` |
|
||||||
|
| 现网 AppKey | `JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY` |
|
||||||
|
| 沙箱 AppKey | `BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi` |
|
||||||
|
|
||||||
|
环境变量(`apps/api` / `.env`):
|
||||||
|
|
||||||
|
```env
|
||||||
|
WX_APPID=wx11f6afc44ea1532f
|
||||||
|
WX_SECRET=…
|
||||||
|
WX_OFFER_ID=1450705308
|
||||||
|
WX_APP_KEY=JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY
|
||||||
|
WX_SANDBOX_APP_KEY=BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi
|
||||||
|
WX_PAY_ENV=0
|
||||||
|
```
|
||||||
|
|
||||||
|
微信后台路径:**支付与交易 → 虚拟支付 → 道具管理**(须与下表 `product_id` / 价格一致后再发版)。
|
||||||
|
|
||||||
|
## 道具目录(Nomadro 小程序)
|
||||||
|
|
||||||
|
| key | 道具 ID (`productId`) | 价格 | 试读% | 图 | 说明 |
|
||||||
|
|---|---|---|---|---|---|
|
||||||
|
| `free` | (空) | 免费 | 100 | — | 不拉起支付 |
|
||||||
|
| `tiktok` | `tiktok` | ¥88(8800 分) | 30 | `props/tiktok.png` | 已发布 |
|
||||||
|
| `youtube` | `youtube` | ¥188(18800 分) | 30 | `props/youtube.png` | 默认付费方案 |
|
||||||
|
| `nomad` | `nomad` | ¥49(4900 分) | 30 | `props/nomad.png` | 已发布 |
|
||||||
|
| `svip` | `svip` | ¥998(99800 分) | 30 | `props/svip.png` | 已发布 |
|
||||||
|
| `ebook` | `ebook_unlock_default` | ¥188(18800 分) | 30 | `props/ebook.png` | 旧默认道具 |
|
||||||
|
| `test` | `test` | ¥1(100 分) | 30 | `props/test.png` | 联调;须在 MP 发布 |
|
||||||
|
|
||||||
|
后台图标目录:`apps/admin/public/props/`。
|
||||||
|
|
||||||
|
遗留数字 ID 映射(旧订单兼容):`298→tiktok`、`188→youtube`、`49→nomad`、`998→svip`。
|
||||||
|
|
||||||
|
## 调用链
|
||||||
|
|
||||||
|
1. 小程序下单 → `POST /pay/...`(`apps/api` ebook_svc)
|
||||||
|
2. 服务端用 OfferID + `productId` + 价格生成 `signData` / `paySig`
|
||||||
|
3. 端上 `wx.requestVirtualPayment`
|
||||||
|
4. 发货 / 查单走 `/xpay/*`,签名用当前环境 AppKey
|
||||||
|
|
||||||
|
## 验收
|
||||||
|
|
||||||
|
- 开发者工具:`WX_PAY_ENV=1` 用沙箱 AppKey
|
||||||
|
- 真机现网:`WX_PAY_ENV=0`,道具已在 MP「发布」且价格与上表一致
|
||||||
|
- 路径:登录 → 下单 → `requestVirtualPayment` → 发货回调
|
||||||
@ -35,8 +35,8 @@ const MATRIX = [
|
|||||||
|
|
||||||
const CHECKLIST = [
|
const CHECKLIST = [
|
||||||
"微信开发者工具导入 apps/miniprogram/weapp(产物 dist/)",
|
"微信开发者工具导入 apps/miniprogram/weapp(产物 dist/)",
|
||||||
"AppID = wx11f6afc44ea1532f(写 env,勿提交密钥)",
|
"AppID = wx11f6afc44ea1532f · OfferID = 1450705308",
|
||||||
"虚拟支付:OfferID + 沙箱/现网 AppKey 配后端",
|
"虚拟支付:现网/沙箱 AppKey 见 apps/miniprogram/docs/wechat-virtual-pay-props.md",
|
||||||
"H5:pnpm --dir h5 dev → :10086",
|
"H5:pnpm --dir h5 dev → :10086",
|
||||||
"抖音:pnpm --dir tt build → 抖音开发者工具打开 tt/",
|
"抖音:pnpm --dir tt build → 抖音开发者工具打开 tt/",
|
||||||
"小红书:pnpm build:xhs 上传 xhs/dist zip",
|
"小红书:pnpm build:xhs 上传 xhs/dist zip",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user