Renaming + fix invoice display when paid and expired

This commit is contained in:
NicolasDorier
2017-09-15 16:06:57 +09:00
parent 6170e5ffd2
commit f8baab8138
36 changed files with 90 additions and 83 deletions

View File

@@ -1,7 +1,7 @@
using BTCPayServer.Configuration; using BTCPayServer.Configuration;
using BTCPayServer.Hosting; using BTCPayServer.Hosting;
using BTCPayServer.Invoicing; using BTCPayServer.Servcices.Invoices;
using BTCPayServer.RateProvider; using BTCPayServer.Services.Rates;
using BTCPayServer.Tests.Logging; using BTCPayServer.Tests.Logging;
using BTCPayServer.Tests.Mocks; using BTCPayServer.Tests.Mocks;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;

View File

@@ -1,7 +1,7 @@
using BTCPayServer.Controllers; using BTCPayServer.Controllers;
using BTCPayServer.Invoicing;
using BTCPayServer.Models.AccountViewModels; using BTCPayServer.Models.AccountViewModels;
using BTCPayServer.Models.StoreViewModels; using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Servcices.Invoices;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NBitcoin; using NBitcoin;
using NBitpayClient; using NBitpayClient;

View File

@@ -9,7 +9,7 @@ using System.Threading;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
using Xunit.Sdk; using Xunit.Sdk;
using BTCPayServer.Invoicing; using BTCPayServer.Servcices.Invoices;
namespace BTCPayServer.Tests namespace BTCPayServer.Tests
{ {
@@ -123,7 +123,7 @@ namespace BTCPayServer.Tests
FullNotifications = true FullNotifications = true
}, Facade.Merchant); }, Facade.Merchant);
var textSearchResult = tester.PayTester.Runtime.InvoiceRepository.GetInvoices(new Invoicing.InvoiceQuery() var textSearchResult = tester.PayTester.Runtime.InvoiceRepository.GetInvoices(new InvoiceQuery()
{ {
StoreId = user.StoreId, StoreId = user.StoreId,
TextSearch = invoice.OrderId TextSearch = invoice.OrderId
@@ -131,7 +131,7 @@ namespace BTCPayServer.Tests
Assert.Equal(1, textSearchResult.Length); Assert.Equal(1, textSearchResult.Length);
textSearchResult = tester.PayTester.Runtime.InvoiceRepository.GetInvoices(new Invoicing.InvoiceQuery() textSearchResult = tester.PayTester.Runtime.InvoiceRepository.GetInvoices(new InvoiceQuery()
{ {
StoreId = user.StoreId, StoreId = user.StoreId,
TextSearch = invoice.Id TextSearch = invoice.Id

View File

@@ -1,8 +1,6 @@
using BTCPayServer.Authentication; using BTCPayServer.Authentication;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using BTCPayServer.Invoicing;
using BTCPayServer.Logging; using BTCPayServer.Logging;
using BTCPayServer.Wallet;
using DBreeze; using DBreeze;
using NBitcoin; using NBitcoin;
using NBXplorer; using NBXplorer;
@@ -15,6 +13,8 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Servcices.Invoices;
using BTCPayServer.Services.Wallets;
namespace BTCPayServer.Configuration namespace BTCPayServer.Configuration
{ {

View File

@@ -13,7 +13,8 @@ using Microsoft.Extensions.Options;
using BTCPayServer.Models; using BTCPayServer.Models;
using BTCPayServer.Models.AccountViewModels; using BTCPayServer.Models.AccountViewModels;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Stores; using BTCPayServer.Services.Mails;
using BTCPayServer.Services.Stores;
namespace BTCPayServer.Controllers namespace BTCPayServer.Controllers
{ {

View File

@@ -1,7 +1,6 @@
using BTCPayServer.Authentication; using BTCPayServer.Authentication;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using BTCPayServer.Filters; using BTCPayServer.Filters;
using BTCPayServer.Invoicing;
using BTCPayServer.Logging; using BTCPayServer.Logging;
using BTCPayServer.Models; using BTCPayServer.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -11,6 +10,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Servcices.Invoices;
namespace BTCPayServer.Controllers namespace BTCPayServer.Controllers
{ {

View File

@@ -1,7 +1,7 @@
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Filters; using BTCPayServer.Filters;
using BTCPayServer.Invoicing;
using BTCPayServer.Models.InvoicingModels; using BTCPayServer.Models.InvoicingModels;
using BTCPayServer.Servcices.Invoices;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;

View File

@@ -12,12 +12,9 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Models; using BTCPayServer.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using BTCPayServer.Invoicing;
using BTCPayServer.Wallet;
using System.Globalization; using System.Globalization;
using NBitcoin; using NBitcoin;
using NBitcoin.DataEncoders; using NBitcoin.DataEncoders;
using BTCPayServer.RateProvider;
using BTCPayServer.Filters; using BTCPayServer.Filters;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using System.Net; using System.Net;
@@ -26,12 +23,15 @@ using Newtonsoft.Json.Linq;
using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding;
using NBitcoin.Payment; using NBitcoin.Payment;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Stores;
using BTCPayServer.Models.InvoicingModels; using BTCPayServer.Models.InvoicingModels;
using System.Security.Claims; using System.Security.Claims;
using BTCPayServer.Services; using BTCPayServer.Services;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using BTCPayServer.Services.Stores;
using BTCPayServer.Servcices.Invoices;
using BTCPayServer.Services.Rates;
using BTCPayServer.Services.Wallets;
namespace BTCPayServer.Controllers namespace BTCPayServer.Controllers
{ {

View File

@@ -14,11 +14,12 @@ using BTCPayServer.Models;
using BTCPayServer.Models.ManageViewModels; using BTCPayServer.Models.ManageViewModels;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Authentication; using BTCPayServer.Authentication;
using BTCPayServer.Wallet;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using NBitpayClient; using NBitpayClient;
using NBitcoin; using NBitcoin;
using BTCPayServer.Stores; using BTCPayServer.Services.Stores;
using BTCPayServer.Services.Wallets;
using BTCPayServer.Services.Mails;
namespace BTCPayServer.Controllers namespace BTCPayServer.Controllers
{ {

View File

@@ -1,5 +1,4 @@
using BTCPayServer.Models; using BTCPayServer.Models;
using BTCPayServer.RateProvider;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -7,6 +6,7 @@ using System.Text;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Filters; using BTCPayServer.Filters;
using BTCPayServer.Services.Rates;
namespace BTCPayServer.Controllers namespace BTCPayServer.Controllers
{ {

View File

@@ -1,8 +1,8 @@
using BTCPayServer.Authentication; using BTCPayServer.Authentication;
using BTCPayServer.Models; using BTCPayServer.Models;
using BTCPayServer.Models.StoreViewModels; using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Stores; using BTCPayServer.Services.Stores;
using BTCPayServer.Wallet; using BTCPayServer.Services.Wallets;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;

View File

@@ -1,5 +1,5 @@
using BTCPayServer.Invoicing; using BTCPayServer.Models;
using BTCPayServer.Models; using BTCPayServer.Servcices.Invoices;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Services.Mails;
namespace BTCPayServer.Services namespace BTCPayServer.Services
{ {

View File

@@ -6,20 +6,20 @@ using System.Text;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using BTCPayServer.Wallet;
using BTCPayServer.RateProvider;
using NBitpayClient; using NBitpayClient;
using NBitcoin; using NBitcoin;
using BTCPayServer.Data; using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.IO; using System.IO;
using Microsoft.Data.Sqlite; using Microsoft.Data.Sqlite;
using BTCPayServer.Invoicing;
using NBXplorer; using NBXplorer;
using BTCPayServer.Stores;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Servcices.Invoices;
using BTCPayServer.Services.Rates;
using BTCPayServer.Services.Stores;
using BTCPayServer.Services.Fees;
namespace BTCPayServer.Hosting namespace BTCPayServer.Hosting
{ {

View File

@@ -20,8 +20,9 @@ using Microsoft.Extensions.Logging;
using BTCPayServer.Logging; using BTCPayServer.Logging;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Stores;
using BTCPayServer.Controllers; using BTCPayServer.Controllers;
using BTCPayServer.Services.Stores;
using BTCPayServer.Services.Mails;
namespace BTCPayServer.Hosting namespace BTCPayServer.Hosting
{ {

View File

@@ -1,6 +1,5 @@
// <auto-generated /> // <auto-generated />
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Invoicing;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;

View File

@@ -1,6 +1,5 @@
// <auto-generated /> // <auto-generated />
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Invoicing;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using BTCPayServer.Invoicing;
using BTCPayServer.Data; using BTCPayServer.Data;
namespace BTCPayServer.Models namespace BTCPayServer.Models

View File

@@ -1,5 +1,4 @@
using BTCPayServer.Invoicing; using BTCPayServer.Validations;
using BTCPayServer.Validations;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;

View File

@@ -1,4 +1,4 @@
using BTCPayServer.Invoicing; using BTCPayServer.Servcices.Invoices;
using BTCPayServer.Validations; using BTCPayServer.Validations;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -0,0 +1,26 @@
using NBitcoin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BTCPayServer.Services.Fees
{
public class FixedFeeProvider : IFeeProvider
{
public FixedFeeProvider(FeeRate feeRate)
{
FeeRate = feeRate;
}
public FeeRate FeeRate
{
get; set;
}
public Task<FeeRate> GetFeeRateAsync()
{
return Task.FromResult(FeeRate);
}
}
}

View File

@@ -0,0 +1,15 @@
using NBitcoin;
using NBXplorer;
using NBXplorer.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BTCPayServer.Services
{
public interface IFeeProvider
{
Task<FeeRate> GetFeeRateAsync();
}
}

View File

@@ -6,13 +6,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BTCPayServer.Services namespace BTCPayServer.Services.Fees
{ {
public interface IFeeProvider
{
Task<FeeRate> GetFeeRateAsync();
}
public class NBXplorerFeeProvider : IFeeProvider public class NBXplorerFeeProvider : IFeeProvider
{ {
public ExplorerClient ExplorerClient public ExplorerClient ExplorerClient
@@ -33,28 +28,10 @@ namespace BTCPayServer.Services
{ {
return (await ExplorerClient.GetFeeRateAsync(BlockTarget).ConfigureAwait(false)).FeeRate; return (await ExplorerClient.GetFeeRateAsync(BlockTarget).ConfigureAwait(false)).FeeRate;
} }
catch(NBXplorerException ex) when( ex.Error.HttpCode == 400 && ex.Error.Code == "fee-estimation-unavailable") catch(NBXplorerException ex) when(ex.Error.HttpCode == 400 && ex.Error.Code == "fee-estimation-unavailable")
{ {
return Fallback; return Fallback;
} }
} }
} }
public class FixedFeeProvider : IFeeProvider
{
public FixedFeeProvider(FeeRate feeRate)
{
FeeRate = feeRate;
}
public FeeRate FeeRate
{
get; set;
}
public Task<FeeRate> GetFeeRateAsync()
{
return Task.FromResult(FeeRate);
}
}
} }

View File

@@ -5,7 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace BTCPayServer.Invoicing namespace BTCPayServer.Servcices.Invoices
{ {
public class BuyerInformation public class BuyerInformation
{ {

View File

@@ -17,7 +17,7 @@ using BTCPayServer.Data;
using System.Globalization; using System.Globalization;
using BTCPayServer.Models.InvoicingModels; using BTCPayServer.Models.InvoicingModels;
namespace BTCPayServer.Invoicing namespace BTCPayServer.Servcices.Invoices
{ {
public class InvoiceRepository public class InvoiceRepository
{ {

View File

@@ -12,7 +12,7 @@ using System.Threading;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using System.Collections.Concurrent; using System.Collections.Concurrent;
namespace BTCPayServer.Invoicing namespace BTCPayServer.Servcices.Invoices
{ {
public class InvoiceWatcher : IHostedService public class InvoiceWatcher : IHostedService
{ {

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BTCPayServer.Services namespace BTCPayServer.Services.Mails
{ {
// This class is used by the application to send email for account confirmation and password reset. // This class is used by the application to send email for account confirmation and password reset.
// For more details see https://go.microsoft.com/fwlink/?LinkID=532713 // For more details see https://go.microsoft.com/fwlink/?LinkID=532713

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BTCPayServer.Services namespace BTCPayServer.Services.Mails
{ {
public interface IEmailSender public interface IEmailSender
{ {

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BTCPayServer.RateProvider namespace BTCPayServer.Services.Rates
{ {
public class BitpayRateProvider : IRateProvider public class BitpayRateProvider : IRateProvider
{ {

View File

@@ -5,7 +5,7 @@ using System.Reflection;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
namespace BTCPayServer.RateProvider namespace BTCPayServer.Services.Rates
{ {
public class CurrencyData public class CurrencyData
{ {

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BTCPayServer.RateProvider namespace BTCPayServer.Services.Rates
{ {
public class Rate public class Rate
{ {

View File

@@ -4,7 +4,7 @@ using System.Text;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BTCPayServer.RateProvider namespace BTCPayServer.Services.Rates
{ {
public class MockRateProvider : IRateProvider public class MockRateProvider : IRateProvider
{ {

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace BTCPayServer.RateProvider namespace BTCPayServer.Services.Rates
{ {
public class RateUnavailableException : Exception public class RateUnavailableException : Exception
{ {

View File

@@ -8,7 +8,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace BTCPayServer.Stores namespace BTCPayServer.Services.Stores
{ {
public class StoreRepository public class StoreRepository
{ {

View File

@@ -8,7 +8,7 @@ using System.Text;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BTCPayServer.Wallet namespace BTCPayServer.Services.Wallets
{ {
public class BTCPayWallet public class BTCPayWallet
{ {

View File

@@ -33,19 +33,7 @@
var display = $(".timer-row__time-left"); // Timer container var display = $(".timer-row__time-left"); // Timer container
// check if the Document expired // check if the Document expired
if (expirationTime <= 0 && !(isArchieved)) { if (expirationTime > 0) {
$(".timer-row__message span").html("Invoice Expired");
$(".timer-row__spinner").html("");
$("#emailAddressView").removeClass("active");
$(".modal-dialog").addClass("expired");
$("#expired").addClass("active");
} else if (isArchieved) {
$(".modal-dialog").addClass("archived");
$("#emailAddressView").removeClass("active");
$("#archived").addClass("active");
} else {
progressStart(maxTime); // Progress bar progressStart(maxTime); // Progress bar
startTimer(expirationTime, display); // Timer startTimer(expirationTime, display); // Timer
@@ -191,6 +179,7 @@ function updateState(status) {
$(".timer-row").removeClass("expiring-soon"); $(".timer-row").removeClass("expiring-soon");
$(".timer-row__message span").html("Invoice expired."); $(".timer-row__message span").html("Invoice expired.");
$(".timer-row__spinner").html(""); $(".timer-row__spinner").html("");
$("#emailAddressView").removeClass("active");
$(".modal-dialog").addClass("expired"); $(".modal-dialog").addClass("expired");
$("#expired").addClass("active"); $("#expired").addClass("active");
} }