mirror of
https://github.com/bitwarden/server.git
synced 2025-05-12 15:12:16 -05:00
[PM-18064] Resolve billing warnings (#5797)
* Resolve Billing warnings * Remove exclusions * Format
This commit is contained in:
parent
ead5bbdd2a
commit
0075a15485
@ -4,8 +4,6 @@
|
|||||||
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
|
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
|
||||||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
||||||
<ANCMPreConfiguredForIIS>true</ANCMPreConfiguredForIIS>
|
<ANCMPreConfiguredForIIS>true</ANCMPreConfiguredForIIS>
|
||||||
<!-- Temp exclusions until warnings are fixed -->
|
|
||||||
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS8604</WarningsNotAsErrors>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
using System.Diagnostics;
|
||||||
using Bit.Api.AdminConsole.Models.Request.Organizations;
|
using Bit.Api.AdminConsole.Models.Request.Organizations;
|
||||||
using Bit.Api.Billing.Models.Requests;
|
using Bit.Api.Billing.Models.Requests;
|
||||||
using Bit.Api.Billing.Models.Responses;
|
using Bit.Api.Billing.Models.Responses;
|
||||||
@ -292,6 +293,7 @@ public class OrganizationBillingController(
|
|||||||
sale.SubscriptionSetup.SkipTrial = true;
|
sale.SubscriptionSetup.SkipTrial = true;
|
||||||
await organizationBillingService.Finalize(sale);
|
await organizationBillingService.Finalize(sale);
|
||||||
var org = await organizationRepository.GetByIdAsync(organizationId);
|
var org = await organizationRepository.GetByIdAsync(organizationId);
|
||||||
|
Debug.Assert(org is not null, "This organization has already been found via this same ID, this should be fine.");
|
||||||
if (organizationSignup.PaymentMethodType != null)
|
if (organizationSignup.PaymentMethodType != null)
|
||||||
{
|
{
|
||||||
var paymentSource = new TokenizedPaymentSource(organizationSignup.PaymentMethodType.Value, organizationSignup.PaymentToken);
|
var paymentSource = new TokenizedPaymentSource(organizationSignup.PaymentMethodType.Value, organizationSignup.PaymentToken);
|
||||||
|
@ -59,7 +59,7 @@ public interface IProviderBillingService
|
|||||||
int seatAdjustment);
|
int seatAdjustment);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether the provided <paramref name="seatAdjustment"/> will result in a purchase for the <paramref name="provider"/>'s <see cref="planType"/>.
|
/// Determines whether the provided <paramref name="seatAdjustment"/> will result in a purchase for the <paramref name="provider"/>'s <see cref="PlanType"/>.
|
||||||
/// Seat adjustments that result in purchases include:
|
/// Seat adjustments that result in purchases include:
|
||||||
/// <list type="bullet">
|
/// <list type="bullet">
|
||||||
/// <item>The <paramref name="provider"/> going from below the seat minimum to above the seat minimum for the provided <paramref name="planType"/></item>
|
/// <item>The <paramref name="provider"/> going from below the seat minimum to above the seat minimum for the provided <paramref name="planType"/></item>
|
||||||
|
@ -5,14 +5,12 @@ using Bit.Core.Entities;
|
|||||||
using Bit.Core.Models.BitStripe;
|
using Bit.Core.Models.BitStripe;
|
||||||
using Bit.Core.Repositories;
|
using Bit.Core.Repositories;
|
||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Bit.Core.Billing.Services.Implementations;
|
namespace Bit.Core.Billing.Services.Implementations;
|
||||||
|
|
||||||
public class PaymentHistoryService(
|
public class PaymentHistoryService(
|
||||||
IStripeAdapter stripeAdapter,
|
IStripeAdapter stripeAdapter,
|
||||||
ITransactionRepository transactionRepository,
|
ITransactionRepository transactionRepository) : IPaymentHistoryService
|
||||||
ILogger<PaymentHistoryService> logger) : IPaymentHistoryService
|
|
||||||
{
|
{
|
||||||
public async Task<IEnumerable<BillingHistoryInfo.BillingInvoice>> GetInvoiceHistoryAsync(
|
public async Task<IEnumerable<BillingHistoryInfo.BillingInvoice>> GetInvoiceHistoryAsync(
|
||||||
ISubscriber subscriber,
|
ISubscriber subscriber,
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute>
|
<GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute>
|
||||||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
||||||
<!-- Temp exclusions until warnings are fixed -->
|
|
||||||
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS1574;CS9113</WarningsNotAsErrors>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
@ -4,7 +4,6 @@ using Bit.Core.Entities;
|
|||||||
using Bit.Core.Models.BitStripe;
|
using Bit.Core.Models.BitStripe;
|
||||||
using Bit.Core.Repositories;
|
using Bit.Core.Repositories;
|
||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NSubstitute;
|
using NSubstitute;
|
||||||
using Stripe;
|
using Stripe;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@ -22,8 +21,7 @@ public class PaymentHistoryServiceTests
|
|||||||
var stripeAdapter = Substitute.For<IStripeAdapter>();
|
var stripeAdapter = Substitute.For<IStripeAdapter>();
|
||||||
stripeAdapter.InvoiceListAsync(Arg.Any<StripeInvoiceListOptions>()).Returns(invoices);
|
stripeAdapter.InvoiceListAsync(Arg.Any<StripeInvoiceListOptions>()).Returns(invoices);
|
||||||
var transactionRepository = Substitute.For<ITransactionRepository>();
|
var transactionRepository = Substitute.For<ITransactionRepository>();
|
||||||
var logger = Substitute.For<ILogger<PaymentHistoryService>>();
|
var paymentHistoryService = new PaymentHistoryService(stripeAdapter, transactionRepository);
|
||||||
var paymentHistoryService = new PaymentHistoryService(stripeAdapter, transactionRepository, logger);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await paymentHistoryService.GetInvoiceHistoryAsync(subscriber);
|
var result = await paymentHistoryService.GetInvoiceHistoryAsync(subscriber);
|
||||||
@ -40,8 +38,7 @@ public class PaymentHistoryServiceTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
var paymentHistoryService = new PaymentHistoryService(
|
var paymentHistoryService = new PaymentHistoryService(
|
||||||
Substitute.For<IStripeAdapter>(),
|
Substitute.For<IStripeAdapter>(),
|
||||||
Substitute.For<ITransactionRepository>(),
|
Substitute.For<ITransactionRepository>());
|
||||||
Substitute.For<ILogger<PaymentHistoryService>>());
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await paymentHistoryService.GetInvoiceHistoryAsync(null);
|
var result = await paymentHistoryService.GetInvoiceHistoryAsync(null);
|
||||||
@ -59,8 +56,7 @@ public class PaymentHistoryServiceTests
|
|||||||
var transactionRepository = Substitute.For<ITransactionRepository>();
|
var transactionRepository = Substitute.For<ITransactionRepository>();
|
||||||
transactionRepository.GetManyByOrganizationIdAsync(subscriber.Id, Arg.Any<int>(), Arg.Any<DateTime?>()).Returns(transactions);
|
transactionRepository.GetManyByOrganizationIdAsync(subscriber.Id, Arg.Any<int>(), Arg.Any<DateTime?>()).Returns(transactions);
|
||||||
var stripeAdapter = Substitute.For<IStripeAdapter>();
|
var stripeAdapter = Substitute.For<IStripeAdapter>();
|
||||||
var logger = Substitute.For<ILogger<PaymentHistoryService>>();
|
var paymentHistoryService = new PaymentHistoryService(stripeAdapter, transactionRepository);
|
||||||
var paymentHistoryService = new PaymentHistoryService(stripeAdapter, transactionRepository, logger);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await paymentHistoryService.GetTransactionHistoryAsync(subscriber);
|
var result = await paymentHistoryService.GetTransactionHistoryAsync(subscriber);
|
||||||
@ -77,8 +73,7 @@ public class PaymentHistoryServiceTests
|
|||||||
// Arrange
|
// Arrange
|
||||||
var paymentHistoryService = new PaymentHistoryService(
|
var paymentHistoryService = new PaymentHistoryService(
|
||||||
Substitute.For<IStripeAdapter>(),
|
Substitute.For<IStripeAdapter>(),
|
||||||
Substitute.For<ITransactionRepository>(),
|
Substitute.For<ITransactionRepository>());
|
||||||
Substitute.For<ILogger<PaymentHistoryService>>());
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await paymentHistoryService.GetTransactionHistoryAsync(null);
|
var result = await paymentHistoryService.GetTransactionHistoryAsync(null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user