diff --git a/src/Api/Controllers/OrganizationsController.cs b/src/Api/Controllers/OrganizationsController.cs index de258a804e..106f341249 100644 --- a/src/Api/Controllers/OrganizationsController.cs +++ b/src/Api/Controllers/OrganizationsController.cs @@ -233,7 +233,7 @@ namespace Bit.Api.Controllers [HttpPost("{id}/seat")] [SelfHosted(NotSelfHostedOnly = true)] - public async Task PostSeat(string id, [FromBody]OrganizationSeatRequestModel model) + public async Task PostSeat(string id, [FromBody]OrganizationSeatRequestModel model) { var orgIdGuid = new Guid(id); if(!_currentContext.OrganizationOwner(orgIdGuid)) @@ -241,7 +241,12 @@ namespace Bit.Api.Controllers throw new NotFoundException(); } - await _organizationService.AdjustSeatsAsync(orgIdGuid, model.SeatAdjustment.Value); + var result = await _organizationService.AdjustSeatsAsync(orgIdGuid, model.SeatAdjustment.Value); + return new PaymentResponseModel + { + Success = true, + PaymentIntentClientSecret = result + }; } [HttpPost("{id}/storage")] diff --git a/src/Core/Services/IOrganizationService.cs b/src/Core/Services/IOrganizationService.cs index 9b1bbb83b7..24c73b6c33 100644 --- a/src/Core/Services/IOrganizationService.cs +++ b/src/Core/Services/IOrganizationService.cs @@ -15,7 +15,7 @@ namespace Bit.Core.Services Task ReinstateSubscriptionAsync(Guid organizationId); Task> UpgradePlanAsync(Guid organizationId, OrganizationUpgrade upgrade); Task AdjustStorageAsync(Guid organizationId, short storageAdjustmentGb); - Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment); + Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment); Task VerifyBankAsync(Guid organizationId, int amount1, int amount2); Task> SignUpAsync(OrganizationSignup organizationSignup); Task> SignUpAsync(OrganizationLicense license, User owner, diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 8667318d25..934f0cf384 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -255,7 +255,7 @@ namespace Bit.Core.Services return secret; } - public async Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment) + public async Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment) { var organization = await GetOrgById(organizationId); if(organization == null) @@ -372,17 +372,20 @@ namespace Bit.Core.Services subUpdateAction = (prorate) => subscriptionItemService.DeleteAsync(seatItem.Id); } + string paymentIntentClientSecret = null; var invoicedNow = false; if(additionalSeats > 0) { var result = await (_paymentService as StripePaymentService).PreviewUpcomingInvoiceAndPayAsync( organization, plan.StripeSeatPlanId, subItemOptions, 500); invoicedNow = result.Item1; + paymentIntentClientSecret = result.Item2; } await subUpdateAction(!invoicedNow); organization.Seats = (short?)newSeatTotal; await ReplaceAndUpdateCache(organization); + return paymentIntentClientSecret; } public async Task VerifyBankAsync(Guid organizationId, int amount1, int amount2)