/pi-payment-backend
-
Authentication & Sessions:
- Replace express-session with Firebase Authentication
- Use Firebase custom tokens for Pi Network integration
- JWT-based session management through Firebase
-
Database:
- Replace MongoDB with Firestore
- Use Firebase Real-time Database for payment status tracking
- Leverage Firebase Cloud Functions for payment webhooks
-
Security:
- Firebase Authentication rules
- Firestore security rules
- Firebase App Check integration
users/ └── {uid}/ ├── username: string ├── piUid: string ├── roles: array ├── lastLogin: timestamp └── accessToken: string
payments/ └── {paymentId}/ ├── status: string ├── amount: number ├── userId: string ├── productId: string ├── txid: string ├── created: timestamp └── updated: timestamp
products/ └── {productId}/ ├── name: string ├── price: number └── description: string
- User authenticates with Pi Network
- Backend verifies Pi Network token
- Create/update Firebase user
- Issue Firebase custom token
- Client authenticates with Firebase
- Payment initiated → Create Firestore document
- Payment approved → Update status & create blockchain transaction
- Payment completed → Update status & verify blockchain
- Real-time status updates via Firebase listeners
Firestore security rules ensure:
- Users can only access their own data
- Payments can only be modified by admin or owner
- Products are read-only for users