Skip to content

Commit

Permalink
[PM-17540]Do not grant re-subscriptions trial period (#5327)
Browse files Browse the repository at this point in the history
* Remove trial for restarted subscription

Signed-off-by: Cy Okeke <[email protected]>

* Resolve the pr comment on initial change

Signed-off-by: Cy Okeke <[email protected]>

* Resolve the issue of not saving payment method

* Refactor the taxinfo mapping

Signed-off-by: Cy Okeke <[email protected]>

---------

Signed-off-by: Cy Okeke <[email protected]>
  • Loading branch information
cyprain-okeke authored Feb 7, 2025
1 parent af07dff commit cc21164
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Api/Billing/Controllers/OrganizationBillingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Bit.Api.AdminConsole.Models.Request.Organizations;
using Bit.Api.Billing.Models.Requests;
using Bit.Api.Billing.Models.Responses;
using Bit.Core.Billing.Models;
using Bit.Core.Billing.Models.Sales;
using Bit.Core.Billing.Services;
using Bit.Core.Context;
Expand All @@ -17,7 +18,6 @@ namespace Bit.Api.Billing.Controllers;
[Authorize("Application")]
public class OrganizationBillingController(
ICurrentContext currentContext,
IFeatureService featureService,
IOrganizationBillingService organizationBillingService,
IOrganizationRepository organizationRepository,
IPaymentService paymentService,
Expand Down Expand Up @@ -282,7 +282,15 @@ public async Task<IResult> RestartSubscriptionAsync([FromRoute] Guid organizatio
var plan = StaticStore.GetPlan(model.PlanType);
sale.Organization.PlanType = plan.Type;
sale.Organization.Plan = plan.Name;
sale.SubscriptionSetup.SkipTrial = true;
await organizationBillingService.Finalize(sale);
var org = await organizationRepository.GetByIdAsync(organizationId);
if (organizationSignup.PaymentMethodType != null)
{
var paymentSource = new TokenizedPaymentSource(organizationSignup.PaymentMethodType.Value, organizationSignup.PaymentToken);
var taxInformation = TaxInformation.From(organizationSignup.TaxInfo);
await organizationBillingService.UpdatePaymentMethod(org, paymentSource, taxInformation);
}

return TypedResults.Ok();
}
Expand Down
1 change: 1 addition & 0 deletions src/Core/Billing/Models/Sales/SubscriptionSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class SubscriptionSetup
public required Plan Plan { get; set; }
public required PasswordManager PasswordManagerOptions { get; set; }
public SecretsManager? SecretsManagerOptions { get; set; }
public bool SkipTrial = false;

public class PasswordManager
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private async Task<Subscription> CreateSubscriptionAsync(
["organizationId"] = organizationId.ToString()
},
OffSession = true,
TrialPeriodDays = plan.TrialPeriodDays
TrialPeriodDays = subscriptionSetup.SkipTrial ? 0 : plan.TrialPeriodDays
};

return await stripeAdapter.SubscriptionCreateAsync(subscriptionCreateOptions);
Expand Down

0 comments on commit cc21164

Please sign in to comment.