From de9ea73dcdc6ff37d08a2c8d35a6184ba133bff6 Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Tue, 20 May 2025 15:45:20 +0530 Subject: [PATCH 1/9] Update firebase.json --- firebase.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase.json b/firebase.json index ecc3d3c..6920866 100644 --- a/firebase.json +++ b/firebase.json @@ -7,7 +7,7 @@ { "source": "functions", "codebase": "default", - "timeoutSeconds": 300, + "timeoutSeconds": 360, "ignore": [ "node_modules", ".git", -- 2.43.0 From 95492d304fc8faadf993758ac30816f85ac55121 Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Tue, 20 May 2025 16:08:33 +0530 Subject: [PATCH 2/9] Update webhook.ts --- functions/src/payments/phonepe/webhook.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/functions/src/payments/phonepe/webhook.ts b/functions/src/payments/phonepe/webhook.ts index 1694817..90a0a43 100644 --- a/functions/src/payments/phonepe/webhook.ts +++ b/functions/src/payments/phonepe/webhook.ts @@ -105,7 +105,15 @@ export const phonePeWebhook = onRequest({ logger.info(`Updated order status via webhook for orderId: ${payload.orderId} to ${payload.state}`); } - if (payload.state === 'COMPLETED') { + logger.info(`Checking payment state`, { + state: payload.state, + stateType: typeof payload.state, + stateLength: payload.state ? payload.state.length : 0, + stateUpperCase: payload.state ? payload.state.toUpperCase() : null, + stateComparison: payload.state === 'COMPLETED' + }); + + if (payload.state && payload.state.trim().toUpperCase() === 'COMPLETED') { try { logger.info(`Starting payment update process for merchantOrderId: ${payload.merchantOrderId}`); -- 2.43.0 From 4ce107c4aff6b1c0bd81fd813055ac370350b9e9 Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Tue, 20 May 2025 16:16:18 +0530 Subject: [PATCH 3/9] Update index.ts --- functions/src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/src/index.ts b/functions/src/index.ts index 19fa4e0..8bc48e9 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -6,3 +6,6 @@ export { processNotificationOnCreate } from './notifications'; export * from './payments'; export { getPlaceDetails, getPlacesAutocomplete } from './places'; export { registerClient } from './clientRegistration'; +import { setGlobalOptions } from "firebase-functions/v2"; + +setGlobalOptions({ timeoutSeconds: 300 }); \ No newline at end of file -- 2.43.0 From 66a65aed386efe885680bf7a0269196b6fee0743 Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Tue, 20 May 2025 16:16:21 +0530 Subject: [PATCH 4/9] Update firebase.json --- firebase.json | 1 - 1 file changed, 1 deletion(-) diff --git a/firebase.json b/firebase.json index 6920866..dfc4226 100644 --- a/firebase.json +++ b/firebase.json @@ -7,7 +7,6 @@ { "source": "functions", "codebase": "default", - "timeoutSeconds": 360, "ignore": [ "node_modules", ".git", -- 2.43.0 From 5d138e5937160633fd5702f18445f10367ec595e Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Tue, 20 May 2025 16:21:38 +0530 Subject: [PATCH 5/9] Update index.ts --- functions/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/index.ts b/functions/src/index.ts index 8bc48e9..57a12f6 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -8,4 +8,4 @@ export { getPlaceDetails, getPlacesAutocomplete } from './places'; export { registerClient } from './clientRegistration'; import { setGlobalOptions } from "firebase-functions/v2"; -setGlobalOptions({ timeoutSeconds: 300 }); \ No newline at end of file +setGlobalOptions({ timeoutSeconds: 400 }); \ No newline at end of file -- 2.43.0 From c252ba8620cc20e50d0b9a8db179d5de0a5f76d1 Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Tue, 20 May 2025 16:27:05 +0530 Subject: [PATCH 6/9] timeout changes --- firebase.json | 1 + functions/src/index.ts | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/firebase.json b/firebase.json index dfc4226..608886c 100644 --- a/firebase.json +++ b/firebase.json @@ -7,6 +7,7 @@ { "source": "functions", "codebase": "default", + "timeoutSeconds": 540, "ignore": [ "node_modules", ".git", diff --git a/functions/src/index.ts b/functions/src/index.ts index 1b8cb5b..19fa4e0 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -6,6 +6,3 @@ export { processNotificationOnCreate } from './notifications'; export * from './payments'; export { getPlaceDetails, getPlacesAutocomplete } from './places'; export { registerClient } from './clientRegistration'; -import { setGlobalOptions } from "firebase-functions/v2"; - -setGlobalOptions({ timeoutSeconds: 400 }); -- 2.43.0 From 3d64e11a056ad2343b51824b3052a6f17805194c Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Tue, 20 May 2025 17:05:30 +0530 Subject: [PATCH 7/9] changes for deploying --- firebase.json | 1 + functions/src/index.ts | 11 +++++++++++ package.json | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/firebase.json b/firebase.json index 608886c..21d0f5f 100644 --- a/firebase.json +++ b/firebase.json @@ -8,6 +8,7 @@ "source": "functions", "codebase": "default", "timeoutSeconds": 540, + "memory": "1GiB", "ignore": [ "node_modules", ".git", diff --git a/functions/src/index.ts b/functions/src/index.ts index 19fa4e0..660ddc7 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -1,3 +1,14 @@ +import { setGlobalOptions } from "firebase-functions/v2"; + +setGlobalOptions({ + region: "#{SERVICES_RGN}#", + memory: "1GiB", + timeoutSeconds: 540, + minInstances: 0, + maxInstances: 10, + concurrency: 80 +}); + export * from './shared/config'; export { sendEmailMessage, sendEmailWithAttachment, sendEmailSES } from './email'; export { sendSMSMessage } from './sms'; diff --git a/package.json b/package.json index 073e12e..da0eb6c 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,7 @@ { "dependencies": { "@types/busboy": "^1.5.4", - "@types/nodemailer": "^6.4.17", - "@types/pdfkit": "^0.13.9", "busboy": "^1.6.0", - "date-fns": "^4.1.0", - "nodemailer": "^7.0.3", - "pdfkit": "^0.17.1" + "date-fns": "^4.1.0" } } -- 2.43.0 From 623ebc84dffd69bbd8c5ef33db4c1d2c3cd7bc73 Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Wed, 21 May 2025 14:12:33 +0530 Subject: [PATCH 8/9] added dependency --- functions/package-lock.json | 10 ++++++++++ functions/package.json | 1 + 2 files changed, 11 insertions(+) diff --git a/functions/package-lock.json b/functions/package-lock.json index e5b23b4..149bfc8 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -13,6 +13,7 @@ "aws-sdk": "^2.1692.0", "axios": "^1.9.0", "cors": "^2.8.5", + "date-fns": "^4.1.0", "firebase-admin": "^12.6.0", "firebase-functions": "^6.0.1", "form-data": "^4.0.1", @@ -3805,6 +3806,15 @@ "utrie": "^1.0.2" } }, + "node_modules/date-fns": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz", + "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/kossnocorp" + } + }, "node_modules/dayjs": { "version": "1.11.13", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", diff --git a/functions/package.json b/functions/package.json index b9f1c89..0e77a8f 100644 --- a/functions/package.json +++ b/functions/package.json @@ -20,6 +20,7 @@ "aws-sdk": "^2.1692.0", "axios": "^1.9.0", "cors": "^2.8.5", + "date-fns": "^4.1.0", "firebase-admin": "^12.6.0", "firebase-functions": "^6.0.1", "form-data": "^4.0.1", -- 2.43.0 From dd060fb963855bd09f24ea58f68039db2ea678b3 Mon Sep 17 00:00:00 2001 From: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Date: Wed, 21 May 2025 15:37:57 +0530 Subject: [PATCH 9/9] changed import and collection name --- functions/src/payments/phonepe/invoice/invoiceService.ts | 4 ++-- functions/src/payments/phonepe/webhook.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/src/payments/phonepe/invoice/invoiceService.ts b/functions/src/payments/phonepe/invoice/invoiceService.ts index 95ffa7d..8c3d491 100644 --- a/functions/src/payments/phonepe/invoice/invoiceService.ts +++ b/functions/src/payments/phonepe/invoice/invoiceService.ts @@ -5,7 +5,7 @@ import * as path from 'path'; import { format } from 'date-fns'; import { sendEmailWithAttachmentUtil } from "../../../utils/emailService"; import { jsPDF } from "jspdf"; -import 'jspdf-autotable'; +import autoTable from 'jspdf-autotable'; const admin = getAdmin(); const logger = getLogger(); @@ -83,7 +83,7 @@ export class InvoiceService { doc.text(`Phone: ${data.phoneNumber}`, 20, 80); doc.text(`Email: ${data.email}`, 20, 90); - (doc as any).autoTable({ + autoTable(doc,{ startY: 110, head: [['No.', 'Description', 'HSN/SAC', 'Amount (INR)']], body: [ diff --git a/functions/src/payments/phonepe/webhook.ts b/functions/src/payments/phonepe/webhook.ts index 90a0a43..42aa29f 100644 --- a/functions/src/payments/phonepe/webhook.ts +++ b/functions/src/payments/phonepe/webhook.ts @@ -154,7 +154,7 @@ export const phonePeWebhook = onRequest({ logger.info(`Fetching user data for userId: ${userId}`); const userDoc = await admin.firestore() - .collection('users') + .collection('client_profiles') .doc(userId) .get(); if (userDoc.exists) { -- 2.43.0