Testing & Sandbox
Use test credentials to safely integrate without processing real payments.
Sandbox environment
| Sandbox | Production | |
|---|---|---|
| API base URL | https://api.peakgateway.co | https://api.peakgateway.co |
| Credentials | Test API keys (prefix tpk_) | Live API keys (prefix lpk_) |
| Charges | No real money moves | Real charges |
| Webhooks | Delivered to registered test endpoints | Delivered to live endpoints |
Test mode is determined by your API key, not a URL parameter. All test transactions are isolated from live data.
Test API keys
Generate test keys from the Settings → API Keys section of the Portal. Test keys always start with tpk_.
# Test request
curl https://api.peakgateway.co/api/v1/transactions \
-H "Authorization: Bearer tpk_your_test_key" \
-d '{ "type": "SALE", "amount": 1000, "currency": "USD", ... }'
Test card numbers
Use these card numbers with any future expiration date (e.g. 12/30) and any 3-digit CVV.
Visa
| Card number | Result |
|---|---|
4111111111111111 | Approved |
4000000000000002 | Declined (generic) |
4000000000009995 | Declined (insufficient funds) |
4000000000000069 | Declined (expired card) |
4000000000000127 | Declined (incorrect CVV) |
Mastercard
| Card number | Result |
|---|---|
5555555555554444 | Approved |
5200828282828210 | Approved (debit) |
5105105105105100 | Declined (generic) |
Amex
| Card number | Result |
|---|---|
378282246310005 | Approved |
371449635398431 | Approved |
Discover
| Card number | Result |
|---|---|
6011111111111117 | Approved |
6011000990139424 | Approved |
Triggering specific scenarios
Control specific outcomes using special amounts:
| Amount (cents) | Behavior |
|---|---|
| Any | Approved (with valid test card) |
999999 | Network timeout simulation |
888888 | Partial approval — approves $50.00 regardless of requested amount |
Testing webhooks
Register a webhook endpoint pointing to a local URL or a service like ngrok for local development:
# Start ngrok to expose local port 3000
ngrok http 3000
# Register the webhook endpoint
curl https://api.peakgateway.co/api/v1/webhooks \
-H "Authorization: Bearer tpk_your_test_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://abc123.ngrok.io/webhooks",
"events": ["payment.completed", "payment.declined"]
}'
All events fired in test mode are delivered to test webhook endpoints only.
Testing subscriptions
Create a subscription with intervalCount: 1 and interval: daily to trigger billing every day. Use an approved test card to see subscription.billed events, or a declining test card to trigger subscription.payment_failed.
Verifying test webhook signatures
The webhook secret shown in your dashboard is unique per environment. Use the test environment secret when developing locally.
import { WebhookVerifier } from '@gateway/sdk';
const verifier = new WebhookVerifier(process.env.WEBHOOK_SECRET_TEST);
// same verification logic as production