-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
feat(pay): add merchant transfer user authorization APIs #4051
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
Open
zhangzhao0219
wants to merge
1
commit into
binarywang:develop
Choose a base branch
from
zhangzhao0219:weixin-java-pay.add-user-authorization
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
There are no files selected for viewing
154 changes: 154 additions & 0 deletions
154
...n/java/com/github/binarywang/wxpay/bean/transfer/PreTransferWithAuthorizationRequest.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,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; | ||
| } | ||
| } |
63 changes: 63 additions & 0 deletions
63
...in/java/com/github/binarywang/wxpay/bean/transfer/PreTransferWithAuthorizationResult.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,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; | ||
| } |
125 changes: 125 additions & 0 deletions
125
...ava/com/github/binarywang/wxpay/bean/transfer/TransferBillsAfterAuthorizationRequest.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,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; | ||
|
|
||
| /** | ||
| * 用户收款感知. | ||
| */ | ||
| @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; | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
用户授权后转账接口的请求体只包含 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;如果调用方像普通转账一样设置这里的notifyUrl,GSON.toJson(request)会把多余字段发给微信支付,容易被接口按参数错误拒绝。建议移除此字段或确保该接口不会序列化它。Useful? React with 👍 / 👎.