Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-17540]Do not grant re-subscriptions trial period #5327

Merged
Merged
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 @@
[Authorize("Application")]
public class OrganizationBillingController(
ICurrentContext currentContext,
IFeatureService featureService,
IOrganizationBillingService organizationBillingService,
IOrganizationRepository organizationRepository,
IPaymentService paymentService,
Expand Down Expand Up @@ -282,7 +282,15 @@
var plan = StaticStore.GetPlan(model.PlanType);
sale.Organization.PlanType = plan.Type;
sale.Organization.Plan = plan.Name;
sale.SubscriptionSetup.SkipTrial = true;

Check warning on line 285 in src/Api/Billing/Controllers/OrganizationBillingController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Billing/Controllers/OrganizationBillingController.cs#L285

Added line #L285 was not covered by tests
await organizationBillingService.Finalize(sale);
var org = await organizationRepository.GetByIdAsync(organizationId);

Check warning on line 287 in src/Api/Billing/Controllers/OrganizationBillingController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Billing/Controllers/OrganizationBillingController.cs#L287

Added line #L287 was not covered by tests
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);
}

Check warning on line 293 in src/Api/Billing/Controllers/OrganizationBillingController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Billing/Controllers/OrganizationBillingController.cs#L289-L293

Added lines #L289 - L293 were not covered by tests

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 @@
["organizationId"] = organizationId.ToString()
},
OffSession = true,
TrialPeriodDays = plan.TrialPeriodDays
TrialPeriodDays = subscriptionSetup.SkipTrial ? 0 : plan.TrialPeriodDays

Check warning on line 382 in src/Core/Billing/Services/Implementations/OrganizationBillingService.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Billing/Services/Implementations/OrganizationBillingService.cs#L382

Added line #L382 was not covered by tests
};

return await stripeAdapter.SubscriptionCreateAsync(subscriptionCreateOptions);
Expand Down
Loading