Make sure NotificationUrl and RedirectUrl are of type Uri

This commit is contained in:
nicolas.dorier 2019-09-04 18:20:36 +09:00
parent f17a359893
commit c247e275f6
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
3 changed files with 8 additions and 8 deletions

View file

@ -67,7 +67,7 @@ namespace BTCPayServer.Controllers
TaxIncluded = _CurrencyNameTable.DisplayFormatCurrency(prodInfo.TaxIncluded, prodInfo.Currency),
NotificationEmail = invoice.NotificationEmail,
NotificationUrl = invoice.NotificationURL,
RedirectUrl = invoice.RedirectURL,
RedirectUrl = invoice.RedirectURL.AbsoluteUri,
ProductInformation = invoice.ProductInformation,
StatusException = invoice.ExceptionStatus,
Events = invoice.Events,
@ -250,7 +250,7 @@ namespace BTCPayServer.Controllers
MaxTimeMinutes = (int)(invoice.ExpirationTime - invoice.InvoiceTime).TotalMinutes,
ItemDesc = invoice.ProductInformation.ItemDesc,
Rate = ExchangeRate(paymentMethod),
MerchantRefLink = invoice.RedirectURL ?? "/",
MerchantRefLink = invoice.RedirectURL?.AbsoluteUri ?? "/",
RedirectAutomatically = invoice.RedirectAutomatically,
StoreName = store.StoreName,
PeerInfo = (paymentMethodDetails as LightningLikePaymentMethodDetails)?.NodeInfo,
@ -424,7 +424,7 @@ namespace BTCPayServer.Controllers
Date = invoice.InvoiceTime,
InvoiceId = invoice.Id,
OrderId = invoice.OrderId ?? string.Empty,
RedirectUrl = invoice.RedirectURL ?? string.Empty,
RedirectUrl = invoice.RedirectURL?.AbsoluteUri ?? string.Empty,
AmountCurrency = _CurrencyNameTable.DisplayFormatCurrency(invoice.ProductInformation.Price, invoice.ProductInformation.Currency),
CanMarkInvalid = state.CanMarkInvalid(),
CanMarkComplete = state.CanMarkComplete(),

View file

@ -87,7 +87,7 @@ namespace BTCPayServer.HostedServices
Name = invoiceEvent.Name
},
ExtendedNotification = extendedNotification,
NotificationURL = invoice.NotificationURL
NotificationURL = invoice.NotificationURL?.AbsoluteUri
};
// For lightning network payments, paid, confirmed and completed come all at once.

View file

@ -297,14 +297,14 @@ namespace BTCPayServer.Services.Invoices
}
[JsonIgnore]
public string RedirectURL => FillPlaceholdersUri(RedirectURLTemplate);
public Uri RedirectURL => FillPlaceholdersUri(RedirectURLTemplate);
private string FillPlaceholdersUri(string v)
private Uri FillPlaceholdersUri(string v)
{
var uriStr = (v ?? string.Empty).Replace("{OrderId}", OrderId ?? "", StringComparison.OrdinalIgnoreCase)
.Replace("{InvoiceId}", Id ?? "", StringComparison.OrdinalIgnoreCase);
if (Uri.TryCreate(uriStr, UriKind.Absolute, out var uri) && (uri.Scheme == "http" || uri.Scheme == "https"))
return uri.AbsoluteUri;
return uri;
return null;
}
@ -339,7 +339,7 @@ namespace BTCPayServer.Services.Invoices
}
[JsonIgnore]
public string NotificationURL => FillPlaceholdersUri(NotificationURLTemplate);
public Uri NotificationURL => FillPlaceholdersUri(NotificationURLTemplate);
public string ServerUrl
{
get;