1
0
mirror of synced 2026-05-27 05:16:18 +08:00

🎨 #4001 【微信支付】为普通商户版退款请求对象类补齐与服务商版一致的“退款资金来源/出资账户明细”参数,以支持在 V3 退款申请时指定退款来源资金账户

This commit is contained in:
Yixuan Xu
2026-05-20 10:23:31 +08:00
committed by GitHub
parent b882c673d9
commit 2dc2da061e
2 changed files with 121 additions and 0 deletions

View File

@@ -84,6 +84,24 @@ public class WxPayRefundV3Request implements Serializable {
*/
@SerializedName(value = "notify_url")
private String notifyUrl;
/**
* <pre>
* 字段名:退款资金来源
* 变量名funds_account
* 是否必填:否
* 类型string[1, 32]
* 描述:
* 若传递此参数则使用对应的资金账户退款,否则默认使用未结算资金退款(仅对老资金流商户适用)
* 示例值:
* UNSETTLED : 未结算资金
* AVAILABLE : 可用余额
* UNAVAILABLE : 不可用余额
* OPERATION : 运营户
* BASIC : 基本账户(含可用余额和不可用余额)
* </pre>
*/
@SerializedName(value = "funds_account")
private String fundsAccount;
/**
* <pre>
* 字段名:订单金额
@@ -152,6 +170,53 @@ public class WxPayRefundV3Request implements Serializable {
*/
@SerializedName(value = "currency")
private String currency;
/**
* <pre>
* 字段名:退款出资账户及金额
* 变量名from
* 是否必填:否
* 类型array
* 描述:
* 退款出资的账户类型及金额信息
* </pre>
*/
@SerializedName(value = "from")
private List<From> from;
}
@Data
@NoArgsConstructor
public static class From implements Serializable {
private static final long serialVersionUID = 1L;
/**
* <pre>
* 字段名:出资账户类型
* 变量名account
* 是否必填:是
* 类型string[1, 32]
* 描述:
* 下面枚举值多选一。
* 枚举值:
* AVAILABLE : 可用余额
* UNAVAILABLE : 不可用余额
* 示例值AVAILABLE
* </pre>
*/
@SerializedName(value = "account")
private String account;
/**
* <pre>
* 字段名:出资金额
* 变量名amount
* 是否必填:是
* 类型int
* 描述:
* 对应账户出资金额
* 示例值444
* </pre>
*/
@SerializedName(value = "amount")
private Integer amount;
}
@Data

View File

@@ -0,0 +1,56 @@
package com.github.binarywang.wxpay.bean.request;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.testng.annotations.Test;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
/**
* {@link WxPayRefundV3Request} 单元测试
*
*/
public class WxPayRefundV3RequestTest {
@Test
public void testFundsAccountSerialization() {
WxPayRefundV3Request request = new WxPayRefundV3Request();
request.setOutRefundNo("1217752501201407033233368018");
request.setFundsAccount("AVAILABLE");
Gson gson = new Gson();
String json = gson.toJson(request);
JsonObject jsonObject = gson.fromJson(json, JsonObject.class);
assertThat(jsonObject.has("funds_account")).isTrue();
assertThat(jsonObject.get("funds_account").getAsString()).isEqualTo("AVAILABLE");
}
@Test
public void testAmountFromSerialization() {
WxPayRefundV3Request.From from = new WxPayRefundV3Request.From();
from.setAccount("AVAILABLE");
from.setAmount(444);
WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount();
amount.setRefund(888);
amount.setTotal(888);
amount.setCurrency("CNY");
amount.setFrom(Collections.singletonList(from));
WxPayRefundV3Request request = new WxPayRefundV3Request();
request.setAmount(amount);
Gson gson = new Gson();
String json = gson.toJson(request);
JsonObject jsonObject = gson.fromJson(json, JsonObject.class);
JsonArray fromJson = jsonObject.getAsJsonObject("amount").getAsJsonArray("from");
assertThat(fromJson).hasSize(1);
assertThat(fromJson.get(0).getAsJsonObject().get("account").getAsString()).isEqualTo("AVAILABLE");
assertThat(fromJson.get(0).getAsJsonObject().get("amount").getAsInt()).isEqualTo(444);
}
}