btcpayserver/BTCPayServer/Events/InvoiceIPNEvent.cs

42 lines
1.3 KiB
C#
Raw Permalink Normal View History

2018-01-14 14:06:06 +01:00
namespace BTCPayServer.Events
{
public class InvoiceIPNEvent : IHasInvoiceId
2018-01-14 14:06:06 +01:00
{
public InvoiceIPNEvent(string invoiceId, int? eventCode, string name, bool extendedNotification)
2018-01-14 14:06:06 +01:00
{
InvoiceId = invoiceId;
2018-01-18 12:56:55 +01:00
EventCode = eventCode;
Name = name;
ExtendedNotification = extendedNotification;
2018-01-14 14:06:06 +01:00
}
2018-01-18 12:56:55 +01:00
public int? EventCode { get; set; }
public string Name { get; set; }
public bool ExtendedNotification { get; }
2018-01-14 14:06:06 +01:00
public string InvoiceId { get; set; }
public string Error { get; set; }
public override string ToString()
{
2018-01-18 12:56:55 +01:00
string ipnType = "IPN";
2020-06-28 10:55:27 +02:00
if (EventCode.HasValue)
2018-01-18 12:56:55 +01:00
{
string suffix = string.Empty;
if (ExtendedNotification)
suffix = " ExtendedNotification";
ipnType = $"IPN ({EventCode.Value} {Name}{suffix})";
}
else
{
string suffix = string.Empty;
if (ExtendedNotification)
suffix = " (ExtendedNotification)";
ipnType += suffix;
2018-01-18 12:56:55 +01:00
}
2018-01-14 14:06:06 +01:00
if (Error == null)
2018-01-18 12:56:55 +01:00
return $"{ipnType} sent for invoice {InvoiceId}";
return $"Error while sending {ipnType}: {Error}";
2018-01-14 14:06:06 +01:00
}
}
}