mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
[AC-1562] Added region custom field to PayPal add credits (#5897)
* Added config service func for getting cloud region * Updated to use `buildServerConfig`
This commit is contained in:
parent
4ba9427967
commit
ab6085cd88
@ -12,6 +12,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
|
||||
import { BitPayInvoiceRequest } from "@bitwarden/common/billing/models/request/bit-pay-invoice.request";
|
||||
import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction";
|
||||
import { PayPalConfig } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
@ -50,7 +51,8 @@ export class AddCreditComponent implements OnInit {
|
||||
private apiService: ApiService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private organizationService: OrganizationService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private configService: ConfigServiceAbstraction
|
||||
) {
|
||||
const payPalConfig = process.env.PAYPAL_CONFIG as PayPalConfig;
|
||||
this.ppButtonFormAction = payPalConfig.buttonAction;
|
||||
@ -77,7 +79,7 @@ export class AddCreditComponent implements OnInit {
|
||||
this.email = this.subject;
|
||||
this.ppButtonCustomField = "user_id:" + this.userId;
|
||||
}
|
||||
this.region = await this.stateService.getRegion();
|
||||
this.region = await this.configService.getCloudRegion();
|
||||
this.ppButtonCustomField += ",account_credit:1";
|
||||
this.ppButtonCustomField += `,region:${this.region}`;
|
||||
this.returnUrl = window.location.href;
|
||||
|
@ -10,4 +10,5 @@ export abstract class ConfigServiceAbstraction {
|
||||
getFeatureFlagBool: (key: FeatureFlag, defaultValue?: boolean) => Promise<boolean>;
|
||||
getFeatureFlagString: (key: FeatureFlag, defaultValue?: string) => Promise<string>;
|
||||
getFeatureFlagNumber: (key: FeatureFlag, defaultValue?: number) => Promise<number>;
|
||||
getCloudRegion: (defaultValue?: string) => Promise<string>;
|
||||
}
|
||||
|
@ -63,6 +63,11 @@ export class ConfigService implements ConfigServiceAbstraction {
|
||||
return await this.getFeatureFlag(key, defaultValue);
|
||||
}
|
||||
|
||||
async getCloudRegion(defaultValue = "US"): Promise<string> {
|
||||
const serverConfig = await this.buildServerConfig();
|
||||
return serverConfig.environment?.cloudRegion ?? defaultValue;
|
||||
}
|
||||
|
||||
private async getFeatureFlag<T>(key: FeatureFlag, defaultValue: T): Promise<T> {
|
||||
const serverConfig = await this.buildServerConfig();
|
||||
if (
|
||||
|
Loading…
Reference in New Issue
Block a user