package com.cirle.scientific.utils.weixin;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import com.github.wxpay.sdk.WXPayConfig;

public class PayConfig implements WXPayConfig{

	private byte[] certData;
	
	private String appId;
	private String mchId;
	private String apiKey;

    public PayConfig(String appId, String mchId, String apiKey) throws Exception {
    	this.appId = appId;
    	this.mchId = mchId;
    	this.apiKey = apiKey;
    	String certPath = "/data/wx_p12/apiclient_cert.p12";
    	System.out.println("****证书路径****："+certPath);
    	File file = new File(certPath);
    	System.out.println("****创建证书文件****："+file);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
    }

    public String getAppID() {
		return this.appId;
    }

    public String getMchID() {
    	return this.mchId;
    }

    public String getKey() {
    	return this.apiKey;
    }

    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    public int getHttpReadTimeoutMs() {
        return 10000;
    }

	public byte[] getCertData() {
		return certData;
	}

	public void setCertData(byte[] certData) {
		this.certData = certData;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getMchId() {
		return mchId;
	}

	public void setMchId(String mchId) {
		this.mchId = mchId;
	}
    
    
}