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 @@ -87,6 +87,12 @@ public class TransferBillsRequest implements Serializable {
@SerializedName("transfer_scene_report_infos")
private List<TransferSceneReportInfo> transferSceneReportInfos;

/**
* 用户收款样式;不传时默认展示收款确认页。
*/
@SerializedName("user_recv_style")
private UserRecvStyle userRecvStyle;

/**
* 自动收款授权信息
*/
Expand Down Expand Up @@ -144,6 +150,21 @@ public static class TransferSceneReportInfo {
private String infoContent;
}

/**
* 用户收款样式。
*/
@Data
@Builder(builderMethodName = "newBuilder")
@AllArgsConstructor
@NoArgsConstructor
public static class UserRecvStyle {
/**
* 样式类型:CONFIRM_PAGE 为收款确认页,RED_PACKET 为红包;红包仅支持部分转账场景且单笔金额不超过 200 元。
*/
@SerializedName("type")
private String type;
}

@Data
@Builder(builderMethodName = "newBuilder")
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.github.binarywang.wxpay.bean.transfer.UserConfirmAuthorizationResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.testng.Assert;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -41,9 +43,34 @@ public void shouldKeepTransferBillsApiPathUnchanged() throws Exception {

Assert.assertEquals(handler.lastPostWithSerialUrl, BASE_URL + "/v3/fund-app/mch-transfer/transfer-bills");
Assert.assertFalse(handler.lastPostWithSerialBody.contains("authorization_info"));
Assert.assertFalse(handler.lastPostWithSerialBody.contains("user_recv_style"));
Assert.assertEquals(result.getPackageInfo(), "transfer-package");
}

/**
* 验证发起转账时用户收款样式及类型按微信接口字段名发送。
*/
public void shouldSendUserRecvStyleInTransferBillsRequest() throws Exception {
RequestCaptureHandler handler = new RequestCaptureHandler();
TransferServiceImpl transferService = new TransferServiceImpl(handler.createWxPayService());

transferService.transferBills(TransferBillsRequest.newBuilder()
.appid("wxf636efh567hg4356")
.outBillNo("plfk2020042014")
.transferSceneId("1000")
.openid("o-MYE42l80oelYMDE34nYD456Xoy")
.transferAmount(100)
.transferRemark("活动奖励")
.userRecvStyle(TransferBillsRequest.UserRecvStyle.newBuilder()
.type("RED_PACKET")
.build())
.build());

JsonObject body = new Gson().fromJson(handler.lastPostWithSerialBody, JsonObject.class);
Assert.assertEquals(handler.lastPostWithSerialUrl, BASE_URL + "/v3/fund-app/mch-transfer/transfer-bills");
Assert.assertEquals(body.getAsJsonObject("user_recv_style").get("type").getAsString(), "RED_PACKET");
}

/**
* 验证“发起转账并完成免确认收款授权”使用独立接口路径和授权参数.
*/
Expand Down