billing - setting storage - methods merged
MODIFY
src/storage/mongodb/SettingStorage.ts
src/storage/mongodb/SettingStorage.ts
@@ -423,31 +423,6 @@ export default class SettingStorage {
// Get BILLING Settings by Identifier
const setting = await SettingStorage.getSettingByIdentifier(tenantID, TenantComponents.BILLING);
if (setting) {
- return SettingStorage.convertToBillingSettings(setting);
- }
- return null;
- }
-
- public static async saveBillingSetting(tenantID: string, billingSettings: BillingSettings): Promise<string> {
- const { id, identifier, sensitiveData, backupSensitiveData, category } = billingSettings;
- const { createdBy, createdOn, lastChangedBy, lastChangedOn } = billingSettings;
- const { type, billing, stripe } = billingSettings;
- const setting: SettingDB = {
- id, identifier, sensitiveData, backupSensitiveData,
- content: {
- type,
- billing,
- },
- category, createdBy, createdOn, lastChangedBy, lastChangedOn,
- };
- if (billingSettings.type === BillingSettingsType.STRIPE) {
- setting.sensitiveData = [ 'content.stripe.secretKey' ];
- setting.content.stripe = stripe;
- }
- return SettingStorage.saveSettings(tenantID, setting);
- }
-
- private static convertToBillingSettings(setting: SettingDB): BillingSettings {
const { id, backupSensitiveData, category } = setting;
const { createdBy, createdOn, lastChangedBy, lastChangedOn } = setting;
const { content } = setting;
@@ -472,4 +447,25 @@ export default class SettingStorage {
}
return billingSettings;
}
+ return null;
+ }
+
+ public static async saveBillingSetting(tenantID: string, billingSettings: BillingSettings): Promise<string> {
+ const { id, identifier, sensitiveData, backupSensitiveData, category } = billingSettings;
+ const { createdBy, createdOn, lastChangedBy, lastChangedOn } = billingSettings;
+ const { type, billing, stripe } = billingSettings;
+ const setting: SettingDB = {
+ id, identifier, sensitiveData, backupSensitiveData,
+ content: {
+ type,
+ billing,
+ },
+ category, createdBy, createdOn, lastChangedBy, lastChangedOn,
+ };
+ if (billingSettings.type === BillingSettingsType.STRIPE) {
+ setting.sensitiveData = [ 'content.stripe.secretKey' ];
+ setting.content.stripe = stripe;
+ }
+ return SettingStorage.saveSettings(tenantID, setting);
+ }
}

billing - setting storage - methods merged