seniorClean Architecture
Handling Third-Party APIs (Gateways) in CA.
Updated Apr 28, 2026
Short answer
Define a domain-specific interface (Port) for the external service and implement an Adapter to handle the API communication.
Deep explanation
If you use Stripe for payments, don't use the stripe object in your Use Case. Create a PaymentProcessor interface. The implementation handles Stripe-specific errors, tokens, and API calls. If you switch to PayPal, only the implementation changes.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro