From 575b6ca2226bcc8966440b8b47f66e0ac0f50fd8 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Fri, 18 Jan 2019 19:15:31 +0900 Subject: [PATCH] Improve error messages when the store has no payment method configured --- BTCPayServer/Controllers/InvoiceController.cs | 2 +- BTCPayServer/Controllers/StoresController.cs | 10 ++++++++++ BTCPayServer/Models/StoreViewModels/TokensViewModel.cs | 1 + BTCPayServer/Views/Stores/ListTokens.cshtml | 9 ++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/Controllers/InvoiceController.cs b/BTCPayServer/Controllers/InvoiceController.cs index 0b62182df..eea614f23 100644 --- a/BTCPayServer/Controllers/InvoiceController.cs +++ b/BTCPayServer/Controllers/InvoiceController.cs @@ -155,7 +155,7 @@ namespace BTCPayServer.Controllers if (supported.Count == 0) { StringBuilder errors = new StringBuilder(); - errors.AppendLine("No payment method available for this store"); + errors.AppendLine("Warning: No wallet has been linked to your BTCPay Store. See the following link for more information on how to connect your store and wallet. (https://docs.btcpayserver.org/btcpay-basics/gettingstarted#connecting-btcpay-store-to-your-wallet)"); foreach (var error in logs.ToList()) { errors.AppendLine(error.ToString()); diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index f0251dc72..4bfa54a29 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -96,6 +96,11 @@ namespace BTCPayServer.Controllers { get; set; } + [TempData] + public bool StoreNotConfigured + { + get; set; + } [HttpGet] [Route("{storeId}/users")] @@ -567,6 +572,7 @@ namespace BTCPayServer.Controllers var model = new TokensViewModel(); var tokens = await _TokenRepository.GetTokensByStoreIdAsync(StoreData.Id); model.StatusMessage = StatusMessage; + model.StoreNotConfigured = StoreNotConfigured; model.Tokens = tokens.Select(t => new TokenViewModel() { Facade = t.Facade, @@ -794,6 +800,10 @@ namespace BTCPayServer.Controllers var pairingResult = await _TokenRepository.PairWithStoreAsync(pairingCode, store.Id); if (pairingResult == PairingResult.Complete || pairingResult == PairingResult.Partial) { + var excludeFilter = store.GetStoreBlob().GetExcludedPaymentMethods(); + StoreNotConfigured = store.GetSupportedPaymentMethods(_NetworkProvider) + .Where(p => !excludeFilter.Match(p.PaymentId)) + .Count() == 0; StatusMessage = "Pairing is successful"; if (pairingResult == PairingResult.Partial) StatusMessage = "Server initiated pairing code: " + pairingCode; diff --git a/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs b/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs index 502ffc3bf..464cf8d0d 100644 --- a/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs @@ -72,5 +72,6 @@ namespace BTCPayServer.Models.StoreViewModels [Display(Name = "API Key")] public string ApiKey { get; set; } public string EncodedApiKey { get; set; } + public bool StoreNotConfigured { get; set; } } } diff --git a/BTCPayServer/Views/Stores/ListTokens.cshtml b/BTCPayServer/Views/Stores/ListTokens.cshtml index a767c548c..b40695d0b 100644 --- a/BTCPayServer/Views/Stores/ListTokens.cshtml +++ b/BTCPayServer/Views/Stores/ListTokens.cshtml @@ -5,6 +5,13 @@ } +@if (Model.StoreNotConfigured) +{ + +}

Access token

@@ -23,7 +30,7 @@ - @foreach(var token in Model.Tokens) + @foreach (var token in Model.Tokens) { @token.Label