Fixed the static developers portal by implementing dynamic API key fetching from authenticated user context and updating all documentation links to point to actual routes instead of "#".
- Added
api_keyfield to theMerchantmodel - Field is optional and unique to prevent duplicates
- Type:
String?with@uniqueconstraint
- Created
generateApiKey()helper function to generate secure API keys - Updated
signupMerchantService()to automatically generate and store API key on merchant registration - Updated
getMerchantUserService()to includeapi_keyin the response (with explicit select) - Updated
regenerateApiKeyService()to store the new API key in the database
- Created new constants file for centralized documentation URL management
- Defined all documentation routes:
- API Reference:
/docs/api-reference - Getting Started:
/docs/getting-started - Authentication:
/docs/authentication - Rate Limits:
/docs/rate-limits - Full Docs:
/docs - Community:
/community - Support:
/support - Status:
/status - FAQs:
/faqs - Contact:
/contact - Pricing:
/pricing
- API Reference:
- Removed hardcoded API key:
"sk_live_51234567890abcdefghijklmnop" - Added
useEffecthook to fetch real API key from authenticated user - Added loading state management
- Updated all documentation links to use
DOCS_URLSconstants - Links updated:
- API Reference
- Getting Started
- Authentication
- Rate Limits
- Full Documentation
- Community Support
- Status & Support
- Removed hardcoded API key placeholder
- Updated
loadMerchantData()to fetch and set the real API key - Changed initial state from hardcoded value to "Loading..."
- API key now displays actual value from database
- Imported
DOCS_URLSconstants - Updated all footer links:
- Privacy Policy:
/privacy - Terms of Use:
/terms - Sign Up:
/signup - Log In:
/login - Pricing:
/pricing - Docs:
/docs - FAQs / Support:
/faqs - Contact us:
/contact
- Privacy Policy:
- Imported
DOCS_URLSconstants - Updated navigation links:
- Pricing:
/pricing - Documentation:
/docs
- Pricing:
To apply the schema changes, run:
cd fluxapay_backend
npx prisma migrate dev --name add_api_key_to_merchant
# or
npm run prisma:pushThis will:
- Add the
api_keycolumn to theMerchanttable - Set it as nullable and unique
- Regenerate Prisma Client with the new schema
After running the migration, generate API keys for existing merchants:
cd fluxapay_backend
npx ts-node src/scripts/generate-api-keys.tsThis script will:
- Find all merchants without API keys
- Generate unique API keys for each
- Update the database with the new keys
- Provide a summary of successful and failed operations
- Verify API key is generated on new merchant signup
- Verify API key is displayed in Developers Portal
- Verify API key is displayed in Settings page
- Verify API key regeneration works and updates in database
- Verify all documentation links navigate to correct routes
- Verify footer links work correctly
- Verify navbar links work correctly
- Test with existing merchants (they will have null api_key initially)
- Existing merchants in the database will have
nullforapi_keyuntil they regenerate their key - Consider adding a migration script to generate API keys for existing merchants
- The API key format is:
fluxapay_live_+ 32 random alphanumeric characters - All documentation routes are now defined but may need actual page implementations