微信对账单 java_[Java]获取微信api中的下载对账单和下载资金账单功能

微信官方给的sdk有点问题,通过百度找到了maven依赖,这个比较靠谱

添加依赖

com.github.wxpay

wxpay-sdk

0.0.3

com.google.code.gson

gson

2.8.2

重写config

public class MyConfig implements WXPayConfig {

private byte[] certData;

public MyConfig() throws Exception {

String certPath = "F:\\work\\WxPayAPI_JAVA\\java_sdk_v3.0.9\\src\\main\\resource\\apiclient_cert.p12";

File file = new File(certPath);

InputStream certStream = new FileInputStream(file);

this.certData = new byte[(int) file.length()];

certStream.read(this.certData);

certStream.close();

}

public String getAppID() {

return "wx888888888";

}

public String getMchID() {

return "1234567897";

}

public String getKey() {

return "00000000000000000000000";

}

public InputStream getCertStream() {

ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);

return certBis;

}

public int getHttpConnectTimeoutMs() {

return 8000;

}

public int getHttpReadTimeoutMs() {

return 10000;

}

}

创建测试文件 WXPayExample.java

MyConfig config = new MyConfig();

WXPay wxpay = new WXPay(config, HMACSHA256);

Map data = new HashMap();

data.put("bill_date", "20181117");

data.put("bill_type", "ALL");

对账单数据

请求下载对账单的api方法

Map resp = wxpay.downloadBill(data);

String s = resp.get("data");

对于数据返回的 比较麻烦,所以用bean对其进行处理,方便装换成我们需要的数据类型

接收的数据bean

public class Pay

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值