WxPayConfigData.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System.Text;
  2. using WingServerCommon.Config;
  3. using WingServerCommon.Config.Parameters;
  4. namespace WingPaymentService.Common.WeChat
  5. {
  6. public class WxPayConfigData : IWxPayIConfig
  7. {
  8. private readonly string _serverIP = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "ServerIP").Value;
  9. private readonly string _protocol = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "Protocol").Value;
  10. private readonly string _gatewayHost = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "GatewayHost").Value;
  11. private readonly string _appId = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "AppId").Value;
  12. private readonly string _mchId = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "MchId").Value;
  13. private readonly string _key = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "Key").Value;
  14. private readonly string _appSecret = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "AppSecret").Value;
  15. private readonly string _sslCertData = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "SSLCertData").Value;
  16. private readonly string _sslCertPassword = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "SSLCertPassword").Value;
  17. private readonly string _notifyUrl = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "NotifyUrl").Value;
  18. //=======【基本信息设置】=====================================
  19. /* 微信公众号信息配置
  20. * APPID:绑定支付的APPID(必须配置)
  21. * MCHID:商户号(必须配置)
  22. * KEY:商户支付密钥,参考开户邮件设置(必须配置),请妥善保管,避免密钥泄露
  23. * APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置),请妥善保管,避免密钥泄露
  24. */
  25. public string GetAppId()
  26. {
  27. return _appId;
  28. }
  29. public string GetMchId()
  30. {
  31. return _mchId;
  32. }
  33. public string GetKey()
  34. {
  35. return _key;
  36. }
  37. public string GetAppSecret()
  38. {
  39. return _appSecret;
  40. }
  41. public string GetServerUrl()
  42. {
  43. var serverUrl = $"{_protocol}://{_gatewayHost}";
  44. return serverUrl;
  45. }
  46. //=======【证书路径设置】=====================================
  47. /* 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要)
  48. * 1.证书文件不能放在web服务器虚拟目录,应放在有访问权限控制的目录中,防止被他人下载;
  49. * 2.建议将证书文件名改为复杂且不容易猜测的文件
  50. * 3.商户服务器要做好病毒和木马防护工作,不被非法侵入者窃取证书文件。
  51. */
  52. public byte[] GetSSlCertData()
  53. {
  54. return Encoding.UTF8.GetBytes(_sslCertData);
  55. }
  56. public string GetSSlCertPassword()
  57. {
  58. return _sslCertPassword;
  59. }
  60. //=======【支付结果通知url】=====================================
  61. /* 支付结果通知回调url,用于商户接收支付结果
  62. */
  63. public string GetNotifyUrl()
  64. {
  65. return _notifyUrl;
  66. }
  67. //=======【商户系统后台机器IP】=====================================
  68. /* 此参数可手动配置也可在程序中自动获取
  69. */
  70. public string GetIp()
  71. {
  72. return _serverIP;
  73. }
  74. //=======【代理服务器设置】===================================
  75. /* 默认IP和端口号分别为0.0.0.0和0,此时不开启代理(如有需要才设置)
  76. */
  77. public string GetProxyUrl()
  78. {
  79. return "";
  80. }
  81. //=======【上报信息配置】===================================
  82. /* 测速上报等级,0.关闭上报; 1.仅错误时上报; 2.全量上报
  83. */
  84. public int GetReportLevel()
  85. {
  86. return 0;
  87. }
  88. //=======【日志级别】===================================
  89. /* 日志等级,0.不输出日志;1.只输出错误信息; 2.输出错误和正常信息; 3.输出错误信息、正常信息和调试信息
  90. */
  91. public int GetLogLevel()
  92. {
  93. return 1;
  94. }
  95. }
  96. }