Skip to content

fix: 允许V2沙箱与V3配置共存 - #4090

Merged
binarywang merged 3 commits into
developfrom
fix/4009-v2-sandbox-with-v3-config
Aug 12, 2026
Merged

fix: 允许V2沙箱与V3配置共存#4090
binarywang merged 3 commits into
developfrom
fix/4009-v2-sandbox-with-v3-config

Conversation

@binarywang

Copy link
Copy Markdown
Owner

变更内容

  • 允许配置了 apiV3Key 的商户继续调用 API v2 仿真环境。
  • 将“API v3 不支持沙箱”的校验移动到 API v3 请求传输层,避免 API v2 沙箱被配置项误伤。
  • 新增 V2 沙箱地址与 V3 请求拒绝场景的回归测试。

根因

getPayBaseUrl()apiV3Key 是否存在判断 API v3 场景,导致同一配置中的 API v2 请求也无法使用仿真环境。

验证

  • TestNG:WxPayServiceSandboxTest,2 passed / 0 failed
  • mvn -pl weixin-java-pay -DskipTests package

@binarywang
binarywang marked this pull request as ready for review August 11, 2026 08:00
Copilot AI lite review requested due to automatic review settings August 11, 2026 08:00
@augmentcode

augmentcode Bot commented Aug 11, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

摘要:本 PR 修复同一商户同时配置 API v3 密钥与 API v2 沙箱时,V2 请求被错误拒绝的问题。

变更:移除了 getPayBaseUrl() 中依据 apiV3Key 拒绝沙箱的全局判断。

将 API v3 不支持沙箱的判断下沉到 Apache HTTP API v3 请求传输路径。

覆盖了 V2 沙箱地址在配置 V3 密钥时的回归场景。

覆盖了默认 WxPayServiceImpl 发起 API v3 请求时的拒绝场景。

注意:需保证所有可选 HTTP 客户端实现保持相同的 API v3 沙箱限制。

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@binarywang binarywang linked an issue Aug 12, 2026 that may be closed by this pull request
@binarywang
binarywang merged commit be7b151 into develop Aug 12, 2026
1 check passed
@binarywang
binarywang deleted the fix/4009-v2-sandbox-with-v3-config branch August 12, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

微信支付V3 目前不支持沙箱模式

3 participants