Allow transaction when Stripe is not available
MODIFY
src/server/ocpp/utils/OCPPUtils.ts
src/server/ocpp/utils/OCPPUtils.ts
@@ -125,6 +125,7 @@ export default class OCPPUtils {
break;
// Stop Transaction
case TransactionAction.STOP:
+ try {
// Delegate
billingDataStop = await billingImpl.stopTransaction(transaction);
// Update
@@ -133,6 +134,17 @@ export default class OCPPUtils {
transaction.billingData.invoiceStatus = billingDataStop.invoiceStatus;
transaction.billingData.invoiceItem = billingDataStop.invoiceItem;
transaction.billingData.lastUpdate = new Date();
+ } catch (error) {
+ Logging.logError({
+ tenantID: tenantID,
+ user: transaction.userID,
+ source: Constants.CENTRAL_SERVER,
+ action: ServerAction.BILLING_TRANSACTION,
+ module: MODULE_NAME, method: 'stopTransaction',
+ message: `Failed to bill transaction ${transaction.id}`,
+ detailedMessages: { error: error.message, stack: error.stack }
+ });
+ }
break;
}
}

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -462,11 +462,11 @@ describe('Billing Service', function() {
});
it('Should set a transaction in error', async () => {
- // Await TestData.setBillingSystemInvalidCredentials(testData);
+ await TestData.setBillingSystemInvalidCredentials(testData);
const transactionID = await generateTransaction(testData.userContext, testData.chargingStationContext);
expect(transactionID).to.not.be.null;
const transactions = await testData.transactionUserService.transactionApi.readAllInError({});
- console.log(transactions);
+ expect(transactions.data.result.find((transaction) => transaction.id === transactionID)).to.not.be.null;
});
});

Allow transaction when Stripe is not available