Controller/Service Architecture Question
Hi,
I have a process that involves several steps. I've decided to break the steps out into several services. For example, when a subscriber is created, my app needs to validate the Stripe coupon, create a Stripe customer, subscribe the provided email to a MailChimp list, create a subscriber record in the DB, then return a view.
I can make this all work by calling each service in my controller. However, this makes my controller fairly large (exception handling) as well as starting to handle some of my business logic. My solution would be to move most of this to its own service class (SubscriberService) which calls each service. That would seem to be a good idea, but the one thing I'm struggling with is how to pass the messages back to the controller in a clean way.
For a successfully subscription, I want to direct to one page with a success message. For a failure I want to redirect back to the subscription page with a message detailing whatever failed. Because of this, I seem to still have a lot of different exceptions to catch in the controller.
Does anyone have a recommendation for how to structure a controller and various services to avoid controller bloat, but still allowing for the proper user messaging?
Please or to participate in this conversation.