1
0
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:
cyprain-okeke
2025-07-22 15:57:58 +01:00
committed by GitHub
parent f4e1e2f1f7
commit 8a5823bff7
6 changed files with 143 additions and 0 deletions

View File

@@ -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();
}
}