mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 19:30:57 +00:00
fix(cbe): update response for settled transactions to indicate Already paid
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user