1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 19:23:52 +00:00

[AC-1939] Manage provider payment information (#9415)

* Added select-payment-method.component in shared lib

Because we're going to be implementing the same functionality for providers and orgs/users, I wanted to start moving some of this shared functionality into libs so it can be accessed in both web and bit-web. Additionally, the Stripe and Braintree functionality has been moved into their own services for more central management.

* Added generalized manage-tax-information component to shared lib

* Added generalized add-account-credit-dialog component to shared libs

* Added generalized verify-bank-account component to shared libs

* Added dialog for selection of provider payment method

* Added provider-payment-method component

* Added provider-payment-method component to provider layout
This commit is contained in:
Alex Morask
2024-06-03 11:01:14 -04:00
committed by GitHub
parent aee9720a6d
commit 28de91888a
42 changed files with 1974 additions and 13 deletions

View File

@@ -0,0 +1,6 @@
export type BankAccount = {
accountHolderName: string;
routingNumber: string;
accountNumber: string;
accountHolderType: string;
};

View File

@@ -0,0 +1,5 @@
export * from "./bank-account";
export * from "./masked-payment-method";
export * from "./payment-method-warning";
export * from "./tax-information";
export * from "./tokenized-payment-method";

View File

@@ -0,0 +1,17 @@
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
import { MaskedPaymentMethodResponse } from "@bitwarden/common/billing/models/response/masked-payment-method.response";
export class MaskedPaymentMethod {
type: PaymentMethodType;
description: string;
needsVerification: boolean;
static from(response: MaskedPaymentMethodResponse | undefined) {
if (response === undefined) {
return null;
}
return {
...response,
};
}
}

View File

@@ -0,0 +1,32 @@
import { TaxInfoResponse } from "@bitwarden/common/billing/models/response/tax-info.response";
export class TaxInformation {
country: string;
postalCode: string;
taxId: string;
line1: string;
line2: string;
city: string;
state: string;
static empty(): TaxInformation {
return {
country: null,
postalCode: null,
taxId: null,
line1: null,
line2: null,
city: null,
state: null,
};
}
static from(response: TaxInfoResponse | null): TaxInformation {
if (response === null) {
return TaxInformation.empty();
}
return {
...response,
};
}
}

View File

@@ -0,0 +1,6 @@
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
export type TokenizedPaymentMethod = {
type: PaymentMethodType;
token: string;
};

View File

@@ -1,6 +1,7 @@
export class BitPayInvoiceRequest {
userId: string;
organizationId: string;
providerId: string;
credit: boolean;
amount: number;
returnUrl: string;

View File

@@ -1,3 +1,5 @@
import { TaxInformation } from "@bitwarden/common/billing/models/domain/tax-information";
import { TaxInfoUpdateRequest } from "./tax-info-update.request";
export class ExpandedTaxInfoUpdateRequest extends TaxInfoUpdateRequest {
@@ -6,4 +8,16 @@ export class ExpandedTaxInfoUpdateRequest extends TaxInfoUpdateRequest {
line2: string;
city: string;
state: string;
static From(taxInformation: TaxInformation): ExpandedTaxInfoUpdateRequest {
const request = new ExpandedTaxInfoUpdateRequest();
request.country = taxInformation.country;
request.postalCode = taxInformation.postalCode;
request.taxId = taxInformation.taxId;
request.line1 = taxInformation.line1;
request.line2 = taxInformation.line2;
request.city = taxInformation.city;
request.state = taxInformation.state;
return request;
}
}

View File

@@ -0,0 +1,14 @@
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
import { TokenizedPaymentMethod } from "@bitwarden/common/billing/models/domain";
export class TokenizedPaymentMethodRequest {
type: PaymentMethodType;
token: string;
static From(tokenizedPaymentMethod: TokenizedPaymentMethod): TokenizedPaymentMethodRequest {
const request = new TokenizedPaymentMethodRequest();
request.type = tokenizedPaymentMethod.type;
request.token = tokenizedPaymentMethod.token;
return request;
}
}

View File

@@ -0,0 +1,9 @@
export class VerifyBankAccountRequest {
amount1: number;
amount2: number;
constructor(amount1: number, amount2: number) {
this.amount1 = amount1;
this.amount2 = amount2;
}
}

View File

@@ -0,0 +1,15 @@
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
import { BaseResponse } from "@bitwarden/common/models/response/base.response";
export class MaskedPaymentMethodResponse extends BaseResponse {
type: PaymentMethodType;
description: string;
needsVerification: boolean;
constructor(response: any) {
super(response);
this.type = this.getResponseProperty("Type");
this.description = this.getResponseProperty("Description");
this.needsVerification = this.getResponseProperty("NeedsVerification");
}
}

View File

@@ -0,0 +1,25 @@
import { BaseResponse } from "../../../models/response/base.response";
import { MaskedPaymentMethodResponse } from "./masked-payment-method.response";
import { TaxInfoResponse } from "./tax-info.response";
export class PaymentInformationResponse extends BaseResponse {
accountCredit: number;
paymentMethod?: MaskedPaymentMethodResponse;
taxInformation?: TaxInfoResponse;
constructor(response: any) {
super(response);
this.accountCredit = this.getResponseProperty("AccountCredit");
const paymentMethod = this.getResponseProperty("PaymentMethod");
if (paymentMethod) {
this.paymentMethod = new MaskedPaymentMethodResponse(paymentMethod);
}
const taxInformation = this.getResponseProperty("TaxInformation");
if (taxInformation) {
this.taxInformation = new TaxInfoResponse(taxInformation);
}
}
}

View File

@@ -13,6 +13,9 @@ export class TaxInfoResponse extends BaseResponse {
constructor(response: any) {
super(response);
this.taxId = this.getResponseProperty("TaxIdNumber");
if (!this.taxId) {
this.taxId = this.getResponseProperty("TaxId");
}
this.taxIdType = this.getResponseProperty("TaxIdType");
this.line1 = this.getResponseProperty("Line1");
this.line2 = this.getResponseProperty("Line2");