V
V
Vasyl Fomin2020-02-17 14:20:53
PHP
Vasyl Fomin, 2020-02-17 14:20:53

What pattern to use for the task of receiving orders, sending order statuses from several different external sources?

Tell me which approach, pattern, structure is better to use to solve the following problem:
There is a store (Laravel), you need to receive orders, send order statuses from several external services - marketplaces for example. Each of the services has its own authorization method, its own request/response formats, and its own statuses.

I understand that it is necessary, for each of the external services, to implement separate classes, and perhaps in each of them you need to use the same interface to work with it.

In general, the main question is how to organize it all correctly, where to indicate which service we are currently working with, whether to create service classes using the same interface or make some kind of adapters?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max, 2020-02-17
@fomvasss

An interface is created and possibly an abstract class where methods that are common to all services will be listed.
Then a factory is created with the help of which you get an instance of the class of the desired service and call the necessary methods.

V
vitaly_74, 2020-02-19
@vitaly_74

I'm doing something like this now. what you need: a factory for sure, one interface for each type of operation (refund deposit), any adapters to communicate with your crm, and decorators (to add functionality at any time without changing the old code). and perhaps a strategy will still be needed (to decide if the transaction is canceled, then what to do).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question