attachPaymentMethod to setupPaymentMethod
MODIFY
src/integration/billing/BillingIntegration.ts
src/integration/billing/BillingIntegration.ts
@@ -572,7 +572,7 @@ export default abstract class BillingIntegration<T extends BillingSetting> {
abstract finalizeInvoice(invoice: BillingInvoice): Promise<string>;
// ##CR - TO BE CLARIFIED - clarify the return type!
- abstract attachPaymentMethod(user: User, paymentMethodId: string): Promise<BillingOperationResult>;
+ abstract setupPaymentMethod(user: User, paymentMethodId: string): Promise<BillingOperationResult>;
abstract chargeInvoice(invoice: BillingInvoice): Promise<unknown>;
abstract handleBillingEvent(req: Request): boolean;

MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -541,7 +541,7 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
return stripeInvoice;
}
- public async attachPaymentMethod(user: User, paymentMethodId: string): Promise<BillingOperationResult> {
+ public async setupPaymentMethod(user: User, paymentMethodId: string): Promise<BillingOperationResult> {
// Check Stripe
await this.checkConnection();
// Check billing data consistency
@@ -550,7 +550,7 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
message: 'User is not yet known in Stripe',
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME,
- method: 'attachPaymentMethod',
+ method: 'setupPaymentMethod',
action: ServerAction.BILLING_TRANSACTION
});
}

MODIFY
src/server/rest/CentralRestServerService.ts
src/server/rest/CentralRestServerService.ts
@@ -82,7 +82,7 @@ class RequestMapper {
[ServerAction.BILLING_SYNCHRONIZE_INVOICES]: BillingService.handleSynchronizeInvoices.bind(this),
[ServerAction.BILLING_FORCE_SYNCHRONIZE_USER_INVOICES]: BillingService.handleForceSynchronizeUserInvoices.bind(this),
[ServerAction.BILLING_CREATE_TRANSACTION_INVOICE]: BillingService.handleCreateTransactionInvoice.bind(this),
- [ServerAction.BILLING_ATTACH_PAYMENT_METHOD]: BillingService.handleBillingAttachPaymentMethod.bind(this),
+ [ServerAction.BILLING_SETUP_PAYMENT_METHOD]: BillingService.handleBillingSetupPaymentMethod.bind(this),
[ServerAction.OCPI_ENPOINT_CREATE]: OCPIEndpointService.handleCreateOcpiEndpoint.bind(this),
[ServerAction.OCPI_ENPOINT_PING]: OCPIEndpointService.handlePingOcpiEndpoint.bind(this),
[ServerAction.OCPI_ENPOINT_CHECK_CDRS]: OCPIEndpointService.handleCheckCdrsEndpoint.bind(this),

MODIFY
src/server/rest/v1/router/api/BillingRouter.ts
src/server/rest/v1/router/api/BillingRouter.ts
@@ -12,13 +12,13 @@ export default class BillingRouter {
}
public buildRoutes(): express.Router {
- this.buildRouteAttachPaymentMethod();
+ this.buildRouteSetupPaymentMethod();
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.BILLING_ATTACH_PAYMENT_METHOD, req, res, next);
+ protected buildRouteSetupPaymentMethod(): void {
+ this.router.put(`/${ServerAction.BILLING_SETUP_PAYMENT_METHOD}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(BillingService.handleBillingSetupPaymentMethod.bind(this), ServerAction.BILLING_SETUP_PAYMENT_METHOD, req, res, next);
});
}
}

MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -492,10 +492,10 @@ export default class BillingService {
next();
}
- public static async handleBillingAttachPaymentMethod(action: ServerAction, req: Request, res: Response): Promise<void> {
+ public static async handleBillingSetupPaymentMethod(action: ServerAction, req: Request, res: Response): Promise<void> {
// Check if component is active
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.BILLING,
- Action.BILLING_ATTACH_PAYMENT_METHOD, Entity.BILLING, MODULE_NAME, 'handleBillingAttachPaymentMethod');
+ Action.BILLING_SETUP_PAYMENT_METHOD, Entity.BILLING, MODULE_NAME, 'handleSetupSetupPaymentMethod');
// Filter
// TODO - const filteredRequest = BillingSecurity.filterSynchronizeUserRequest(req.body);
// Get the billing impl
@@ -505,7 +505,7 @@ export default class BillingService {
source: Constants.CENTRAL_SERVER,
errorCode: HTTPError.GENERAL_ERROR,
message: 'Billing service is not configured',
- module: MODULE_NAME, method: 'handleBillingAttachPaymentMethod',
+ module: MODULE_NAME, method: 'handleBillingSetupPaymentMethod',
action: action,
user: req.user
});
@@ -513,10 +513,10 @@ export default class BillingService {
// Get user
const user: User = await UserStorage.getUser(req.user.tenantID, req.user.id);
UtilsService.assertObjectExists(action, user, `User '${req.user.id}' does not exist`,
- MODULE_NAME, 'handleAttachPaymentMethod', req.user);
+ MODULE_NAME, 'handleSetupPaymentMethod', req.user);
// Invoke the billing implementation
const paymentMethodId: string = req.body.paymentMethodId;
- const operationResult: BillingOperationResult = await billingImpl.attachPaymentMethod(user, paymentMethodId);
+ const operationResult: BillingOperationResult = await billingImpl.setupPaymentMethod(user, paymentMethodId);
if (operationResult) {
console.log(operationResult);
}

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -122,7 +122,7 @@ export enum Action {
REFUND_TRANSACTION = 'RefundTransaction',
SYNCHRONIZE_BILLING_USERS = 'SynchronizeBillingUsers',
SYNCHRONIZE_BILLING_USER = 'SynchronizeBillingUser',
- BILLING_ATTACH_PAYMENT_METHOD = 'BillingAttachPaymentMethod',
+ BILLING_SETUP_PAYMENT_METHOD = 'BillingSetupPaymentMethod',
BILLING_CHARGE_INVOICE = 'BillingChargeInvoice',
CHECK_CONNECTION = 'CheckConnection',
RETRIEVE_CONSUMPTION = 'RetrieveConsumption',

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -379,7 +379,7 @@ export enum ServerAction {
BILLING_DOWNLOAD_INVOICE = 'BillingDownloadInvoice',
BILLING_CREATE_TRANSACTION_INVOICE = 'BillingCreateTransactionInvoice',
BILLING_NEW_INVOICE = 'BillingNewInvoice',
- BILLING_ATTACH_PAYMENT_METHOD = 'BillingAttachPaymentMethod',
+ BILLING_SETUP_PAYMENT_METHOD = 'BillingSetupPaymentMethod',
BILLING_CHARGE_INVOICE = 'BillingChargeInvoice',
BILLING_WEB_HOOK = 'BillingWebHook',

attachPaymentMethod to setupPaymentMethod