mirror of
https://github.com/bitwarden/server.git
synced 2025-02-01 23:31:41 +01:00
billing info when self hosted with no gateway info
This commit is contained in:
parent
67edcd035c
commit
a020a7268e
@ -444,14 +444,16 @@ namespace Bit.Api.Controllers
|
|||||||
throw new UnauthorizedAccessException();
|
throw new UnauthorizedAccessException();
|
||||||
}
|
}
|
||||||
|
|
||||||
var paymentService = user.GetPaymentService(_globalSettings);
|
if(!_globalSettings.SelfHosted && user.Gateway != null)
|
||||||
var billingInfo = await paymentService.GetBillingAsync(user);
|
|
||||||
if(billingInfo == null)
|
|
||||||
{
|
{
|
||||||
throw new NotFoundException();
|
var paymentService = user.GetPaymentService(_globalSettings);
|
||||||
|
var billingInfo = await paymentService.GetBillingAsync(user);
|
||||||
|
return new BillingResponseModel(user, billingInfo, _licenseService);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new BillingResponseModel(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BillingResponseModel(user, billingInfo, _licenseService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("payment")]
|
[HttpPut("payment")]
|
||||||
|
@ -23,6 +23,14 @@ namespace Bit.Core.Models.Api
|
|||||||
License = new UserLicense(user, billing, licenseService);
|
License = new UserLicense(user, billing, licenseService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BillingResponseModel(User user)
|
||||||
|
: base("billing")
|
||||||
|
{
|
||||||
|
StorageName = user.Storage.HasValue ? Utilities.CoreHelpers.ReadableBytesSize(user.Storage.Value) : null;
|
||||||
|
StorageGb = user.Storage.HasValue ? Math.Round(user.Storage.Value / 1073741824D, 2) : 0; // 1 GB
|
||||||
|
MaxStorageGb = user.MaxStorageGb;
|
||||||
|
}
|
||||||
|
|
||||||
public string StorageName { get; set; }
|
public string StorageName { get; set; }
|
||||||
public double? StorageGb { get; set; }
|
public double? StorageGb { get; set; }
|
||||||
public short? MaxStorageGb { get; set; }
|
public short? MaxStorageGb { get; set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user