Core
Testing
Test safely with sandbox environment
Sandbox is the default environment - completely isolated from production.
Test Cards
Successful payments:
| Card | Brand |
|---|---|
4242 4242 4242 4242 | Visa |
5555 5555 5555 4444 | Mastercard |
Use any future expiry and any 3-digit CVC.
Failed payments:
| Card | Scenario |
|---|---|
4000 0000 0000 9995 | Insufficient funds |
4000 0000 0000 0002 | Card declined |
3D Secure:
| Card | Description |
|---|---|
4000 0025 0000 3155 | Requires authentication |
Test Flow
// 1. Create customer
const customer = await commet.customers.create({
email: 'test@example.com',
externalId: `test_${Date.now()}`,
})
// 2. Create subscription
const subscription = await commet.subscriptions.create({
externalId: customer.data.externalId,
planCode: 'pro',
})
// 3. Pay with test card at checkoutUrl
// 4. Track usage
await commet.usage.track({
externalId: customer.data.externalId,
eventType: 'api_call',
})Production
const commet = new Commet({
apiKey: process.env.COMMET_PRODUCTION_KEY!,
environment: 'production',
})How is this guide?