puzhibing
2024-08-17 1b43670626f48266efb898ec7cd7deedcab9ba10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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.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);
        try {
            certData = IOUtils.toByteArray(certStream);
        } catch (IOException e) {
            throw new RuntimeException("私钥文件未找到");
        }finally {
            try {
                certStream.close();
            } catch (IOException e) {
                log.error("私钥流关闭异常");
            }
        }
        return new ByteArrayInputStream(certData);
    }
}