Interactive Firebase Setup & System Initialization Wizard
STEP 1
Create Firebase Project & Enable Services
1. Open the Firebase Console and click "Add Project".
2. Navigate to Build > Authentication > Click "Get Started" > Enable Email/Password.
3. Navigate to Build > Firestore Database > Click "Create Database" > Select Production Mode.
4. Go to Project Settings (Gear Icon) > General > Your Apps > Add Web App (`>`) > Register App.
STEP 2
Enter Firebase Web SDK Credentials
Copy the configuration object from your Firebase Web App settings and paste below. This will automatically update both the Main Website and the APK/js/firebase.js.
STEP 3
Deploy Firestore Security Rules
In Firebase Console > Firestore Database > Rules tab, paste the rules from firebase/firestore-rules.txt:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() { return request.auth != null; }
function isOwner(userId) { return isAuthenticated() && request.auth.uid == userId; }
function isAdmin() { return isAuthenticated() && (request.auth.token.role == 'admin' || request.auth.token.email == 'admin@payments.system'); }
function isDeviceActive(deviceId) { return exists(/databases/$(database)/documents/devices/$(deviceId)) && get(/databases/$(database)/documents/devices/$(deviceId)).data.status == 'active'; }
match /users/{userId} { allow read, write: if isOwner(userId) || isAdmin(); }
match /domains/{domainId} { allow read: if (isAuthenticated() && resource.data.userId == request.auth.uid) || isAdmin() || resource.data.status == 'verified'; allow write: if isAuthenticated() || isAdmin(); }
match /devices/{deviceId} { allow read, write: if (isAuthenticated() && resource.data.userId == request.auth.uid) || isAdmin(); }
match /payment_methods/{methodId} { allow read: if true; allow write: if (isAuthenticated() && resource.data.userId == request.auth.uid) || isAdmin(); }
match /packages/{packageId} { allow read: if true; allow write: if isAuthenticated() || isAdmin(); }
match /payments/{paymentId} {
allow read: if (isAuthenticated() && resource.data.userId == request.auth.uid) || isAdmin();
allow create: if isAuthenticated() && isDeviceActive(request.resource.data.deviceId);
allow update, delete: if (isAuthenticated() && resource.data.userId == request.auth.uid) || isAdmin();
}
match /payment_pages/{pageId} { allow read: if true; allow write: if isAuthenticated() || isAdmin(); }
match /api_keys/{keyId} { allow read, write: if isAuthenticated() || isAdmin(); }
match /verification_logs/{logId} { allow read: if isAuthenticated(); allow create: if true; }
}
}
STEP 4
Register Administrator Account
Once your configuration is saved, click the button below to create your initial merchant or superadmin account. Accounts with email containing admin or role set to admin will unlock the Superadmin Portal.