using CrazyStudio.Core.Common.WeChat;

namespace CrazyStudio.Core.Pay.TenPay.Lib
{
    /**
    * 	配置账号信息
    */
    public class WxPayConfig
    {
        //=======【基本信息设置】=====================================
        /* 微信公众号信息配置
        * APPID：绑定支付的APPID（必须配置）
        * MCHID：商户号（必须配置）
        * KEY：商户支付密钥，参考开户邮件设置（必须配置）
        * APPSECRET：公众帐号secert（仅JSAPI支付的时候需要配置）
        * MpTag：微信公众平台标识
        * OpenTag：微信开放平台标识
        */
        //public static string APPID = "";// ConfigExtensions.Configuration["WeChat:Open:AppID"];
        //public static string APPSECRET = "";//ConfigExtensions.Configuration["WeChat:Open:APPSECRET"];

        //public static string MCHID = "";//ConfigExtensions.Configuration["WeChat:Open:MchID"];
        //public static string MpTag = ConfigurationManager.AppSettings["WeChat.MP.Tag"];
        //public static string OpenTag = ConfigurationManager.AppSettings["WeChat.Open.Tag"];

        ///*公众平台参数*/
        public static string MP_APPID = "";// ConfigExtensions.Configuration["WeChat:MP:AppID"];
        public static string MP_APPSECRET = "";//ConfigExtensions.Configuration["WeChat:MP:APPSECRET"];
        public static string MP_MCHID = "";//ConfigExtensions.Configuration["WeChat:MP:MchID"];
        public static string MCHKEY = "";//ConfigExtensions.Configuration["WeChat:MP:MchKEY"];

        //=======【证书路径设置】===================================== 
        /* 证书路径,注意应该填写绝对路径（仅退款、撤销订单时需要）
        */
        public static string SSLCERT_PATH = "";//ConfigExtensions.Configuration["WeChat:MchP12_PATH"];//p12
        public static string SSLCERT_PASSWORD = "";//ConfigExtensions.Configuration["WeChat:MchP12_PASSWORD"];//p12;//"1233410002";



        //=======【支付结果通知url】===================================== 
        /* 支付结果通知回调url，用于商户接收支付结果
        */
        public static string PAY_NOTIFY_URL = "";//ConfigExtensions.Configuration["WeChat:NOTIFY_URL"];

        //=======【退款结果通知url】===================================== 
        /* 退款结果通知回调url，用于商户接收支付结果
        */
        public static string REFUND_NOTIFY_URL = "";//ConfigExtensions.Configuration["WeChat:NOTIFY_URL"];

        //=======【商户系统后台机器IP】===================================== 
        /* 此参数可手动配置也可在程序中自动获取
        */
        public static string IP = "";//ConfigExtensions.Configuration["WeChat:BACKGROUND_WANIP"];


        //=======【代理服务器设置】===================================
        /* 默认IP和端口号分别为0.0.0.0和0，此时不开启代理（如有需要才设置）
        */
        public const string PROXY_URL = "http://10.152.18.220:8080";

        //=======【上报信息配置】===================================
        /* 测速上报等级，0.关闭上报; 1.仅错误时上报; 2.全量上报
        */
        public const int REPORT_LEVENL = 1;

        //=======【日志级别】===================================
        /* 日志等级，0.不输出日志；1.只输出错误信息; 2.输出错误和正常信息; 3.输出错误信息、正常信息和调试信息
        */
        public const int LOG_LEVENL = 0;


        public readonly static WeChatOptions WeChatOptions;

        static WxPayConfig()
        {
            const string WeChatOption = "WeChat";
            WeChatOptions = new WeChatOptions
            {
                AppID = AppSettings.Option(WeChatOption, "AppID"),
                AppSecret = AppSettings.Option(WeChatOption, "AppSecret"),
                Ip = AppSettings.Option(WeChatOption, "Ip"),
                MchID = AppSettings.Option(WeChatOption, "MchID"),
                MchKey = AppSettings.Option(WeChatOption, "MchKey"),
                PayNotifyUrl = AppSettings.Option(WeChatOption, "PayNotifyUrl"),
                RefundNotifyUrl = AppSettings.Option(WeChatOption, "RefundNotifyUrl"),
                SslCertPath = AppSettings.Option(WeChatOption, "SslCertPath"),
                SslCertPassword = AppSettings.Option(WeChatOption, "SslCertPassword"),
            };

            MP_APPID = WeChatOptions.AppID;
            MP_APPSECRET = WeChatOptions.AppSecret;
            MP_MCHID = WeChatOptions.MchID;
            MCHKEY = WeChatOptions.MchKey;

            SSLCERT_PATH = WeChatOptions.SslCertPath;
            SSLCERT_PASSWORD = WeChatOptions.SslCertPassword;

            PAY_NOTIFY_URL = WeChatOptions.PayNotifyUrl;
            REFUND_NOTIFY_URL = WeChatOptions.RefundNotifyUrl;
            IP = WeChatOptions.Ip;
        }

    }
}