mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 22:11:40 +08:00
发送红包接口增加证书
This commit is contained in:
parent
a4642896a3
commit
f7f7d12347
@ -74,8 +74,9 @@ 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_4&index=3
|
||||||
* 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4
|
* 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4
|
||||||
* </pre>
|
* </pre>
|
||||||
|
* @param keyFile 证书文件对象
|
||||||
*/
|
*/
|
||||||
WxRedpackResult sendRedpack(WxSendRedpackRequest request) throws WxErrorException;
|
WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
|
@ -160,14 +160,15 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxRedpackResult sendRedpack(WxSendRedpackRequest request)
|
public WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile)
|
||||||
throws WxErrorException {
|
throws WxErrorException {
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
xstream.processAnnotations(WxSendRedpackRequest.class);
|
xstream.processAnnotations(WxSendRedpackRequest.class);
|
||||||
xstream.processAnnotations(WxRedpackResult.class);
|
xstream.processAnnotations(WxRedpackResult.class);
|
||||||
|
|
||||||
request.setWxAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
|
request.setWxAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
|
||||||
request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId());
|
String mchId = this.wxMpService.getWxMpConfigStorage().getPartnerId();
|
||||||
|
request.setMchId(mchId);
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
|
|
||||||
String sign = this.createSign(this.xmlBean2Map(request),
|
String sign = this.createSign(this.xmlBean2Map(request),
|
||||||
@ -180,7 +181,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
url = PAY_BASE_URL + "/mmpaymkttransfers/sendgroupredpack";
|
url = PAY_BASE_URL + "/mmpaymkttransfers/sendgroupredpack";
|
||||||
}
|
}
|
||||||
|
|
||||||
String responseContent = this.wxMpService.post(url, xstream.toXML(request));
|
String responseContent = this.executeRequestWithKeyFile(url, xstream.toXML(request), keyFile, mchId);
|
||||||
WxRedpackResult redpackResult = (WxRedpackResult) xstream
|
WxRedpackResult redpackResult = (WxRedpackResult) xstream
|
||||||
.fromXML(responseContent);
|
.fromXML(responseContent);
|
||||||
if ("FAIL".equals(redpackResult.getResultCode())) {
|
if ("FAIL".equals(redpackResult.getResultCode())) {
|
||||||
|
@ -62,7 +62,8 @@ public class WxMpPayServiceImplTest {
|
|||||||
request.setMchBillno("aaaa");
|
request.setMchBillno("aaaa");
|
||||||
request
|
request
|
||||||
.setReOpenid(((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid());
|
.setReOpenid(((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid());
|
||||||
WxRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request);
|
File keyFile = new File("E:\\dlt.p12");
|
||||||
|
WxRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request, keyFile);
|
||||||
System.err.println(redpackResult);
|
System.err.println(redpackResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user