Skip to main content

Testing & Sandbox

Use test credentials to safely integrate without processing real payments.

Sandbox environment

SandboxProduction
API base URLhttps://api.peakgateway.cohttps://api.peakgateway.co
CredentialsTest API keys (prefix tpk_)Live API keys (prefix lpk_)
ChargesNo real money movesReal charges
WebhooksDelivered to registered test endpointsDelivered 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 numberResult
4111111111111111Approved
4000000000000002Declined (generic)
4000000000009995Declined (insufficient funds)
4000000000000069Declined (expired card)
4000000000000127Declined (incorrect CVV)

Mastercard

Card numberResult
5555555555554444Approved
5200828282828210Approved (debit)
5105105105105100Declined (generic)

Amex

Card numberResult
378282246310005Approved
371449635398431Approved

Discover

Card numberResult
6011111111111117Approved
6011000990139424Approved

Triggering specific scenarios

Control specific outcomes using special amounts:

Amount (cents)Behavior
AnyApproved (with valid test card)
999999Network timeout simulation
888888Partial 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