mirror of
https://github.com/bitwarden/server
synced 2025-12-13 14:53:34 +00:00
[PM 18701]Optional payment modal after signup (#6014)
* Add endpoint to swap plan frequency * Add endpoint to swap plan frequency * Resolve pr comments Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Refactor the code Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Refactor for thr update change frequency * Add Automatic modal opening * catch for organization paying with PayPal --------- Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
@@ -382,4 +382,35 @@ public class OrganizationBillingController(
|
||||
|
||||
return TypedResults.Ok(response);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("change-frequency")]
|
||||
[SelfHosted(NotSelfHostedOnly = true)]
|
||||
public async Task<IResult> ChangePlanSubscriptionFrequencyAsync(
|
||||
[FromRoute] Guid organizationId,
|
||||
[FromBody] ChangePlanFrequencyRequest request)
|
||||
{
|
||||
if (!await currentContext.EditSubscription(organizationId))
|
||||
{
|
||||
return Error.Unauthorized();
|
||||
}
|
||||
|
||||
var organization = await organizationRepository.GetByIdAsync(organizationId);
|
||||
|
||||
if (organization == null)
|
||||
{
|
||||
return Error.NotFound();
|
||||
}
|
||||
|
||||
if (organization.PlanType == request.NewPlanType)
|
||||
{
|
||||
return Error.BadRequest("Organization is already on the requested plan frequency.");
|
||||
}
|
||||
|
||||
await organizationBillingService.UpdateSubscriptionPlanFrequency(
|
||||
organization,
|
||||
request.NewPlanType);
|
||||
|
||||
return TypedResults.Ok();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user