Merged
Conversation
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] 支付回调结果解析报错
Fix payment callback parsing error with helpful format detection
Sep 22, 2025
Owner
|
@copilot 请用中文改下描述文字 |
Contributor
Author
已将PR描述改为中文。 |
Copilot
AI
changed the title
Fix payment callback parsing error with helpful format detection
修复支付回调结果解析报错问题
Nov 28, 2025
There was a problem hiding this comment.
Pull request overview
此PR旨在改善开发者误将微信支付V3版本的JSON格式通知数据传递给V2版本XML解析方法时的错误提示。通过在解析前检测数据格式,将原本晦涩的XStream解析异常替换为清晰的指导信息,告知开发者应使用parseOrderNotifyV3Result方法处理V3 API的JSON通知数据。
主要变更:
- 在
BaseWxPayServiceImpl.parseOrderNotifyResult()方法中添加JSON格式检测逻辑 - 当检测到JSON格式数据时,抛出带有明确指导的
WxPayException异常 - 添加测试用例验证JSON输入会触发异常
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/service/impl/BaseWxPayServiceImpl.java |
在parseOrderNotifyResult方法中添加JSON格式检测,当检测到以{开头的数据时抛出带有V3 API使用指导的异常 |
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResultTest.java |
添加测试用例验证传入JSON格式数据时会抛出异常(但测试路径与实现不匹配) |
...va-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResultTest.java
Outdated
Show resolved
Hide resolved
...in-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
Outdated
Show resolved
Hide resolved
Closed
…ice/impl/BaseWxPayServiceImpl.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Remove incorrect test from WxPayOrderNotifyResultTest that tested fromXML() directly - Add proper test in BaseWxPayServiceImplTest that tests parseOrderNotifyResult() service method - New test verifies that JSON format triggers helpful error message with V3 API guidance Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复支付回调结果解析报错问题
修复当开发者使用微信支付V3 API的JSON格式通知数据调用
parseOrderNotifyResult方法时出现的解析错误问题。问题描述
在使用Spring Boot 3.4.2配合WxJava 4.7.7.B时,调用
parseOrderNotifyResult处理V3版本的JSON通知数据会报错:错误原因:
{"id": "...", "resource_type": "encrypt-resource", ...}<xml><appid>...</appid>...</xml>解决方案
在
parseOrderNotifyResult方法中添加数据格式检测逻辑:{开头(JSON格式)WxPayException:使用示例
主要改动
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.javaparseOrderNotifyResult(String xmlData, String signType)BaseWxPayServiceImplTest.java中添加JSON格式检测测试验证
mvn checkstyle:check)修复 #3699
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.