feat: ( payments ) add merchant-order and booking/PNR payment status lookups

This commit is contained in:
Abubeker Yasin
2026-07-18 09:55:09 +03:00
parent 718c384a06
commit 85de05cb40
5 changed files with 231 additions and 3 deletions

View File

@@ -12,8 +12,15 @@ import {
PaymentIntentSnapshot,
PaymentReferenceType,
PaymentService,
ProviderStatus,
} from "@edr/types";
/** Side-by-side DB row + live provider status from the payment service diagnostic endpoints. */
export interface PaymentDiagnostic {
db: Record<string, unknown> | null;
provider: ProviderStatus | null;
}
/**
* Thin HTTP client for the payment microservice (apps/edr-payment-api) — the passenger app's
* side of the Phase 6 cutover (docs/payment-service §10). Domain validation stays here;
@@ -55,6 +62,28 @@ export class PaymentClientService {
}
}
/**
* GET /payments/diagnostic?… — DB intent row + live provider status for a domain reference,
* side by side. Returns { db: null, provider: null } when the payment service has no intent.
*/
async getDiagnosticByReference(
referenceType: PaymentReferenceType,
referenceId: string,
): Promise<PaymentDiagnostic> {
const query = new URLSearchParams({
service: PaymentService.PASSENGER,
referenceType,
referenceId,
});
try {
return await this.call("GET", `/payments/diagnostic?${query.toString()}`);
} catch (err) {
if (err instanceof AxiosError && err.response?.status === 404)
return { db: null, provider: null };
throw err;
}
}
/**
* POST /payments/intents/:id/confirm — submit an OTP for a COLLECT_OTP provider (CAC Bank).
* A wrong/expired OTP comes back as 400 from the payment service; surface that as a