Compare commits
No commits in common. "bd00a6125e7f831563aece34ef71914795332f8d" and "07470c037d45ec9cfb058ac7ced7dbaf0602f3cc" have entirely different histories.
bd00a6125e
...
07470c037d
|
@ -1,28 +0,0 @@
|
||||||
-----BEGIN PRIVATE KEY-----
|
|
||||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDMBI4+DYjagdDr
|
|
||||||
HHIEBu2xyZQXhtKHvwwawu//wx/qm9WLS4U4hIgpIIAIhMlCna6w9RbFM4b09ycL
|
|
||||||
GHR+Iq5jaEbekSPH/98ssEN48CCuZoCrVoaArSpayDO2++4VGkZrWJAPXckTVV3c
|
|
||||||
NXQVQIPnvm9YY2FQjAKGvzQ3bNLF6xOBfN8kn9ZZEyXEYa/acaD5YzbUoB45P6Yp
|
|
||||||
Df4WtLDAVj8qW+yUFLsmKuuISBBBhZPMMaDCaVWXPevwCUEV8JE7GHzpoHlEq/Lh
|
|
||||||
khXU1yoTL0E8l6Dw+t6fXMAxRr/g7BzPrDwc3Csd/fePybgVDyIaJIkT75X37OSc
|
|
||||||
klhZlOuBAgMBAAECggEAOc1wn5QmGgJ9tp8wjoOIBL8f/ipsq5ktTMe+R7B48neE
|
|
||||||
YRrce87Q5RYYMFGu0/jo7aoC8YxPyEfd//7FwpcA4ZlBuv1ULe4IxRiLhVBDciYI
|
|
||||||
foLdSMfHIEFopYdrRP9UxEUrS68+sQOWvDVI1lyZAqep1FkT0UZZ0OOLX8itTvVx
|
|
||||||
6EN67EjpVfg60sQ3IxDc1qmhh/+qKC1XBmnCn73wB/OZ6EtVjmgQEVJFspK9bK7j
|
|
||||||
J9zHBPTaeyNwC9eKKUeoxiESd5r2sugu8yZ8kvqwhJECa4AgHOZfskxG4YhmhROk
|
|
||||||
l7aI0Vw/fXngj7hXyMXXHuk7FgkdMpNcVwz2RBR4AQKBgQDmaxiV52tjMp+vqNAi
|
|
||||||
XjsE/jLAQuOI1Sz9gUoHipT4qdHnPgvtygMjSrVBCb28CE/tyNp3t/DVDuRmg+HE
|
|
||||||
GGXhfJPA2L6uOelsH7QKyQlWSqcv8BykDPEumwhubjv/bjJw4/HkZOP3LiLSGuzu
|
|
||||||
K+1dlcww3Fa2bEL62pN6TltdsQKBgQDiqxvG3vVIQo4kckaGNyrPDi55oph8k4H1
|
|
||||||
s450YDfEXCy95PXpeltK9gJO/bUDmqcliLDY8PBK7aGcmEdkRcLo6KBpOS0KDRdu
|
|
||||||
ATadnGn1w+DCtHSmrecZ5J6If+F/9YIPCCQ4gYXsVIniX6xDxhcR/Y6VVP0WwO37
|
|
||||||
QwaDzmnO0QKBgAbl6eSC+xoLJ/CwUxrUS1wI6CgNWJZ+G0yzlC3JnlAbdWdA2kaS
|
|
||||||
J6nk0KxTyFRaw1nRC4lN/m3CdmADTrz6JgKsIhhB5ON+ZFiSUmeIQTlOHtc2jwTy
|
|
||||||
Rj4o8gWsUyuAdw4eJN27j3+U6AH2QGWY9xA4LdbAoe/wKcksxgGBWwbhAoGBAJSJ
|
|
||||||
susxAqX2z3U82dBsaIZFcdlN3wWMGJctsoW64/CuwrcySqBVCWxnKH4hLjUNbMlg
|
|
||||||
+RtBUQaZENYwyGACg0bj4vLxf/1dNORmsSa58IoYcbrGTMdJoO9L7UPgIaMb/L3j
|
|
||||||
BPFul5eWksEhFx9WuZmVgpGDn1MA3TNR6fwIEThxAoGBAIcHOfiJH3d3q33aODPA
|
|
||||||
cqZb5RVNc1ZpiXC5yBwsiuTw3TYXuJmcUrRKuStsXXkIr2vyc3x9Af5+vWy7eJw/
|
|
||||||
+N+p5zxW9F5QQdEZKt/ALjXEonxkRlebz+GvsWYEP9+Li8DwFM1wlc97kLLt4XJn
|
|
||||||
EK4LLlyBAz3ZBGm18p7RgnMP
|
|
||||||
-----END PRIVATE KEY-----
|
|
11
pom.xml
11
pom.xml
|
@ -20,17 +20,6 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<!-- 使用谷歌的gson来实现json的传递-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
|
|
@ -9,8 +9,6 @@ import com.jwl.driver.server.vo.AppletPayVo;
|
||||||
import com.wechat.pay.java.core.Config;
|
import com.wechat.pay.java.core.Config;
|
||||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||||
import com.wechat.pay.java.core.exception.ServiceException;
|
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.JsapiServiceExtension;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.model.*;
|
import com.wechat.pay.java.service.payments.jsapi.model.*;
|
||||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||||
|
@ -23,20 +21,16 @@ 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 org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UncheckedIOException;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付小程序 接口
|
* 微信支付小程序 接口
|
||||||
*/
|
*/
|
||||||
@Api(tags = "小程序支付")
|
@Api(tags = "小程序支付")
|
||||||
@RestController
|
@Controller
|
||||||
@RequestMapping("/applet/pay")
|
@RequestMapping("/applet/pay")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AppletPayController {
|
public class AppletPayController {
|
||||||
|
@ -52,7 +46,6 @@ public class AppletPayController {
|
||||||
@PostMapping("/prepay")
|
@PostMapping("/prepay")
|
||||||
public BaseResponse createPrepay(@RequestBody AppletPayVo payDto){
|
public BaseResponse createPrepay(@RequestBody AppletPayVo payDto){
|
||||||
// 构建service
|
// 构建service
|
||||||
log.info("payDto===================>{}",payDto);
|
|
||||||
JsapiServiceExtension service = createService();
|
JsapiServiceExtension service = createService();
|
||||||
OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(payDto.getMoney(),payDto.getUserId(), payDto.getDescription(), payDto.getOutTradeNo(), "applet");
|
OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(payDto.getMoney(),payDto.getUserId(), payDto.getDescription(), payDto.getOutTradeNo(), "applet");
|
||||||
|
|
||||||
|
@ -73,46 +66,25 @@ public class AppletPayController {
|
||||||
// 调用下单方法,得到应答
|
// 调用下单方法,得到应答
|
||||||
PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
|
PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
|
||||||
// 使用微信扫描 code_url 对应的二维码,即可体验Native支付
|
// 使用微信扫描 code_url 对应的二维码,即可体验Native支付
|
||||||
log.info("response=================>{}",response);
|
// log.info(response);
|
||||||
// return BaseResponse.success();
|
|
||||||
return BaseResponse.success(response);
|
return BaseResponse.success(response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 构建service */
|
/** 构建service */
|
||||||
private JsapiServiceExtension createService() {
|
private JsapiServiceExtension createService() {
|
||||||
|
ClassPathResource keyClassPath = new ClassPathResource("/wechatpay/apiclient_key.pem");
|
||||||
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("wechatPay/apiclient_key.pem");
|
String privateKeyPath = null;
|
||||||
String keyString;
|
|
||||||
try {
|
try {
|
||||||
Throwable var2 = null;
|
privateKeyPath = keyClassPath.getURL().getPath();
|
||||||
try {
|
} catch (IOException e) {
|
||||||
keyString = IOUtil.toString(inputStream);
|
throw new RuntimeException(e);
|
||||||
} 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 =
|
Config config =
|
||||||
new RSAAutoCertificateConfig.Builder()
|
new RSAAutoCertificateConfig.Builder()
|
||||||
.merchantId(wechatPayConfig.getMchId())
|
.merchantId(wechatPayConfig.getMchId())
|
||||||
.privateKey(PemUtil.loadPrivateKeyFromString(keyString))
|
|
||||||
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
|
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
|
||||||
|
.privateKeyFromPath(privateKeyPath)
|
||||||
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
||||||
.apiV3Key(wechatPayConfig.getApiV3Key())
|
.apiV3Key(wechatPayConfig.getApiV3Key())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -8,8 +8,6 @@ import com.jwl.driver.server.vo.H5PayVo;
|
||||||
import com.wechat.pay.java.core.Config;
|
import com.wechat.pay.java.core.Config;
|
||||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||||
import com.wechat.pay.java.core.exception.ServiceException;
|
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.H5Service;
|
||||||
import com.wechat.pay.java.service.payments.h5.model.*;
|
import com.wechat.pay.java.service.payments.h5.model.*;
|
||||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||||
|
@ -22,12 +20,9 @@ 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 org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UncheckedIOException;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -35,7 +30,7 @@ import java.util.Objects;
|
||||||
* 微信支付小程序 接口
|
* 微信支付小程序 接口
|
||||||
*/
|
*/
|
||||||
@Api(tags = "H5支付")
|
@Api(tags = "H5支付")
|
||||||
@RestController
|
@Controller
|
||||||
@RequestMapping("/H5/pay")
|
@RequestMapping("/H5/pay")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class H5PayController {
|
public class H5PayController {
|
||||||
|
@ -78,38 +73,18 @@ public class H5PayController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private H5Service createService() {
|
private H5Service createService() {
|
||||||
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("wechatPay/apiclient_key.pem");
|
ClassPathResource keyClassPath = new ClassPathResource("/wechatpay/apiclient_key.pem");
|
||||||
String keyString;
|
String privateKeyPath = null;
|
||||||
try {
|
try {
|
||||||
Throwable var2 = null;
|
privateKeyPath = keyClassPath.getURL().getPath();
|
||||||
try {
|
} catch (IOException e) {
|
||||||
keyString = IOUtil.toString(inputStream);
|
throw new RuntimeException(e);
|
||||||
} 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 =
|
Config config =
|
||||||
new RSAAutoCertificateConfig.Builder()
|
new RSAAutoCertificateConfig.Builder()
|
||||||
.merchantId(wechatPayConfig.getMchId())
|
.merchantId(wechatPayConfig.getMchId())
|
||||||
.privateKey(PemUtil.loadPrivateKeyFromString(keyString))
|
|
||||||
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
|
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
|
||||||
|
.privateKeyFromPath(privateKeyPath)
|
||||||
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
||||||
.apiV3Key(wechatPayConfig.getApiV3Key())
|
.apiV3Key(wechatPayConfig.getApiV3Key())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -70,7 +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
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,14 @@ package com.jwl.driver.server;
|
||||||
import com.jwl.driver.server.config.WechatPayConfig;
|
import com.jwl.driver.server.config.WechatPayConfig;
|
||||||
import com.wechat.pay.java.core.Config;
|
import com.wechat.pay.java.core.Config;
|
||||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
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 com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.data.repository.init.ResourceReader;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UncheckedIOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 曹林
|
* @author 曹林
|
||||||
|
@ -32,42 +26,17 @@ public class WechatPayTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createService() throws IOException {
|
void createService() throws IOException {
|
||||||
|
ClassPathResource keyClassPath = new ClassPathResource("/wechatpay/apiclient_key.pem");
|
||||||
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("wechatPay/apiclient_key.pem");
|
String privateKeyPath = keyClassPath.getURL().getPath();
|
||||||
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 =
|
Config config =
|
||||||
new RSAAutoCertificateConfig.Builder()
|
new RSAAutoCertificateConfig.Builder()
|
||||||
.merchantId(wechatPayConfig.getMchId())
|
.merchantId(wechatPayConfig.getMchId())
|
||||||
.privateKey(PemUtil.loadPrivateKeyFromString(keyString))
|
.privateKeyFromPath(privateKeyPath)
|
||||||
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
|
|
||||||
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
|
||||||
.apiV3Key(wechatPayConfig.getApiV3Key())
|
.apiV3Key(wechatPayConfig.getApiV3Key())
|
||||||
.build();
|
.build();
|
||||||
H5Service service = new H5Service.Builder().config(config).build();
|
JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(config).build();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue