Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines +87 to +104
/**
* <pre>
* 字段名:订单金额
Expand Down Expand Up @@ -152,6 +170,53 @@ public static class Amount 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}