Documentation Index
Fetch the complete documentation index at: https://mintlify.com/CodeLudovic/last_frontend_educastream/llms.txt
Use this file to discover all available pages before exploring further.
Overview
EducaStream uses Stripe to process course payments securely. The integration handles:- Shopping cart checkout
- Payment session creation
- Redirect to Stripe-hosted checkout
- Payment confirmation and fulfillment
Stripe handles all sensitive payment data, so you never need to process credit card information directly.
Stripe Dependencies
EducaStream uses the following Stripe packages frompackage.json:14-15,27:
@stripe/stripe-js
Official Stripe.js library for client-side
@stripe/react-stripe-js
React components for Stripe Elements
stripe
Server-side Stripe SDK (backend)
Setup Stripe Account
Create Stripe Account
- Go to Stripe Dashboard
- Sign up for a new account
- Complete account verification
Get API Keys
- Navigate to Developers → API Keys
- Copy your Publishable key (starts with
pk_) - Copy your Secret key (starts with
sk_)
Configure Test Mode
For development, use Stripe’s test mode:
- Toggle Test mode in the top right of the dashboard
- Use test API keys (pk_test_… and sk_test_…)
- Use test card numbers for testing
Environment Variables
Add your Stripe keys to environment variables:- Frontend (.env)
- Backend
Payment Flow
The payment implementation fromsrc/Components/PayButton/Paybutton.jsx:1-35:
Paybutton.jsx
Payment Process
User Initiates Checkout
When user clicks the PayButton:
- Cart items retrieved from localStorage
- User ID retrieved from session
- Request sent to backend
Backend Creates Checkout Session
Backend endpoint
/payment/create-checkout-session:- Validates cart items and user
- Creates Stripe Checkout Session
- Returns session URL
Redirect to Stripe
User is redirected to Stripe-hosted checkout:
- Secure payment form
- Support for cards, Apple Pay, Google Pay
- PCI-compliant payment processing
Backend Implementation
Your backend needs to implement the checkout session creation:Success Page Implementation
The success route is defined inApp.jsx:120-122:
CheckOut.jsx
Webhooks for Payment Verification
For production, implement Stripe webhooks to verify payments:Testing Payments
Test Card Numbers
Use these test cards in Stripe test mode:Successful Payment
4242 4242 4242 4242Any future expiry, any CVC
Payment Declined
4000 0000 0000 0002Card declined
Insufficient Funds
4000 0000 0000 9995Insufficient funds
3D Secure
4000 0025 0000 3155Requires authentication
Testing Workflow
Cart Integration
The cart is managed byCartContext.jsx:1-117 with localStorage persistence:
Security Best Practices
Never expose Stripe Secret Key in frontend code
Always validate cart items on the backend
Verify payment amounts server-side
Use webhooks for payment confirmation
Implement idempotency keys for duplicate requests
Enable Stripe Radar for fraud detection
Use HTTPS in production
Common Issues
CORS errors when calling Stripe
CORS errors when calling Stripe
Ensure your backend has proper CORS configuration:
Invalid API Key errors
Invalid API Key errors
- Verify you’re using the correct key (test vs live)
- Check the key is properly set in environment variables
- Ensure no extra spaces in the key
Payment succeeds but order not fulfilled
Payment succeeds but order not fulfilled
- Implement webhook handlers
- Check webhook signing secret is correct
- Verify webhook endpoint is publicly accessible
Redirect not working after payment
Redirect not working after payment
- Check success_url and cancel_url are correct
- Verify URLs are properly encoded
- Ensure frontend routes exist
Production Checklist
Switch to Live Mode
- Use live API keys (pk_live_… and sk_live_…)
- Update environment variables
- Complete Stripe account activation
Monitoring Payments
In Stripe Dashboard:- Payments - View all transactions
- Customers - Manage customer data
- Products - Configure course products
- Reports - Analyze revenue and trends
Next Steps
Architecture
Understand the full application architecture
Firebase Config
Configure Firebase Storage
Additional Resources
Stripe Checkout Docs
Official Stripe Checkout documentation
Testing Stripe
Stripe testing guide with test card numbers