Skip to content

Latest commit

 

History

History
58 lines (47 loc) · 1.88 KB

File metadata and controls

58 lines (47 loc) · 1.88 KB

UTrack Payment Function Fix - Testing Guide

🎯 Issue Resolved

Fixed the Firebase Functions error: TypeError: Cannot read properties of undefined (reading 'serverTimestamp')

🛠️ What Was Fixed

  1. Firebase Admin SDK FieldValue Access: Extracted admin.firestore.FieldValue to a constant to prevent runtime access issues
  2. Environment Configuration: Added proper .env files with Firebase and Razorpay credentials
  3. All FieldValue References: Updated 7+ instances throughout functions/index.js

🧪 Testing the Fix

Option 1: Quick Test with Mock Server

cd functions
node test-server.cjs

Then open payment-test.html in your browser and set endpoint to http://localhost:3001/createPaymentOrder

Option 2: Test with Firebase Emulators

  1. Install Firebase CLI: npm install -g firebase-tools
  2. Start emulators: firebase emulators:start
  3. Open payment-test.html and use endpoint: http://localhost:5001/utrack-d3efb/us-central1/createPaymentOrder

Option 3: Run Comprehensive Test Suite

cd functions
node test-payment-functions.cjs

🔧 Configuration

Functions Environment (functions/.env)

RAZORPAY_KEY_ID=your_actual_razorpay_key_id
RAZORPAY_KEY_SECRET=your_actual_razorpay_secret
SENDGRID_API_KEY=your_sendgrid_key
ADMIN_EMAIL=your_admin_email

Frontend Environment (.env)

VITE_RAZORPAY_KEY_ID=your_actual_razorpay_key_id

🚀 Next Steps

  1. Replace test Razorpay keys with actual production keys
  2. Deploy functions: firebase deploy --only functions
  3. Test with the React frontend integration
  4. Update the Razorpay embed button with your actual payment link

✅ Verification

  • ✅ Firebase Admin SDK working
  • ✅ FieldValue.serverTimestamp() working
  • ✅ Environment variables loading
  • ✅ CORS configured properly
  • ✅ Payment order creation logic validated
  • ✅ Razorpay integration ready