feat(payments): orchestrate screening and bank submission - #225
Merged
Conversation
Add PaymentOrchestrator that drives an initiated payment through in-process decision-engine screening and then bank submission. The orchestrator is not transactional: it screens the payment to SCREENING in one short transaction, evaluates the configured rule with the embedded engine, and on approval calls the bank provider outside any transaction, then settles the result (SUBMITTED on accept, FAILED on reject) in another short transaction; a declined screening fails the payment without calling the bank. A technical bank failure propagates and leaves the payment in SCREENING for the retry job to re-attempt. The screening rule is generic configuration parsed fail-closed at startup (default approve-all), so an invalid rule fails startup rather than silently approving. The bank's provider reference is persisted for later webhook correlation. Closes #213
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.
What
Sixth slice of E-02.
PaymentOrchestratordrives an initiated payment through in-process Decision-Engine screening and thenBankProvidersubmission, wiring #211 (service) + #212 (bank port) + the embedded #175 decision-engine library.PaymentOrchestrator, NOT@Transactional):screen(INITIATED -> SCREENING, one short tx) -> evaluate the configured rule in-process -> on Approve callBankProvider.submitoutside any transaction ->Accepted-> SUBMITTED (markSubmitted, emitsPaymentScreened, storesprovider_reference),Rejected-> FAILED (PaymentFailed); Decline -> FAILED without calling the bank.submitruns between two separate-bean@TransactionalPaymentServicetransitions. ABankProviderException(transient) propagates and leaves the payment inSCREENINGfor the retry job (F-02.8 Scheduled payment retry job #215), never a wrong terminal outcome.ScreeningEvaluator): embedscom.fincore:decision-engine(RuleParser+RuleEvaluator); the rule is@ConfigurationPropertiesparsed fail-closed at startup (default approve-all, generic, no business threshold);EvaluationInputfrom amount/currency/reference.@Transactionalscreen/markSubmitted/markFailedonPaymentService(domaintransitionTo+ persist + outbox emit). New nullablepayments.provider_referencecolumn (producer for F-02.7 Inbound webhook handler (HMAC verify + dedup) #214 webhook correlation).@EnableConfigurationPropertieson aPaymentsConfig.Event placement follows the 5-event taxonomy (no
PaymentSubmittedexists):PaymentScreenedon the approved+submitted path,PaymentFailedon failure, nothing on the bare SCREENING transition.Gates
Local (
-x integrationTest)::services:payments:{test,detekt,detektTest,spotlessCheck,assemble,compileIntegrationTestKotlin}green. critic GO (C-1 bank-exception-stays-SCREENING + H-1 reentrancy applied), security-auditor PASS (§8.10 + §5.3 verified), evaluator 0.875 (independently confirmed the event placement is correct for the taxonomy). Full INITIATED->SUBMITTED lifecycle IT is #217.Closes #213