mirror of
https://github.com/bitwarden/server.git
synced 2025-05-29 23:34:53 -05:00
PaymentResponseModel for storage and seat adjustments
This commit is contained in:
parent
74bbeae776
commit
157cafa551
@ -233,7 +233,7 @@ namespace Bit.Api.Controllers
|
|||||||
|
|
||||||
[HttpPost("{id}/seat")]
|
[HttpPost("{id}/seat")]
|
||||||
[SelfHosted(NotSelfHostedOnly = true)]
|
[SelfHosted(NotSelfHostedOnly = true)]
|
||||||
public async Task PostSeat(string id, [FromBody]OrganizationSeatRequestModel model)
|
public async Task<PaymentResponseModel> PostSeat(string id, [FromBody]OrganizationSeatRequestModel model)
|
||||||
{
|
{
|
||||||
var orgIdGuid = new Guid(id);
|
var orgIdGuid = new Guid(id);
|
||||||
if(!_currentContext.OrganizationOwner(orgIdGuid))
|
if(!_currentContext.OrganizationOwner(orgIdGuid))
|
||||||
@ -241,7 +241,12 @@ namespace Bit.Api.Controllers
|
|||||||
throw new NotFoundException();
|
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")]
|
[HttpPost("{id}/storage")]
|
||||||
|
@ -15,7 +15,7 @@ namespace Bit.Core.Services
|
|||||||
Task ReinstateSubscriptionAsync(Guid organizationId);
|
Task ReinstateSubscriptionAsync(Guid organizationId);
|
||||||
Task<Tuple<bool, string>> UpgradePlanAsync(Guid organizationId, OrganizationUpgrade upgrade);
|
Task<Tuple<bool, string>> UpgradePlanAsync(Guid organizationId, OrganizationUpgrade upgrade);
|
||||||
Task<string> AdjustStorageAsync(Guid organizationId, short storageAdjustmentGb);
|
Task<string> AdjustStorageAsync(Guid organizationId, short storageAdjustmentGb);
|
||||||
Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment);
|
Task<string> AdjustSeatsAsync(Guid organizationId, int seatAdjustment);
|
||||||
Task VerifyBankAsync(Guid organizationId, int amount1, int amount2);
|
Task VerifyBankAsync(Guid organizationId, int amount1, int amount2);
|
||||||
Task<Tuple<Organization, OrganizationUser>> SignUpAsync(OrganizationSignup organizationSignup);
|
Task<Tuple<Organization, OrganizationUser>> SignUpAsync(OrganizationSignup organizationSignup);
|
||||||
Task<Tuple<Organization, OrganizationUser>> SignUpAsync(OrganizationLicense license, User owner,
|
Task<Tuple<Organization, OrganizationUser>> SignUpAsync(OrganizationLicense license, User owner,
|
||||||
|
@ -255,7 +255,7 @@ namespace Bit.Core.Services
|
|||||||
return secret;
|
return secret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment)
|
public async Task<string> AdjustSeatsAsync(Guid organizationId, int seatAdjustment)
|
||||||
{
|
{
|
||||||
var organization = await GetOrgById(organizationId);
|
var organization = await GetOrgById(organizationId);
|
||||||
if(organization == null)
|
if(organization == null)
|
||||||
@ -372,17 +372,20 @@ namespace Bit.Core.Services
|
|||||||
subUpdateAction = (prorate) => subscriptionItemService.DeleteAsync(seatItem.Id);
|
subUpdateAction = (prorate) => subscriptionItemService.DeleteAsync(seatItem.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string paymentIntentClientSecret = null;
|
||||||
var invoicedNow = false;
|
var invoicedNow = false;
|
||||||
if(additionalSeats > 0)
|
if(additionalSeats > 0)
|
||||||
{
|
{
|
||||||
var result = await (_paymentService as StripePaymentService).PreviewUpcomingInvoiceAndPayAsync(
|
var result = await (_paymentService as StripePaymentService).PreviewUpcomingInvoiceAndPayAsync(
|
||||||
organization, plan.StripeSeatPlanId, subItemOptions, 500);
|
organization, plan.StripeSeatPlanId, subItemOptions, 500);
|
||||||
invoicedNow = result.Item1;
|
invoicedNow = result.Item1;
|
||||||
|
paymentIntentClientSecret = result.Item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
await subUpdateAction(!invoicedNow);
|
await subUpdateAction(!invoicedNow);
|
||||||
organization.Seats = (short?)newSeatTotal;
|
organization.Seats = (short?)newSeatTotal;
|
||||||
await ReplaceAndUpdateCache(organization);
|
await ReplaceAndUpdateCache(organization);
|
||||||
|
return paymentIntentClientSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task VerifyBankAsync(Guid organizationId, int amount1, int amount2)
|
public async Task VerifyBankAsync(Guid organizationId, int amount1, int amount2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user