mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 02:33:46 +00:00
[PM-5971] Fix Payment Method Warning Bugs (#7923)
* Rework implementation of payment method warnings * Move payment-method-warnings.component to module * Moved timer/subscribe to app.component * Remove unrelated refactoring * Remaining feedback * Add paymentMethodWarningsService tests * Thomas' feedback * fix tests * Use barrel file imports * Make banner work with new vault navigation * Matt's feedback
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { SubscriptionCancellationRequest } from "../../billing/models/request/subscription-cancellation.request";
|
||||
import { OrganizationBillingStatusResponse } from "../../billing/models/response/organization-billing-status.response";
|
||||
|
||||
export abstract class BillingApiServiceAbstraction {
|
||||
cancelOrganizationSubscription: (
|
||||
@@ -6,4 +7,5 @@ export abstract class BillingApiServiceAbstraction {
|
||||
request: SubscriptionCancellationRequest,
|
||||
) => Promise<void>;
|
||||
cancelPremiumUserSubscription: (request: SubscriptionCancellationRequest) => Promise<void>;
|
||||
getBillingStatus: (id: string) => Promise<OrganizationBillingStatusResponse>;
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
export class BillingBannerServiceAbstraction {
|
||||
paymentMethodBannerStates$: Observable<{ organizationId: string; visible: boolean }[]>;
|
||||
setPaymentMethodBannerState: (organizationId: string, visible: boolean) => Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
import { PaymentMethodWarning } from "../models/domain/payment-method-warning";
|
||||
|
||||
export abstract class PaymentMethodWarningsServiceAbstraction {
|
||||
/**
|
||||
* An {@link Observable} record in the {@link ActiveUserState} of the user's organization IDs each mapped to their respective {@link PaymentMethodWarning}.
|
||||
*/
|
||||
paymentMethodWarnings$: Observable<Record<string, PaymentMethodWarning>>;
|
||||
/**
|
||||
* Updates the {@link ActiveUserState} by setting `acknowledged` to `true` for the {@link PaymentMethodWarning} represented by the provided organization ID.
|
||||
* @param organizationId - The ID of the organization whose warning you'd like to acknowledge.
|
||||
*/
|
||||
acknowledge: (organizationId: string) => Promise<void>;
|
||||
/**
|
||||
* Updates the {@link ActiveUserState} by setting `risksSubscriptionFailure` to `false` for the {@link PaymentMethodWarning} represented by the provided organization ID.
|
||||
* @param organizationId - The ID of the organization whose subscription risk you'd like to remove.
|
||||
*/
|
||||
removeSubscriptionRisk: (organizationId: string) => Promise<void>;
|
||||
/**
|
||||
* Clears the {@link PaymentMethodWarning} record from the {@link ActiveUserState}.
|
||||
*/
|
||||
clear: () => Promise<void>;
|
||||
/**
|
||||
* Tries to retrieve the {@link PaymentMethodWarning} for the provided organization ID from the {@link ActiveUserState}.
|
||||
* If the warning does not exist, or if the warning has been in state for longer than a week, fetches the current {@link OrganizationBillingStatusResponse} for the organization
|
||||
* from the API and uses it to update the warning in state.
|
||||
* @param organizationId - The ID of the organization whose {@link PaymentMethodWarning} you'd like to update.
|
||||
*/
|
||||
update: (organizationId: string) => Promise<void>;
|
||||
}
|
||||
Reference in New Issue
Block a user