fix(cbe): update response for settled transactions to indicate Already paid

This commit is contained in:
Marshal
2026-08-06 18:18:02 +00:00
parent 9366dd9752
commit 8e75ebf5dc
2 changed files with 12 additions and 26 deletions

View File

@@ -184,24 +184,12 @@ export class CbeBillService {
);
if (prior) {
if (prior.tradeStatus === "SUCCESS") {
// A replay must be the SAME attempt. A reused id with different money details is
// not a retry — echoing the stored success would fake a settlement that never ran.
const orig = prior.requestPayload as unknown as
| CbePaymentRequestDto
| undefined;
if (
orig &&
(orig.Bill_Id !== dto.Bill_Id ||
orig.Cbe_Txn_Ref !== dto.Cbe_Txn_Ref ||
Number(orig.Amount) !== Number(dto.Amount))
) {
return mapPaymentFailure(
dto,
"Duplicate End_To_End_Txn_Id",
);
}
// Replay the stored body verbatim. Never re-settle.
return prior.responsePayload as unknown as CbePaymentResponseDto;
// Per CBE integration request: a settled End_To_End_Txn_Id never replays the stored
// success — every repeat answers "Already paid". Money moved exactly once (the first
// call); this only changes what a duplicate hears back. NOTE this diverges from the
// original §6.5 replay design: if CBE retries because our SUCCESS response was lost
// in transit, it now sees FAILED for a debit we kept — reconcile such cases manually.
return mapPaymentFailure(dto, "Already paid");
}
if (prior.tradeStatus === "PENDING") {
return mapPaymentFailure(dto, "Payment in progress");