2018-01-14 14:06:06 +01:00
|
|
|
namespace BTCPayServer.Events
|
|
|
|
{
|
2020-11-06 14:23:10 +01:00
|
|
|
public class InvoiceIPNEvent : IHasInvoiceId
|
2018-01-14 14:06:06 +01:00
|
|
|
{
|
2022-01-11 16:26:12 +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;
|
2022-01-11 16:26:12 +01:00
|
|
|
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; }
|
2022-01-11 16:26:12 +01:00
|
|
|
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
|
|
|
{
|
2022-01-11 16:26:12 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|