architecture – How to abstract a payment service to make developing new payment microservices faster


I am part of a team that is primarily working on payments integration. Creating a new microservice to handle a new payment type and integration takes us so much time and involves a lot of boilerplate and duplication especially when it comes to creating cloud infrastructure.

We currently build out our services on the AWS platform. We use Terraform for codifying
our infrastructure and we build all services using the microservices pattern. We do this currently by using AWS route53 latency routing to either to a backing AWS API Gateway or Load balancer that then routes requests in a round-robin fashion to docker containers in AWS ECS or AWS Fargate clusters. The domain routing is made up of a global domain and then regional domains mapped to the regional services (From the API Gateway or ALB inwards into the system, most infrastructure are regional infrastructure). We use AWS WAF and Shield for security.

We have somehow agreed on a way to optimise the infrastructure part. What is remaining now is the functional parts that run within the containers. We build those in Javascript/NodeJS/Express and store data in AWS DynamoDB. Most of our code is functional javascript code where Classes are used minimally or not at all.

I have recommended the use of OOP features like Interfaces/Abstract Classes/Inheritance. As the concept of Interfaces is not available in Javascript, I can see how promising the Inheritance feature can be for this if we create a base class that has unimplemented or default implementations of common payment service functionalities as functions. All the concrete payment types (e.g. Direct Debit, Credit Card, PayPal, etc) can inherit this base class and override these common functions while using mixins to extend a class’ functionality with functionality from other useful utility classes or objects that might be required in multiple places or by multiple payment methods (but not all of them).

The issue is that a key member of the team believes in sticking to the functional approach as much as is possible.

Please provide your thoughts and propose a better approach if you can. Is it also possible to use mixins alone and drop using OOP’s inheritance altogether in this case?

Thank you very much for your responses in advance.