From b808aa4971ae02c0ce6b74b74238be75b6cf9737 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Tue, 18 Jun 2019 18:31:20 +0200 Subject: [PATCH] allow language parameter in pay button endpoint --- BTCPayServer/Controllers/PublicController.cs | 11 ++++++++++- .../Models/StoreViewModels/PayButtonViewModel.cs | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Controllers/PublicController.cs b/BTCPayServer/Controllers/PublicController.cs index 9faef2565..975e29e18 100644 --- a/BTCPayServer/Controllers/PublicController.cs +++ b/BTCPayServer/Controllers/PublicController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using System.Web; using BTCPayServer.Filters; using BTCPayServer.Models; using BTCPayServer.Models.StoreViewModels; @@ -58,7 +59,15 @@ namespace BTCPayServer.Controllers RedirectURL = model.BrowserRedirect, FullNotifications = true }, store, HttpContext.Request.GetAbsoluteRoot(), cancellationToken: cancellationToken); - return Redirect(invoice.Data.Url); + if (string.IsNullOrEmpty(model.Language)) + { + return Redirect(invoice.Data.Url); + } + var uriBuilder = new UriBuilder(invoice.Data.Url); + var paramValues = HttpUtility.ParseQueryString(uriBuilder.Query); + paramValues.Add("lang", model.Language); + uriBuilder.Query = paramValues.ToString(); + return Redirect(uriBuilder.Uri.AbsoluteUri); } } } diff --git a/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs b/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs index dc5c1ea23..122d476d8 100644 --- a/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs @@ -30,6 +30,7 @@ namespace BTCPayServer.Models.StoreViewModels public string NotifyEmail { get; set; } public string StoreId { get; set; } + public string Language { get; set; } // Data that influences Pay Button UI, but not invoice creation public string UrlRoot { get; set; }