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

@@ -129,7 +129,6 @@ describe("CBE Unified Bill (payment service as biller)", () => {
});
let settleBody: Record<string, string>;
let settledTxnRef: string;
it("settles the freight invoice when CBE reports the debit", async () => {
const invoice = await currentInvoice(invoiceId);
@@ -147,7 +146,6 @@ describe("CBE Unified Bill (payment service as biller)", () => {
const res = await cbe(token, "/cbe/payment", settleBody);
expect(res.status).toBe(200);
expect(res.body.Response_Code).toBe("0");
settledTxnRef = res.body.Destination_Txn_Ref;
const paid = await poll<{ status: string }>(
"invoice PAID via CBE bill",
@@ -159,22 +157,22 @@ describe("CBE Unified Bill (payment service as biller)", () => {
expect(paid.status).toBe("PAID");
});
it("replays the stored success when CBE retries the same attempt verbatim", async () => {
it("answers 'Already paid' when the settled attempt is sent again verbatim", async () => {
const res = await cbe(token, "/cbe/payment", settleBody);
expect(res.status).toBe(200);
expect(res.body.Response_Code).toBe("0");
// The stored body, not a re-settlement — same order id as the first answer.
expect(res.body.Destination_Txn_Ref).toBe(settledTxnRef);
expect(res.body.Status).toBe("FAILED");
expect(res.body.Response_Code).toBe("2");
expect(res.body.Response_Description).toBe("Already paid");
});
it("rejects a settled End_To_End_Txn_Id reused with a different amount", async () => {
it("answers 'Already paid' when the settled End_To_End_Txn_Id is reused with a different amount", async () => {
const res = await cbe(token, "/cbe/payment", {
...settleBody,
Amount: "1.00",
});
expect(res.status).toBe(200);
expect(res.body.Response_Code).toBe("2");
expect(res.body.Response_Description).toBe("Duplicate End_To_End_Txn_Id");
expect(res.body.Response_Description).toBe("Already paid");
});
it("rejects a second debit on the same bill", async () => {