mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 22:11:48 +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) &&
|
Uri.TryCreate(invoice.NotificationURL, UriKind.Absolute, out var notificationUri) &&
|
||||||
(notificationUri.Scheme == "http" || notificationUri.Scheme == "https"))
|
(notificationUri.Scheme == "http" || notificationUri.Scheme == "https"))
|
||||||
{
|
{
|
||||||
entity.NotificationURL = notificationUri.AbsoluteUri;
|
entity.NotificationURLTemplate = notificationUri.AbsoluteUri;
|
||||||
}
|
}
|
||||||
entity.NotificationEmail = invoice.NotificationEmail;
|
entity.NotificationEmail = invoice.NotificationEmail;
|
||||||
entity.BuyerInformation = Map<CreateInvoiceRequest, BuyerInformation>(invoice);
|
entity.BuyerInformation = Map<CreateInvoiceRequest, BuyerInformation>(invoice);
|
||||||
|
@ -119,9 +119,9 @@ namespace BTCPayServer.Controllers
|
||||||
entity.ProductInformation = Map<CreateInvoiceRequest, ProductInformation>(invoice);
|
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))
|
if (!Uri.IsWellFormedUriString(entity.RedirectURL, UriKind.Absolute))
|
||||||
entity.RedirectURL = null;
|
entity.RedirectURLTemplate = null;
|
||||||
|
|
||||||
entity.RedirectAutomatically =
|
entity.RedirectAutomatically =
|
||||||
invoice.RedirectAutomatically.GetValueOrDefault(storeBlob.RedirectAutomatically);
|
invoice.RedirectAutomatically.GetValueOrDefault(storeBlob.RedirectAutomatically);
|
||||||
|
|
|
@ -289,12 +289,22 @@ namespace BTCPayServer.Services.Invoices
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
public string RedirectURL
|
[JsonProperty("redirectURL")]
|
||||||
|
public string RedirectURLTemplate
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
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
|
public bool RedirectAutomatically
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -317,11 +327,16 @@ namespace BTCPayServer.Services.Invoices
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
public string NotificationURL
|
|
||||||
|
[JsonProperty("notificationURL")]
|
||||||
|
public string NotificationURLTemplate
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public string NotificationURL => FillPlaceholders(NotificationURLTemplate);
|
||||||
public string ServerUrl
|
public string ServerUrl
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|
Loading…
Add table
Reference in a new issue