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 pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Clean Architecture interview questions

View all →