wechatpay-apiv3 / wechatpay-java

微信支付 APIv3 的官方 Java Library
Apache License 2.0
870 stars 195 forks source link

feat: 下载账单 #212

Closed xy-peng closed 11 months ago

xy-peng commented 11 months ago
  1. 下载账单API
  2. 为交易账单和资金账单封装了一个接口,把申请和下载合为一步,并且提供了验证摘要的方法。

以下是示例,开发指引文档会在文档中心提供

BillDownloadServiceExtension service =
    new BillDownloadServiceExtension.Builder().config(config).build();
GetTradeBillRequest request = new GetTradeBillRequest();
request.setBillDate("2023-07-23");
request.setBillType(BillType.ALL);
request.setTarType(TarType.GZIP);
DigestBillEntity bill = service.getTradeBill(request);

try (InputStream inputStream = bill.getInputStream()) {
  try (BufferedOutputStream outputStream =
      new BufferedOutputStream(new PrintStream(System.out))) {
    byte[] buffer = new byte[16384];
    int bytesRead;
    while ((bytesRead = inputStream.read(buffer)) != -1) {
      outputStream.write(buffer, 0, bytesRead);
    }
  }
}

if (bill.verifyHash()) throw new RuntimeException();
sonarcloud[bot] commented 11 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

warning The version of Java (11.0.20) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17. Read more here