Skip to content

fix: 保留小程序纯签约 version 字段兼容性#4074

Open
binarywang wants to merge 3 commits into
developfrom
agent/preserve-ma-entrust-version
Open

fix: 保留小程序纯签约 version 字段兼容性#4074
binarywang wants to merge 3 commits into
developfrom
agent/preserve-ma-entrust-version

Conversation

@binarywang

Copy link
Copy Markdown
Owner

变更内容

  • 保留 WxMaEntrustRequest.version 的 getter/setter/Builder 兼容性,但标记为 Deprecated。
  • 从小程序纯签约的 JSON、普通 XML 和快速 XML 输出中排除该字段。
  • 在签名计算中显式忽略该字段。

原因

微信小程序纯签约接口不支持 version;该字段出现在请求参数中会导致签名校验失败。

验证

  • 新增 WxMaEntrustRequestTest,覆盖显式设置 version("1.0") 后的 JSON、两种 XML 序列化和签名行为。
  • mvn -pl weixin-java-pay -DskipTests compile test-compile
  • 使用 TestNG 直接运行 WxMaEntrustRequestTest:1 passed, 0 failed。

@binarywang
binarywang marked this pull request as ready for review July 22, 2026 06:22
Copilot AI review requested due to automatic review settings July 22, 2026 06:22

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 针对 小程序纯签约请求参数中的 WxMaEntrustRequest.version 做兼容性处理:保留对外 API(getter/setter/Builder)但避免其进入请求序列化与签名计算,从而防止因微信接口不支持该字段导致的签名校验失败。

Changes:

  • version 标记为 @Deprecated,并在 XML 序列化中通过 @XStreamOmitField 排除,同时使用 transient 避免进入 JSON 输出。
  • 在签名计算中通过覆写 getIgnoredParamsForSign() 显式忽略 version
  • 新增 WxMaEntrustRequestTest,覆盖 JSON、普通 XML、快速 XML 输出不包含 version,以及签名忽略 version 的行为。

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMaEntrustRequest.java version 兼容保留但从序列化与签名中排除,避免影响小程序纯签约签名校验。
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/WxMaEntrustRequestTest.java 新增回归测试,验证 version 不进入 JSON/XML(含 fastMode)且不参与签名。

@augmentcode

augmentcode Bot commented Jul 22, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: 本 PR 修复小程序纯签约请求中携带 version 字段导致微信侧签名校验失败的问题,并尽量保持对存量代码的兼容性。

Changes:

  • 保留 WxMaEntrustRequest.version 的 getter/setter/Builder,但标记为 @Deprecated
  • 在 JSON、普通 XML(XStream)以及快速 XML 输出中排除该字段
  • 签名计算时通过 getIgnoredParamsForSign() 显式忽略 version
  • 新增 WxMaEntrustRequestTest 覆盖序列化与签名回归用例
Conclusion: 变更聚焦且包含回归测试,当前 diff 未发现阻止合并的问题。

🤖 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.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@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: f2260125c3

ℹ️ 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".

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.

2 participants