From 916293e8b1192851cda1f594be0bb4ff72c22d8d Mon Sep 17 00:00:00 2001 From: Allen T J Date: Fri, 23 May 2025 07:15:32 +0000 Subject: [PATCH] phonepe (#44) Co-authored-by: AllenTJ7 <163137620+AllenTJ7@users.noreply.github.com> Reviewed-on: https://git.cosqnet.com/cosqnet/fitlien-services/pulls/44 --- .../phonepe/invoice/invoiceService.ts | 26 +++++++++---------- functions/src/payments/phonepe/webhook.ts | 4 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/functions/src/payments/phonepe/invoice/invoiceService.ts b/functions/src/payments/phonepe/invoice/invoiceService.ts index bcc78a4..741b900 100644 --- a/functions/src/payments/phonepe/invoice/invoiceService.ts +++ b/functions/src/payments/phonepe/invoice/invoiceService.ts @@ -54,7 +54,7 @@ export class InvoiceService { doc.setFontSize(20); doc.setFont('helvetica', 'bold'); - doc.text(data.businessName, 20, 20); + doc.text(data.businessName, 13, 20); doc.setFontSize(12); doc.setFont('helvetica', 'normal'); @@ -66,10 +66,10 @@ export class InvoiceService { if (addressLines.length <= 2) { for (let i = 0; i < addressLines.length; i++) { - doc.text(addressLines[i], 20, 30 + (i * lineHeight)); + doc.text(addressLines[i], 13, 30 + (i * lineHeight)); } } else { - doc.text(addressLines[0], 20, 30); + doc.text(addressLines[0], 13, 30); let secondLine = addressLines[1]; if (secondLine.length > 3) { @@ -77,7 +77,7 @@ export class InvoiceService { } else { secondLine += '...'; } - doc.text(secondLine, 20, 35); + doc.text(secondLine, 13, 35); } const gstYPosition = 40; @@ -97,10 +97,10 @@ export class InvoiceService { doc.line(20, 45, 190, 45); doc.setFontSize(12); - const receiptToBoxX = 15; + const receiptToBoxX = 13; const receiptToBoxY = 55; - const receiptToBoxWidth = 175; - const receiptToBoxHeight = 45; + const receiptToBoxWidth = 140; + const receiptToBoxHeight = 40; doc.setDrawColor(0, 0, 0); doc.setLineWidth(0.5); @@ -166,12 +166,12 @@ export class InvoiceService { const paymentY = hasGst ? finalY + 50 : finalY + 20; - doc.line(20, 45, 190, 45); + doc.line(13, 45, 190, 45); - const boxX = 15; + const boxX = 13; const boxY = paymentY - 5; - const boxWidth = 175; - const boxHeight = 45; + const boxWidth = 140; + const boxHeight = 40; doc.setDrawColor(0, 0, 0); doc.setLineWidth(0.5); @@ -181,8 +181,8 @@ export class InvoiceService { doc.text('Payment Information:', 20, paymentY); doc.setFont('helvetica', 'normal'); - doc.text(`Transaction ID: ${data.transactionId}`, 20, paymentY + 10); - doc.text(`Payment Method: ${data.paymentMethod}`, 20, paymentY + 20); + doc.text(`Transaction ID: ${data.transactionId}`, 18, paymentY + 10); + doc.text(`Payment Method: ${data.paymentMethod}`, 18, paymentY + 20); doc.text(`Payment Date: ${formattedDate}`, 20, paymentY + 30); doc.setFontSize(12); diff --git a/functions/src/payments/phonepe/webhook.ts b/functions/src/payments/phonepe/webhook.ts index 42aa29f..9c1f6cc 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('client_profiles') + .collection('users') .doc(userId) .get(); if (userDoc.exists) { @@ -245,7 +245,7 @@ export const phonePeWebhook = onRequest({ customerName: userData?.displayName || `${membershipData?.fields?.['first-name'] || ''} ${membershipData?.fields?.['last-name'] || ''}`.trim(), phoneNumber: membershipData?.fields?.['phone-number'] || orderData.metaInfo?.phoneNumber || '', email: membershipData?.fields?.['email'] || '', - planName: orderData.metaInfo?.planName || subscriptionName || paymentType, + planName: orderData.metaInfo?.planName || subscriptionName, amount: orderData.amount, transactionId: payload.orderId, paymentDate: new Date(),