-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
fix: WxPayPartnerRefundV3Request 缺少 sp_appid 和 sub_appid 字段 #3918
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
Merged
+87
−3
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
55 changes: 55 additions & 0 deletions
55
...c/test/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3RequestTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package com.github.binarywang.wxpay.bean.request; | ||
|
|
||
| import com.google.gson.Gson; | ||
| import com.google.gson.JsonObject; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| /** | ||
| * {@link WxPayPartnerRefundV3Request} 单元测试 | ||
| * | ||
| */ | ||
| public class WxPayPartnerRefundV3RequestTest { | ||
|
|
||
| @Test | ||
| public void testSpAppidAndSubAppidSerialization() { | ||
| WxPayPartnerRefundV3Request request = new WxPayPartnerRefundV3Request(); | ||
| request.setSpAppid("wx8888888888888888"); | ||
| request.setSubAppid("wxd678efh567hg6999"); | ||
| request.setSubMchid("1230000109"); | ||
| request.setOutRefundNo("1217752501201407033233368018"); | ||
| request.setFundsAccount("AVAILABLE"); | ||
|
|
||
| Gson gson = new Gson(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里使用 Severity: low Other Locations
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| String json = gson.toJson(request); | ||
| JsonObject jsonObject = gson.fromJson(json, JsonObject.class); | ||
|
|
||
| assertThat(jsonObject.has("sp_appid")).isTrue(); | ||
| assertThat(jsonObject.get("sp_appid").getAsString()).isEqualTo("wx8888888888888888"); | ||
| assertThat(jsonObject.has("sub_appid")).isTrue(); | ||
| assertThat(jsonObject.get("sub_appid").getAsString()).isEqualTo("wxd678efh567hg6999"); | ||
| assertThat(jsonObject.has("sub_mchid")).isTrue(); | ||
| assertThat(jsonObject.get("sub_mchid").getAsString()).isEqualTo("1230000109"); | ||
| assertThat(jsonObject.has("out_refund_no")).isTrue(); | ||
| assertThat(jsonObject.get("out_refund_no").getAsString()).isEqualTo("1217752501201407033233368018"); | ||
| assertThat(jsonObject.has("funds_account")).isTrue(); | ||
| assertThat(jsonObject.get("funds_account").getAsString()).isEqualTo("AVAILABLE"); | ||
binarywang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Test | ||
| public void testSubAppidIsOptional() { | ||
| WxPayPartnerRefundV3Request request = new WxPayPartnerRefundV3Request(); | ||
| request.setSpAppid("wx8888888888888888"); | ||
| request.setSubMchid("1230000109"); | ||
| request.setOutRefundNo("1217752501201407033233368018"); | ||
|
|
||
| Gson gson = new Gson(); | ||
| String json = gson.toJson(request); | ||
| JsonObject jsonObject = gson.fromJson(json, JsonObject.class); | ||
|
|
||
| assertThat(jsonObject.has("sp_appid")).isTrue(); | ||
| assertThat(jsonObject.get("sp_appid").getAsString()).isEqualTo("wx8888888888888888"); | ||
| assertThat(jsonObject.has("sub_appid")).isFalse(); | ||
| } | ||
| } | ||
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.
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.
sp_appid在微信服务商退款接口里是必填项,但目前WxPayService#partnerRefundV3只会兜底补sub_mchid/notify_url,如果调用方遗漏spAppid仍会发出不合法请求并被微信侧拒绝;建议确认是否需要在调用链上做同样的兜底或校验。Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.