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
@@ -0,0 +1,154 @@
package com.github.binarywang.wxpay.bean.transfer;

import com.github.binarywang.wxpay.v3.SpecEncrypt;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
* 发起转账并完成免确认收款授权请求参数.
*
* <p>该接口和普通 {@link TransferBillsRequest} 一样会创建商家转账单,但额外携带
* {@code authorization_info},用于在用户确认收款时同时引导用户完成免确认收款授权。</p>
*
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4014399293">发起转账并完成免确认收款授权</a>
*/
@Data
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
public class PreTransferWithAuthorizationRequest implements Serializable {
private static final long serialVersionUID = 1L;

/**
* 商户 AppID.
*/
@SerializedName("appid")
private String appid;

/**
* 商户系统内部的商家单号.
*/
@SerializedName("out_bill_no")
private String outBillNo;

/**
* 转账场景 ID.
*/
@SerializedName("transfer_scene_id")
private String transferSceneId;

/**
* 收款用户 OpenID.
*/
@SerializedName("openid")
private String openid;

/**
* 收款用户姓名.
*
* <p>该字段为敏感信息,提交前需要使用微信支付公钥或平台证书公钥加密。</p>
*/
@SpecEncrypt
@SerializedName("user_name")
private String userName;

/**
* 转账金额,单位为分.
*/
@SerializedName("transfer_amount")
private Integer transferAmount;

/**
* 转账备注,用户确认收款时可见.
*/
@SerializedName("transfer_remark")
private String transferRemark;

/**
* 转账结果通知地址.
*/
@SerializedName("notify_url")
private String notifyUrl;

/**
* 用户收款感知.
*/
@SerializedName("user_recv_perception")
private String userRecvPerception;

/**
* 转账场景报备信息.
*/
@SerializedName("transfer_scene_report_infos")
private List<TransferSceneReportInfo> transferSceneReportInfos;

/**
* 免确认收款授权信息.
*/
@SerializedName("authorization_info")
private AuthorizationInfo authorizationInfo;

/**
* 出资商户号.
*/
@SerializedName("sponsor_mchid")
private String sponsorMchid;

/**
* 转账场景报备信息.
*/
@Data
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
public static class TransferSceneReportInfo implements Serializable {
private static final long serialVersionUID = 1L;

/**
* 信息类型.
*/
@SerializedName("info_type")
private String infoType;

/**
* 信息内容.
*/
@SerializedName("info_content")
private String infoContent;
}

/**
* 免确认收款授权信息.
*/
@Data
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
public static class AuthorizationInfo implements Serializable {
private static final long serialVersionUID = 1L;

/**
* 用户展示名称,用于在授权详情中区分用户在商户侧的账号.
*/
@SerializedName("user_display_name")
private String userDisplayName;

/**
* 商户侧授权单号.
*/
@SerializedName("out_authorization_no")
private String outAuthorizationNo;

/**
* 免确认收款授权结果通知地址.
*/
@SerializedName("authorization_notify_url")
private String authorizationNotifyUrl;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.github.binarywang.wxpay.bean.transfer;

import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* 发起转账并完成免确认收款授权响应结果.
*
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4014399293">发起转账并完成免确认收款授权</a>
*/
@Data
@NoArgsConstructor
public class PreTransferWithAuthorizationResult implements Serializable {
private static final long serialVersionUID = 1L;

/**
* 商户单号.
*/
@SerializedName("out_bill_no")
private String outBillNo;

/**
* 微信转账单号.
*/
@SerializedName("transfer_bill_no")
private String transferBillNo;

/**
* 单据创建时间.
*/
@SerializedName("create_time")
private String createTime;

/**
* 单据状态.
*
* @see WxPayConstants.TransformBillState
*/
@SerializedName("state")
private String state;

/**
* 跳转领取页面的 package 信息.
*/
@SerializedName("package_info")
private String packageInfo;

/**
* 用户展示名称.
*/
@SerializedName("user_display_name")
private String userDisplayName;

/**
* 商户侧授权单号.
*/
@SerializedName("out_authorization_no")
private String outAuthorizationNo;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package com.github.binarywang.wxpay.bean.transfer;

import com.github.binarywang.wxpay.v3.SpecEncrypt;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
* 用户授权后转账请求参数.
*
* <p>该接口用于给已经完成免确认收款授权的用户发起转账。请求中不再传 openid,
* 而是通过微信免确认收款授权单号或商户侧授权单号定位已授权用户。</p>
*
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4014399371">用户授权后转账</a>
*/
@Data
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
public class TransferBillsAfterAuthorizationRequest implements Serializable {
private static final long serialVersionUID = 1L;

/**
* 商户 AppID.
*/
@SerializedName("appid")
private String appid;

/**
* 商户系统内部的商家转账单号.
*/
@SerializedName("out_bill_no")
private String outBillNo;

/**
* 收款用户姓名.
*
* <p>该字段为敏感信息,提交前需要使用微信支付公钥或平台证书公钥加密。</p>
*/
@SpecEncrypt
@SerializedName("user_name")
private String userName;

/**
* 转账金额,单位为分.
*/
@SerializedName("transfer_amount")
private Integer transferAmount;

/**
* 转账备注.
*/
@SerializedName("transfer_remark")
private String transferRemark;

/**
* 转账结果通知地址.
*/
@SerializedName("notify_url")
private String notifyUrl;
Comment on lines +64 to +65

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 不要在授权后转账请求中序列化 notify_url

用户授权后转账接口的请求体只包含 appid/out_bill_no/transfer_scene_id/user_name/transfer_amount/transfer_remark/user_recv_perception/transfer_scene_report_infos/authorization_id/sponsor_mchid/out_authorization_no,并没有 notify_url;如果调用方像普通转账一样设置这里的 notifyUrlGSON.toJson(request) 会把多余字段发给微信支付,容易被接口按参数错误拒绝。建议移除此字段或确保该接口不会序列化它。

Useful? React with 👍 / 👎.


/**
* 用户收款感知.
*/
@SerializedName("user_recv_perception")
private String userRecvPerception;

/**
* 转账场景 ID.
*/
@SerializedName("transfer_scene_id")
private String transferSceneId;

/**
* 转账场景报备信息.
*/
@SerializedName("transfer_scene_report_infos")
private List<TransferSceneReportInfo> transferSceneReportInfos;

/**
* 微信免确认收款授权单号,通常可从授权成功回调或授权查询接口获取.
*/
@SerializedName("authorization_id")
private String authorizationId;

/**
* 出资商户号.
*/
@SerializedName("sponsor_mchid")
private String sponsorMchid;

/**
* 商户侧授权单号,对应发起授权时传入的 out_authorization_no.
*/
@SerializedName("out_authorization_no")
private String outAuthorizationNo;

/**
* 转账场景报备信息.
*/
@Data
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
public static class TransferSceneReportInfo implements Serializable {
private static final long serialVersionUID = 1L;

/**
* 信息类型.
*/
@SerializedName("info_type")
private String infoType;

/**
* 信息内容.
*/
@SerializedName("info_content")
private String infoContent;
}
}
Loading