You can create a simple service with the API payment and then you inject the service inside your Livewire component which need it.
https://farhan.dev/tutorial/laravel-service-classes-explained/
Dear Laravel community,
I am currently working on a fully custom e-commerce site. I am just not quite sure how to implement the payments. The problem here is that I have to write my own API-drivers for multiple different payment providers. So we have some payment methods that are provided by provider A and some by provider B.
I thought I'd make an abstract class PaymentDriver and then store the concrete implementation in my payment_methods table in the database:
driver: for example \App\Payments\PaymentDriverA
In the corresponding Livewire components I don't want to implement all the API logic because it might be that I want to have multiple different components for example for the checkout, returning an order or editing an order in the backend. So I need a global service that makes the Payment Api available to all these components. In the end, I just want to pass the PaymentMethod Model to my livewire components and that should be enough.
Please or to participate in this conversation.