router - -buildRouteAttachPaymentMethod
MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -438,7 +438,6 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
public async chargeInvoice(invoice: BillingInvoice): Promise<unknown> {
await this.checkConnection();
-
// Fetch the invoice from stripe (do NOT TRUST the local copy)
let stripeInvoice : invoices.IInvoice = await this.stripe.invoices.retrieve(invoice.invoiceID);
// Check the current invoice status

MODIFY
src/server/rest/v1/router/GlobalRouter.ts
src/server/rest/v1/router/GlobalRouter.ts
@@ -2,6 +2,7 @@ import express, { NextFunction, Request, Response } from 'express';
import AuthRouter from './auth/AuthRouter';
import AuthService from '../service/AuthService';
+import BillingRouter from './api/BillingRouter';
import { StatusCodes } from 'http-status-codes';
import SwaggerRouter from './doc/SwaggerRouter';
import TenantRouter from './api/TenantRouter';
@@ -19,6 +20,7 @@ export default class GlobalRouter {
this.buildRouteAPI();
this.buildRouteUtils();
this.buildRouteDocs();
+ this.buildRouteBilling();
this.buildUnknownRoute();
return this.router;
}
@@ -41,6 +43,10 @@ export default class GlobalRouter {
this.router.use('/docs', new SwaggerRouter().buildRoutes());
}
+ protected buildRouteBilling(): void {
+ this.router.use('/docs', new BillingRouter().buildRoutes());
+ }
+
protected buildUnknownRoute(): void {
this.router.use('*', (req: Request, res: Response, next: NextFunction) => {
if (!res.headersSent) {

ADD
src/server/rest/v1/router/api/BillingRouter.ts
+import express, { NextFunction, Request, Response } from 'express';
+
+import BillingService from '../../service/BillingService';
+import RouterUtils from '../RouterUtils';
+import { ServerAction } from '../../../../../types/Server';
+
+export default class BillingRouter {
+ private router: express.Router;
+
+ public constructor() {
+ this.router = express.Router();
+ }
+
+ public buildRoutes(): express.Router {
+ this.buildRouteAttachPaymentMethod();
+ return this.router;
+ }
+
+ protected buildRouteAttachPaymentMethod(): void {
+ this.router.put(`/${ServerAction.BILLING_ATTACH_PAYMENT_METHOD}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(BillingService.handleBillingAttachPaymentMethod.bind(this), ServerAction.REST_TENANTS, req, res, next);
+ });
+ }
+}

router - -buildRouteAttachPaymentMethod