mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-25 12:15:18 +01:00
Move WebConstants values to environment config files (#1184)
* Moving the web constants to the app config for more flexibility * removing personal integrations from QA * changing the PayPal Configuration setup to match the pattern in the services module * removing the webConstants file after successful test * renaming the braintree config key to something more understandable
This commit is contained in:
parent
fb89421b09
commit
7f76084109
@ -1,3 +1,9 @@
|
|||||||
{
|
{
|
||||||
"urls": {}
|
"urls": {},
|
||||||
|
"stripeKey": "pk_test_KPoCfZXu7mznb9uSCPZ2JpTD",
|
||||||
|
"braintreeKey": "sandbox_r72q8jq6_9pnxkwm75f87sdc2",
|
||||||
|
"paypal": {
|
||||||
|
"businessId": "AD3LAUZSNVPJY",
|
||||||
|
"buttonAction": "https://www.sandbox.paypal.com/cgi-bin/webscr"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,11 @@
|
|||||||
"icons": "https://icons.bitwarden.net",
|
"icons": "https://icons.bitwarden.net",
|
||||||
"notifications": "https://notifications.bitwarden.com",
|
"notifications": "https://notifications.bitwarden.com",
|
||||||
"enterprise": "https://portal.bitwarden.com"
|
"enterprise": "https://portal.bitwarden.com"
|
||||||
|
},
|
||||||
|
"stripeKey": "pk_live_bpN0P37nMxrMQkcaHXtAybJk",
|
||||||
|
"braintreeKey": "production_qfbsv8kc_njj2zjtyngtjmbjd",
|
||||||
|
"paypal": {
|
||||||
|
"businessId": "4ZDA7DLUUJGMN",
|
||||||
|
"buttonAction": "https://www.paypal.com/cgi-bin/webscr"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,4 @@
|
|||||||
"notifications": "https://notifications.qa.bitwarden.pw",
|
"notifications": "https://notifications.qa.bitwarden.pw",
|
||||||
"enterprise": "https://portal.qa.bitwarden.pw"
|
"enterprise": "https://portal.qa.bitwarden.pw"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||||
|
import { PayPalConfig } from 'jslib-common/abstractions/environment.service';
|
||||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||||
import { UserService } from 'jslib-common/abstractions/user.service';
|
import { UserService } from 'jslib-common/abstractions/user.service';
|
||||||
|
|
||||||
@ -16,8 +17,6 @@ import { PaymentMethodType } from 'jslib-common/enums/paymentMethodType';
|
|||||||
|
|
||||||
import { BitPayInvoiceRequest } from 'jslib-common/models/request/bitPayInvoiceRequest';
|
import { BitPayInvoiceRequest } from 'jslib-common/models/request/bitPayInvoiceRequest';
|
||||||
|
|
||||||
import { WebConstants } from '../../services/webConstants';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-add-credit',
|
selector: 'app-add-credit',
|
||||||
templateUrl: 'add-credit.component.html',
|
templateUrl: 'add-credit.component.html',
|
||||||
@ -33,8 +32,8 @@ export class AddCreditComponent implements OnInit {
|
|||||||
@ViewChild('ppButtonForm', { read: ElementRef, static: true }) ppButtonFormRef: ElementRef;
|
@ViewChild('ppButtonForm', { read: ElementRef, static: true }) ppButtonFormRef: ElementRef;
|
||||||
|
|
||||||
paymentMethodType = PaymentMethodType;
|
paymentMethodType = PaymentMethodType;
|
||||||
ppButtonFormAction = WebConstants.paypal.buttonActionProduction;
|
ppButtonFormAction: string;
|
||||||
ppButtonBusinessId = WebConstants.paypal.businessIdProduction;
|
ppButtonBusinessId: string;
|
||||||
ppButtonCustomField: string;
|
ppButtonCustomField: string;
|
||||||
ppLoading = false;
|
ppLoading = false;
|
||||||
subject: string;
|
subject: string;
|
||||||
@ -47,10 +46,9 @@ export class AddCreditComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private userService: UserService, private apiService: ApiService,
|
constructor(private userService: UserService, private apiService: ApiService,
|
||||||
private platformUtilsService: PlatformUtilsService) {
|
private platformUtilsService: PlatformUtilsService) {
|
||||||
if (process.env.ENV !== 'cloud' || platformUtilsService.isDev()) {
|
const payPalConfig = process.env.PAYPAL_CONFIG as PayPalConfig;
|
||||||
this.ppButtonFormAction = WebConstants.paypal.buttonActionSandbox;
|
this.ppButtonFormAction = payPalConfig.buttonAction;
|
||||||
this.ppButtonBusinessId = WebConstants.paypal.businessIdSandbox;
|
this.ppButtonBusinessId = payPalConfig.businessId;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
@ -9,8 +9,6 @@ import { PaymentMethodType } from 'jslib-common/enums/paymentMethodType';
|
|||||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||||
|
|
||||||
import { WebConstants } from '../../services/webConstants';
|
|
||||||
|
|
||||||
const StripeElementStyle = {
|
const StripeElementStyle = {
|
||||||
base: {
|
base: {
|
||||||
color: '#333333',
|
color: '#333333',
|
||||||
@ -67,8 +65,7 @@ export class PaymentComponent implements OnInit {
|
|||||||
this.stripeScript.src = 'https://js.stripe.com/v3/';
|
this.stripeScript.src = 'https://js.stripe.com/v3/';
|
||||||
this.stripeScript.async = true;
|
this.stripeScript.async = true;
|
||||||
this.stripeScript.onload = () => {
|
this.stripeScript.onload = () => {
|
||||||
this.stripe = (window as any).Stripe(process.env.ENV === 'cloud' && !platformUtilsService.isDev() ?
|
this.stripe = (window as any).Stripe(process.env.STRIPE_KEY);
|
||||||
WebConstants.stripeLiveKey : WebConstants.stripeTestKey);
|
|
||||||
this.stripeElements = this.stripe.elements();
|
this.stripeElements = this.stripe.elements();
|
||||||
this.setStripeElement();
|
this.setStripeElement();
|
||||||
};
|
};
|
||||||
@ -126,8 +123,7 @@ export class PaymentComponent implements OnInit {
|
|||||||
if (this.method === PaymentMethodType.PayPal) {
|
if (this.method === PaymentMethodType.PayPal) {
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
(window as any).braintree.dropin.create({
|
(window as any).braintree.dropin.create({
|
||||||
authorization: process.env.ENV === 'cloud' ?
|
authorization: process.env.BRAINTREE_KEY,
|
||||||
WebConstants.btProductionKey : WebConstants.btSandboxKey,
|
|
||||||
container: '#bt-dropin-container',
|
container: '#bt-dropin-container',
|
||||||
paymentOptionPriority: ['paypal'],
|
paymentOptionPriority: ['paypal'],
|
||||||
paypal: {
|
paypal: {
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
export class WebConstants {
|
|
||||||
static readonly stripeTestKey = 'pk_test_KPoCfZXu7mznb9uSCPZ2JpTD';
|
|
||||||
static readonly stripeLiveKey = 'pk_live_bpN0P37nMxrMQkcaHXtAybJk';
|
|
||||||
static readonly btSandboxKey = 'sandbox_r72q8jq6_9pnxkwm75f87sdc2';
|
|
||||||
static readonly btProductionKey = 'production_qfbsv8kc_njj2zjtyngtjmbjd';
|
|
||||||
static readonly paypal = {
|
|
||||||
businessIdProduction: '4ZDA7DLUUJGMN',
|
|
||||||
businessIdSandbox: 'AD3LAUZSNVPJY',
|
|
||||||
buttonActionProduction: 'https://www.paypal.com/cgi-bin/webscr',
|
|
||||||
buttonActionSandbox: 'https://www.sandbox.paypal.com/cgi-bin/webscr',
|
|
||||||
};
|
|
||||||
}
|
|
@ -148,6 +148,9 @@ const plugins = [
|
|||||||
'APPLICATION_VERSION': pjson.version,
|
'APPLICATION_VERSION': pjson.version,
|
||||||
'CACHE_TAG': Math.random().toString(36).substring(7),
|
'CACHE_TAG': Math.random().toString(36).substring(7),
|
||||||
'URLS': envConfig['urls'] ?? {},
|
'URLS': envConfig['urls'] ?? {},
|
||||||
|
'STRIPE_KEY': envConfig['stripeKey'] ?? '',
|
||||||
|
'BRAINTREE_KEY': envConfig['braintreeKey'] ?? '',
|
||||||
|
'PAYPAL_CONFIG': envConfig['paypal'] ?? {},
|
||||||
}),
|
}),
|
||||||
new AngularCompilerPlugin({
|
new AngularCompilerPlugin({
|
||||||
tsConfigPath: 'tsconfig.json',
|
tsConfigPath: 'tsconfig.json',
|
||||||
|
Loading…
Reference in New Issue
Block a user