package com.ruoyi.payment.wx.model;
|
|
import lombok.Data;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.poi.util.IOUtils;
|
|
import java.io.ByteArrayInputStream;
|
import java.io.FileInputStream;
|
import java.io.IOException;
|
import java.io.InputStream;
|
|
/**
|
* @author xiaochen
|
* @ClassName V3
|
* @Description
|
*/
|
@Slf4j
|
@Data
|
public class V3 {
|
/**
|
* 获取 API 密钥
|
*
|
* @return API密钥
|
*/
|
private String apiKey;
|
/**
|
* 秘钥路径,apiclient_key.pem
|
*/
|
private String privateKeyPath;
|
/**
|
* 商户证书序列号
|
*/
|
private String mchSerialNo;
|
|
/**
|
* 支付回调地址
|
*
|
* @return
|
*/
|
private String notifyPayUrl;
|
|
/**
|
* 退款回调地址
|
*
|
* @return
|
*/
|
private String notifyRefundUrl;
|
|
/**
|
* 退款回调地址
|
*/
|
private String notifyTravelRefundUrl;
|
|
|
public InputStream getPrivateKeyStream() {
|
// 需要证书释放
|
byte[] certData;
|
// InputStream certStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(this.privateKeyPath);
|
InputStream certStream = null;
|
try {
|
certStream = new FileInputStream(this.privateKeyPath);
|
certData = IOUtils.toByteArray(certStream);
|
} catch (IOException e) {
|
e.printStackTrace();
|
throw new RuntimeException("私钥文件未找到");
|
}finally {
|
if(null != certStream){
|
try {
|
certStream.close();
|
} catch (IOException e) {
|
log.error("私钥流关闭异常");
|
}
|
}
|
}
|
return new ByteArrayInputStream(certData);
|
}
|
}
|