mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
Adding Reference Number to Payment Requests
This commit is contained in:
committed by
nicolas.dorier
parent
92e7c7a5f9
commit
d2debaa842
@@ -37,6 +37,8 @@ namespace BTCPayServer.Client.Models
|
|||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public string Email { 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; }
|
public bool AllowCustomPaymentAmounts { get; set; }
|
||||||
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ namespace BTCPayServer.Controllers
|
|||||||
data.Amount = viewModel.Amount;
|
data.Amount = viewModel.Amount;
|
||||||
data.Currency = viewModel.Currency ?? store.GetStoreBlob().DefaultCurrency;
|
data.Currency = viewModel.Currency ?? store.GetStoreBlob().DefaultCurrency;
|
||||||
data.Expiry = viewModel.ExpiryDate?.ToUniversalTime();
|
data.Expiry = viewModel.ExpiryDate?.ToUniversalTime();
|
||||||
|
blob.ReferenceNumber = viewModel.ReferenceNumber;
|
||||||
blob.AllowCustomPaymentAmounts = viewModel.AllowCustomPaymentAmounts;
|
blob.AllowCustomPaymentAmounts = viewModel.AllowCustomPaymentAmounts;
|
||||||
blob.FormId = viewModel.FormId;
|
blob.FormId = viewModel.FormId;
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels
|
|||||||
Description = blob.Description;
|
Description = blob.Description;
|
||||||
ExpiryDate = data.Expiry?.UtcDateTime;
|
ExpiryDate = data.Expiry?.UtcDateTime;
|
||||||
Email = blob.Email;
|
Email = blob.Email;
|
||||||
|
ReferenceNumber = blob.ReferenceNumber;
|
||||||
AllowCustomPaymentAmounts = blob.AllowCustomPaymentAmounts;
|
AllowCustomPaymentAmounts = blob.AllowCustomPaymentAmounts;
|
||||||
FormResponse = blob.FormResponse is null
|
FormResponse = blob.FormResponse is null
|
||||||
? null
|
? null
|
||||||
@@ -84,6 +85,10 @@ namespace BTCPayServer.Models.PaymentRequestViewModels
|
|||||||
[MailboxAddress]
|
[MailboxAddress]
|
||||||
public string Email { get; set; }
|
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")]
|
[Display(Name = "Allow payee to create invoices with custom amounts")]
|
||||||
public bool AllowCustomPaymentAmounts { get; set; }
|
public bool AllowCustomPaymentAmounts { get; set; }
|
||||||
|
|
||||||
@@ -106,6 +111,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels
|
|||||||
Description = blob.Description;
|
Description = blob.Description;
|
||||||
ExpiryDate = data.Expiry?.UtcDateTime;
|
ExpiryDate = data.Expiry?.UtcDateTime;
|
||||||
Email = blob.Email;
|
Email = blob.Email;
|
||||||
|
ReferenceNumber = blob.ReferenceNumber;
|
||||||
AllowCustomPaymentAmounts = blob.AllowCustomPaymentAmounts;
|
AllowCustomPaymentAmounts = blob.AllowCustomPaymentAmounts;
|
||||||
switch (data.Status)
|
switch (data.Status)
|
||||||
{
|
{
|
||||||
@@ -127,6 +133,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public StoreBrandingViewModel StoreBranding { get; set; }
|
public StoreBrandingViewModel StoreBranding { get; set; }
|
||||||
|
public string ReferenceNumber { get; set; }
|
||||||
public bool AllowCustomPaymentAmounts { get; set; }
|
public bool AllowCustomPaymentAmounts { get; set; }
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
@@ -147,11 +154,11 @@ namespace BTCPayServer.Models.PaymentRequestViewModels
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
public class InvoiceList : List<PaymentRequestInvoice>
|
public class InvoiceList : List<PaymentRequestInvoice>
|
||||||
{
|
{
|
||||||
static HashSet<InvoiceState> stateAllowedToDisplay = new HashSet<InvoiceState>
|
private static HashSet<InvoiceState> stateAllowedToDisplay =
|
||||||
{
|
[
|
||||||
new InvoiceState(InvoiceStatus.New, InvoiceExceptionStatus.None),
|
new(InvoiceStatus.New, InvoiceExceptionStatus.None),
|
||||||
new InvoiceState(InvoiceStatus.New, InvoiceExceptionStatus.PaidPartial),
|
new(InvoiceStatus.New, InvoiceExceptionStatus.PaidPartial)
|
||||||
};
|
];
|
||||||
public InvoiceList()
|
public InvoiceList()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -195,7 +202,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels
|
|||||||
|
|
||||||
public class PaymentRequestInvoicePayment
|
public class PaymentRequestInvoicePayment
|
||||||
{
|
{
|
||||||
public static List<ViewPaymentRequestViewModel.PaymentRequestInvoicePayment>
|
public static List<PaymentRequestInvoicePayment>
|
||||||
GetViewModels(
|
GetViewModels(
|
||||||
InvoiceEntity invoice,
|
InvoiceEntity invoice,
|
||||||
DisplayFormatter displayFormatter,
|
DisplayFormatter displayFormatter,
|
||||||
@@ -215,7 +222,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels
|
|||||||
|
|
||||||
string link = paymentMethodId is null ? null : txLinkProvider.GetTransactionLink(paymentMethodId, txId);
|
string link = paymentMethodId is null ? null : txLinkProvider.GetTransactionLink(paymentMethodId, txId);
|
||||||
|
|
||||||
return new ViewPaymentRequestViewModel.PaymentRequestInvoicePayment
|
return new PaymentRequestInvoicePayment
|
||||||
{
|
{
|
||||||
Amount = paymentEntity.PaidAmount.Gross,
|
Amount = paymentEntity.PaidAmount.Gross,
|
||||||
Paid = paymentEntity.InvoicePaidAmount.Net,
|
Paid = paymentEntity.InvoicePaidAmount.Net,
|
||||||
|
|||||||
@@ -82,6 +82,11 @@
|
|||||||
<label asp-for="AllowCustomPaymentAmounts" class="form-check-label"></label>
|
<label asp-for="AllowCustomPaymentAmounts" class="form-check-label"></label>
|
||||||
<span asp-validation-for="AllowCustomPaymentAmounts" class="text-danger"></span>
|
<span asp-validation-for="AllowCustomPaymentAmounts" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="ReferenceNumber" class="form-label"></label>
|
||||||
|
<input asp-for="ReferenceNumber" class="form-control" />
|
||||||
|
<span asp-validation-for="ReferenceNumber" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="ExpiryDate" class="form-label"></label>
|
<label asp-for="ExpiryDate" class="form-label"></label>
|
||||||
<div class="input-group ">
|
<div class="input-group ">
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
|
<th text-translate="true">Number</th>
|
||||||
<th text-translate="true">Status</th>
|
<th text-translate="true">Status</th>
|
||||||
<th class="amount-col" text-translate="true">Amount</th>
|
<th class="amount-col" text-translate="true">Amount</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
@@ -106,6 +107,9 @@
|
|||||||
<td class="date-col">
|
<td class="date-col">
|
||||||
@(item.ExpiryDate?.ToBrowserDate() ?? new HtmlString("<span class=\"text-muted\">No Expiry</span>"))
|
@(item.ExpiryDate?.ToBrowserDate() ?? new HtmlString("<span class=\"text-muted\">No Expiry</span>"))
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.ReferenceNumber
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="badge badge-@item.Status.ToLower() status-badge">@item.Status</span>
|
<span class="badge badge-@item.Status.ToLower() status-badge">@item.Status</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user