Commet
  • Pricing
Log InTry out
Introduction

Quickstart

Learn

Resources

SDK ReferenceError HandlingTestingCLI

Plugins

Better Auth
DocumentationKnowledge BaseBuild with AIAPI ReferenceWebhooks

Testing

Test safely with sandbox environment

Sandbox is the default environment — completely isolated from production.

Test Flow

// 1. Create customer
const customerId = `test_${Date.now()}`
const customer = await commet.customers.create({
  email: 'test@example.com',
  id: customerId,
})

// 2. Create subscription
const subscription = await commet.subscriptions.create({
  customerId,
  planCode: 'pro',
})

// 3. Pay with test card at checkoutUrl

// 4. Track usage
await commet.usage.track({
  customerId,
  feature: 'api_calls',
})

Dev Tools Panel

A floating widget that appears on all sandbox pages. The Test Clock tab is available everywhere. The Test Data tab (address and card presets) only appears on checkout pages.

Test Clock

Simulate future dates to test billing cycles, renewals, and prorations without waiting for real time to pass.

Current Time — displays the simulated time in UTC, or the real time if no simulation is active.

Set Time — pick a future date from a calendar. Time can only move forward and cannot be reverted.

Quick Advance — jump forward by a preset amount:

ButtonDays
+ 1 Day1
+ 1 Week7
+ 2 Weeks14
+ 1 Month30
+ 3 Months90

Run Billing Cron — manually trigger billing processing at the simulated time. This processes renewals, generates invoices, and applies usage charges.

Example workflow: advance 1 month to reach the next billing cycle, then run billing cron to generate renewal invoices and verify charges.

Test Data

The Test Data tab automates checkout form filling with valid test data for 60+ countries. Open it from the Dev Tools panel on any sandbox checkout page.

Address autofill — select a country and the checkout address form is automatically filled with a valid name, street, city, postal code, and phone number for that country. No need to type anything manually.

Country-specific test cards — after selecting a country, the panel shows the test card number that matches that country. Click to copy. Expiry and CVC are always 12/34 and 123.

Failure scenarios — generic cards are available to test error handling: declined payments, insufficient funds, expired cards, and 3D Secure authentication. See the tables below.

Test cards by country

CountryCardBrand
United States (US)4242 4242 4242 4242Visa
Argentina (AR)4000 0032 0000 0021Visa
Australia (AU)4000 0003 6000 0006Visa
Austria (AT)4000 0004 0000 0008Visa
Belarus (BY)4000 0011 2000 0005Visa
Belgium (BE)4000 0005 6000 0004Visa
Brazil (BR)4000 0076 0000 0002Visa
Bulgaria (BG)4000 0010 0000 0000Visa
Canada (CA)4000 0012 4000 0000Visa
Chile (CL)4000 0015 2000 0001Visa
China (CN)4000 0015 6000 0002Visa
Colombia (CO)4000 0017 0000 0003Visa
Costa Rica (CR)4000 0018 8000 0005Visa
Croatia (HR)4000 0019 1000 0009Visa
Cyprus (CY)4000 0019 6000 0008Visa
Czech Republic (CZ)4000 0020 3000 0002Visa
Denmark (DK)4000 0020 8000 0001Visa
Ecuador (EC)4000 0021 8000 0000Visa
Estonia (EE)4000 0023 3000 0009Visa
Finland (FI)4000 0024 6000 0001Visa
France (FR)4000 0025 0000 0003Visa
Germany (DE)4000 0027 6000 0016Visa
Gibraltar (GI)4000 0029 2000 0005Visa
Greece (GR)4000 0030 0000 0030Visa
Hong Kong (HK)4000 0034 4000 0004Visa
Hungary (HU)4000 0034 8000 0005Visa
India (IN)4000 0035 6000 0008Visa
Ireland (IE)4000 0037 2000 0005Visa
Italy (IT)4000 0038 0000 0008Visa
Japan (JP)4000 0039 2000 0003Visa
Japan (JP)3530 1113 3330 0000JCB
Latvia (LV)4000 0042 8000 0005Visa
Liechtenstein (LI)4000 0043 8000 0004Visa
Lithuania (LT)4000 0044 0000 0000Visa
Luxembourg (LU)4000 0044 2000 0006Visa
Malaysia (MY)4000 0045 8000 0002Visa
Malta (MT)4000 0047 0000 0007Visa
Mexico (MX)4000 0048 4000 8001Visa
Mexico (MX)5062 2100 0000 0009Carnet
Netherlands (NL)4000 0052 8000 0002Visa
New Zealand (NZ)4000 0055 4000 0008Visa
Norway (NO)4000 0057 8000 0007Visa
Panama (PA)4000 0059 1000 0000Visa
Paraguay (PY)4000 0060 0000 0066Visa
Peru (PE)4000 0060 4000 0068Visa
Poland (PL)4000 0061 6000 0005Visa
Portugal (PT)4000 0062 0000 0007Visa
Romania (RO)4000 0064 2000 0001Visa
Saudi Arabia (SA)4000 0068 2000 0007Visa
Singapore (SG)4000 0070 2000 0003Visa
Slovakia (SK)4000 0070 3000 0001Visa
Slovenia (SI)4000 0070 5000 0006Visa
Spain (ES)4000 0072 4000 0007Visa
Sweden (SE)4000 0075 2000 0008Visa
Switzerland (CH)4000 0075 6000 0009Visa
Taiwan (TW)4000 0015 8000 0008Visa
Thailand (TH)4000 0076 4000 0003Visa
Thailand (TH)4000 0576 4000 0008Visa (debit)
United Arab Emirates (AE)4000 0078 4000 0001Visa
United Arab Emirates (AE)5200 0078 4000 0022Mastercard
United Kingdom (GB)4000 0082 6000 0000Visa
United Kingdom (GB)4000 0582 6000 0005Visa (debit)
United Kingdom (GB)5555 5582 6555 4449Mastercard
Uruguay (UY)4000 0085 8000 0003Visa

Failure scenarios

CardScenario
4000 0000 0000 9995Insufficient funds
4000 0000 0000 0002Card declined
4000 0000 0000 0069Expired card

3D Secure

CardDescription
4000 0000 0000 3220Requires authentication
4000 0025 0000 3155Requires authentication

Production

const commet = new Commet({
  apiKey: process.env.COMMET_PRODUCTION_KEY!,
  environment: 'production',
})

How is this guide?

Error Handling

Handle errors with automatic retries and typed error classes

CLI

Install and use the Commet CLI to generate TypeScript types from your dashboard.

On this page

Test Flow
Dev Tools Panel
Test Clock
Test Data
Test cards by country
Failure scenarios
3D Secure
Production