Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

gaigeshen/wechat-pay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

微信支付开发手册

License Build Status Maven Central Sonatype Nexus (Snapshots) GitHub last commit

添加依赖

<dependency>
  <groupId>me.gaigeshen.wechat</groupId>
  <artifactId>wechat-pay</artifactId>
  <version>${VERSION}</version>
</dependency>

构造配置实例

Config config = Config.builder()
    .appid("your appid")
    .mchId("your mchId")
    .key("your key")
    .secret("your secret")
    .build();

构造请求执行器实例

InputStream in = ...;
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(in, "your password".toCharArray());

SSLContext sslContext = SSLContextBuilder.create().loadKeyMaterial(keyStore, "your password".toCharArray()

HttpClientExecutor httpClient = new HttpClientExecutor(2000, 2000, 3000, sslContext);
RequestExecutor executor = new RequestExecutor(httpClient, config);

// 在必要的时候关闭
executor.close();

使用方式

// 普通请求
Request req = ...;
Response resp = executor.execute(req);

// 涉及下载文件的请求
Request req = ...;
ResponseBodyHandler handler = ...;
Response resp = executor.execute(req, handler);