Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marketintelligence's avatar

Advice on how to make code abstract

We plan to link various suppliers in our system to products we have. The flow with us is that we receive an order via an ecommerce channel, we then forward the order to a supplier.

Now we prefer to make it very generic, we can communicate with all those third parties and the actions we perform are always the same for every platform, for example:

getOrder updateOrder updateShipmentForOrder updateShipmentSettings authorize

Under water, all those functions would then be able to address the APIs of the relevant supplier. So I'm actually thinking of a kind of solution with which you can determine with an interface and a kind of factory which supplier client you should address, and because you have abstraction in the internal endpoints, each provider will have is own implementation as it follows the interface/contract.

Real world example;

Suppose you have an platform where you have a checkout flow, but as you have multiple payment gateway options ( Bank Transfer, Paypal, Stripe ). How to make it as generic as possible to make it more easy to connect other payment options like Alipay for example. As the flow on each payment option is basically the same, setup a payment, check payment status ect.

Any advice on how to do this?

0 likes
0 replies

Please or to participate in this conversation.