mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Allow Placeholders in redirectURL (Fix #169)
This commit is contained in:
parent
57b436417c
commit
6bd601137a
2 changed files with 21 additions and 6 deletions
|
@ -86,7 +86,7 @@ namespace BTCPayServer.Controllers
|
|||
Uri.TryCreate(invoice.NotificationURL, UriKind.Absolute, out var notificationUri) &&
|
||||
(notificationUri.Scheme == "http" || notificationUri.Scheme == "https"))
|
||||
{
|
||||
entity.NotificationURL = notificationUri.AbsoluteUri;
|
||||
entity.NotificationURLTemplate = notificationUri.AbsoluteUri;
|
||||
}
|
||||
entity.NotificationEmail = invoice.NotificationEmail;
|
||||
entity.BuyerInformation = Map<CreateInvoiceRequest, BuyerInformation>(invoice);
|
||||
|
@ -119,9 +119,9 @@ namespace BTCPayServer.Controllers
|
|||
entity.ProductInformation = Map<CreateInvoiceRequest, ProductInformation>(invoice);
|
||||
|
||||
|
||||
entity.RedirectURL = invoice.RedirectURL ?? store.StoreWebsite;
|
||||
entity.RedirectURLTemplate = invoice.RedirectURL ?? store.StoreWebsite;
|
||||
if (!Uri.IsWellFormedUriString(entity.RedirectURL, UriKind.Absolute))
|
||||
entity.RedirectURL = null;
|
||||
entity.RedirectURLTemplate = null;
|
||||
|
||||
entity.RedirectAutomatically =
|
||||
invoice.RedirectAutomatically.GetValueOrDefault(storeBlob.RedirectAutomatically);
|
||||
|
|
|
@ -289,12 +289,22 @@ namespace BTCPayServer.Services.Invoices
|
|||
get;
|
||||
set;
|
||||
}
|
||||
public string RedirectURL
|
||||
[JsonProperty("redirectURL")]
|
||||
public string RedirectURLTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
public string RedirectURL => FillPlaceholders(RedirectURLTemplate);
|
||||
|
||||
private string FillPlaceholders(string v)
|
||||
{
|
||||
return (v ?? string.Empty).Replace("{OrderId}", OrderId ?? "", StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("{InvoiceId}", Id ?? "", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public bool RedirectAutomatically
|
||||
{
|
||||
get;
|
||||
|
@ -317,11 +327,16 @@ namespace BTCPayServer.Services.Invoices
|
|||
get;
|
||||
set;
|
||||
}
|
||||
public string NotificationURL
|
||||
|
||||
[JsonProperty("notificationURL")]
|
||||
public string NotificationURLTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public string NotificationURL => FillPlaceholders(NotificationURLTemplate);
|
||||
public string ServerUrl
|
||||
{
|
||||
get;
|
||||
|
|
Loading…
Add table
Reference in a new issue