diff --git a/apps/web/src/app/billing/individual/upgrade/upgrade-payment/services/upgrade-payment.service.spec.ts b/apps/web/src/app/billing/individual/upgrade/upgrade-payment/services/upgrade-payment.service.spec.ts index e20d20b0770..9d17d62e4dc 100644 --- a/apps/web/src/app/billing/individual/upgrade/upgrade-payment/services/upgrade-payment.service.spec.ts +++ b/apps/web/src/app/billing/individual/upgrade/upgrade-payment/services/upgrade-payment.service.spec.ts @@ -436,7 +436,7 @@ describe("UpgradePaymentService", () => { tier: "families", passwordManager: { additionalStorage: 0, - seats: 6, + seats: 1, sponsored: false, }, }, diff --git a/apps/web/src/app/billing/individual/upgrade/upgrade-payment/services/upgrade-payment.service.ts b/apps/web/src/app/billing/individual/upgrade/upgrade-payment/services/upgrade-payment.service.ts index 9bb963c210d..94f1c816168 100644 --- a/apps/web/src/app/billing/individual/upgrade/upgrade-payment/services/upgrade-payment.service.ts +++ b/apps/web/src/app/billing/individual/upgrade/upgrade-payment/services/upgrade-payment.service.ts @@ -98,41 +98,37 @@ export class UpgradePaymentService { planDetails: PlanDetails, billingAddress: BillingAddress, ): Promise { + const isFamiliesPlan = planDetails.tier === PersonalSubscriptionPricingTierIds.Families; + const isPremiumPlan = planDetails.tier === PersonalSubscriptionPricingTierIds.Premium; + + let taxClientCall: Promise | null = null; + + if (isFamiliesPlan) { + // Currently, only Families plan is supported for organization plans + const request: OrganizationSubscriptionPurchase = { + tier: "families", + cadence: "annually", + passwordManager: { seats: 1, additionalStorage: 0, sponsored: false }, + }; + + taxClientCall = this.taxClient.previewTaxForOrganizationSubscriptionPurchase( + request, + billingAddress, + ); + } + + if (isPremiumPlan) { + taxClientCall = this.taxClient.previewTaxForPremiumSubscriptionPurchase(0, billingAddress); + } + + if (taxClientCall === null) { + throw new Error("Tax client call is not defined"); + } + try { - const isOrganizationPlan = planDetails.tier === PersonalSubscriptionPricingTierIds.Families; - const isPremiumPlan = planDetails.tier === PersonalSubscriptionPricingTierIds.Premium; - - let taxClientCall: Promise | null = null; - - if (isOrganizationPlan) { - const seats = this.getPasswordManagerSeats(planDetails); - if (seats === 0) { - throw new Error("Seats must be greater than 0 for organization plan"); - } - // Currently, only Families plan is supported for organization plans - const request: OrganizationSubscriptionPurchase = { - tier: "families", - cadence: "annually", - passwordManager: { seats, additionalStorage: 0, sponsored: false }, - }; - - taxClientCall = this.taxClient.previewTaxForOrganizationSubscriptionPurchase( - request, - billingAddress, - ); - } - - if (isPremiumPlan) { - taxClientCall = this.taxClient.previewTaxForPremiumSubscriptionPurchase(0, billingAddress); - } - - if (taxClientCall === null) { - throw new Error("Tax client call is not defined"); - } - const preview = await taxClientCall; return preview.tax; - } catch (error: unknown) { + } catch (error) { this.logService.error("Tax calculation failed:", error); throw error; }