package ink.wgink.module.wechat.manager.pay.v3;

import ink.wgink.module.wechat.utils.pay.PayCertificateUtil;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.security.cert.X509Certificate;

/**
 * @ClassName: PayMiniappManager
 * @Description: 支付管理
 * @Author: wanggeng
 * @Date: 2021/8/19 11:10 上午
 * @Version: 1.0
 */
public class PayManager {

    private static final PayManager PAY_MANAGER = PayMiniappManagerBuilder.payManager;
    private X509Certificate x509Certificate;

    private PayManager() {
    }

    public static PayManager getInstance() {
        return PAY_MANAGER;
    }

    public X509Certificate getX509Certificate() {
        return x509Certificate;
    }

    public void setX509Certificate(String certificatePath) throws FileNotFoundException {
        this.x509Certificate = PayCertificateUtil.getCertificate(new FileInputStream(certificatePath));
    }

    private static class PayMiniappManagerBuilder {
        public static PayManager payManager = new PayManager();
    }

}
