From 1f20bcecf0b0154ed45c889625e734069113a643 Mon Sep 17 00:00:00 2001
From: Alex Morask <144709477+amorask-bitwarden@users.noreply.github.com>
Date: Mon, 21 Jul 2025 15:06:02 -0500
Subject: [PATCH] Hide bank account for premium and when non-premium selects
non-US country (#15707)
---
.../change-payment-method-dialog.component.ts | 6 +++-
.../enter-payment-method.component.ts | 31 ++++++++++---------
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/apps/web/src/app/billing/payment/components/change-payment-method-dialog.component.ts b/apps/web/src/app/billing/payment/components/change-payment-method-dialog.component.ts
index efd0055fb95..ff5156ba636 100644
--- a/apps/web/src/app/billing/payment/components/change-payment-method-dialog.component.ts
+++ b/apps/web/src/app/billing/payment/components/change-payment-method-dialog.component.ts
@@ -28,7 +28,11 @@ type DialogResult =
{{ "changePaymentMethod" | i18n }}
diff --git a/apps/web/src/app/billing/payment/components/enter-payment-method.component.ts b/apps/web/src/app/billing/payment/components/enter-payment-method.component.ts
index 4f5b2e3b15c..b73c3297e9e 100644
--- a/apps/web/src/app/billing/payment/components/enter-payment-method.component.ts
+++ b/apps/web/src/app/billing/payment/components/enter-payment-method.component.ts
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from "@angular/core";
import { FormControl, FormGroup, Validators } from "@angular/forms";
-import { BehaviorSubject, startWith, Subject, takeUntil } from "rxjs";
+import { map, Observable, of, startWith, Subject, takeUntil } from "rxjs";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
@@ -48,7 +48,7 @@ type PaymentMethodFormGroup = FormGroup<{
{{ "creditCard" | i18n }}
- @if (showBankAccount) {
+ @if (showBankAccount$ | async) {
@@ -226,20 +226,12 @@ type PaymentMethodFormGroup = FormGroup<{
export class EnterPaymentMethodComponent implements OnInit {
@Input({ required: true }) group!: PaymentMethodFormGroup;
- private showBankAccountSubject = new BehaviorSubject(true);
- showBankAccount$ = this.showBankAccountSubject.asObservable();
- @Input()
- set showBankAccount(value: boolean) {
- this.showBankAccountSubject.next(value);
- }
- get showBankAccount(): boolean {
- return this.showBankAccountSubject.value;
- }
-
- @Input() showPayPal: boolean = true;
- @Input() showAccountCredit: boolean = false;
- @Input() includeBillingAddress: boolean = false;
+ @Input() private showBankAccount = true;
+ @Input() showPayPal = true;
+ @Input() showAccountCredit = false;
+ @Input() includeBillingAddress = false;
+ protected showBankAccount$!: Observable;
protected selectableCountries = selectableCountries;
private destroy$ = new Subject();
@@ -267,7 +259,16 @@ export class EnterPaymentMethodComponent implements OnInit {
}
if (!this.includeBillingAddress) {
+ this.showBankAccount$ = of(this.showBankAccount);
this.group.controls.billingAddress.disable();
+ } else {
+ this.group.controls.billingAddress.patchValue({
+ country: "US",
+ });
+ this.showBankAccount$ = this.group.controls.billingAddress.controls.country.valueChanges.pipe(
+ startWith(this.group.controls.billingAddress.controls.country.value),
+ map((country) => this.showBankAccount && country === "US"),
+ );
}
this.group.controls.type.valueChanges