Test Mode vs Live Mode
| Aspect | Test Mode | Live Mode |
|---|---|---|
| API Keys | pk_test_*, sk_test_* | pk_live_*, sk_live_* |
| Card Numbers | Stripe test cards | Real credit cards |
| Charges | No real money | Real transactions |
| Webhook URL | .../webhooks/{id}/test | .../webhooks/{id}/live |
Development Testing Workflow
Step 1: Configure Test Mode
In Cloud Admin, navigate to Payments > Settings and enter your test credentials:Get Test Keys from Stripe
Go to Stripe Dashboard > Developers > API keysCopy:
- Publishable key:
pk_test_... - Secret key:
sk_test_...
Step 2: Set Up Local Webhook Testing
Use Stripe CLI to forward webhooks to your local development environment:Replace
{your-project-id} with your actual project UUID from Cloud Admin.Step 3: Trigger Test Events
Use Stripe CLI to simulate events:Test Card Numbers
Use these Stripe test cards to simulate various scenarios:Successful Payments
| Card Number | Description |
|---|---|
4242 4242 4242 4242 | Standard successful payment |
4000 0025 0000 3155 | Requires 3D Secure authentication |
5555 5555 5555 4444 | Mastercard (successful) |
3782 822463 10005 | American Express (successful) |
Failed Payments
| Card Number | Failure Type |
|---|---|
4000 0000 0000 0002 | Card declined |
4000 0000 0000 9995 | Insufficient funds |
4000 0000 0000 9987 | Lost card |
4000 0000 0000 9979 | Stolen card |
4000 0000 0000 0069 | Expired card |
4000 0000 0000 0127 | Incorrect CVC |
Special Scenarios
| Card Number | Scenario |
|---|---|
4000 0027 6000 3184 | Requires authentication (fails if not completed) |
4000 0000 0000 3220 | 3D Secure 2 required |
4000 0000 0000 0341 | Attach payment method fails |
Testing Subscription Scenarios
New Subscription Flow
Test Plan Changes
Test Payment Failure
Update to Failing Card
In Stripe Dashboard, update the customer’s payment method to
4000 0000 0000 0341.Test Cancellation
Monitoring Test Events
Stripe CLI Output
Watch the CLI for incoming webhooks:Cloud Admin Dashboard
After test events:- Statistics - Verify subscription and transaction counts update
- Subscriptions - New subscription appears in the list
- Transactions - Payment record shows in transaction history
Stripe Dashboard
Check webhook logs for delivery status:- Go to Developers > Webhooks
- Select your test endpoint
- View recent deliveries and response codes
Testing Checklist
Use this checklist before going live:Basic Checkout
- Successful payment with
4242 4242 4242 4242 - Subscription created in Cloud Admin
- User sees active subscription in dashboard
Payment Failures
- Declined card shows appropriate error
- Insufficient funds triggers retry
- Subscription goes to
past_duecorrectly
Subscription Management
- Plan upgrade creates proration charge
- Plan downgrade creates proration credit
- Cancellation marks subscription correctly
- Uncancellation works if before period end
Going Live Checklist
When testing is complete, prepare for production:Configure Live Credentials
In Cloud Admin: Payments > Settings > Live ModeEnter your live Stripe keys (
pk_live_*, sk_live_*).Create Live Webhook
In Stripe Dashboard, create a new webhook endpoint with your live URL:
https://api.devkit4ai.com/api/v1/payments/stripe/webhooks/{project_id}/liveMake a Real Test
Process a small real transaction (e.g., $1) and immediately refund it to verify the live integration.
Troubleshooting Tests
Webhooks not received locally
Webhooks not received locally
- Verify Stripe CLI is running:
stripe listen --forward-to ... - Check the forwarding URL is correct
- Ensure no firewall blocking outbound connections
- Try
stripe listen --print-jsonfor detailed output
Signature verification failed
Signature verification failed
- Use the webhook secret from the current
stripe listensession - Secrets change each time you restart Stripe CLI
- For persistent secrets, create an endpoint in Stripe Dashboard
Test payment not appearing
Test payment not appearing
- Check webhook delivery in Stripe Dashboard
- Verify the project_id in the webhook URL matches your project
- Check Cloud API logs for processing errors
3D Secure not triggering
3D Secure not triggering
- Use card
4000 0025 0000 3155which requires authentication - Ensure your checkout session has correct billing address fields

