stripe - reverting - liveMode flag not in settings
MODIFY
src/integration/billing/BillingIntegration.ts
src/integration/billing/BillingIntegration.ts
@@ -20,6 +20,9 @@ const MODULE_NAME = 'BillingIntegration';
export default abstract class BillingIntegration<T extends BillingSetting> {
+ // TO BE REMOVED - flag to switch ON/OFF some STRIPE integration logic not yet finalized!
+ protected readonly __liveMode: boolean = false;
+
protected readonly tenantID: string; // Assuming UUID or other string format ID
protected settings: T;
@@ -439,7 +442,7 @@ export default abstract class BillingIntegration<T extends BillingSetting> {
});
}
- if (this.settings.liveMode) {
+ if (this.__liveMode) {
// Check Billing Data (only in Live Mode)
if (!transaction.user.billingData) {
throw new BackendError({
@@ -465,7 +468,7 @@ export default abstract class BillingIntegration<T extends BillingSetting> {
});
}
- if (this.settings.liveMode) {
+ if (this.__liveMode) {
// Check Billing Data (only in Live Mode)
const billingUser = transaction.user;
if (!billingUser.billingData || !billingUser.billingData.customerID) {

MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -619,7 +619,7 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
// Check Transaction
this.checkStartTransaction(transaction);
- if (this.settings.liveMode) {
+ if (this.__liveMode) {
// Check that the customer STRIPE
const customer = await this.getStripeCustomer(transaction.user);
if (!customer) {
@@ -631,6 +631,8 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
action: ServerAction.BILLING_TRANSACTION
});
}
+ } else {
+ // Not yet LIVE ... starting a transaction without a STRIPE CUSTOMER is allowed
}
return {
cancelTransaction: false
@@ -725,7 +727,7 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
invoiceID: billingInvoice.id,
invoiceStatus: billingInvoice.status
};
- } else if (this.settings.liveMode) {
+ } else if (this.__liveMode) {
throw new Error('Unexpected situation - no customer - The transaction should not have been started in this context');
}
} catch (error) {

MODIFY
src/server/rest/v1/service/security/SettingSecurity.ts
src/server/rest/v1/service/security/SettingSecurity.ts
@@ -144,8 +144,7 @@ export default class SettingSecurity {
periodicBillingAllowed: sanitize(request.content.stripe.periodicBillingAllowed),
advanceBillingAllowed: sanitize(request.content.stripe.advanceBillingAllowed),
currency: sanitize(request.content.stripe.currency),
- taxID: sanitize(request.content.stripe.taxID),
- liveMode: sanitize(request.content.stripe.liveMode),
+ taxID: sanitize(request.content.stripe.taxID)
};
break;
case SmartChargingSettingsType.SAP_SMART_CHARGING:

MODIFY
src/storage/mongodb/SettingStorage.ts
src/storage/mongodb/SettingStorage.ts
@@ -306,8 +306,7 @@ export default class SettingStorage {
periodicBillingAllowed: config.stripe.periodicBillingAllowed ? config.stripe.periodicBillingAllowed : false,
usersLastSynchronizedOn: config.stripe.usersLastSynchronizedOn ? config.stripe.usersLastSynchronizedOn : new Date(0),
invoicesLastSynchronizedOn: config.stripe.invoicesLastSynchronizedOn ? config.stripe.invoicesLastSynchronizedOn : new Date(0),
- taxID: config.stripe.taxID ? (config.stripe.taxID !== 'none' ? config.stripe.taxID : null) : null,
- liveMode: !!config.stripe.liveMode,
+ taxID: config.stripe.taxID ? (config.stripe.taxID !== 'none' ? config.stripe.taxID : null) : null
};
}
return billingSettings;

MODIFY
src/types/Setting.ts
src/types/Setting.ts
@@ -201,8 +201,7 @@ export interface BillingSettings extends Setting{
export interface BillingSetting {
usersLastSynchronizedOn?: Date;
- invoicesLastSynchronizedOn?: Date;
- liveMode: boolean;
+ invoicesLastSynchronizedOn?: Date
}
export interface StripeBillingSetting extends BillingSetting {

MODIFY
test/api/BillingStripeTestData.ts
test/api/BillingStripeTestData.ts
@@ -91,8 +91,7 @@ export default class StripeIntegrationTestData {
currency: config.get('billing.currency'),
immediateBillingAllowed: config.get('billing.immediateBillingAllowed'),
periodicBillingAllowed: config.get('billing.periodicBillingAllowed'),
- taxID: config.get('billing.taxID'),
- liveMode: config.get('billing.liveMode')
+ taxID: config.get('billing.taxID')
};
}

MODIFY
test/api/context/BillingContext.ts
test/api/context/BillingContext.ts
@@ -28,8 +28,7 @@ export default class BillingContext {
currency: config.get('billing.currency'),
immediateBillingAllowed: config.get('billing.immediateBillingAllowed'),
periodicBillingAllowed: config.get('billing.periodicBillingAllowed'),
- taxID: config.get('billing.taxID'),
- liveMode: config.get('billing.liveMode')
+ taxID: config.get('billing.taxID')
};
}

MODIFY
test/api/context/ContextDefinition.ts
test/api/context/ContextDefinition.ts
@@ -184,8 +184,7 @@ export default class ContextDefinition {
immediateBillingAllowed: true,
periodicBillingAllowed: true,
advanceBillingAllowed: true,
- taxID: '',
- liveMode: false
+ taxID: ''
}
}
}
@@ -314,8 +313,7 @@ export default class ContextDefinition {
immediateBillingAllowed: true,
periodicBillingAllowed: true,
advanceBillingAllowed: true,
- taxID: '',
- liveMode: false
+ taxID: ''
}
}
},

MODIFY
test/config-template.json
test/config-template.json
"noCardAllowed": true,
"advanceBillingAllowed": true,
"immediateBillingAllowed": true,
- "periodicBillingAllowed": true,
- "liveMode": false
+ "periodicBillingAllowed": true
},
"smartCharging": {
"optimizerUrl": "",

MODIFY
test/config.js
test/config.js
@@ -296,11 +296,6 @@ const config = convict({
doc: 'taxes to apply by default',
format: String,
default: ''
- },
- liveMode: {
- doc: 'Allow a preview of billing features',
- format: Boolean,
- default: ''
}
},
smartCharging: {

stripe - reverting - liveMode flag not in settings