From 9cf71e7e7a56ed515392eccfc3342a162ad9e597 Mon Sep 17 00:00:00 2001 From: Abubeker Yasin Date: Wed, 15 Jul 2026 21:23:10 +0300 Subject: [PATCH] feat: ( payment ) add waafi webhook log --- .../src/modules/webhooks/handlers/waafi-webhook.service.ts | 6 ++++++ .../src/modules/webhooks/webhooks.controller.ts | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/edr-payment-api/src/modules/webhooks/handlers/waafi-webhook.service.ts b/apps/edr-payment-api/src/modules/webhooks/handlers/waafi-webhook.service.ts index 232957f79..3cd0b4c1c 100644 --- a/apps/edr-payment-api/src/modules/webhooks/handlers/waafi-webhook.service.ts +++ b/apps/edr-payment-api/src/modules/webhooks/handlers/waafi-webhook.service.ts @@ -45,6 +45,12 @@ export class WaafiWebhookService { const mapped = this.provider.mapWebhookStatus(payment.status); + this.logger.log( + `Waafi authorization: ref=${payment.reference_id} txn=${payment.transaction_id} ` + + `rawStatus=${payment.status} mapped=${mapped} ` + + `signatureValid=${signatureValid} (fresh=${this.isFresh(timestamp)}) eventId=${eventId ?? "n/a"}`, + ); + await this.processor.process({ provider: this.provider.method, // X-Webhook-Event-Id is unique per event; fall back to a derived id if absent. diff --git a/apps/edr-payment-api/src/modules/webhooks/webhooks.controller.ts b/apps/edr-payment-api/src/modules/webhooks/webhooks.controller.ts index f1e4fa6b0..6c923e8b4 100644 --- a/apps/edr-payment-api/src/modules/webhooks/webhooks.controller.ts +++ b/apps/edr-payment-api/src/modules/webhooks/webhooks.controller.ts @@ -127,10 +127,14 @@ export class WebhooksController { @Req() req: { rawBody?: Buffer }, ) { - this.logger.log("\n\n\n\nWaafi payment notification callback (Djibouti)\n\n\n\n"); this.logger.log( `Waafi webhook hit: event=${payload?.event ?? "unknown"} eventId=${headers["x-webhook-event-id"] ?? "n/a"}`, ); + this.logger.log(`Waafi webhook headers: ${JSON.stringify(headers)}`); + this.logger.log(`Waafi webhook payload: ${JSON.stringify(payload)}`); + this.logger.log( + `Waafi webhook raw body: ${req.rawBody?.toString("utf8") ?? "(none)"}`, + ); try { // HMAC verification must sign over the exact raw bytes Waafi sent, not re-serialized JSON. const rawBody = req.rawBody?.toString("utf8") ?? "";