Here's an abstract question with real world implications.
I have two microservices; let's call them the CreditCardsService
and the SubscriptionsService
.
I also have a SPA that is supposed to use the SubscriptionsService
so that customers can subscribe. To do that, the SubscriptionsService
has an endpoint where you can POST
a subscription model to create a subscription, and in that model is a creditCardId
that points to a credit card that should pay for the subscription. There are certain business rules that say whether or not you can use said credit card for the subscription (expiration is more than 12 months away, it's a VISA, etc). These specific business rules are tied to the SubscriptionsService
The problem is that the team working on the SPA want a /CreditCards
endpoint in the SubscriptonsService
that returns all valid credit cards of the user that can be used in the subscriptions model. They don't want to implement the same business validation rules in the SPA that are in the SubscriptionsService
itself.
To me this seems to go against the SOLID principles that are central to microservice design; specifically separation of concerns. I also ask myself, what precedent is this going to set? Are we going to have to add a /CreditCards
endpoint to the OrdersService or any other service that might use creditCardId
as a property of it's model?
So the main question is this: What is the best way to design this? Should the business validation logic be duplicated between the frontend and the backend? Should this new endpoint be added to the SubscriptionsService
? Should we try to simplify the business logic?