Config.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5. using System.Xml.Serialization;
  6. namespace Wechat.PayAPI
  7. {
  8. /**
  9. * 配置账号信息
  10. */
  11. //public sealed class WxPayConfig
  12. //{
  13. // //=======【基本信息设置】=====================================
  14. // /* 微信公众号信息配置
  15. // * APPID:绑定支付的APPID(必须配置)
  16. // * SUBAPPID: 子商户的APPID
  17. // * MCHID:商户号(必须配置)
  18. // * SUBMCHID:子商户号
  19. // * KEY:商户支付密钥,参考开户邮件设置(必须配置)
  20. // * APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置)
  21. // */
  22. // public string APPID { get; set; }
  23. // public string SUBAPPID { get; set; }
  24. // public string MCHID { get; set; }
  25. // public string SUBMCHID { get; set; }
  26. // public string KEY { get; set; }
  27. // public string APPSECRET { get; set; }
  28. // //=======【证书设置】=====================================
  29. // /* 证书文件名(仅退款、撤销订单时需要)
  30. // */
  31. // public string SSLCERT { get; set; }
  32. // public string SSLCERT_PASSWORD { get; set; }
  33. // //=======【支付结果通知url】=====================================
  34. // /* 支付结果通知回调url,用于商户接收支付结果
  35. // */
  36. // public string NOTIFY_URL { get; set; }
  37. // //=======【商户系统后台机器IP】=====================================
  38. // /* 此参数可手动配置也可在程序中自动获取
  39. // */
  40. // public string IP { get; set; }
  41. // //=======【代理服务器设置】===================================
  42. // /* 默认IP和端口号分别为0.0.0.0和0,此时不开启代理(如有需要才设置)
  43. // */
  44. // public string PROXY_URL { get; set; }
  45. // //=======【上报信息配置】===================================
  46. // /* 测速上报等级,0.关闭上报; 1.仅错误时上报; 2.全量上报
  47. // */
  48. // public int REPORT_LEVENL { get; set; }
  49. // //=======【日志级别】===================================
  50. // /* 日志等级,0.不输出日志;1.只输出错误信息; 2.输出错误和正常信息; 3.输出错误信息、正常信息和调试信息
  51. // */
  52. // //public const int LOG_LEVENL = 0;
  53. // // the following are for singelton
  54. // private const string CONFIG_PATH = @"\WeChatPaymentProcessor\Wechat\Config\";
  55. // private const string CONFIG_FILE = @"\WxPayConfig.xml";
  56. // private const string CERT_PATH = @"\WeChatPaymentProcessor\Wechat\Cert\";
  57. // private static volatile WxPayConfig instance = null;
  58. // private static volatile Dictionary<string, WxPayConfigs> instances = new Dictionary<string, WxPayConfigs>();
  59. // private static object syncRoot = new Object();
  60. // public static WxPayConfigs Instances(string buId)
  61. // {
  62. // if (!instances.ContainsKey(buId))
  63. // {
  64. // //var newConfig= new WxPayConfig(buId);
  65. // string configName = "WeChatPayConfig";
  66. // string serviceUrl = "http://127.0.0.1:8889";
  67. // var configuration = ExtentionMethod.LoadElectronicPayConfig(serviceUrl, configName, buId);
  68. // byte[] bytes = Encoding.UTF8.GetBytes(configuration.Value);
  69. // MemoryStream stream = new MemoryStream(bytes);
  70. // XmlSerializer deserializer = new XmlSerializer(typeof(WxPayConfigs));
  71. // TextReader reader = new StreamReader(stream);
  72. // WxPayConfigs config = (WxPayConfigs)deserializer.Deserialize(reader);
  73. // instances.Add(buId, config);
  74. // return config;
  75. // }
  76. // else
  77. // {
  78. // return instances[buId];
  79. // }
  80. // }
  81. // // used for serilization and deserilization
  82. // private WxPayConfig()
  83. // { }
  84. // // used for singleton instance
  85. // private WxPayConfig(int dummy)
  86. // {
  87. // var executionFolder = AppDomain.CurrentDomain.BaseDirectory;
  88. // var cfgFilePath = executionFolder + CONFIG_PATH + CONFIG_FILE;
  89. // XmlSerializer deserializer = new XmlSerializer(typeof(WxPayConfig));
  90. // TextReader reader = new StreamReader(cfgFilePath);
  91. // object obj = deserializer.Deserialize(reader);
  92. // WxPayConfig XmlData = (WxPayConfig)obj;
  93. // reader.Close();
  94. // APPID = XmlData.APPID;
  95. // MCHID = XmlData.MCHID;
  96. // KEY = XmlData.KEY;
  97. // APPSECRET = XmlData.APPSECRET;
  98. // SSLCERT = executionFolder + CERT_PATH + XmlData.SSLCERT;
  99. // SSLCERT_PASSWORD = XmlData.SSLCERT_PASSWORD;
  100. // NOTIFY_URL = XmlData.NOTIFY_URL;
  101. // IP = XmlData.IP;
  102. // PROXY_URL = XmlData.PROXY_URL;
  103. // REPORT_LEVENL = XmlData.REPORT_LEVENL;
  104. // }
  105. // public WxPayConfig(string buId)
  106. // {
  107. // var executionFolder = AppDomain.CurrentDomain.BaseDirectory + buId;
  108. // DirectoryInfo directory = new DirectoryInfo(executionFolder);
  109. // if (!directory.Exists)
  110. // {
  111. // directory.Create();
  112. // }
  113. // var cfgFilePath = executionFolder + CONFIG_PATH + CONFIG_FILE;
  114. // XmlSerializer deserializer = new XmlSerializer(typeof(WxPayConfig));
  115. // TextReader reader = new StreamReader(cfgFilePath);
  116. // object obj = deserializer.Deserialize(reader);
  117. // WxPayConfig XmlData = (WxPayConfig)obj;
  118. // reader.Close();
  119. // APPID = XmlData.APPID;
  120. // SUBAPPID = XmlData.SUBAPPID;
  121. // MCHID = XmlData.MCHID;
  122. // SUBMCHID = XmlData.SUBMCHID;
  123. // KEY = XmlData.KEY;
  124. // APPSECRET = XmlData.APPSECRET;
  125. // SSLCERT = executionFolder + CERT_PATH + XmlData.SSLCERT;
  126. // SSLCERT_PASSWORD = XmlData.SSLCERT_PASSWORD;
  127. // NOTIFY_URL = XmlData.NOTIFY_URL;
  128. // IP = XmlData.IP;
  129. // PROXY_URL = XmlData.PROXY_URL;
  130. // REPORT_LEVENL = XmlData.REPORT_LEVENL;
  131. // }
  132. //}
  133. }