mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 02:03:39 +00:00
Require provider payment method during setup behind FF (#14550)
This commit is contained in:
@@ -3,13 +3,14 @@
|
||||
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
||||
import { FormBuilder, Validators } from "@angular/forms";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Subject, switchMap } from "rxjs";
|
||||
import { firstValueFrom, Subject, switchMap } from "rxjs";
|
||||
import { first, takeUntil } from "rxjs/operators";
|
||||
|
||||
import { ManageTaxInformationComponent } from "@bitwarden/angular/billing/components";
|
||||
import { ProviderApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/provider/provider-api.service.abstraction";
|
||||
import { ProviderSetupRequest } from "@bitwarden/common/admin-console/models/request/provider/provider-setup.request";
|
||||
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||
@@ -17,12 +18,14 @@ import { ProviderKey } from "@bitwarden/common/types/key";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { ToastService } from "@bitwarden/components";
|
||||
import { KeyService } from "@bitwarden/key-management";
|
||||
import { PaymentComponent } from "@bitwarden/web-vault/app/billing/shared/payment/payment.component";
|
||||
|
||||
@Component({
|
||||
selector: "provider-setup",
|
||||
templateUrl: "setup.component.html",
|
||||
})
|
||||
export class SetupComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(PaymentComponent) paymentComponent: PaymentComponent;
|
||||
@ViewChild(ManageTaxInformationComponent) taxInformationComponent: ManageTaxInformationComponent;
|
||||
|
||||
loading = true;
|
||||
@@ -36,6 +39,10 @@ export class SetupComponent implements OnInit, OnDestroy {
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
requireProviderPaymentMethodDuringSetup$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.PM19956_RequireProviderPaymentMethodDuringSetup,
|
||||
);
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private i18nService: I18nService,
|
||||
@@ -134,6 +141,14 @@ export class SetupComponent implements OnInit, OnDestroy {
|
||||
request.taxInfo.city = taxInformation.city;
|
||||
request.taxInfo.state = taxInformation.state;
|
||||
|
||||
const requireProviderPaymentMethodDuringSetup = await firstValueFrom(
|
||||
this.requireProviderPaymentMethodDuringSetup$,
|
||||
);
|
||||
|
||||
if (requireProviderPaymentMethodDuringSetup) {
|
||||
request.paymentSource = await this.paymentComponent.tokenize();
|
||||
}
|
||||
|
||||
const provider = await this.providerApiService.postProviderSetup(this.providerId, request);
|
||||
|
||||
this.toastService.showToast({
|
||||
|
||||
Reference in New Issue
Block a user