NotifyEventArgs.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using PaySharp.Core.Response;
  3. using PaySharp.Core.Utils;
  4. namespace PaySharp.Core
  5. {
  6. /// <summary>
  7. /// 事件数据的基类
  8. /// </summary>
  9. public abstract class NotifyEventArgs : EventArgs
  10. {
  11. #region 私有字段
  12. protected BaseGateway _gateway;
  13. #endregion
  14. #region 构造函数
  15. /// <summary>
  16. /// 构造函数
  17. /// </summary>
  18. /// <param name="gateway">支付网关</param>
  19. protected NotifyEventArgs(BaseGateway gateway)
  20. {
  21. _gateway = gateway;
  22. NotifyServerHostAddress = HttpUtil.RemoteIpAddress;
  23. }
  24. #endregion
  25. #region 属性
  26. /// <summary>
  27. /// 发送支付通知的网关IP地址
  28. /// </summary>
  29. public string NotifyServerHostAddress { get; private set; }
  30. /// <summary>
  31. /// 网关的数据
  32. /// </summary>
  33. public GatewayData GatewayData => _gateway.GatewayData;
  34. /// <summary>
  35. /// 网关类型
  36. /// </summary>
  37. public Type GatewayType => _gateway.GetType();
  38. /// <summary>
  39. /// 通知数据
  40. /// </summary>
  41. public IResponse NotifyResponse => _gateway.NotifyResponse;
  42. /// <summary>
  43. /// 通知类型
  44. /// </summary>
  45. public NotifyType NotifyType => HttpUtil.RequestType == "GET" ? NotifyType.Sync : NotifyType.Async;
  46. #endregion
  47. }
  48. }