Skip to content

补充小程序虚拟支付 xpay_complaint_notify 投诉推送事件支持#3963

Merged
binarywang merged 4 commits intodevelopfrom
copilot/support-virtual-payment
Apr 14, 2026
Merged

补充小程序虚拟支付 xpay_complaint_notify 投诉推送事件支持#3963
binarywang merged 4 commits intodevelopfrom
copilot/support-virtual-payment

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

WxMaXPayService 服务端 API 已完整实现,但 xpay_complaint_notify(用户投诉推送)消息事件的解析支持缺失。

变更内容

  • WxMaConstants.XPayNotifyEvent — 新增 COMPLAINT = "xpay_complaint_notify" 常量,与 COIN_PAYGOODS_DELIVERREFUND 对齐

  • WxMaMessage — 新增投诉推送专用字段:

    字段 说明
    complaintTransactionId 微信支付交易单号(TransactionId
    complaintId 投诉单号(ComplaintId
    complaintDetail 投诉详情(ComplaintDetail
    complaintTime 投诉时间戳(ComplaintTime
    requestId 请求编号(RequestId

    同时将 openId@SerializedName 改为支持 OpenId/OpenID 两种大小写形式(JSON),修复 xpay 事件中大小写不一致导致的解析缺陷。

  • XStreamTransformer — 注册 OpenId XML 别名,使 XML 格式推送中的 OpenId 也能正确映射到 openId 字段(与已有的 MsgID/MsgId 处理方式一致)

  • WxMaMessageTest — 新增 testXPayComplaintNotifyFromXml()testXPayComplaintNotifyFromJson(),覆盖全字段解析

// 使用常量路由投诉推送事件
if (WxMaConstants.XPayNotifyEvent.COMPLAINT.equals(message.getEvent())) {
    String complaintId = message.getComplaintId();
    String detail = message.getComplaintDetail();
    Long time = message.getComplaintTime();
    // handle complaint...
}

Copilot AI linked an issue Apr 14, 2026 that may be closed by this pull request
@binarywang
Copy link
Copy Markdown
Owner

@copilot 主要是解决这个问题:#3961 (comment)

Copilot AI changed the title [WIP] Add support for virtual payment in mini program 补充小程序虚拟支付 xpay_complaint_notify 投诉推送事件支持 Apr 14, 2026
Copilot AI requested a review from binarywang April 14, 2026 07:52
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 14, 2026

@copilot 主要是解决这个问题:#3961 (comment)

已确认签名大小写问题在本 PR 中已修复:WxMaXPaySigParams.calcSig() 返回值已调用 .toLowerCase() 转为小写,与 calcPaySig() 保持一致,避免了"用户态签名(signature)校验失败"错误。

WxMaXPaySigParamsTest 中已有验证测试,3 条测试全部通过(含 calcSig 返回值全小写、64位十六进制格式验证)。用户当前遇到的问题是使用了旧发布版本,本 PR 合并发版后即可解决,无需手动改代码。

@binarywang binarywang marked this pull request as ready for review April 14, 2026 08:19
Copilot AI review requested due to automatic review settings April 14, 2026 08:19
@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 14, 2026

🤖 Augment PR Summary

Summary: This PR adds missing parsing support for the Miniapp virtual payment complaint notification event.

Changes:

  • Added xpay_complaint_notify as WxMaConstants.XPayNotifyEvent.COMPLAINT to align with existing XPay event constants.
  • Extended WxMaMessage with complaint-notify fields (transaction/complaint identifiers, detail, timestamp, request id).
  • Improved openId JSON compatibility by accepting both OpenID and OpenId casings.
  • Updated XStreamTransformer to alias OpenId in XML so XPay event payloads map correctly.
  • Added XML and JSON unit tests covering full-field parsing for the complaint notification.

Technical Notes: The change is primarily about wire-format compatibility (JSON/XML key casing + new event fields) and is validated via new JUnit tests.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

为小程序虚拟支付的 xpay_complaint_notify(用户投诉推送)事件补齐消息解析能力,完善 XML/JSON 两种推送格式下的字段映射,并通过单元测试覆盖关键字段解析。

Changes:

  • WxMaConstants.XPayNotifyEvent 中新增 COMPLAINT = "xpay_complaint_notify" 事件常量
  • WxMaMessage 中新增投诉推送相关字段,并增强 openIdOpenId/OpenID 的 JSON 兼容解析
  • XStreamTransformer 中补充 OpenId 的 XML 别名映射,并新增对应 XML/JSON 解析测试用例

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java 增加投诉推送事件常量,便于事件路由/判断
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java 增加投诉推送字段并增强 openId 的 JSON 反序列化兼容性
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java 为 XML 推送补充 OpenId -> openId 别名映射
weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java 新增投诉推送 XML/JSON 解析测试,覆盖新增字段与 OpenId 映射

…stant/WxMaConstants.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@binarywang binarywang merged commit 9fca71d into develop Apr 14, 2026
1 check was pending
@binarywang binarywang deleted the copilot/support-virtual-payment branch April 14, 2026 09:17
@binarywang binarywang added this to the 4.8.3 milestone Apr 20, 2026
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.

小程序虚拟支付业务支持了吗

3 participants