resolve merge conflict

This commit is contained in:
Marshal
2026-08-01 12:16:12 +00:00
171 changed files with 8253 additions and 1318 deletions

View File

@@ -27,7 +27,9 @@ import type {
CacPaymentInitiateResponse,
} from "./cac-bank.types";
/** Bank-enforced amount bounds (PaymentInitiateRequest spec: between 10 and 100,000 DJF). */
/** Bank-enforced amount bounds (PaymentInitiateRequest spec: between 10 and 100,000 DJF). Not
* documented for other settlement currencies (e.g. USD) — skip the local pre-check there and
* let the bank's own validation reject an out-of-range amount. */
const CAC_MIN_AMOUNT = 10;
const CAC_MAX_AMOUNT = 100_000;
@@ -73,10 +75,14 @@ export class CacBankProvider implements PaymentProvider, OnModuleInit {
}
const customerMobile = normalizeCacMobile(input.payerAccount);
const amount = this.toMajorAmount(input.amountMinor, input.currency);
if (amount < CAC_MIN_AMOUNT || amount > CAC_MAX_AMOUNT) {
const amount = this.toMajorAmount(input.amountMinor);
const currency = (input.currency || this.defaultCurrency).toUpperCase();
if (
currency === "DJF" &&
(amount < CAC_MIN_AMOUNT || amount > CAC_MAX_AMOUNT)
) {
throw new Error(
`CAC Bank amount ${amount} ${input.currency} is outside the accepted range ` +
`CAC Bank amount ${amount} DJF is outside the accepted range ` +
`(${CAC_MIN_AMOUNT}${CAC_MAX_AMOUNT} DJF)`,
);
}
@@ -85,7 +91,7 @@ export class CacBankProvider implements PaymentProvider, OnModuleInit {
app_key: this.appKey,
api_key: this.apiKey,
customer_mobile: customerMobile,
currency: input.currency || this.defaultCurrency,
currency,
desc: `${input.orderRef}`.slice(0, 500),
vender_ref: input.merchantOrderId,
amount,
@@ -303,12 +309,14 @@ export class CacBankProvider implements PaymentProvider, OnModuleInit {
return this.auth;
}
/** DJF has no fractional units — amountMinor is the major amount. */
private toMajorAmount(amountMinor: number, currency: string): number {
if (currency.toUpperCase() === "DJF") {
return amountMinor;
}
return amountMinor / 100;
/**
* Both callers (freight's invoice.balanceAmount, passenger's CurrencyService) already
* hand off a major-currency amount — e.g. 700 for $700, not 70000 cents — with the target
* currency's own decimal precision already applied (0dp for DJF, 2dp for USD/ETB). CAC Bank
* bills in that same major unit, so it is forwarded unchanged.
*/
private toMajorAmount(amountMinor: number): number {
return amountMinor;
}
private sanitizeKeys(

View File

@@ -24,6 +24,12 @@ export enum ProviderMethod {
CARD = "CARD",
DMONEY = "DMONEY",
CAC_BANK = "CAC_BANK",
/**
* CBE Unified Bill Payment — inbound biller integration. We never call CBE: the customer
* takes the bill reference to any CBE channel and CBE calls payment-api's /cbe/* endpoints.
* No entry in PAYMENT_PROVIDER_MAP by design (docs/cbe/CBE_IMPLEMENTATION_PLAN.md D5).
*/
CBE_BILL = "CBE_BILL",
}
export type PaymentPlatform = "web" | "mobile";
@@ -40,6 +46,13 @@ export type ClientAction =
type: "COLLECT_OTP";
providerOrderId: string;
message?: string;
}
| {
/** CBE_BILL: show the bill reference the customer pays at any CBE channel. */
type: "SHOW_BILL_REFERENCE";
billReference: string;
instructions?: string;
expiresAt?: string;
};
export interface ProviderInitiationInput {
@@ -130,6 +143,16 @@ export interface InitiatePaymentRequest {
failureUrl?: string;
/** Optional caller key to dedupe retried initiations beyond the per-reference upsert. */
idempotencyKey?: string;
/**
* Payer full name snapshot (CBE_BILL: fallback for the mandatory Full_Name in /cbe/query
* responses when the domain app's bill-query is unreachable).
*/
payerName?: string;
/**
* Intent expiry, ISO-8601. CBE_BILL: the booking's own payment deadline — NOT a provider
* session TTL (the reconciliation sweep cancels the intent when this passes).
*/
expiresAt?: string;
}
/** Body of `POST /payments/intents/:id/confirm` (OTP-based providers such as CAC Bank). */
@@ -154,6 +177,8 @@ export type PaymentIntentSnapshot ={
failureCode?: string;
failureMessage?: string;
expiresAt?: string;
/** CBE_BILL only: the short numeric Bill_Id the customer pays at a CBE channel. */
billReference?: string;
/**
* Raw provider payload for inspection/debugging — the audit copy of the provider
* initiation response merged with the latest status-query response (secrets redacted