feat: ( payment ) implement cbe payment

This commit is contained in:
Abubeker
2026-07-31 07:50:10 +00:00
parent e4a2c61224
commit 37855b0a83
52 changed files with 2244 additions and 368 deletions

View File

@@ -0,0 +1,30 @@
import { CbeFailureClass } from "../entities/cbe-bill-operation.entity";
/**
* A CBE business/transport outcome we detected ourselves. `failureClass` drives the §6.5
* same-End_To_End_Txn_Id retry policy: BUSINESS outcomes are final (retrying cannot change
* the answer), TRANSIENT ones (our 5xx, domain app unreachable) may be retried by CBE.
*/
export class CbeBillError extends Error {
constructor(
message: string,
readonly failureClass: CbeFailureClass,
) {
super(message);
this.name = "CbeBillError";
}
}
/**
* Every failure maps to Response_Code "3" — the AAFDA spec (§2.10, §3.10) defines only
* 0 (success), 1 (auth), 3 (business); only the description is specific (plan §6.6).
*/
export function toCbeFailure(err: unknown): {
description: string;
failureClass: CbeFailureClass;
} {
if (err instanceof CbeBillError) {
return { description: err.message, failureClass: err.failureClass };
}
return { description: "Internal server error.", failureClass: "TRANSIENT" };
}