Router
The router service is implemented in Rust to ensure type safety and high performance. It follows a hexagonal architecture, promoting modularity by allowing independent management of different components. l-lin.github.io
Core API Layer
Request Handling: Incoming HTTP requests are directed to the Core API Layer.
Authentication: Depending on the API endpoint or group, appropriate authentication mechanisms are applied to verify the request.
Data Validation: The payload of incoming data is validated. This includes checking the data itself and ensuring it aligns with the merchant's configuration. For instance, a refund request should correspond to a successful payment.
Data Storage and Response: Valid data is stored. If the API action is standalone, a success response is returned. If it involves connector calls, the response's success or failure depends on the connector module's status.
Error Handling: In case of a connector failure, appropriate status mapping ensures a unified user interface.
Connectors
Connectors are external services that the router interacts with, such as payment processors, fraud and risk management services, and tokenization services.
Selection Criteria: The API request type, data, and merchant configuration determine which connectors the router will call.
Connector Module: This module contains the logic to construct necessary request data for the selected services and to interpret their responses.github.com+5thetechedvocate.org+5alexis-lozano.com+5
Complex Operations: Some services may require multiple API calls for a single action, which the connector can handle.
Asynchronous Jobs Scheduler
Certain API actions might be time-consuming, making it impractical to delay the API response until completion. In such cases, the router returns a success response with an intermediate state, like "processing." For example, if a payment processor doesn't immediately confirm success, the router will check the status later.
Job Queueing: The necessary action is queued for the scheduler to execute asynchronously.
Scheduler Function: The scheduler determines which jobs to run based on their scheduled times, executes them, updates the router's storage, and triggers any other required actions, such as webhook calls to the server.
This design ensures that the router service remains efficient, modular, and capable of handling complex operations without compromising performance.
Last updated
Was this helpful?