Skip to content

Commit ce9a3de

Browse files
Philipp91ampaze
andcommitted
Improved heuristic for single-transaction VOP results
Proposed by ampaze@ in #513 (comment). Co-authored-by: ampaze <[email protected]> Co-authored-by: Philipp Keck <[email protected]>
1 parent 44ed489 commit ce9a3de

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/Fhp/Segment/VPP/VopHelper.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,31 @@ public static function checkVopConfirmationRequired(
109109
if ($hivpp->ergebnisVopPruefungEinzeltransaktion === null) {
110110
throw new UnsupportedException('Missing paymentStatusReport and ergebnisVopPruefungEinzeltransaktion');
111111
}
112-
$verificationResultCode = $hivpp->ergebnisVopPruefungEinzeltransaktion->vopPruefergebnis;
112+
$verificationResult = VopVerificationResult::parse(
113+
$hivpp->ergebnisVopPruefungEinzeltransaktion->vopPruefergebnis
114+
);
113115
$verificationNotApplicableReason = $hivpp->ergebnisVopPruefungEinzeltransaktion->grundRVNA;
114116
} else {
115117
$report = simplexml_load_string($hivpp->paymentStatusReport->getData());
116-
$verificationResultCode = $report->CstmrPmtStsRpt->OrgnlGrpInfAndSts->GrpSts ?: null;
118+
$verificationResult = VopVerificationResult::parse(
119+
$report->CstmrPmtStsRpt->OrgnlGrpInfAndSts->GrpSts ?: null
120+
);
121+
122+
// For a single transaction, we can do better than "CompletedPartialMatch",
123+
// which can indicate either CompletedCloseMatch or CompletedNoMatch
124+
if (intval($report->CstmrPmtStsRpt->OrgnlGrpInfAndSts->OrgnlNbOfTxs ?: 0) === 1
125+
&& $verificationResult === VopVerificationResult::CompletedPartialMatch
126+
&& $verificationResultCode = $report->CstmrPmtStsRpt->OrgnlPmtInfAndSts->TxInfAndSts?->TxSts
127+
) {
128+
$verificationResult = VopVerificationResult::parse($verificationResultCode);
129+
}
117130
}
118131

119132
return new VopConfirmationRequestImpl(
120133
$hivpp->vopId,
121134
$hivpp->vopIdGueltigBis?->asDateTime(),
122135
$hivpp->aufklaerungstextAutorisierungTrotzAbweichung,
123-
VopVerificationResult::parse($verificationResultCode),
136+
$verificationResult,
124137
$verificationNotApplicableReason,
125138
);
126139
}

lib/Tests/Fhp/Integration/Atruvia/SendTransferVoPTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function testVopWithResultPartialMatch(): void
125125
$this->assertFalse($action->needsTan());
126126
$this->assertFalse($action->isDone());
127127
$this->assertEquals(
128-
VopVerificationResult::CompletedPartialMatch,
128+
VopVerificationResult::CompletedNoMatch,
129129
$action->getVopConfirmationRequest()->getVerificationResult()
130130
);
131131

0 commit comments

Comments
 (0)