From d25dbaabbc432f6824bb9b1f3fb111916da5d6d0 Mon Sep 17 00:00:00 2001 From: Bufo Date: Wed, 8 Oct 2025 11:34:23 +0200 Subject: [PATCH 1/2] feat: add {Status} template string in redirect url --- BTCPayServer/Services/Invoices/InvoiceEntity.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index bbbd2a2c9..1ce0f8c13 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -484,7 +484,8 @@ namespace BTCPayServer.Services.Invoices private Uri FillPlaceholdersUri(string v) { var uriStr = (v ?? string.Empty).Replace("{OrderId}", System.Web.HttpUtility.UrlEncode(Metadata.OrderId) ?? "", StringComparison.OrdinalIgnoreCase) - .Replace("{InvoiceId}", System.Web.HttpUtility.UrlEncode(Id) ?? "", StringComparison.OrdinalIgnoreCase); + .Replace("{InvoiceId}", System.Web.HttpUtility.UrlEncode(Id) ?? "", StringComparison.OrdinalIgnoreCase) + .Replace("{Status}", (Status == InvoiceStatus.Settled) ? "success" : "failed", StringComparison.OrdinalIgnoreCase); if (Uri.TryCreate(uriStr, UriKind.Absolute, out var uri) && (uri.Scheme == "http" || uri.Scheme == "https")) return uri; return null; From 49e5afcacfc93512fe9a11dd4804c4d75acba606 Mon Sep 17 00:00:00 2001 From: Bufo Date: Mon, 20 Oct 2025 10:36:58 +0400 Subject: [PATCH 2/2] chore: update status replace logic --- BTCPayServer/Services/Invoices/InvoiceEntity.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index 1ce0f8c13..12639c904 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -485,7 +485,8 @@ namespace BTCPayServer.Services.Invoices { var uriStr = (v ?? string.Empty).Replace("{OrderId}", System.Web.HttpUtility.UrlEncode(Metadata.OrderId) ?? "", StringComparison.OrdinalIgnoreCase) .Replace("{InvoiceId}", System.Web.HttpUtility.UrlEncode(Id) ?? "", StringComparison.OrdinalIgnoreCase) - .Replace("{Status}", (Status == InvoiceStatus.Settled) ? "success" : "failed", StringComparison.OrdinalIgnoreCase); + // NOTE: Not recommended to depend on the status on client side, rather fetch invoice status via API instead + .Replace("{Status}", System.Web.HttpUtility.UrlEncode(Status.ToString()) ?? "", StringComparison.OrdinalIgnoreCase); if (Uri.TryCreate(uriStr, UriKind.Absolute, out var uri) && (uri.Scheme == "http" || uri.Scheme == "https")) return uri; return null;