查询调整
parent
66548f73df
commit
07470c037d
|
@ -16,12 +16,14 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,10 +73,18 @@ public class AppletPayController {
|
||||||
|
|
||||||
/** 构建service */
|
/** 构建service */
|
||||||
private JsapiServiceExtension createService() {
|
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 =
|
Config config =
|
||||||
new RSAAutoCertificateConfig.Builder()
|
new RSAAutoCertificateConfig.Builder()
|
||||||
.merchantId(wechatPayConfig.getMchId())
|
.merchantId(wechatPayConfig.getMchId())
|
||||||
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
|
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
|
||||||
|
.privateKeyFromPath(privateKeyPath)
|
||||||
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
||||||
.apiV3Key(wechatPayConfig.getApiV3Key())
|
.apiV3Key(wechatPayConfig.getApiV3Key())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -15,12 +15,14 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -71,10 +73,18 @@ public class H5PayController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private H5Service createService() {
|
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 =
|
Config config =
|
||||||
new RSAAutoCertificateConfig.Builder()
|
new RSAAutoCertificateConfig.Builder()
|
||||||
.merchantId(wechatPayConfig.getMchId())
|
.merchantId(wechatPayConfig.getMchId())
|
||||||
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
|
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
|
||||||
|
.privateKeyFromPath(privateKeyPath)
|
||||||
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
||||||
.apiV3Key(wechatPayConfig.getApiV3Key())
|
.apiV3Key(wechatPayConfig.getApiV3Key())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -70,6 +70,7 @@ wechatpay:
|
||||||
mchId: 1650477646
|
mchId: 1650477646
|
||||||
apiV3Key: JingWuLianJiaKao20120813ZhouHong
|
apiV3Key: JingWuLianJiaKao20120813ZhouHong
|
||||||
mchSerialNo: 52974C99DFCC518EA2E5AD20C3753E38B924868D
|
mchSerialNo: 52974C99DFCC518EA2E5AD20C3753E38B924868D
|
||||||
|
# privateKeyPath: classpath*:/wechatPay/apiclient_key.pem
|
||||||
privateKeyPath: classpath*:/wechatPay/apiclient_key.pem
|
privateKeyPath: classpath*:/wechatPay/apiclient_key.pem
|
||||||
payNoticeUrl: https://jwl.ahduima.com/driver-api/payNoticeLog
|
payNoticeUrl: https://jwl.ahduima.com/driver-api/payNoticeLog
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,42 @@
|
||||||
package com.jwl.driver.server;
|
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 曹林
|
* @author 曹林
|
||||||
* @description 微信支付
|
* @description 微信支付
|
||||||
* @create 2023/8/21 10:36
|
* @create 2023/8/21 10:36
|
||||||
*/
|
*/
|
||||||
|
@SpringBootTest
|
||||||
|
@Profile("dev")
|
||||||
public class WechatPayTest {
|
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();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue