package com.zhongzheng.common.config;

import com.zhongzheng.common.utils.wxpay.IWXPayDomain;
import com.zhongzheng.common.utils.wxpay.WXPayConfig;
import com.zhongzheng.common.utils.wxpay.WXPayConstants;
import org.springframework.beans.factory.annotation.Value;

import java.io.InputStream;

public class WxSmallConfig extends WXPayConfig {

    private String appid;

    private String mchid;

    private String key;

    public WxSmallConfig(String appid,String mchid,String key)  {
      this.appid = appid;
      this.mchid = mchid;
      this.key = key;
    }
    @Override
    public String getAppID() {
        return appid;
    }

    @Override
    public String getMchID() {
        return mchid;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public InputStream getCertStream() {
        return null;
    }

    @Override
    public IWXPayDomain getWXPayDomain() {

        // 这个方法需要这样实现, 否则无法正常初始化WXPay
        IWXPayDomain iwxPayDomain = new IWXPayDomain() {

            public void report(String domain, long elapsedTimeMillis, Exception ex) {

            }

            public DomainInfo getDomain(WXPayConfig config) {
                return new IWXPayDomain.DomainInfo(WXPayConstants.DOMAIN_API, true);
            }
        };
        return iwxPayDomain;

    }
}
