Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

微信支付相关:新商户不再支持平台证书模式 只支持公钥模式 导致调用https://api.mch.weixin.qq.com/v3/certificates接口返回证书不存在 #3402

Copy link
Copy link
Closed
@lin-youming

Description

@lin-youming
Issue body actions

简要描述

微信支付官方的变更导致目前 新商户想入驻平台 调起支付时报错

模块版本情况

  • WxJava 模块名: weixin-java-pay
  • WxJava 版本号:4.6.0

详细描述

该方法请求https://api.mch.weixin.qq.com/v3/certificates接口获取平台证书 返回证书不存在 目前因微信官方变更导致新入驻的商户不在支持平台证书模式 转而支持公钥模式
private void autoUpdateCert() throws IOException, GeneralSecurityException {
WxPayV3HttpClientBuilder wxPayV3HttpClientBuilder = WxPayV3HttpClientBuilder.create()
.withCredentials(credentials)
.withValidator(verifier == null ? response -> true : new WxPayValidator(verifier));

//调用自定义扩展设置设置HTTP PROXY对象
HttpProxyUtils.initHttpProxy(wxPayV3HttpClientBuilder,this.wxPayHttpProxy);

//增加自定义扩展点,子类可以设置其他构造参数
this.customHttpClientBuilder(wxPayV3HttpClientBuilder);

CloseableHttpClient httpClient = wxPayV3HttpClientBuilder.build();

HttpGet httpGet = new HttpGet(CERT_DOWNLOAD_PATH);
httpGet.addHeader("Accept", "application/json");

CloseableHttpResponse response = httpClient.execute(httpGet);
int statusCode = response.getStatusLine().getStatusCode();
String body = EntityUtils.toString(response.getEntity());
if (statusCode == HttpStatus.SC_OK) {
  List<X509Certificate> newCertList = deserializeToCerts(apiV3Key, body);
  if (newCertList.isEmpty()) {
    throw new WxRuntimeException("Cert list is empty");
  }
  this.verifier = new CertificatesVerifier(newCertList);
} else {
  log.warn("Auto update cert failed, statusCode = " + statusCode + ",body = " + body);
  throw new WxRuntimeException(this.getErrorMsg(body));
}

}
sp20241030_173902_671

sp20241030_175710_193

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.