Middle
Describe the sequence diagram for the online bookstore payment process via an external bank payment API. Is the integration synchronous or asynchronous? How to implement asynchrony via REST without a message broker?
sobes.tech AI
Answer from AI
Sequence diagram of the payment process via an external bank payment API:
- The user selects books and initiates payment on the online bookstore website.
- The store forms a payment request and sends it to the external bank API.
- The bank processes the request and returns a response (success/error).
- The store receives the response and informs the user of the result.
Integration type:
- Usually, a synchronous call is used: the store sends the request and waits for the bank's response to immediately show the result to the user.
Implementation of asynchrony via REST without a message broker:
- The store sends a payment request with a callback URL (webhook).
- The bank immediately responds with an acceptance confirmation (e.g., HTTP 202 Accepted).
- After processing the payment, the bank calls the store's callback URL with the result.
- The store updates the order status and notifies the user.
Thus, asynchrony is achieved through webhooks and repeated HTTP requests, without the need for message brokers.