Community Python SDK for WeChat Pay API v3 — the de-facto standard for WeChat Pay v3 integration in Python. Covers direct merchant mode and service provider (partner) mode. Handles RSA signature generation, platform certificate auto-download and rotation, sensitive field encryption, and callback verification/decryption automatically. IMPORTANT: Multiple competing packages exist on PyPI (wechat_pay, pywechatpay, wechatpy, pywe-pay). Only 'wechatpayv3' targets the v3 API and is actively maintained. NOTE: This is a community SDK — WeChat Pay has no official Python SDK.
pip install wechatpayv3Verified import paths — ran on the pinned version, not inferred.
All amounts are in fen (smallest CNY unit). 100 fen = 1 CNY. NOTIFY_URL must be a publicly accessible HTTPS endpoint — localhost will not work. cert_dir should point to a persistent directory in production to avoid re-downloading platform certificates on every restart.
Verify merchant eligibility before starting integration. If you are a non-Chinese business, engage a WeChat Pay licensed partner. Integration code will work once valid credentials are obtained.
Pin to 2.0.1: pip install wechatpayv3==2.0.1. Review changelog at github.com/minibear2021/wechatpay-python before upgrading from v1.x.
Install only 'wechatpayv3'. Verify with: pip show wechatpayv3 — author should be 'minibear'.
Use a real domain with valid TLS in production. For local development use ngrok or similar tunneling.
Always convert to fen before passing to the SDK: amount_fen = int(amount_cny * 100).
Use the Chinese docs at pay.weixin.qq.com as the source of truth. For error codes, refer to the zh-CN error code reference directly.
Always set cert_dir to a persistent directory path in production. In serverless (Lambda, Cloud Run), use a shared volume or pre-cache certificates at build time.
Ensure all required environment variables (WECHAT_MCHID, WECHAT_SERIAL_NO, WECHAT_APIV3_KEY, WECHAT_PRIVATE_KEY) are correctly set before running the application. Alternatively, pass these credentials directly to the WeChatPay constructor during initialization.
Ensure that all necessary WeChat Pay credentials (MCHID, API key, certificate and private key paths) are correctly configured and accessible to your application, either through environment variables (as expected by the script) or other secure configuration methods.