2018-01-14 22:06:06 +09:00
|
|
|
namespace BTCPayServer.Events
|
|
|
|
{
|
2020-11-06 22:23:10 +09:00
|
|
|
public class InvoiceIPNEvent : IHasInvoiceId
|
2018-01-14 22:06:06 +09:00
|
|
|
{
|
2022-01-12 00:26:12 +09:00
|
|
|
public InvoiceIPNEvent(string invoiceId, int? eventCode, string name, bool extendedNotification)
|
2018-01-14 22:06:06 +09:00
|
|
|
{
|
|
|
|
InvoiceId = invoiceId;
|
2018-01-18 20:56:55 +09:00
|
|
|
EventCode = eventCode;
|
|
|
|
Name = name;
|
2022-01-12 00:26:12 +09:00
|
|
|
ExtendedNotification = extendedNotification;
|
2018-01-14 22:06:06 +09:00
|
|
|
}
|
|
|
|
|
2018-01-18 20:56:55 +09:00
|
|
|
public int? EventCode { get; set; }
|
|
|
|
public string Name { get; set; }
|
2022-01-12 00:26:12 +09:00
|
|
|
public bool ExtendedNotification { get; }
|
2018-01-14 22:06:06 +09:00
|
|
|
public string InvoiceId { get; set; }
|
|
|
|
public string Error { get; set; }
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2018-01-18 20:56:55 +09:00
|
|
|
string ipnType = "IPN";
|
2020-06-28 17:55:27 +09:00
|
|
|
if (EventCode.HasValue)
|
2018-01-18 20:56:55 +09:00
|
|
|
{
|
2022-01-12 00:26:12 +09: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 20:56:55 +09:00
|
|
|
}
|
2018-01-14 22:06:06 +09:00
|
|
|
if (Error == null)
|
2018-01-18 20:56:55 +09:00
|
|
|
return $"{ipnType} sent for invoice {InvoiceId}";
|
|
|
|
return $"Error while sending {ipnType}: {Error}";
|
2018-01-14 22:06:06 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|