bp - cleanup
MODIFY
src/integration/billing/stripe/StripeHelpers.ts
src/integration/billing/stripe/StripeHelpers.ts
-import { BillingAdditionalData, BillingError, BillingErrorCode, BillingErrorType, BillingInvoice, BillingInvoiceItem, BillingSessionData } from '../../../types/Billing';
+import { BillingError, BillingErrorCode, BillingErrorType, BillingInvoice, BillingInvoiceItem, BillingSessionData } from '../../../types/Billing';
-import BillingStorage from '../../../storage/mongodb/BillingStorage';
import Constants from '../../../utils/Constants';
import Countries from 'i18n-iso-countries';
import I18nManager from '../../../utils/I18nManager';
import Stripe from 'stripe';
-import Tenant from '../../../types/Tenant';
import User from '../../../types/User';
import Utils from '../../../utils/Utils';
@@ -18,11 +16,12 @@ export interface StripeChargeOperationResult {
export default class StripeHelpers {
public static enrichInvoiceWithAdditionalData(billingInvoice: BillingInvoice, operationResult: StripeChargeOperationResult, billingInvoiceItem?: BillingInvoiceItem): void {
- // Do we have an error to preserve
- let billingError: BillingError;
if (operationResult && !operationResult.succeeded) {
// The operation failed
- billingError = StripeHelpers.convertToBillingError(operationResult.error);
+ const billingError = StripeHelpers.convertToBillingError(operationResult.error);
+ if (billingError) {
+ billingInvoice.lastError = billingError;
+ }
}
if (billingInvoiceItem) {
const session: BillingSessionData = {
@@ -36,10 +35,6 @@ export default class StripeHelpers {
billingInvoice.sessions = [ session ];
}
}
- // Is there anything to update?
- if (billingError) {
- billingInvoice.lastError = billingError;
- }
}
public static convertToBillingError(error: Error): BillingError {

MODIFY
src/storage/mongodb/BillingStorage.ts
src/storage/mongodb/BillingStorage.ts
-import { BillingAccount, BillingAdditionalData, BillingInvoice, BillingInvoiceStatus, BillingSessionData, BillingTransfer, BillingTransferSession } from '../../types/Billing';
+import { BillingAccount, BillingInvoice, BillingInvoiceStatus, BillingTransfer, BillingTransferSession } from '../../types/Billing';
import global, { DatabaseCount, FilterParams } from '../../types/GlobalType';
import Constants from '../../utils/Constants';

MODIFY
src/types/Billing.ts
src/types/Billing.ts
@@ -150,11 +150,6 @@ export enum BillingErrorCode {
CARD_ERROR = 'card_error',
}
-export interface BillingAdditionalData {
- session?: BillingSessionData,
- lastError?: BillingError,
-}
-
export enum BillingAccountStatus {
IDLE = 'idle',
PENDING = 'pending',

bp - cleanup