Skip to content

[PM-20059]Restart-subscription being invoked without payment method #5631

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/Api/Billing/Controllers/OrganizationBillingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,16 @@
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)

if (organizationSignup.PaymentMethodType == null || string.IsNullOrEmpty(organizationSignup.PaymentToken))
{
var paymentSource = new TokenizedPaymentSource(organizationSignup.PaymentMethodType.Value, organizationSignup.PaymentToken);
var taxInformation = TaxInformation.From(organizationSignup.TaxInfo);
await organizationBillingService.UpdatePaymentMethod(org, paymentSource, taxInformation);
return Error.BadRequest("A payment method is required to restart the subscription.");

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L291 was not covered by tests
}
var org = await organizationRepository.GetByIdAsync(organizationId);
var paymentSource = new TokenizedPaymentSource(organizationSignup.PaymentMethodType.Value, organizationSignup.PaymentToken);
var taxInformation = TaxInformation.From(organizationSignup.TaxInfo);
await organizationBillingService.UpdatePaymentMethod(org, paymentSource, taxInformation);
await organizationBillingService.Finalize(sale);

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L293 - L297 were not covered by tests

return TypedResults.Ok();
}
Expand Down
Loading