mirror of
https://github.com/bitwarden/browser
synced 2026-01-28 15:23:53 +00:00
BREAKING CHANGE: rename tax-client and add proration endpoint
update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export * from "./organization-billing.client";
|
||||
export * from "./subscriber-billing.client";
|
||||
export * from "./tax.client";
|
||||
export * from "./preview-invoice.client";
|
||||
export * from "./account-billing.client";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { ProductTierType } from "@bitwarden/common/billing/enums";
|
||||
import { BaseResponse } from "@bitwarden/common/models/response/base.response";
|
||||
import { BillingAddress } from "@bitwarden/web-vault/app/billing/payment/types";
|
||||
|
||||
@@ -16,6 +17,20 @@ class TaxAmountResponse extends BaseResponse implements TaxAmounts {
|
||||
}
|
||||
}
|
||||
|
||||
export class ProrationPreviewResponse extends BaseResponse {
|
||||
tax: number;
|
||||
total: number;
|
||||
credit: number;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
|
||||
this.tax = this.getResponseProperty("Tax");
|
||||
this.total = this.getResponseProperty("Total");
|
||||
this.credit = this.getResponseProperty("Credit");
|
||||
}
|
||||
}
|
||||
|
||||
export type OrganizationSubscriptionPlan = {
|
||||
tier: "families" | "teams" | "enterprise";
|
||||
cadence: "annually" | "monthly";
|
||||
@@ -51,7 +66,7 @@ export interface TaxAmounts {
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class TaxClient {
|
||||
export class PreviewInvoiceClient {
|
||||
constructor(private apiService: ApiService) {}
|
||||
|
||||
previewTaxForOrganizationSubscriptionPurchase = async (
|
||||
@@ -60,7 +75,7 @@ export class TaxClient {
|
||||
): Promise<TaxAmounts> => {
|
||||
const json = await this.apiService.send(
|
||||
"POST",
|
||||
"/billing/tax/organizations/subscriptions/purchase",
|
||||
"/billing/preview-invoice/organizations/subscriptions/purchase",
|
||||
{
|
||||
purchase,
|
||||
billingAddress,
|
||||
@@ -82,7 +97,7 @@ export class TaxClient {
|
||||
): Promise<TaxAmounts> => {
|
||||
const json = await this.apiService.send(
|
||||
"POST",
|
||||
`/billing/tax/organizations/${organizationId}/subscription/plan-change`,
|
||||
`/billing/preview-invoice/organizations/${organizationId}/subscription/plan-change`,
|
||||
{
|
||||
plan,
|
||||
billingAddress,
|
||||
@@ -100,7 +115,7 @@ export class TaxClient {
|
||||
): Promise<TaxAmounts> => {
|
||||
const json = await this.apiService.send(
|
||||
"POST",
|
||||
`/billing/tax/organizations/${organizationId}/subscription/update`,
|
||||
`/billing/preview-invoice/organizations/${organizationId}/subscription/update`,
|
||||
{
|
||||
update,
|
||||
},
|
||||
@@ -117,7 +132,7 @@ export class TaxClient {
|
||||
): Promise<TaxAmounts> => {
|
||||
const json = await this.apiService.send(
|
||||
"POST",
|
||||
`/billing/tax/premium/subscriptions/purchase`,
|
||||
`/billing/preview-invoice/premium/subscriptions/purchase`,
|
||||
{
|
||||
additionalStorage,
|
||||
billingAddress,
|
||||
@@ -128,4 +143,22 @@ export class TaxClient {
|
||||
|
||||
return new TaxAmountResponse(json);
|
||||
};
|
||||
|
||||
previewProrationForPremiumUpgrade = async (
|
||||
planTier: ProductTierType,
|
||||
billingAddress: BillingAddress,
|
||||
): Promise<ProrationPreviewResponse> => {
|
||||
const prorationResponse = await this.apiService.send(
|
||||
"POST",
|
||||
`/billing/preview-invoice/premium/subscriptions/upgrade`,
|
||||
{
|
||||
targetProductTierType: planTier,
|
||||
billingAddress,
|
||||
},
|
||||
true,
|
||||
true,
|
||||
);
|
||||
|
||||
return new ProrationPreviewResponse(prorationResponse);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user