Skip to content

fix: 小程序纯签约移除version参数#4073

Open
cofedream wants to merge 1 commit into
binarywang:developfrom
cofedream:develop
Open

fix: 小程序纯签约移除version参数#4073
cofedream wants to merge 1 commit into
binarywang:developfrom
cofedream:develop

Conversation

@cofedream

Copy link
Copy Markdown
  1. 纯小程序签约无version参数,使用该参数生成的签名在跳转签约的时候会提示“商家系统错误”
Screenshot_2026-07-20-16-12-50-90_e39d2c7de19156b0683cd93e8735f348

1. 纯小程序签约无version参数,新增该参数会导致生成的签名错误

@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: 46e7e1297f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

private String version;


/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 保留已发布的 version API

在已发布的 SDK 中直接删除 version 字段会同时移除 Lombok 生成的 getVersion/setVersionWxMaEntrustRequestBuilder.version(...) 以及全参构造器参数;下游如果已经按旧 API 调用 .version("1.0"),升级这个补丁后会出现编译失败,已编译产物也可能在运行时遇到 NoSuchMethodError。这里可以保留并标记废弃兼容入口,同时确保它不再参与小程序纯签约的输出或签名。

Useful? React with 👍 / 👎.

@augmentcode

augmentcode Bot commented Jul 20, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: 修复微信支付小程序纯签约场景不应携带 version 参数,避免跳转签约时报“商家系统错误”。

Changes: 移除 WxMaEntrustRequest 中的 version 字段及其必填/序列化声明,使签名与输出参数不再包含该字段。

🤖 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. 2 suggestions posted.

Fix All in Augment

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

*/
@Required
@XStreamAlias("version")
private String version;

@augmentcode augmentcode Bot Jul 20, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMaEntrustRequest.java:115
这里直接移除了 version 字段(@Data/@Builder 会对外暴露 getVersion/setVersion 及 builder 方法),对下游源码/二进制兼容是破坏性的;建议在发布说明/升级指引中明确该不兼容变更的影响范围。

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

* </pre>
*/
@Required
@XStreamAlias("version")

@augmentcode augmentcode Bot Jul 20, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxMaEntrustRequest.java:114
本次变更会影响 maSign 生成的签名与输出参数,当前 WxEntrustPapServiceTest#testMaSign 没有断言(例如确认 json 中不再包含 version),可能难以及时发现回归。

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@binarywang

Copy link
Copy Markdown
Owner

建议不要直接删除 version 字段,而是保留它以避免破坏现有的 getter/setter 和 Builder API,同时让它既不参与签名,也不出现在最终小程序纯签约的 JSON 请求中。

可考虑:

@Deprecated
@XStreamOmitField
private transient String version;

@Override
protected String[] getIgnoredParamsForSign() {
  return new String[]{"version"};
}

原因是:仅在签名时忽略 version 不够;maSign() 会把对象序列化为 JSON,若请求里仍带有 version,微信侧可能按实际入参验签,依旧会不匹配。transient 能使 Gson 不输出该字段,@XStreamOmitField 也能避免未来 XML 路径带出;显式忽略签名则覆盖普通反射签名模式。

建议补一个回归测试:显式设置 .version("1.0") 后,断言 maSign() 的 JSON 不含 version,且签名与未设置时一致。请评估这种兼容性处理是否更合适。

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