Billing - issue - prevent exceptions by checking settings consistency
MODIFY
src/integration/billing/BillingFactory.ts
src/integration/billing/BillingFactory.ts
@@ -25,7 +25,10 @@ export default class BillingFactory {
let billingIntegrationImpl = null;
switch (settings.type) {
case BillingSettingsType.STRIPE:
+ if (StripeBillingIntegration.checkSettingsConsistency(settings.stripe)) {
+ // Only call the constructor when the prerequisites are met
billingIntegrationImpl = new StripeBillingIntegration(tenantID, settings.stripe);
+ }
break;
}
return billingIntegrationImpl;

MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -34,6 +34,14 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
this.axiosInstance = AxiosFactory.getAxiosInstance(this.tenantID);
}
+ public static checkSettingsConsistency(settings: StripeBillingSetting): boolean {
+ if (settings.url && settings.secretKey && settings.publicKey) {
+ return true;
+ }
+ // STRIPE prerequisites are not met
+ return false ;
+ }
+
public async getStripeInstance(): Promise<Stripe> {
// TODO - To be removed - only used by automated tests!
await this.checkConnection();

Billing - issue #2183 - prevent exceptions by checking settings consistency