HomeChallengesRepsProblemsLeaderboardTake a challenge

The gateway’s JSON, parsed in the business logic

A subscription service reaches into a payment provider’s JSON — txn_st_v3, ch_ident_key, resp_cd — and decides business outcomes from it. Put an adapter and a domain model between them so swapping provider is a new class, not a rewrite.

Intermediate20 min on the clock5 graded checks · 100 pointsCode Someone Else Can Change, in C#Pro

See alsoThe vendor’s field names, everywhereThe same boundary in JavaScript, without an interface to hang it on.

Graded by reading your code against the checklist below.

What you build

  • A PaymentResult domain record
  • An IGatewayResponseAdapter interface
  • A VendorPaymentAdapter that does all the parsing
  • SubscriptionManager depends on the interface, not the vendor
  • No JSON and no vendor key anywhere in SubscriptionManager

Done means

A second provider is a second adapter, and no existing business code changes.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. A domain record carries the outcome+20Enforcing the rules of your data
  2. The seam is an interface in the domain+20Where code lives
  3. All parsing happens in the adapter+30Where code lives
  4. The manager depends on the seam, not the vendor+20Where code lives
  5. What "succeeded" means is decided once+10Where code lives

What it teaches

The rest of Code Someone Else Can Change, in C#