TrainMe: Payment System Rescue
How we fixed critical payment blocking issues and got a fitness training platform processing payments in 1 day
Project Overview
The Situation: While building TrainMe's app, the founder got the payment system working locally but ran into technical blockers when moving to production. After spending significant time troubleshooting these deployment issues, he wanted to shift focus back to growing the business rather than continuing to spend time on technical blockers.
The Problem
TrainMe is a fitness training platform connecting personal trainers with athletes. Parents book training sessions and pay through the app using Stripe. During development, the payment system worked fine locally but had issues when deployed to the production environment.
Three Critical Issues Blocking Deployment
CORS Configuration
When testing payment flows in the deployed environment, the browser blocked requests with CORS errors. The Cloud Function wasn't configured to accept requests from the production domain.
Firestore Permissions
The Cloud Function couldn't read booking data from Firestore due to missing permissions, preventing payment processing.
Authentication Redirect Loops
During testing, the authentication flow caused infinite redirect loops after login. The authentication flow tried to navigate immediately after login, conflicting with the app's routing logic.
Our Solution
We systematically debugged and fixed each issue while documenting security considerations and best practices for the founder's future reference.
1. Fixed CORS Configuration
Reconfigured the Cloud Function to properly handle cross-origin requests from the production domain while maintaining security through authentication requirements on all payment operations.
2. Configured Firestore Permissions
Granted proper permissions for the Cloud Function to access booking data from Firestore, following least-privilege security principles.
3. Fixed Authentication Flow
Resolved conflicting navigation logic that was causing infinite redirect loops, allowing users to log in and complete payments without interruption.
Technical Details
Technologies Involved
Results
Key Outcomes
- Payment system fully functional in production environment
- Payment flow works seamlessly from click to Stripe checkout
- Authentication is stable with no redirect loops
- Comprehensive documentation added for future maintenance
- Security considerations documented in code comments
- Production deployment completed with monitoring in place
- App is now live and processing payments at trainme-production.web.app
What Made This Successful
We worked with the existing codebase and fixed specific issues rather than rebuilding from scratch. All changes were thoroughly documented for future maintenance. The founder kept full ownership of the code and gained best practices for ongoing development.
Stuck on a Similar Problem?
Whether it's payments, authentication, deployment, or any other blocker - we can help you fix it and get to production.