Fixed the Firebase Functions error: TypeError: Cannot read properties of undefined (reading 'serverTimestamp')
- Firebase Admin SDK FieldValue Access: Extracted
admin.firestore.FieldValueto a constant to prevent runtime access issues - Environment Configuration: Added proper
.envfiles with Firebase and Razorpay credentials - All FieldValue References: Updated 7+ instances throughout
functions/index.js
cd functions
node test-server.cjsThen open payment-test.html in your browser and set endpoint to http://localhost:3001/createPaymentOrder
- Install Firebase CLI:
npm install -g firebase-tools - Start emulators:
firebase emulators:start - Open
payment-test.htmland use endpoint:http://localhost:5001/utrack-d3efb/us-central1/createPaymentOrder
cd functions
node test-payment-functions.cjsRAZORPAY_KEY_ID=your_actual_razorpay_key_id
RAZORPAY_KEY_SECRET=your_actual_razorpay_secret
SENDGRID_API_KEY=your_sendgrid_key
ADMIN_EMAIL=your_admin_emailVITE_RAZORPAY_KEY_ID=your_actual_razorpay_key_id- Replace test Razorpay keys with actual production keys
- Deploy functions:
firebase deploy --only functions - Test with the React frontend integration
- Update the Razorpay embed button with your actual payment link
- ✅ Firebase Admin SDK working
- ✅ FieldValue.serverTimestamp() working
- ✅ Environment variables loading
- ✅ CORS configured properly
- ✅ Payment order creation logic validated
- ✅ Razorpay integration ready