mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
实现查询企业付款的API。 finish #51
This commit is contained in:
@@ -18,6 +18,7 @@ public interface WxMpPayService {
|
||||
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
|
||||
* 接口地址:https://api.mch.weixin.qq.com/pay/unifiedorder
|
||||
* @throws WxErrorException
|
||||
* @param request 请求对象
|
||||
*
|
||||
*/
|
||||
WxUnifiedOrderResult unifiedOrder(WxUnifiedOrderRequest request)
|
||||
@@ -26,11 +27,10 @@ public interface WxMpPayService {
|
||||
/**
|
||||
* 该接口调用“统一下单”接口,并拼装发起支付请求需要的参数
|
||||
* 详见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
|
||||
*
|
||||
* @param request 请求对象
|
||||
*/
|
||||
Map<String, String> getPayInfo(WxUnifiedOrderRequest request) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 该接口提供所有微信支付订单的查询,当支付通知处理异常戒丢失的情冴,商户可以通过该接口查询订单支付状态。
|
||||
* 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
|
||||
@@ -53,6 +53,7 @@ public interface WxMpPayService {
|
||||
* 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
|
||||
* 接口链接:https://api.mch.weixin.qq.com/secapi/pay/refund
|
||||
* </pre>
|
||||
* @param request 请求对象
|
||||
* @param keyFile 证书文件对象
|
||||
* @return 退款操作结果
|
||||
*/
|
||||
@@ -74,6 +75,7 @@ public interface WxMpPayService {
|
||||
* 发送普通红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3
|
||||
* 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4
|
||||
* </pre>
|
||||
* @param request 请求对象
|
||||
* @param keyFile 证书文件对象
|
||||
*/
|
||||
WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile) throws WxErrorException;
|
||||
@@ -86,9 +88,22 @@ public interface WxMpPayService {
|
||||
* 注意:与商户微信支付收款资金并非同一账户,需要单独充值。
|
||||
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
|
||||
* 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers
|
||||
* @param keyFile 证书文件对象
|
||||
* </pre>
|
||||
* @param request 请求对象
|
||||
* @param keyFile 证书文件对象
|
||||
*/
|
||||
WxEntPayResult entPay(WxEntPayRequest request, File keyFile) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 查询企业付款API
|
||||
* 用于商户的企业付款操作进行结果查询,返回付款操作详细结果。
|
||||
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3
|
||||
* 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo
|
||||
* </pre>
|
||||
* @param partnerTradeNo 商户订单号
|
||||
* @param keyFile 证书文件对象
|
||||
*/
|
||||
WxEntPayQueryResult queryEntPay(String partnerTradeNo, File keyFile) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
||||
@@ -369,6 +369,31 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxEntPayQueryResult queryEntPay(String partnerTradeNo, File keyFile) throws WxErrorException {
|
||||
XStream xstream = XStreamInitializer.getInstance();
|
||||
xstream.processAnnotations(WxEntPayQueryRequest.class);
|
||||
xstream.processAnnotations(WxEntPayQueryResult.class);
|
||||
|
||||
WxEntPayQueryRequest request = new WxEntPayQueryRequest();
|
||||
request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
|
||||
request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId());
|
||||
request.setNonceStr(System.currentTimeMillis() + "");
|
||||
|
||||
String sign = this.createSign(xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey());
|
||||
request.setSign(sign);
|
||||
|
||||
String url = PAY_BASE_URL + "/mmpaymkttransfers/gettransferinfo";
|
||||
|
||||
String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), request.getMchId());
|
||||
WxEntPayQueryResult result = (WxEntPayQueryResult) xstream.fromXML(responseContent);
|
||||
if ("FAIL".equals(result.getResultCode())) {
|
||||
throw new WxErrorException(
|
||||
WxError.newBuilder().setErrorMsg(result.getErrCode() + ":" + result.getErrCodeDes()).build());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String executeRequestWithKeyFile( String url, File keyFile, String requestStr, String mchId) throws WxErrorException {
|
||||
try (FileInputStream inputStream = new FileInputStream(keyFile)) {
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
|
||||
Reference in New Issue
Block a user