From 38d5092ee3283dc779d0b9bb573fa451be79206c Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Mon, 12 May 2025 13:13:27 +0530 Subject: [PATCH 1/2] Update webhook.ts --- functions/src/payments/phonepe/webhook.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/functions/src/payments/phonepe/webhook.ts b/functions/src/payments/phonepe/webhook.ts index d8696dc..e5d87ab 100644 --- a/functions/src/payments/phonepe/webhook.ts +++ b/functions/src/payments/phonepe/webhook.ts @@ -10,6 +10,13 @@ export const phonePeWebhook = onRequest({ region: '#{SERVICES_RGN}#' }, async (request: Request, response) => { try { + + logger.info('Received webhook request', { + headers: request.headers, + body: request.body, + method: request.method + }); + const authHeader = request.headers['authorization'] as string; const username = process.env.PHONEPE_WEBHOOK_USERNAME; const password = process.env.PHONEPE_WEBHOOK_PASSWORD; -- 2.43.0 From 6d64f1e4d73341b77bb0df73614a57902d146be2 Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Wed, 14 May 2025 18:34:58 +0530 Subject: [PATCH 2/2] Logging and client profile change --- functions/src/clientRegistration/clientRegistration.ts | 2 +- functions/src/payments/phonepe/webhook.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/src/clientRegistration/clientRegistration.ts b/functions/src/clientRegistration/clientRegistration.ts index 8ed51fb..fe2fafc 100644 --- a/functions/src/clientRegistration/clientRegistration.ts +++ b/functions/src/clientRegistration/clientRegistration.ts @@ -82,7 +82,7 @@ export const registerClient = onRequest({ phoneNumber: formattedPhoneNumber, }; - await admin.firestore().collection('client_profile').doc(clientUid).set(clientData); + await admin.firestore().collection('client_profiles').doc(clientUid).set(clientData); return res.status(201).json({ success: true, diff --git a/functions/src/payments/phonepe/webhook.ts b/functions/src/payments/phonepe/webhook.ts index e5d87ab..9f522f9 100644 --- a/functions/src/payments/phonepe/webhook.ts +++ b/functions/src/payments/phonepe/webhook.ts @@ -27,14 +27,12 @@ export const phonePeWebhook = onRequest({ return; } - // Calculate expected authorization value const credentialString = `${username}:${password}`; const expectedAuth = crypto .createHash('sha256') .update(credentialString) .digest('hex'); - // PhonePe may send the header with a prefix like "SHA256 " or just the hash const receivedAuth = authHeader.replace(/^SHA256\s+/i, ''); if (receivedAuth.toLowerCase() !== expectedAuth.toLowerCase()) { -- 2.43.0