refactor: normalize provider statuses and events at the payment boundary#1678
Merged
Conversation
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
…-provider-statuses
mellelieuwes
approved these changes
Jul 23, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Keeps OPP's wire vocabulary inside its own adapter so a second provider maps its strings once.
:pending | :completed | :failedatom (withdrawals were already done), keeping the provider's word asraw_statusfor the audit trail.:verified | :rejected | :new | :pending; unknown →:pendingso an unknown state never authorizes a payout. Merchant status left raw (no consumers).categoryand resolves the owningmerchant_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.