diff --git a/BTCPayServer.Plugins.Branta/BTCPayServer.Plugins.Branta.csproj b/BTCPayServer.Plugins.Branta/BTCPayServer.Plugins.Branta.csproj index 39ec69e..c6c550e 100644 --- a/BTCPayServer.Plugins.Branta/BTCPayServer.Plugins.Branta.csproj +++ b/BTCPayServer.Plugins.Branta/BTCPayServer.Plugins.Branta.csproj @@ -46,7 +46,7 @@ - + diff --git a/BTCPayServer.Plugins.Branta/Views/UIBranta/EditBranta.cshtml b/BTCPayServer.Plugins.Branta/Views/UIBranta/EditBranta.cshtml index 521e045..b0d9562 100644 --- a/BTCPayServer.Plugins.Branta/Views/UIBranta/EditBranta.cshtml +++ b/BTCPayServer.Plugins.Branta/Views/UIBranta/EditBranta.cshtml @@ -3,7 +3,12 @@ @using BTCPayServer.Plugins.Branta.Enums @using BTCPayServer.Plugins.Branta.Models @using BTCPayServer.Plugins.Branta.Views +@using Branta.Classes @using Branta.Enums +@using Branta.V2.Classes +@using System.Diagnostics + +@inject BrantaClient BrantaClient @model BTCPayServer.Plugins.Branta.Models.BrantaSettingsViewModel @@ -11,6 +16,20 @@ Layout = "~/Views/Shared/_SettingsLayout.cshtml"; ViewData["BrantaSettingsActiveTab"] = "EditBranta"; ViewData.SetActivePage(BrantaNavPages.Index, "Branta - Settings"); + + var productionApiKeyValid = !string.IsNullOrEmpty(Model.Settings.ProductionApiKey) ? await BrantaClient.IsApiKeyValidAsync(new BrantaClientOptions() + { + BaseUrl = Debugger.IsAttached ? BrantaServerBaseUrl.Localhost : BrantaServerBaseUrl.Production, + DefaultApiKey = Model.Settings.ProductionApiKey + }) : true; + + var stagingApiKeyValid = !string.IsNullOrEmpty(Model.Settings.StagingApiKey) ? await BrantaClient.IsApiKeyValidAsync(new BrantaClientOptions() + { + BaseUrl = Debugger.IsAttached ? BrantaServerBaseUrl.Localhost : BrantaServerBaseUrl.Staging, + DefaultApiKey = Model.Settings.StagingApiKey + }) : true; + + var advancedSettingsError = !stagingApiKeyValid; } @section PageHeadContent { @@ -115,7 +134,15 @@
- +
+ + @if (!productionApiKeyValid) + { + + API Key is invalid + + } +
@@ -127,12 +154,20 @@

Visit your Branta Dashboard to create an API Key.

- +
+ @if (advancedSettingsError) + { + + + + } + +
@@ -171,6 +206,12 @@
+ @if (!stagingApiKeyValid) + { + + API Key is invalid + + }