Improve error messages when the store has no payment method configured

This commit is contained in:
nicolas.dorier
2019-01-18 19:15:31 +09:00
parent b5a0e844d2
commit 575b6ca222
4 changed files with 20 additions and 2 deletions

View File

@@ -155,7 +155,7 @@ namespace BTCPayServer.Controllers
if (supported.Count == 0) if (supported.Count == 0)
{ {
StringBuilder errors = new StringBuilder(); 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()) foreach (var error in logs.ToList())
{ {
errors.AppendLine(error.ToString()); errors.AppendLine(error.ToString());

View File

@@ -96,6 +96,11 @@ namespace BTCPayServer.Controllers
{ {
get; set; get; set;
} }
[TempData]
public bool StoreNotConfigured
{
get; set;
}
[HttpGet] [HttpGet]
[Route("{storeId}/users")] [Route("{storeId}/users")]
@@ -567,6 +572,7 @@ namespace BTCPayServer.Controllers
var model = new TokensViewModel(); var model = new TokensViewModel();
var tokens = await _TokenRepository.GetTokensByStoreIdAsync(StoreData.Id); var tokens = await _TokenRepository.GetTokensByStoreIdAsync(StoreData.Id);
model.StatusMessage = StatusMessage; model.StatusMessage = StatusMessage;
model.StoreNotConfigured = StoreNotConfigured;
model.Tokens = tokens.Select(t => new TokenViewModel() model.Tokens = tokens.Select(t => new TokenViewModel()
{ {
Facade = t.Facade, Facade = t.Facade,
@@ -794,6 +800,10 @@ namespace BTCPayServer.Controllers
var pairingResult = await _TokenRepository.PairWithStoreAsync(pairingCode, store.Id); var pairingResult = await _TokenRepository.PairWithStoreAsync(pairingCode, store.Id);
if (pairingResult == PairingResult.Complete || pairingResult == PairingResult.Partial) 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"; StatusMessage = "Pairing is successful";
if (pairingResult == PairingResult.Partial) if (pairingResult == PairingResult.Partial)
StatusMessage = "Server initiated pairing code: " + pairingCode; StatusMessage = "Server initiated pairing code: " + pairingCode;

View File

@@ -72,5 +72,6 @@ namespace BTCPayServer.Models.StoreViewModels
[Display(Name = "API Key")] [Display(Name = "API Key")]
public string ApiKey { get; set; } public string ApiKey { get; set; }
public string EncodedApiKey { get; set; } public string EncodedApiKey { get; set; }
public bool StoreNotConfigured { get; set; }
} }
} }

View File

@@ -5,6 +5,13 @@
} }
<partial name="_StatusMessage" for="StatusMessage" /> <partial name="_StatusMessage" for="StatusMessage" />
@if (Model.StoreNotConfigured)
{
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<span>Warning: No wallet has been linked to your BTCPay Store. See <a href="https://docs.btcpayserver.org/btcpay-basics/gettingstarted#connecting-btcpay-store-to-your-wallet" target="_blank">this link</a> for more information on how to connect your store and wallet.</span>
</div>
}
<h4>Access token</h4> <h4>Access token</h4>
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
@@ -23,7 +30,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach(var token in Model.Tokens) @foreach (var token in Model.Tokens)
{ {
<tr> <tr>
<td>@token.Label</td> <td>@token.Label</td>