diff --git a/BTCPayServer.Client/Models/PaymentRequestBaseData.cs b/BTCPayServer.Client/Models/PaymentRequestBaseData.cs index d425f61d0..8856e57b5 100644 --- a/BTCPayServer.Client/Models/PaymentRequestBaseData.cs +++ b/BTCPayServer.Client/Models/PaymentRequestBaseData.cs @@ -37,6 +37,8 @@ namespace BTCPayServer.Client.Models public string Title { get; set; } public string Description { get; set; } public string Email { get; set; } + // Allow payment requests to be linked to invoices outside BTCPay Server using Reference Number + public string ReferenceNumber { get; set; } public bool AllowCustomPaymentAmounts { get; set; } [JsonConverter(typeof(StringEnumConverter))] diff --git a/BTCPayServer/Controllers/UIPaymentRequestController.cs b/BTCPayServer/Controllers/UIPaymentRequestController.cs index 192347685..1ac3663cd 100644 --- a/BTCPayServer/Controllers/UIPaymentRequestController.cs +++ b/BTCPayServer/Controllers/UIPaymentRequestController.cs @@ -206,6 +206,7 @@ namespace BTCPayServer.Controllers data.Amount = viewModel.Amount; data.Currency = viewModel.Currency ?? store.GetStoreBlob().DefaultCurrency; data.Expiry = viewModel.ExpiryDate?.ToUniversalTime(); + blob.ReferenceNumber = viewModel.ReferenceNumber; blob.AllowCustomPaymentAmounts = viewModel.AllowCustomPaymentAmounts; blob.FormId = viewModel.FormId; diff --git a/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs b/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs index c1c000c44..7600af000 100644 --- a/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs +++ b/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs @@ -48,6 +48,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels Description = blob.Description; ExpiryDate = data.Expiry?.UtcDateTime; Email = blob.Email; + ReferenceNumber = blob.ReferenceNumber; AllowCustomPaymentAmounts = blob.AllowCustomPaymentAmounts; FormResponse = blob.FormResponse is null ? null @@ -84,6 +85,10 @@ namespace BTCPayServer.Models.PaymentRequestViewModels [MailboxAddress] public string Email { get; set; } + [Display(Name = "Reference Number")] + [MaxLength(50)] + public string ReferenceNumber { get; set; } + [Display(Name = "Allow payee to create invoices with custom amounts")] public bool AllowCustomPaymentAmounts { get; set; } @@ -106,6 +111,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels Description = blob.Description; ExpiryDate = data.Expiry?.UtcDateTime; Email = blob.Email; + ReferenceNumber = blob.ReferenceNumber; AllowCustomPaymentAmounts = blob.AllowCustomPaymentAmounts; switch (data.Status) { @@ -127,6 +133,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels } } public StoreBrandingViewModel StoreBranding { get; set; } + public string ReferenceNumber { get; set; } public bool AllowCustomPaymentAmounts { get; set; } public string Email { get; set; } public string Status { get; set; } @@ -147,11 +154,11 @@ namespace BTCPayServer.Models.PaymentRequestViewModels #nullable enable public class InvoiceList : List { - static HashSet stateAllowedToDisplay = new HashSet - { - new InvoiceState(InvoiceStatus.New, InvoiceExceptionStatus.None), - new InvoiceState(InvoiceStatus.New, InvoiceExceptionStatus.PaidPartial), - }; + private static HashSet stateAllowedToDisplay = + [ + new(InvoiceStatus.New, InvoiceExceptionStatus.None), + new(InvoiceStatus.New, InvoiceExceptionStatus.PaidPartial) + ]; public InvoiceList() { @@ -195,7 +202,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels public class PaymentRequestInvoicePayment { - public static List + public static List GetViewModels( InvoiceEntity invoice, DisplayFormatter displayFormatter, @@ -215,7 +222,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels string link = paymentMethodId is null ? null : txLinkProvider.GetTransactionLink(paymentMethodId, txId); - return new ViewPaymentRequestViewModel.PaymentRequestInvoicePayment + return new PaymentRequestInvoicePayment { Amount = paymentEntity.PaidAmount.Gross, Paid = paymentEntity.InvoicePaidAmount.Net, diff --git a/BTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtml b/BTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtml index 0c56a10a7..1cf5fbc20 100644 --- a/BTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtml +++ b/BTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtml @@ -82,6 +82,11 @@ +
+ + + +
diff --git a/BTCPayServer/Views/UIPaymentRequest/GetPaymentRequests.cshtml b/BTCPayServer/Views/UIPaymentRequest/GetPaymentRequests.cshtml index afdfc41ce..2ca3f637d 100644 --- a/BTCPayServer/Views/UIPaymentRequest/GetPaymentRequests.cshtml +++ b/BTCPayServer/Views/UIPaymentRequest/GetPaymentRequests.cshtml @@ -91,6 +91,7 @@
+ Number Status Amount @@ -106,6 +107,9 @@ @(item.ExpiryDate?.ToBrowserDate() ?? new HtmlString("No Expiry")) + + @item.ReferenceNumber + @item.Status