mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
[AC-1900] Update Vault DB to support provider billing (#3875)
* Add Gateway columns to Provider table * Add ProviderId column to Transaction table * Create ProviderPlan table * Matt's feedback * Rui's feedback * Fixed Gateway parameter on Provider
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System.Net;
|
||||
using Bit.Core.AdminConsole.Enums.Provider;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.AdminConsole.Entities.Provider;
|
||||
@ -29,6 +30,9 @@ public class Provider : ITableObject<Guid>
|
||||
public bool Enabled { get; set; } = true;
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
public GatewayType? Gateway { get; set; }
|
||||
public string GatewayCustomerId { get; set; }
|
||||
public string GatewaySubscriptionId { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
|
23
src/Core/Billing/Entities/ProviderPlan.cs
Normal file
23
src/Core/Billing/Entities/ProviderPlan.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Billing.Entities;
|
||||
|
||||
public class ProviderPlan : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProviderId { get; set; }
|
||||
public PlanType PlanType { get; set; }
|
||||
public int? SeatMinimum { get; set; }
|
||||
public int? PurchasedSeats { get; set; }
|
||||
public int? AllocatedSeats { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if (Id == default)
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
9
src/Core/Billing/Repositories/IProviderPlanRepository.cs
Normal file
9
src/Core/Billing/Repositories/IProviderPlanRepository.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using Bit.Core.Billing.Entities;
|
||||
using Bit.Core.Repositories;
|
||||
|
||||
namespace Bit.Core.Billing.Repositories;
|
||||
|
||||
public interface IProviderPlanRepository : IRepository<ProviderPlan, Guid>
|
||||
{
|
||||
Task<ProviderPlan> GetByProviderId(Guid providerId);
|
||||
}
|
@ -20,6 +20,7 @@ public class Transaction : ITableObject<Guid>
|
||||
[MaxLength(50)]
|
||||
public string GatewayId { get; set; }
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
public Guid? ProviderId { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
|
@ -7,5 +7,6 @@ public interface ITransactionRepository : IRepository<Transaction, Guid>
|
||||
{
|
||||
Task<ICollection<Transaction>> GetManyByUserIdAsync(Guid userId);
|
||||
Task<ICollection<Transaction>> GetManyByOrganizationIdAsync(Guid organizationId);
|
||||
Task<ICollection<Transaction>> GetManyByProviderIdAsync(Guid providerId);
|
||||
Task<Transaction> GetByGatewayIdAsync(GatewayType gatewayType, string gatewayId);
|
||||
}
|
||||
|
Reference in New Issue
Block a user