mirror of
https://github.com/bitwarden/browser
synced 2026-02-04 02:33:33 +00:00
feat(billing): add account billing client
This commit is contained in:
24
apps/web/src/app/billing/clients/account-billing.client.ts
Normal file
24
apps/web/src/app/billing/clients/account-billing.client.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
|
||||
import { BillingAddress, TokenizedPaymentMethod } from "../payment/types";
|
||||
|
||||
@Injectable()
|
||||
export class AccountBillingClient {
|
||||
private endpoint = "/account/billing/vnext";
|
||||
private apiService: ApiService;
|
||||
|
||||
constructor(apiService: ApiService) {
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
purchasePremiumSubscription = async (
|
||||
paymentMethod: TokenizedPaymentMethod,
|
||||
billingAddress: Pick<BillingAddress, "country" | "postalCode">,
|
||||
): Promise<void> => {
|
||||
const path = `${this.endpoint}/subscription`;
|
||||
const request = { tokenizedPaymentMethod: paymentMethod, billingAddress: billingAddress };
|
||||
await this.apiService.send("POST", path, request, true, true);
|
||||
};
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./organization-billing.client";
|
||||
export * from "./subscriber-billing.client";
|
||||
export * from "./account-billing.client";
|
||||
|
||||
Reference in New Issue
Block a user