From a637fdf213bb65e99533317d4d4ffead118d644b Mon Sep 17 00:00:00 2001 From: wwwwwwwww <526125649@qq.com> Date: Thu, 11 Jun 2026 18:28:17 +0800 Subject: [PATCH] 1 --- .../src/pages/AdminPaymentConfig.tsx | 5 ----- video-gen-api/app/api/v1/payments.py | 3 +-- video-gen-api/app/services/payment.py | 18 ++++++++---------- video-gen-api/test_wechatpay.py | 9 +++++++++ 4 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 video-gen-api/test_wechatpay.py diff --git a/video-gen-admin/src/pages/AdminPaymentConfig.tsx b/video-gen-admin/src/pages/AdminPaymentConfig.tsx index 866b65da..a7f42eb8 100644 --- a/video-gen-admin/src/pages/AdminPaymentConfig.tsx +++ b/video-gen-admin/src/pages/AdminPaymentConfig.tsx @@ -26,7 +26,6 @@ const AdminPaymentConfig: React.FC = () => { wechat_private_key: map['payment_wechat_private_key'] || '', wechat_cert_serial_no: map['payment_wechat_cert_serial_no'] || '', wechat_api_v3_key: map['payment_wechat_api_v3_key'] || '', - wechat_gateway: map['payment_wechat_gateway'] || '', wechat_notify_url: map['payment_wechat_notify_url'] || '', alipay_app_id: map['payment_alipay_app_id'] || '', alipay_private_key: map['payment_alipay_private_key'] || '', @@ -58,7 +57,6 @@ const AdminPaymentConfig: React.FC = () => { payment_wechat_private_key: values.wechat_private_key || '', payment_wechat_cert_serial_no: values.wechat_cert_serial_no || '', payment_wechat_api_v3_key: values.wechat_api_v3_key || '', - payment_wechat_gateway: values.wechat_gateway || '', payment_wechat_notify_url: values.wechat_notify_url || '', payment_alipay_enabled: String(alipayEnabled), payment_alipay_app_id: values.alipay_app_id || '', @@ -168,9 +166,6 @@ const AdminPaymentConfig: React.FC = () => { - - - diff --git a/video-gen-api/app/api/v1/payments.py b/video-gen-api/app/api/v1/payments.py index 717fd944..d85a6236 100644 --- a/video-gen-api/app/api/v1/payments.py +++ b/video-gen-api/app/api/v1/payments.py @@ -112,9 +112,8 @@ async def wechat_callback(request: Request, db: AsyncSession = Depends(get_db)): cert_serial_no = db_configs.get("payment_wechat_cert_serial_no", "") api_v3_key = db_configs.get("payment_wechat_api_v3_key", "") appid = db_configs.get("payment_wechat_appid", "") - gateway = db_configs.get("payment_wechat_gateway", "") - client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid, gateway) + client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid) if not client: logger.error("WeChat client not initialized for callback") return {"code": "SUCCESS", "message": "OK"} diff --git a/video-gen-api/app/services/payment.py b/video-gen-api/app/services/payment.py index 35b1169e..6aac28aa 100644 --- a/video-gen-api/app/services/payment.py +++ b/video-gen-api/app/services/payment.py @@ -357,7 +357,8 @@ def _get_wechat_client( cert_serial_no: str, api_v3_key: str, appid: str, - gateway: str = "" + notify_url: str = "", + cert_dir: str | None = None ): """Get or create a WeChat Pay client. Recreated if config changes.""" global _wechat_client, _wechat_mch_id @@ -388,7 +389,8 @@ def _get_wechat_client( cert_serial_no=cert_serial_no, appid=appid, apiv3_key=api_v3_key, - gateway=gateway or "https://api.mch.weixin.qq.com", + notify_url=notify_url, + cert_dir=cert_dir, ) _wechat_mch_id = mch_id logger.info("WeChat Pay client initialized successfully") @@ -411,14 +413,13 @@ def _create_wechat_order(order: PaymentOrder, db_configs: dict[str, str]) -> str cert_serial_no = db_configs.get("payment_wechat_cert_serial_no", "") api_v3_key = db_configs.get("payment_wechat_api_v3_key", "") appid = db_configs.get("payment_wechat_appid", "") - gateway = db_configs.get("payment_wechat_gateway", "") notify_url = db_configs.get("payment_wechat_notify_url", "") if not all([mch_id, private_key, cert_serial_no, api_v3_key, appid]): logger.warning("WeChat payment config missing in database") return None - client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid, gateway) + client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid, notify_url) if client is None: return None @@ -461,9 +462,8 @@ async def _close_wechat_order(db: AsyncSession, order: PaymentOrder, db_configs: cert_serial_no = db_configs.get("payment_wechat_cert_serial_no", "") api_v3_key = db_configs.get("payment_wechat_api_v3_key", "") appid = db_configs.get("payment_wechat_appid", "") - gateway = db_configs.get("payment_wechat_gateway", "") - client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid, gateway) + client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid) if client is None: return False @@ -494,9 +494,8 @@ async def _query_wechat_order(db: AsyncSession, order: PaymentOrder, db_configs: cert_serial_no = db_configs.get("payment_wechat_cert_serial_no", "") api_v3_key = db_configs.get("payment_wechat_api_v3_key", "") appid = db_configs.get("payment_wechat_appid", "") - gateway = db_configs.get("payment_wechat_gateway", "") - client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid, gateway) + client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid) if client is None: return None @@ -537,9 +536,8 @@ async def _refund_wechat_order( cert_serial_no = db_configs.get("payment_wechat_cert_serial_no", "") api_v3_key = db_configs.get("payment_wechat_api_v3_key", "") appid = db_configs.get("payment_wechat_appid", "") - gateway = db_configs.get("payment_wechat_gateway", "") - client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid, gateway) + client = _get_wechat_client(mch_id, private_key, cert_serial_no, api_v3_key, appid) if client is None: return {"success": False, "message": "微信支付客户端初始化失败"} diff --git a/video-gen-api/test_wechatpay.py b/video-gen-api/test_wechatpay.py new file mode 100644 index 00000000..c80671ea --- /dev/null +++ b/video-gen-api/test_wechatpay.py @@ -0,0 +1,9 @@ + +from wechatpayv3 import WeChatPay +import inspect + +print("WeChatPay.__init__ signature:") +print(inspect.signature(WeChatPay.__init__)) + +print("\nWeChatPay.__init__ docstring:") +print(inspect.getdoc(WeChatPay.__init__))