Build a Unified Payments Client

Adapter pattern

Challenge 1 of Wrap & ExtendBeginner~55 minFree

Two payment gateways, two incompatible SDKs, one checkout button. The Adapter pattern wraps each mismatched provider API in a common interface so the rest of your system never has to care which gateway it is talking to. Build a Stripe adapter and a PayPal adapter behind a single charge() contract, write a client that works with either, map declines to a uniform result, and finish with a factory that hands you the right adapter by name.

5 steps

  1. 1The Target Interface + Stripe Adapter
  2. 2The PayPal Adapter
  3. 3A Provider-Agnostic Client
  4. 4Uniform Failure Handling
  5. 5The Adapter Factory
Start step 1