chargeInvoice endpoint - some cleanup
MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -590,8 +590,8 @@ export default class BillingService {
// Filter
const filteredRequest = BillingSecurity.filterChargeInvoiceRequest(req.body);
// Get the Invoice
- const invoice = await BillingStorage.getInvoice(req.user.tenantID, filteredRequest.invoiceID);
- UtilsService.assertObjectExists(action, invoice, `Invoice ID '${filteredRequest.invoiceID}' does not exist`,
+ const invoice = await BillingStorage.getInvoice(req.user.tenantID, filteredRequest.ID); // ID of the Billing Invoice (not the stripe invoice)
+ UtilsService.assertObjectExists(action, invoice, `Invoice ID '${filteredRequest.ID}' does not exist`,
MODULE_NAME, 'handleDownloadInvoice', req.user);
// Check Auth
// if (!Authorizations.canChargeInvoice(req.user, invoice.userID)) {

MODIFY
src/server/rest/v1/service/security/BillingSecurity.ts
src/server/rest/v1/service/security/BillingSecurity.ts
import { HttpBillingInvoiceRequest, HttpBillingWebHookRequest } from '../../../../../types/requests/HttpBillingRequest';
-import { HttpChargeInvoiceRequest, HttpCreateTransactionInvoiceRequest, HttpForceSynchronizeUserInvoicesRequest, HttpSynchronizeUserRequest } from '../../../../../types/requests/HttpUserRequest';
+import { HttpCreateTransactionInvoiceRequest, HttpForceSynchronizeUserInvoicesRequest, HttpSynchronizeUserRequest } from '../../../../../types/requests/HttpUserRequest';
import HttpByIDRequest from '../../../../../types/requests/HttpByIDRequest';
import UtilsSecurity from './UtilsSecurity';
@@ -57,9 +57,9 @@ export default class BillingSecurity {
};
}
- static filterChargeInvoiceRequest(request: any): HttpChargeInvoiceRequest {
+ static filterChargeInvoiceRequest(request: any): HttpByIDRequest {
return {
- invoiceID: sanitize(request.invoiceID)
+ ID: sanitize(request.ID)
};
}

MODIFY
src/types/requests/HttpUserRequest.ts
src/types/requests/HttpUserRequest.ts
@@ -17,10 +17,6 @@ export interface HttpCreateTransactionInvoiceRequest {
transactionID?: string;
}
-export interface HttpChargeInvoiceRequest {
- invoiceID?: string;
-}
-
export interface HttpUserMobileTokenRequest {
id: string;
mobileToken: string;

chargeInvoice endpoint - some cleanup