mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 23:35:42 +00:00
feat: ( payment ) implement cbe payment
This commit is contained in:
@@ -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" };
|
||||
}
|
||||
Reference in New Issue
Block a user