No suggestions?
Use StripeController action in ProductController?
Hi everybody, I created my own laravel-vue e-commerce app, people buy Product Model with Stripe PHP sdk, what I was doing till now is I created a StripeController for handling stripe operations like charge, start subscriptions, refunds (for me this made sense), but I noticed my StripeController is not the best way to do this, before finsihing a charge I performed some actions like:
1)Transform cartTotalPrice to cents. 2)Check if cart items were all on stock with Product::outOfStock($cartItems);
- And maybe some simple auth check
This to me started to smell of bad code practice, so I'm thinking now I should move this actions (atleast charging and subscribing) to their related Model controllers (Product in this case) adn maybe transform my StripeController into a helper calss where I can wrap my refund, charge, createCustomer and getCustomerPaymentMethods actions into a Stripe helper class I would call in my ProductController, DiscountController or any other "buyable" model right?.
Another option would be calling my StripeController actions from ProductController but that smells even worse honestly.
What do you guys think of my idea?
Please or to participate in this conversation.