-
-
Notifications
You must be signed in to change notification settings - Fork 9k
修复支付回调结果解析报错问题 #3709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
修复支付回调结果解析报错问题 #3709
Conversation
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
|
@copilot 请用中文改下描述文字 |
已将PR描述改为中文。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
…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>
修复支付回调结果解析报错问题
修复当开发者使用微信支付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.