1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

adjust storage with payment intent/method handling

This commit is contained in:
Kyle Spearrin
2019-08-10 12:59:32 -04:00
parent e60f1a4f50
commit 74bbeae776
9 changed files with 66 additions and 22 deletions

View File

@ -529,7 +529,7 @@ namespace Bit.Api.Controllers
[HttpPost("storage")]
[SelfHosted(NotSelfHostedOnly = true)]
public async Task PostStorage([FromBody]StorageRequestModel model)
public async Task<PaymentResponseModel> PostStorage([FromBody]StorageRequestModel model)
{
var user = await _userService.GetUserByPrincipalAsync(User);
if(user == null)
@ -537,7 +537,12 @@ namespace Bit.Api.Controllers
throw new UnauthorizedAccessException();
}
await _userService.AdjustStorageAsync(user, model.StorageGbAdjustment.Value);
var result = await _userService.AdjustStorageAsync(user, model.StorageGbAdjustment.Value);
return new PaymentResponseModel
{
Success = true,
PaymentIntentClientSecret = result
};
}
[HttpPost("license")]

View File

@ -246,7 +246,7 @@ namespace Bit.Api.Controllers
[HttpPost("{id}/storage")]
[SelfHosted(NotSelfHostedOnly = true)]
public async Task PostStorage(string id, [FromBody]StorageRequestModel model)
public async Task<PaymentResponseModel> PostStorage(string id, [FromBody]StorageRequestModel model)
{
var orgIdGuid = new Guid(id);
if(!_currentContext.OrganizationOwner(orgIdGuid))
@ -254,7 +254,12 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
await _organizationService.AdjustStorageAsync(orgIdGuid, model.StorageGbAdjustment.Value);
var result = await _organizationService.AdjustStorageAsync(orgIdGuid, model.StorageGbAdjustment.Value);
return new PaymentResponseModel
{
Success = true,
PaymentIntentClientSecret = result
};
}
[HttpPost("{id}/verify-bank")]