Testing Your Deployment
Now that your API is deployed, let's make sure everything works! We'll test each part of your system step by step.
Prerequisites ✅
Before starting, make sure you have:
- Your API Gateway URL (from previous step)
- Stripe CLI installed
- MQTT client (Mosquitto) installed
- Test environment variables configured in Lambda
Keep Your Tools Ready
You'll need several terminal windows open for testing. Consider using VSCode's integrated terminal with split panes to keep everything organized!
Part 1: Basic API Testing 🔍
Let's start by making sure your API endpoints are accessible.
1. Test Status Endpoint
Expected response:
Getting a 404?
If you get a "Not Found" error:
- Double-check your API URL
- Verify the endpoint is deployed
- Check Lambda logs for errors
Part 2: Payment Flow Testing 💳
1. Create Payment Link
curl -X POST https://your-api-url/create-payment-link \
-H "Content-Type: application/json" \
-d '{"machine_id":"test123"}'
Expected response:
2. Test Payment Processing
-
Start Stripe webhook forwarding:
-
Open the payment URL in your browser
-
Complete a test payment:
- Card number: 4242 4242 4242 4242
- Any future expiry date
- Any 3-digit CVC
- Any ZIP code
Test Cards
Stripe provides several test cards for different scenarios:
- 4242 4242 4242 4242 - Successful payment
- 4000 0000 0000 9995 - Declined payment
- Find more in the Stripe testing docs
Part 3: MQTT Message Testing 📡
1. Watch for Messages
In a new terminal, subscribe to MQTT topics:
mosquitto_sub -h your.emqx.cloud.broker -p 8883 \
-t "arcade/machine/+/coinpulse" \
-t "arcade/machine/+/gameover" \
--cafile emqx.ca \
-u "your_username" -P "your_password"
2. Test Game Over Signal
curl -X POST https://your-api-url/gameover \
-H "Content-Type: application/json" \
-d '{"machine_id":"test123"}'
Watch your MQTT subscriber terminal for the game over message!
Part 4: End-to-End Testing 🔄
Time to test the complete flow! You should see:
- Payment link creation ✓
- Successful payment ✓
- MQTT coin pulse message ✓
- Game over signal ✓
- MQTT game over message ✓
Working System
If you see all these steps working, congratulations! Your arcade payment system is ready for action! 🎮
Monitoring and Logs 📊
Check CloudWatch Logs
- Go to AWS Console → CloudWatch → Log Groups
- Find your Lambda function's log group
- Look for any errors or warnings
Monitor Stripe Dashboard
- Go to Stripe Dashboard → Events
- Look for successful test payments
- Verify webhook deliveries
Log Investigation
If something's not working, logs are your best friend! They'll tell you exactly where things went wrong.
Common Issues and Solutions 🔧
API Gateway Issues
- 403 Forbidden: Check Lambda permissions
- 502 Bad Gateway: Review Lambda function configuration
- Timeout: Adjust Lambda timeout settings
Stripe Issues
- Webhook errors: Verify endpoint URL and secrets
- Payment failures: Check test card numbers
- Missing events: Confirm webhook forwarding is running
MQTT Issues
- Connection refused: Check broker address and credentials
- No messages: Verify topic subscriptions
- SSL errors: Check certificate configuration
Still Stuck?
- Check the Troubleshooting Guide
- Review specific error messages
- Ask your teacher or mentor for help
Security Checks 🔐
Before finishing testing, verify:
- Environment variables are properly set
- Stripe webhook secret is configured
- MQTT credentials are secure
- API endpoints are working as expected
Next Steps 🎯
Once testing is complete:
- Document any issues found
- Save test outputs for reference
- Plan your next features or modifications
- Consider moving to production mode
Continue to Making Modifications → Back to API Gateway Setup
Keep Testing!
Regular testing helps catch issues early. Consider setting up automated tests for your system!