billing -  fix stop transaction status + FT cleanup
MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -436,9 +436,7 @@ export default class StripeBillingIntegration extends BillingIntegration {
await StripeHelpers.updateInvoiceAdditionalData(this.tenant, billingInvoice, operationResult);
// Send a notification to the user
void this.sendInvoiceNotification(billingInvoice);
- if (FeatureToggles.isFeatureActive(Feature.BILLING_ASYNC_UPDATE_TRANSACTION)) {
await this._updateTransactionsBillingData(billingInvoice);
- }
return billingInvoice;
}
@@ -770,12 +768,10 @@ export default class StripeBillingIntegration extends BillingIntegration {
this.checkStartTransaction(transaction);
// Check Start Transaction Prerequisites
const customerID: string = transaction.user?.billingData?.customerID;
- if (FeatureToggles.isFeatureActive(Feature.BILLING_CHECK_CUSTOMER_ID)) {
// Check whether the customer exists or not
const customer = await this.checkStripeCustomer(customerID);
// Check whether the customer has a default payment method
this.checkStripePaymentMethod(customer);
- }
// Well ... when in test mode we may allow to start the transaction
if (!customerID) {
// Not yet LIVE ... starting a transaction without a STRIPE CUSTOMER is allowed
@@ -807,7 +803,6 @@ export default class StripeBillingIntegration extends BillingIntegration {
}
private checkStripePaymentMethod(customer: Stripe.Customer): void {
- if (FeatureToggles.isFeatureActive(Feature.BILLING_CHECK_USER_DEFAULT_PAYMENT_METHOD)) {
if (!customer.default_source && !customer.invoice_settings?.default_payment_method) {
throw new BackendError({
message: `Customer has no default payment method - ${customer.id}`,
@@ -818,7 +813,6 @@ export default class StripeBillingIntegration extends BillingIntegration {
});
}
}
- }
// eslint-disable-next-line @typescript-eslint/require-await
public async updateTransaction(transaction: Transaction): Promise<BillingDataTransactionUpdate> {
@@ -921,7 +915,6 @@ export default class StripeBillingIntegration extends BillingIntegration {
status: BillingStatus.UNBILLED
};
}
- if (FeatureToggles.isFeatureActive(Feature.BILLING_ASYNC_BILL_TRANSACTION)) {
// Create and Save async task
await AsyncTaskManager.createAndSaveAsyncTasks({
name: AsyncTasks.BILL_TRANSACTION,
@@ -935,15 +928,10 @@ export default class StripeBillingIntegration extends BillingIntegration {
method: 'stopTransaction',
});
// Inform the calling layer that the operation has been postponed
- if (!transaction.billingData?.withBillingActive) {
return {
status: BillingStatus.PENDING
};
}
- } else {
- return await this.billTransaction(transaction);
- }
- }
public async billTransaction(transaction: Transaction): Promise<BillingDataTransactionStop> {
// Check Stripe
@@ -1462,7 +1450,6 @@ export default class StripeBillingIntegration extends BillingIntegration {
}
// Check user prerequisites
const customerID: string = user?.billingData?.customerID;
- if (FeatureToggles.isFeatureActive(Feature.BILLING_CHECK_CUSTOMER_ID)) {
try {
// Check whether the customer exists or not
const customer = await this.checkStripeCustomer(customerID);
@@ -1479,7 +1466,6 @@ export default class StripeBillingIntegration extends BillingIntegration {
// TODO - return a more precise error code when payment method has expired
errorCodes.push(StartTransactionErrorCode.BILLING_NO_PAYMENT_METHOD);
}
- }
// Let's return the check results!
return errorCodes;
}

MODIFY
src/utils/FeatureToggles.ts
src/utils/FeatureToggles.ts
@@ -4,13 +4,9 @@ export enum Feature {
BILLING_SYNC_USERS,
BILLING_SYNC_USER,
BILLING_CHECK_USER_BILLING_DATA,
- BILLING_CHECK_CUSTOMER_ID,
- BILLING_CHECK_USER_DEFAULT_PAYMENT_METHOD,
BILLING_WITH_PARKING_TIME,
BILLING_ITEM_WITH_PARKING_TIME,
BILLING_ITEM_WITH_START_DATE,
- BILLING_ASYNC_BILL_TRANSACTION,
- BILLING_ASYNC_UPDATE_TRANSACTION,
}
export default class FeatureToggles {
@@ -19,12 +15,8 @@ export default class FeatureToggles {
// Feature.BILLING_SYNC_USERS, - When switched OFF the sync of the user should be implicit (LAZY mode)
Feature.BILLING_SYNC_USER,
Feature.BILLING_CHECK_USER_BILLING_DATA,
- Feature.BILLING_CHECK_CUSTOMER_ID,
- Feature.BILLING_CHECK_USER_DEFAULT_PAYMENT_METHOD,
// Feature.BILLING_ITEM_WITH_PARKING_TIME,
Feature.BILLING_ITEM_WITH_START_DATE,
- Feature.BILLING_ASYNC_BILL_TRANSACTION,
- Feature.BILLING_ASYNC_UPDATE_TRANSACTION,
];
// Check whether the feature is active or not!

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -167,10 +167,8 @@ class TestData {
const stopTransactionResponse = await this.chargingStationContext.stopTransaction(transactionId, tagId, meterStop, stopDate);
expect(stopTransactionResponse).to.be.transactionStatus('Accepted');
}
- if (FeatureToggles.isFeatureActive(Feature.BILLING_ASYNC_BILL_TRANSACTION)) {
// Give some time to the asyncTask to bill the transaction
await this.waitForAsyncTasks();
- }
return transactionId;
}

billing -  fix stop transaction status + FT cleanup