phonepe #47

Merged
allentj merged 22 commits from phonepe into dev 2025-05-23 08:14:12 +00:00
2 changed files with 17 additions and 16 deletions

View File

@ -99,19 +99,19 @@ export class InvoiceService {
doc.setFontSize(12); doc.setFontSize(12);
const receiptToBoxX = 13; const receiptToBoxX = 13;
const receiptToBoxY = 55; const receiptToBoxY = 55;
const receiptToBoxWidth = 140; const receiptToBoxWidth = 100;
const receiptToBoxHeight = 40; const receiptToBoxHeight = 40;
doc.setDrawColor(0, 0, 0); doc.setDrawColor(0, 0, 0);
doc.setLineWidth(0.5); doc.setLineWidth(0.5);
doc.rect(receiptToBoxX, receiptToBoxY, receiptToBoxWidth, receiptToBoxHeight); doc.rect(receiptToBoxX, receiptToBoxY, receiptToBoxWidth, receiptToBoxHeight);
doc.setFont('helvetica', 'bold'); doc.setFont('helvetica', 'bold');
doc.text('Receipt To:', 20, 60); doc.text('Receipt To:', 18, 60);
doc.setFont('helvetica', 'normal'); doc.setFont('helvetica', 'normal');
doc.text(data.customerName, 20, 70); doc.text(data.customerName, 18, 70);
doc.text(`Phone: ${data.phoneNumber}`, 20, 80); doc.text(`Phone: ${data.phoneNumber}`, 18, 80);
doc.text(`Email: ${data.email}`, 20, 90); doc.text(`Email: ${data.email}`, 18, 90);
autoTable(doc, { autoTable(doc, {
startY: 110, startY: 110,
@ -155,10 +155,13 @@ export class InvoiceService {
doc.text('CGST (9%):', 150, finalY + 20, { align: 'right' }); doc.text('CGST (9%):', 150, finalY + 20, { align: 'right' });
doc.text(`${cgst.toFixed(2)} INR`, 190, finalY + 20, { align: 'right' }); doc.text(`${cgst.toFixed(2)} INR`, 190, finalY + 20, { align: 'right' });
doc.line(120, finalY + 25, 190, finalY + 25);
doc.setFont('helvetica', 'bold'); doc.setFont('helvetica', 'bold');
doc.text('Total Amount:', 150, finalY + 30, { align: 'right' }); doc.text('Total Amount:', 150, finalY + 30, { align: 'right' });
doc.text(`${data.amount.toFixed(2)} INR`, 190, finalY + 30, { align: 'right' }); doc.text(`${data.amount.toFixed(2)} INR`, 190, finalY + 30, { align: 'right' });
} else { } else {
doc.line(120, finalY - 5, 190, finalY - 5);
doc.setFont('helvetica', 'bold'); doc.setFont('helvetica', 'bold');
doc.text('Total Amount:', 150, finalY, { align: 'right' }); doc.text('Total Amount:', 150, finalY, { align: 'right' });
doc.text(`${data.amount.toFixed(2)} INR`, 190, finalY, { align: 'right' }); doc.text(`${data.amount.toFixed(2)} INR`, 190, finalY, { align: 'right' });
@ -166,11 +169,9 @@ export class InvoiceService {
const paymentY = hasGst ? finalY + 50 : finalY + 20; const paymentY = hasGst ? finalY + 50 : finalY + 20;
doc.line(13, 45, 190, 45);
const boxX = 13; const boxX = 13;
const boxY = paymentY - 5; const boxY = paymentY - 5;
const boxWidth = 140; const boxWidth = 100;
const boxHeight = 40; const boxHeight = 40;
doc.setDrawColor(0, 0, 0); doc.setDrawColor(0, 0, 0);
@ -178,12 +179,12 @@ export class InvoiceService {
doc.rect(boxX, boxY, boxWidth, boxHeight); doc.rect(boxX, boxY, boxWidth, boxHeight);
doc.setFont('helvetica', 'bold'); doc.setFont('helvetica', 'bold');
doc.text('Payment Information:', 20, paymentY); doc.text('Payment Information:', 18, paymentY);
doc.setFont('helvetica', 'normal'); doc.setFont('helvetica', 'normal');
doc.text(`Transaction ID: ${data.transactionId}`, 18, paymentY + 10); doc.text(`Transaction ID: ${data.transactionId}`, 18, paymentY + 10);
doc.text(`Payment Method: ${data.paymentMethod}`, 18, paymentY + 20); doc.text(`Payment Method: ${data.paymentMethod}`, 18, paymentY + 20);
doc.text(`Payment Date: ${formattedDate}`, 20, paymentY + 30); doc.text(`Payment Date: ${formattedDate}`, 18, paymentY + 30);
doc.setFontSize(12); doc.setFontSize(12);
doc.setFont('helvetica', 'italic'); doc.setFont('helvetica', 'italic');

View File

@ -150,15 +150,15 @@ export const phonePeWebhook = onRequest({
logger.info(`Membership data retrieved successfully for membershipId: ${membershipId}`); logger.info(`Membership data retrieved successfully for membershipId: ${membershipId}`);
const membershipData = membershipDoc.data(); const membershipData = membershipDoc.data();
const userId = membershipData?.userId; const uid = membershipData?.userId;
logger.info(`Fetching user data for userId: ${userId}`); logger.info(`Fetching user data for uid(Client): ${uid}`);
const userDoc = await admin.firestore() const userDoc = await admin.firestore()
.collection('users') .collection('client_profiles')
.doc(userId) .doc(uid)
.get(); .get();
if (userDoc.exists) { if (userDoc.exists) {
logger.info(`User data retrieved successfully for userId(Client): ${userId}`); logger.info(`User data retrieved successfully for uid(Client): ${uid}`);
logger.info(`Starting invoice generation process for payment: ${payload.merchantOrderId}`); logger.info(`Starting invoice generation process for payment: ${payload.merchantOrderId}`);
@ -197,7 +197,7 @@ export const phonePeWebhook = onRequest({
const gymData = gymDoc.data(); const gymData = gymDoc.data();
gymName = gymData?.name || 'Fitlien'; gymName = gymData?.name || 'Fitlien';
gymAddress = gymData?.address || ''; gymAddress = gymData?.address || '';
subscriptionName = gymData?.subscriptions?.name || ''; subscriptionName = membershipData?.subscription?.normalizedName || '';
if (gymData?.userId) { if (gymData?.userId) {
const gymOwnerDoc = await admin.firestore() const gymOwnerDoc = await admin.firestore()