Documentation Index
Fetch the complete documentation index at: https://mintlify.com/flan02/speak-english-now-app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Speak English Now uses Mercado Pago as the payment gateway for processing class bookings. The system handles payment preferences, webhooks for real-time updates, and automatic class creation upon successful payment.Payment Model
ThePaymentMercadoPago model tracks all payment transactions:
The
preferenceId is unique and serves as the primary link between Mercado Pago’s payment system and your database.Payment Flow
The complete payment process follows these steps:Step 1: Create Payment Preference
When a user selects a class, create a Mercado Pago preference:Database Function
Step 2: Webhook Handling
Mercado Pago sends webhooks when payment status changes:Webhook Security: Unlike Stripe, Mercado Pago does not sign webhook payloads. Always verify payment status by fetching the merchant order from Mercado Pago’s API using the resource URL.
Update Payment Status
Step 3: Callback Pages
After payment, users are redirected to status-specific callback pages:URL Parameters
Mercado Pago redirects with these query parameters:Pricing Configuration
Prices are configured in a JSON file:- Individual Classes
- Group Classes
- Open Classes
Base Price: 15,000 ARS
- One-on-one instruction
- Personalized curriculum
- Flexible scheduling
Environment Variables
Required environment variables for Mercado Pago integration:Get your Mercado Pago credentials from the Mercado Pago Dashboard.
Webhook Configuration
Setup in Mercado Pago Dashboard
- Go to Mercado Pago Developers Panel
- Navigate to “Webhooks” section
- Add webhook URL:
https://yourdomain.com/api/mercado-pago/webhook - Select events to listen to:
- ✅
merchant_order(recommended) - ❌
payment(optional, usually ignored)
- ✅
Local Testing with ngrok
Payment Status Flow
Error Handling
Common Issues
Webhook not receiving events
- Verify webhook URL is publicly accessible
- Check Mercado Pago dashboard for webhook status
- Ensure HTTPS in production (HTTP allowed for testing)
- Check webhook logs for errors
- Verify Google Calendar API credentials
- Ensure
preferenceIdmatches between payment and booking
- Use
preferenceIdas unique constraint - Implement idempotency in webhook handler
- Check for race conditions in concurrent requests
Testing Payments
Mercado Pago provides test cards for development:Use test credentials from the Mercado Pago dashboard when testing. Switch to production credentials before going live.
Security Best Practices
Security Checklist
✅ Always verify payment status by fetching from Mercado Pago API, not trusting webhook data alone✅ Use HTTPS for webhook endpoints in production✅ Store access tokens in environment variables, never in code✅ Validate user authentication before creating preferences✅ Implement rate limiting on payment endpoints✅ Log all webhook events for audit trail✅ Handle webhook retries idempotently (Mercado Pago may send duplicates)
Integration with Virtual Classes
After successful payment, the system automatically:- Updates payment status to
approved - Creates Google Calendar event (see Calendar Integration)
- Updates booking status to
scheduled - Generates access code for participants
- Sends confirmation email (if configured)
API Reference
Create Preference
Webhook Endpoint
Related Features
- Virtual Classes - Class booking and management
- Calendar Integration - Google Calendar event creation
- Learning Activities - Post-payment activity access