Skip to content

refactor: normalize provider statuses and events at the payment boundary#1678

Merged
JoeriDijkstra merged 3 commits into
developfrom
refactor/normalize-provider-statuses
Jul 23, 2026
Merged

refactor: normalize provider statuses and events at the payment boundary#1678
JoeriDijkstra merged 3 commits into
developfrom
refactor/normalize-provider-statuses

Conversation

@jdijkstra-eyra

@jdijkstra-eyra jdijkstra-eyra commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Keeps OPP's wire vocabulary inside its own adapter so a second provider maps its strings once.

  • Transaction + transfer statuses normalize to the shared :pending | :completed | :failed atom (withdrawals were already done), keeping the provider's word as raw_status for the audit trail.
  • Bank-account KYC status normalizes to :verified | :rejected | :new | :pending; unknown → :pending so an unknown state never authorizes a payout. Merchant status left raw (no consumers).
  • OPP.Webhook classifies events into a provider-agnostic category and resolves the owning merchant_uid; the controller routes purely on category and never sees a provider string.

Addresses the "normalize provider statuses" (9995556065) and "normalize provider events" (10000440219) tech-debt tickets.

Stop OPP's wire vocabulary from leaking into domain code so a second
provider maps its strings once, in its own adapter.

- Lifecycle statuses (transaction + transfer) now normalize to the shared
  :pending | :completed | :failed atom, keeping the provider's word as
  raw_status for the audit trail (withdrawals were already done).
- Bank-account KYC status normalizes to :verified | :rejected | :new |
  :pending; unknown maps to :pending so an unknown state never authorizes a
  payout. Merchant status is left raw — it has no domain consumers.
- Webhook events are classified into a provider-agnostic category
  (:transaction | :withdrawal | :kyc | :ignored) inside OPP.Webhook, which
  also resolves the owning merchant_uid and logs unroutable KYC events. The
  controller now routes purely on category and never sees a provider string.
- Controller guards the :kyc route on a binary merchant_uid so a future
  provider can't reach notify_kyc/1 with nil.

Addresses the "normalize provider statuses" and "normalize provider events"
tech-debt tickets.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0179xMCWA3jhqdCpg6r28Y6g
Comment thread core/systems/payment/provider/opp/webhook.ex Outdated
An unresolvable KYC event was logged in OPP.Webhook (:error, with the OPP
identifiers) and then, because it was reclassified to :ignored, logged again
by the controller's generic "ignoring" line. Keep it a :kyc event with a nil
merchant instead; the controller no-ops on it, leaving the single detailed
:error log.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0179xMCWA3jhqdCpg6r28Y6g
@JoeriDijkstra
JoeriDijkstra merged commit 044a3c7 into develop Jul 23, 2026
1 check passed
@JoeriDijkstra
JoeriDijkstra deleted the refactor/normalize-provider-statuses branch July 23, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants