查询调整

dev
caolin 2023-08-24 03:01:33 +08:00
parent 443cf0b890
commit ae3af80e9c
3 changed files with 101 additions and 10 deletions

View File

@ -9,6 +9,8 @@ import com.jwl.driver.server.vo.AppletPayVo;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.exception.ServiceException;
import com.wechat.pay.java.core.util.IOUtil;
import com.wechat.pay.java.core.util.PemUtil;
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import com.wechat.pay.java.service.payments.jsapi.model.*;
import com.wechat.pay.java.service.payments.model.Transaction;
@ -23,7 +25,10 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.math.BigDecimal;
/**
@ -74,11 +79,37 @@ public class AppletPayController {
/** 构建service */
private JsapiServiceExtension createService() {
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("wechatPay/apiclient_key.pem");
String keyString;
try {
Throwable var2 = null;
try {
keyString = IOUtil.toString(inputStream);
} catch (Throwable var13) {
var2 = var13;
throw var13;
} finally {
if (inputStream != null) {
if (var2 != null) {
try {
inputStream.close();
} catch (Throwable var12) {
var2.addSuppressed(var12);
}
} else {
inputStream.close();
}
}
}
} catch (IOException var15) {
throw new UncheckedIOException(var15);
}
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
// .privateKeyFromPath(privateKeyPath)
.privateKey(PemUtil.loadPrivateKeyFromString(keyString))
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();

View File

@ -8,6 +8,8 @@ import com.jwl.driver.server.vo.H5PayVo;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.exception.ServiceException;
import com.wechat.pay.java.core.util.IOUtil;
import com.wechat.pay.java.core.util.PemUtil;
import com.wechat.pay.java.service.payments.h5.H5Service;
import com.wechat.pay.java.service.payments.h5.model.*;
import com.wechat.pay.java.service.payments.model.Transaction;
@ -23,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.math.BigDecimal;
import java.util.Objects;
@ -73,12 +77,38 @@ public class H5PayController {
}
private H5Service createService() {
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("wechatPay/apiclient_key.pem");
String keyString;
try {
Throwable var2 = null;
try {
keyString = IOUtil.toString(inputStream);
} catch (Throwable var13) {
var2 = var13;
throw var13;
} finally {
if (inputStream != null) {
if (var2 != null) {
try {
inputStream.close();
} catch (Throwable var12) {
var2.addSuppressed(var12);
}
} else {
inputStream.close();
}
}
}
} catch (IOException var15) {
throw new UncheckedIOException(var15);
}
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
// .privateKeyFromPath(privateKeyPath)
.privateKey(PemUtil.loadPrivateKeyFromString(keyString))
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();

View File

@ -3,14 +3,20 @@ 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.core.util.IOUtil;
import com.wechat.pay.java.core.util.PemUtil;
import com.wechat.pay.java.service.payments.h5.H5Service;
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 org.springframework.data.repository.init.ResourceReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
/**
* @author
@ -27,17 +33,41 @@ public class WechatPayTest {
@Test
void createService() throws IOException {
String privateKeyPath = Thread.currentThread().getContextClassLoader().getResource("wechatPay/apiclient_key.pem").getPath();
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("wechatPay/apiclient_key.pem");
String keyString;
try {
Throwable var2 = null;
try {
keyString = IOUtil.toString(inputStream);
} catch (Throwable var13) {
var2 = var13;
throw var13;
} finally {
if (inputStream != null) {
if (var2 != null) {
try {
inputStream.close();
} catch (Throwable var12) {
var2.addSuppressed(var12);
}
} else {
inputStream.close();
}
}
}
} catch (IOException var15) {
throw new UncheckedIOException(var15);
}
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
// .privateKeyFromPath(privateKeyPath)
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.privateKey(PemUtil.loadPrivateKeyFromString(keyString))
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();
JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(config).build();
H5Service service = new H5Service.Builder().config(config).build();
}
}