查询调整

dev
caolin 2023-08-24 01:06:56 +08:00
parent 66548f73df
commit 07470c037d
4 changed files with 56 additions and 2 deletions

View File

@ -16,12 +16,14 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
/**
@ -71,10 +73,18 @@ public class AppletPayController {
/** 构建service */
private JsapiServiceExtension createService() {
ClassPathResource keyClassPath = new ClassPathResource("/wechatpay/apiclient_key.pem");
String privateKeyPath = null;
try {
privateKeyPath = keyClassPath.getURL().getPath();
} catch (IOException e) {
throw new RuntimeException(e);
}
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.privateKeyFromPath(privateKeyPath)
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();

View File

@ -15,12 +15,14 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Objects;
@ -71,10 +73,18 @@ public class H5PayController {
}
private H5Service createService() {
ClassPathResource keyClassPath = new ClassPathResource("/wechatpay/apiclient_key.pem");
String privateKeyPath = null;
try {
privateKeyPath = keyClassPath.getURL().getPath();
} catch (IOException e) {
throw new RuntimeException(e);
}
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.privateKeyFromPath(privateKeyPath)
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();

View File

@ -70,6 +70,7 @@ wechatpay:
mchId: 1650477646
apiV3Key: JingWuLianJiaKao20120813ZhouHong
mchSerialNo: 52974C99DFCC518EA2E5AD20C3753E38B924868D
# privateKeyPath: classpath*:/wechatPay/apiclient_key.pem
privateKeyPath: classpath*:/wechatPay/apiclient_key.pem
payNoticeUrl: https://jwl.ahduima.com/driver-api/payNoticeLog

View File

@ -1,9 +1,42 @@
package com.jwl.driver.server;
import com.jwl.driver.server.config.WechatPayConfig;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Profile;
import org.springframework.core.io.ClassPathResource;
import java.io.IOException;
/**
* @author
* @description
* @create 2023/8/21 10:36
*/
@SpringBootTest
@Profile("dev")
public class WechatPayTest {
@Autowired
private WechatPayConfig wechatPayConfig;
@Test
void createService() throws IOException {
ClassPathResource keyClassPath = new ClassPathResource("/wechatpay/apiclient_key.pem");
String privateKeyPath = keyClassPath.getURL().getPath();
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
.privateKeyFromPath(privateKeyPath)
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();
JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(config).build();
}
}