From 8f05581ba0fbbe38161fc9703049a90818f85557 Mon Sep 17 00:00:00 2001
From: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com>
Date: Fri, 20 Sep 2024 14:58:53 +0100
Subject: [PATCH] [AC-3052] [Defect] Payment method section is blank when
upgrading Teams SM trial initiated org paid with Bank Account (#11158)
* Fix the payment method issue
* Resolve the navigation after upgrade
---
.../change-plan-dialog.component.html | 18 ++++--
.../change-plan-dialog.component.ts | 60 ++++++++++++++-----
...ganization-subscription-cloud.component.ts | 5 +-
3 files changed, 61 insertions(+), 22 deletions(-)
diff --git a/apps/web/src/app/billing/organizations/change-plan-dialog.component.html b/apps/web/src/app/billing/organizations/change-plan-dialog.component.html
index 120b570cb1..bd8ae20c92 100644
--- a/apps/web/src/app/billing/organizations/change-plan-dialog.component.html
+++ b/apps/web/src/app/billing/organizations/change-plan-dialog.component.html
@@ -86,9 +86,9 @@
}"
>
- {{
+ {{
selectableProduct.nameLocalizationKey | i18n
}}
{{ "paymentMethod" | i18n }}
-
+
- {{ billing.paymentSource.description }}
+ {{ billing?.paymentSource?.description }}
+ {{
+ "changePaymentMethod" | i18n
+ }}
+
+
+
+
+ {{ paymentSource?.description }}
{{
"changePaymentMethod" | i18n
}}
@@ -513,7 +521,7 @@
{{ "serviceAccounts" | i18n | lowercase }}
×
{{ selectedPlan?.SecretsManager?.additionalPricePerServiceAccount | currency: "$" }}
- /{{ "month" | i18n }}
+ /{{ "year" | i18n }}
{{ additionalServiceAccountTotal(selectedPlan) | currency: "$" }}
diff --git a/apps/web/src/app/billing/organizations/change-plan-dialog.component.ts b/apps/web/src/app/billing/organizations/change-plan-dialog.component.ts
index 52ca5857a0..63ac3afb93 100644
--- a/apps/web/src/app/billing/organizations/change-plan-dialog.component.ts
+++ b/apps/web/src/app/billing/organizations/change-plan-dialog.component.ts
@@ -32,6 +32,7 @@ import { PaymentRequest } from "@bitwarden/common/billing/models/request/payment
import { UpdatePaymentMethodRequest } from "@bitwarden/common/billing/models/request/update-payment-method.request";
import { BillingResponse } from "@bitwarden/common/billing/models/response/billing.response";
import { OrganizationSubscriptionResponse } from "@bitwarden/common/billing/models/response/organization-subscription.response";
+import { PaymentSourceResponse } from "@bitwarden/common/billing/models/response/payment-source.response";
import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
@@ -163,6 +164,8 @@ export class ChangePlanDialogComponent implements OnInit, OnDestroy {
currentFocusIndex = 0;
isCardStateDisabled = false;
focusedIndex: number | null = null;
+ accountCredit: number;
+ paymentSource?: PaymentSourceResponse;
deprecateStripeSourcesAPI: boolean;
@@ -200,7 +203,14 @@ export class ChangePlanDialogComponent implements OnInit, OnDestroy {
this.currentPlan = this.sub?.plan;
this.selectedPlan = this.sub?.plan;
this.organization = await this.organizationService.get(this.organizationId);
- this.billing = await this.organizationApiService.getBilling(this.organizationId);
+ if (this.deprecateStripeSourcesAPI) {
+ const { accountCredit, paymentSource } =
+ await this.billingApiService.getOrganizationPaymentMethod(this.organizationId);
+ this.accountCredit = accountCredit;
+ this.paymentSource = paymentSource;
+ } else {
+ this.billing = await this.organizationApiService.getBilling(this.organizationId);
+ }
}
if (!this.selfHosted) {
@@ -669,7 +679,7 @@ export class ChangePlanDialogComponent implements OnInit, OnDestroy {
if (!this.acceptingSponsorship && !this.isInTrialFlow) {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
- this.router.navigate(["/organizations/" + orgId + "/members"]);
+ this.router.navigate(["/organizations/" + orgId + "/billing/subscription"]);
}
if (this.isInTrialFlow) {
@@ -836,20 +846,38 @@ export class ChangePlanDialogComponent implements OnInit, OnDestroy {
}
get paymentSourceClasses() {
- if (this.billing.paymentSource == null) {
- return [];
- }
- switch (this.billing.paymentSource.type) {
- case PaymentMethodType.Card:
- return ["bwi-credit-card"];
- case PaymentMethodType.BankAccount:
- return ["bwi-bank"];
- case PaymentMethodType.Check:
- return ["bwi-money"];
- case PaymentMethodType.PayPal:
- return ["bwi-paypal text-primary"];
- default:
+ if (this.deprecateStripeSourcesAPI) {
+ if (this.paymentSource == null) {
return [];
+ }
+ switch (this.paymentSource.type) {
+ case PaymentMethodType.Card:
+ return ["bwi-credit-card"];
+ case PaymentMethodType.BankAccount:
+ return ["bwi-bank"];
+ case PaymentMethodType.Check:
+ return ["bwi-money"];
+ case PaymentMethodType.PayPal:
+ return ["bwi-paypal text-primary"];
+ default:
+ return [];
+ }
+ } else {
+ if (this.billing.paymentSource == null) {
+ return [];
+ }
+ switch (this.billing.paymentSource.type) {
+ case PaymentMethodType.Card:
+ return ["bwi-credit-card"];
+ case PaymentMethodType.BankAccount:
+ return ["bwi-bank"];
+ case PaymentMethodType.Check:
+ return ["bwi-money"];
+ case PaymentMethodType.PayPal:
+ return ["bwi-paypal text-primary"];
+ default:
+ return [];
+ }
}
}
@@ -863,6 +891,8 @@ export class ChangePlanDialogComponent implements OnInit, OnDestroy {
return this.i18nService.t("planNameFamilies");
case ProductTierType.Teams:
return this.i18nService.t("planNameTeams");
+ case ProductTierType.TeamsStarter:
+ return this.i18nService.t("planNameTeamsStarter");
}
}
diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts
index fa6db94bf5..7a66faa0a4 100644
--- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts
+++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts
@@ -422,9 +422,10 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
const result = await lastValueFrom(reference.closed);
- if (result === ChangePlanDialogResultType.Submitted) {
- await this.load();
+ if (result === ChangePlanDialogResultType.Closed) {
+ return;
}
+ await this.load();
} else {
this.showChangePlan = !this.showChangePlan;
}