fix: WxPayPartnerRefundV3Request 缺少 sp_appid 和 sub_appid 字段#3918
fix: WxPayPartnerRefundV3Request 缺少 sp_appid 和 sub_appid 字段#3918binarywang merged 3 commits intodevelopfrom
Conversation
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
🤖 Augment PR SummarySummary: 修复服务商退款 V3 请求对象缺失字段问题,使其可按微信 API 规范构造合法请求。 Changes:
Technical Notes: 新增字段直接影响请求体 JSON,缺失或 key 不匹配会触发微信侧参数校验失败。 🤖 Was this summary useful? React with 👍 or 👎 |
| * 示例值:wx8888888888888888 | ||
| * </pre> | ||
| */ | ||
| @SerializedName(value = "sp_appid") |
| request.setOutRefundNo("1217752501201407033233368018"); | ||
| request.setFundsAccount("AVAILABLE"); | ||
|
|
||
| Gson gson = new Gson(); |
There was a problem hiding this comment.
这里使用 new Gson() 做序列化断言,可能与生产路径里统一使用的 Gson 配置(例如 BaseWxPayServiceImpl 内的 GsonBuilder 实例)在未来发生偏离,导致单测与真实请求不一致;建议确认是否应复用项目内同一套 Gson 构建方式。
Severity: low
Other Locations
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3RequestTest.java:43
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Pull request overview
本 PR 针对微信支付 服务商退款(V3)请求对象补齐缺失字段,使 SDK 能构造符合接口要求的请求参数,并通过单元测试验证序列化后的 JSON key 映射正确。
Changes:
- 在
WxPayPartnerRefundV3Request中新增sp_appid(spAppid,必填)与sub_appid(subAppid,选填)字段及对应序列化注解。 - 新增
WxPayPartnerRefundV3RequestTest,覆盖包含/不包含sub_appid两种序列化场景。
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3Request.java | 为服务商退款请求补齐 sp_appid/sub_appid 字段并映射到正确的 JSON key |
| weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3RequestTest.java | 新增序列化单测,验证新增字段的 JSON key 映射及 sub_appid 的可选性 |
...-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3Request.java
Show resolved
Hide resolved
.../src/test/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3RequestTest.java
Outdated
Show resolved
Hide resolved
.../src/test/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3RequestTest.java
Show resolved
Hide resolved
...-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3Request.java
Show resolved
Hide resolved
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
已在提交 5aa16cf 中按 Review 意见完成以下修改:
|
|
@copilot apply changes based on the comments in this thread |
Review 线程中的所有变更均已在提交 5aa16cf 中完成:
|
WxPayPartnerRefundV3Request缺少微信服务商退款 API 要求的sp_appid(必填)和sub_appid(选填)字段,导致无法构造合法的退款请求。变更
WxPayPartnerRefundV3Request:新增两个字段spAppid→sp_appid(必填):服务商应用 IDsubAppid→sub_appid(选填):子商户应用 IDBaseWxPayServiceImpl.partnerRefundV3():与unifiedPartnerOrderV3等同类服务商接口保持一致,在请求未显式设置时自动从配置补齐字段:sp_appid:未设置时从config.getAppId()自动填充(必填)sub_appid:未设置且配置中存在非空值时才自动填充(选填,避免向微信 API 发送空字符串)WxPayPartnerRefundV3RequestTest:新增序列化测试,覆盖有/无sub_appid两种场景,验证 JSON key 名称正确映射;所有断言在getAsString()前先通过has()检查 key 是否存在,提升测试失败时的可读性。Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.