Update waafi.provider.ts

This commit is contained in:
Abubeker Yasin
2026-06-17 15:59:46 +03:00
parent 58af6ee2db
commit 6ecc19c69c

View File

@@ -86,6 +86,21 @@ export class WaafiProvider implements PaymentProvider {
requestBody,
);
// Waafi returns transaction info (params.status) ONLY when responseCode is 2001. For an
// unpaid or not-yet-existing transaction it returns an error envelope (e.g. 5001 / E10206
// "Failed to get transaction info") with no status. Treat that as still-pending (PROCESSING),
// never terminal — so the intent keeps waiting for the webhook / its expiry rather than being
// wrongly resolved off a "no info" response.
if (response.responseCode !== WAAFI_SUCCESS_CODE) {
this.logger.debug(
`Waafi HPP_GETTRANINFO ${merchantOrderId}: ${response.responseCode}/${response.errorCode} ${response.responseMsg} — treating as pending`,
);
return {
status: ProviderPaymentStatus.PROCESSING,
rawResponse: response as unknown as Record<string, unknown>,
};
}
const rawState = response.params?.status ?? response.params?.tranStatusDesc;
const transactionId = response.params?.transactionId;
const mapped = this.mapStatus(rawState);