fix: 允许V2沙箱与V3配置共存 - #4090
Conversation
🤖 Augment PR Summary摘要:本 PR 修复同一商户同时配置 API v3 密钥与 API v2 沙箱时,V2 请求被错误拒绝的问题。 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
该 PR 针对微信支付 SDK(weixin-java-pay)的沙箱场景做了行为修正:允许同一份配置里同时存在 apiV3Key 与 API v2 沙箱调用,并将“API v3 不支持沙箱”的拦截下沉到 v3 传输层,避免 v2 沙箱被配置项误伤。
Changes:
- 调整
getPayBaseUrl():在启用沙箱时不再因apiV3Key存在而直接拒绝,确保 v2 沙箱 URL 可正常返回。 - 在 Apache HttpClient 的 v3 请求路径中增加“沙箱不支持 v3”的运行时拦截。
- 新增回归测试覆盖“V2 沙箱 + 配置 V3Key 共存”与“沙箱下拒绝 V3 请求”的场景。
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java | 放开沙箱模式下对 apiV3Key 的硬拦截,保证 v2 沙箱 baseUrl 生成不被误伤 |
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java | 在 v3 请求传输层增加沙箱拦截逻辑,避免 v3 在沙箱模式下继续执行 |
| weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceSandboxTest.java | 增加 v2 沙箱 URL 与 v3 沙箱拒绝的回归测试 |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 067cfd446c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
变更内容
apiV3Key的商户继续调用 API v2 仿真环境。根因
getPayBaseUrl()以apiV3Key是否存在判断 API v3 场景,导致同一配置中的 API v2 请求也无法使用仿真环境。验证
WxPayServiceSandboxTest,2 passed / 0 failedmvn -pl weixin-java-pay -DskipTests package