🆕 #3474 【微信支付】增加2025.1.15正式上线的商户转账新版本的相关接口

This commit is contained in:
allovine
2025-01-16 13:46:02 +08:00
committed by GitHub
parent 83bd92d260
commit be0dd8b692
8 changed files with 317 additions and 0 deletions

View File

@@ -111,4 +111,31 @@ public interface TransferService {
*/
TransferBatchDetailResult transferBatchesOutBatchNoDetail(String outBatchNo, String outDetailNo) throws WxPayException;
/**
* <pre>
*
* 2025.1.15 开始新接口 发起商家转账API
*
* 请求方式POSTHTTPS
* 请求地址:<a href="https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills">请求地址</a>
*
* 文档地址:<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716434">发起商家转账API</a>
* </pre>
*
* @param request 转账请求参数
* @return TransferBillsResult 转账结果
* @throws WxPayException .
*/
TransferBillsResult transferBills(TransferBillsRequest request) throws WxPayException;
/**
* 2025.1.15 开始新接口 解析商家转账结果
* 详见<a href="https://pay.weixin.qq.com/doc/v3/merchant/4012712115"></a>
*
* @param notifyData 通知数据
* @param header 通知头部数据,不传则表示不校验头
* @return the wx transfer notify result
* @throws WxPayException the wx pay exception
*/
TransferBillsNotifyResult parseTransferBillsNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
}

View File

@@ -6,6 +6,7 @@ import com.github.binarywang.wxpay.bean.notify.*;
import com.github.binarywang.wxpay.bean.request.*;
import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.bean.transfer.TransferBillsNotifyResult;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.exception.WxPayException;
@@ -991,6 +992,17 @@ public interface WxPayService {
*/
WxPayTransferBatchesNotifyV3Result parseTransferBatchesNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException;
/**
* 解析商家转账批次回调通知
* https://pay.weixin.qq.com/doc/v3/merchant/4012712115
*
* @param notifyData
* @param header
* @return
* @throws WxPayException
*/
TransferBillsNotifyResult parseTransferBillsNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException;
/**
* 解析服务商模式退款结果通知
* 详见https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_11.shtml

View File

@@ -11,6 +11,7 @@ import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult;
import com.github.binarywang.wxpay.bean.request.*;
import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.bean.transfer.TransferBillsNotifyResult;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.config.WxPayConfigHolder;
import com.github.binarywang.wxpay.constant.WxPayConstants;
@@ -442,6 +443,11 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
return this.baseParseOrderNotifyV3Result(notifyData, header, WxPayTransferBatchesNotifyV3Result.class, WxPayTransferBatchesNotifyV3Result.DecryptNotifyResult.class);
}
@Override
public TransferBillsNotifyResult parseTransferBillsNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException {
return this.baseParseOrderNotifyV3Result(notifyData, header, TransferBillsNotifyResult.class, TransferBillsNotifyResult.DecryptNotifyResult.class);
}
@Override
public WxPayPartnerRefundNotifyV3Result parsePartnerRefundNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException {
return this.baseParseOrderNotifyV3Result(notifyData, header, WxPayPartnerRefundNotifyV3Result.class, WxPayPartnerRefundNotifyV3Result.DecryptNotifyResult.class);

View File

@@ -85,4 +85,20 @@ public class TransferServiceImpl implements TransferService {
String result = this.payService.getV3(url);
return GSON.fromJson(result, TransferBatchDetailResult.class);
}
@Override
public TransferBillsResult transferBills(TransferBillsRequest request) throws WxPayException {
String url = String.format("%s/v3/fund-app/mch-transfer/transfer-bills", this.payService.getPayBaseUrl());
if (request.getUserName() != null && request.getUserName().length() > 0) {
X509Certificate validCertificate = this.payService.getConfig().getVerifier().getValidCertificate();
RsaCryptoUtil.encryptFields(request, validCertificate);
}
String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(result, TransferBillsResult.class);
}
@Override
public TransferBillsNotifyResult parseTransferBillsNotifyResult(String notifyData, SignatureHeader header) throws WxPayException {
return this.payService.baseParseOrderNotifyV3Result(notifyData, header, TransferBillsNotifyResult.class, TransferBillsNotifyResult.DecryptNotifyResult.class);
}
}