1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-06 19:53:59 +00:00

Merge branch 'main' into SM-1273-AddAdditionalSecretEventLogs

This commit is contained in:
cd-bitwarden
2025-06-24 12:09:16 -04:00
committed by GitHub
2 changed files with 28 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions";
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
import { TaxInformation } from "@bitwarden/common/billing/models/domain";
import { VerifyBankAccountRequest } from "@bitwarden/common/billing/models/request/verify-bank-account.request";
import { OrganizationSubscriptionResponse } from "@bitwarden/common/billing/models/response/organization-subscription.response";
import { PaymentSourceResponse } from "@bitwarden/common/billing/models/response/payment-source.response";
@@ -54,6 +55,8 @@ export class OrganizationPaymentMethodComponent implements OnDestroy {
protected readonly Math = Math;
launchPaymentModalAutomatically = false;
protected taxInformation: TaxInformation;
constructor(
private activatedRoute: ActivatedRoute,
private billingApiService: BillingApiServiceAbstraction,
@@ -108,6 +111,12 @@ export class OrganizationPaymentMethodComponent implements OnDestroy {
}
protected addAccountCredit = async (): Promise<void> => {
if (this.subscriptionStatus === "trialing") {
const hasValidBillingAddress = await this.checkBillingAddressForTrialingOrg();
if (!hasValidBillingAddress) {
return;
}
}
const dialogRef = openAddCreditDialog(this.dialogService, {
data: {
organizationId: this.organizationId,
@@ -124,11 +133,12 @@ export class OrganizationPaymentMethodComponent implements OnDestroy {
protected load = async (): Promise<void> => {
this.loading = true;
try {
const { accountCredit, paymentSource, subscriptionStatus } =
const { accountCredit, paymentSource, subscriptionStatus, taxInformation } =
await this.billingApiService.getOrganizationPaymentMethod(this.organizationId);
this.accountCredit = accountCredit;
this.paymentSource = paymentSource;
this.subscriptionStatus = subscriptionStatus;
this.taxInformation = taxInformation;
if (this.organizationId) {
const organizationSubscriptionPromise = this.organizationApiService.getSubscription(
@@ -247,4 +257,17 @@ export class OrganizationPaymentMethodComponent implements OnDestroy {
const key = this.paymentSource == null ? "addPaymentMethod" : "changePaymentMethod";
return this.i18nService.t(key);
}
private async checkBillingAddressForTrialingOrg(): Promise<boolean> {
const hasBillingAddress = this.taxInformation != null;
if (!hasBillingAddress) {
this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("billingAddressRequiredToAddCredit"),
});
return false;
}
return true;
}
}

View File

@@ -10695,5 +10695,9 @@
"example": "12/31/2024"
}
}
},
"billingAddressRequiredToAddCredit": {
"message": "Billing address required to add credit.",
"description": "Error message shown when trying to add credit to a trialing organization without a billing address."
}
}