You need to build a C# Web API that exposes a single endpoint:
POST /payout
Your service must:
-
Accept incoming requests with header:
x-provider: Aor
x-provider: B -
Forward the request to the correct mock provider (
http://provider-a:5001/payoutorhttp://provider-b:5002/payout). -
Each provider has:
- Different request schema
- Different response schema
-
Your solution should:
-
Keep the controller thin — it should only delegate work to your application services.
-
Introduce a central service (for example,
PayoutCoreService) that orchestrates the flow:- Log the start of a payout.
- Translate the incoming request into the provider’s format.
- Call the provider.
- Translate the provider’s response back to your system’s response format.
- Log the successful payout.
-
Encapsulate provider-specific logic behind interfaces so it’s easy to add new providers later.
-
Introduce a mapping layer to handle conversions between your internal DTOs and provider-specific DTOs.
-
-
A design where:
- Provider selection is not hardcoded in the controller (it should be resolved cleanly elsewhere).
- Mappers/adapters handle translation of requests and responses.
- A single orchestration service ties everything together.
You are free to design the abstractions as you see fit. What matters most is that the code is extensible, clean, and testable.