🆕 #1746: 【企业微信】第三方应用增加授权配置接口,同时增加向员工付款的接口

This commit is contained in:
LinXiaoHuChong
2020-11-29 23:00:38 +08:00
committed by GitHub
parent c0af379370
commit 0e2186632a
6 changed files with 324 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package com.github.binarywang.wxpay.service;
import com.github.binarywang.wxpay.bean.entpay.*;
import com.github.binarywang.wxpay.bean.entwxpay.EntWxEmpPayRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
/**
@@ -143,4 +144,15 @@ public interface EntPayService {
* @throws WxPayException the wx pay exception
*/
EntPayRedpackQueryResult queryEnterpriseRedpack(EntPayRedpackQueryRequest request) throws WxPayException;
/**
* 向员工付款
* 文档详见 https://work.weixin.qq.com/api/doc/90000/90135/90278
* 接口链接 https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/paywwsptrans2pocket
*
* @param request 请求对象
* @return EntPayResult the ent pay result
* @throws WxPayException the wx pay exception
*/
EntPayResult toEmpPay(EntWxEmpPayRequest request) throws WxPayException;
}

View File

@@ -1,6 +1,7 @@
package com.github.binarywang.wxpay.service.impl;
import com.github.binarywang.wxpay.bean.entpay.*;
import com.github.binarywang.wxpay.bean.entwxpay.EntWxEmpPayRequest;
import com.github.binarywang.wxpay.bean.request.WxPayDefaultRequest;
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
import com.github.binarywang.wxpay.constant.WxPayConstants;
@@ -151,6 +152,24 @@ public class EntPayServiceImpl implements EntPayService {
return result;
}
@Override
public EntPayResult toEmpPay(EntWxEmpPayRequest request) throws WxPayException {
//企业微信签名,需要在请求签名之前
request.setNonceStr(String.valueOf(System.currentTimeMillis()));
request.setWorkWxSign(SignUtils.createEntSign(request.getAmount(), request.getAppid(), request.getDescription(),
request.getMchId(), request.getNonceStr(), request.getOpenid(), request.getPartnerTradeNo(),
request.getWwMsgType(), payService.getConfig().getEntPayKey(), WxPayConstants.SignType.MD5));
request.checkAndSign(this.payService.getConfig());
String url = this.payService.getPayBaseUrl() + "/mmpaymkttransfers/promotion/paywwsptrans2pocket";
String responseContent = this.payService.post(url, request.toXML(), true);
final EntPayResult result = BaseWxPayResult.fromXML(responseContent, EntPayResult.class);
result.checkResult(this.payService, request.getSignType(), true);
return result;
}
private String encryptRSA(File publicKeyFile, String srcString) throws WxPayException {
try {
Security.addProvider(new BouncyCastleProvider());