Testing Your Integration
Thoroughly test your ACP implementation before enabling live transactions.
Test Environment
Stripe Test Mode
Use Stripe’s test mode for development:
# Test API keys
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...Test Card Numbers
| Card Number | Scenario |
|---|---|
4242424242424242 | Successful payment |
4000000000000002 | Card declined |
4000000000009995 | Insufficient funds |
4000000000000069 | Expired card |
Local Development
Using ngrok
Expose your local server for webhook testing:
# Install ngrok
brew install ngrok # macOS
# or download from ngrok.com
# Start tunnel
ngrok http 3000
# Use the HTTPS URL for webhooks
# https://abc123.ngrok.ioRequest Signing
Test signature verification with sample payloads:
import crypto from 'crypto';
function generateTestSignature(body, secret, timestamp) {
return crypto
.createHmac('sha256', secret)
.update(`${timestamp}.${JSON.stringify(body)}`)
.digest('base64');
}
// Example test
const testBody = { cart_items: [{ product_id: 'test', quantity: 1 }] };
const timestamp = Date.now().toString();
const signature = generateTestSignature(testBody, 'test_secret', timestamp);API Testing
Create Session
curl -X POST https://your-server.com/checkout_sessions \
-H "Content-Type: application/json" \
-H "timestamp: $(date +%s)" \
-H "signature: YOUR_SIGNATURE" \
-d '{
"cart_items": [
{"product_id": "prod_123", "quantity": 1}
],
"currency": "USD"
}'Expected Response
{
"checkout_session_id": "cs_abc123",
"state": "ready_for_payment",
"cart": {
"items": [...]
},
"totals": {
"total": 2999
}
}Validation Checklist
âś…
Complete this checklist before going live.
Session Management
- Sessions created with unique IDs
- Sessions expire after 30 minutes
- Invalid sessions return 404
Payment Flow
- Test payments succeed
- Declined cards handled gracefully
- Delegated payment tokens work correctly
Error Handling
- Invalid signatures return 401
- Missing fields return 400
- Server errors return 500
Security
- HTTPS enforced
- Signatures verified on all requests
- Sensitive data not logged
Integration Testing
Simulate Agent Flow
- Create checkout session
- Simulate shipping address update
- Complete payment with test token
- Verify order creation
Load Testing
Test concurrent sessions:
# Using Apache Bench
ab -n 1000 -c 10 https://your-server.com/checkout_sessions
# Using k6
k6 run load-test.jsGoing Live
Once all tests pass:
- Switch to live Stripe keys
- Update webhook URLs
- Enable production logging
- Monitor initial transactions