What test card numbers are and why they exist
Test card numbers are fake credit card numbers that payment processors and card networks issue for developers and merchants to use during testing. They look like real card numbers — they pass the Luhn algorithm check that validates card number format — but they are not connected to any actual bank account or cardholder. When you use a test card number in a sandbox environment, the transaction does not charge anyone and does not create a real payment record.
Payment processors like Stripe, Square, PayPal, and others maintain their own test card numbers so that developers can build and test checkout flows, recurring billing systems, and payment integrations without risking real money or creating fraudulent transactions. Each major card network — Visa, Mastercard, American Express, Discover — has its own set of test numbers that work only in sandbox mode.
Test cards are essential infrastructure for anyone building a payment system. A developer testing a subscription renewal flow, a merchant testing a new checkout page, or a QA team validating error handling all need a way to simulate transactions without touching production systems or real customer funds.
Key Takeaways
- Test card numbers are fake numbers that pass format validation but are not connected to real bank accounts, and they work only in sandbox or test environments.
- Each payment processor and card network publishes its own test card numbers, and using the wrong set for your processor will not work.
- Test cards can simulate different outcomes — successful charges, declined cards, expired cards, and specific error codes — depending on the number and expiration date you enter.
- Test card numbers should never be used in production environments, and real card numbers should never be used in test environments.
- Most payment processors provide test card numbers in their developer documentation, usually organized by card type and outcome.
How test card numbers work in sandbox environments
A sandbox is an isolated testing environment that mimics the production payment system but does not process real transactions or touch real money. When you submit a test card number to a sandbox, the payment processor recognizes it as a test number and returns a simulated response — success, decline, or a specific error — based on the number and details you provide.
The sandbox sits between your process and the live payment network. In production, your checkout form sends real card data to the processor, which routes it to the card network and the issuing bank. In sandbox mode, your checkout form sends test card data to a test version of the processor, which returns a canned response without ever contacting a real bank. This means you can test your entire payment flow — form submission, error handling, receipt generation, database updates — without any actual money changing hands.
Most payment processors require you to use a different API key or account for sandbox versus production. If you accidentally use your production API key with a test card number, the processor will reject it. If you accidentally use a test card number in production, it will fail. This separation is intentional: it prevents test transactions from leaking into your real payment records and prevents developers from accidentally charging customers during testing.
Test card numbers by processor and card type
Each major payment processor publishes test card numbers in its developer documentation. The numbers vary by processor because each one maintains its own sandbox system. A Stripe test card will not work in a Square sandbox, and vice versa.
Stripe publishes test cards for Visa, Mastercard, American Express, and Discover. For example, Stripe's Visa test number is 4242 4242 4242 4242, with any future expiration date and any three-digit CVC. Stripe also provides specific test numbers that trigger specific outcomes: 4000 0000 0000 0002 declines the charge, 4000 0025 0000 3155 requires authentication, and others simulate different error states.
Square provides test card numbers for each card type in its developer documentation. Square's Visa test number is 4111 1111 1111 1111. Like Stripe, Square offers variations that simulate declines, authentication requirements, and other scenarios.
PayPal uses test accounts rather than individual test card numbers. You create a test buyer account and a test seller account in the PayPal sandbox, then use those accounts to simulate transactions. This approach differs from Stripe and Square because PayPal's sandbox is account-based rather than card-based.
Braintree (owned by PayPal) provides test card numbers similar to Stripe's model. Braintree's Visa test number is 4111 1111 1111 1111, and it offers variations for different outcomes.
The specific numbers, expiration dates, and CVCs required vary by processor. Always check your processor's developer documentation for the exact test cards to use, because using the wrong set will cause your tests to fail.
Simulating different transaction outcomes with test cards
Payment processors allow you to simulate different outcomes — approvals, declines, authentication requirements — by using specific test card numbers or by entering specific amounts. This lets you test how your process handles success and failure without waiting for real transactions to process.
In Stripe, for example, entering an amount of $0.02 (two cents) triggers a decline. Entering $0.05 triggers an authentication requirement. Entering most other amounts results in approval. This means you can test your decline handling, your authentication flow, and your success flow all with the same test card number, just by changing the amount.
Other processors use different test card numbers to simulate different outcomes. Square, for instance, provides one test card number that always succeeds and others that always decline or require authentication. Check your processor's documentation for the specific mechanism — some use amounts, some use card numbers, and some use both.
This outcome simulation is critical for testing error handling. You need to verify that your process displays the right error message when a card is declined, that it prompts for authentication when required, and that it handles network timeouts gracefully. Test cards let you trigger these scenarios reliably without needing to coordinate with real banks or wait for edge cases to occur naturally.
Test card numbers for specific card networks
The major card networks — Visa, Mastercard, American Express, and Discover — each have their own test card numbers. Most payment processors support all four networks in their sandbox environments.
Visa test cards typically start with 4. The most common Visa test number across processors is 4111 1111 1111 1111 or 4242 4242 4242 4242, depending on the processor.
Mastercard test cards typically start with 5. Common Mastercard test numbers are 5555 5555 5555 4444 or 5200 0000 0000 0000.
American Express test cards typically start with 3. Common American Express test numbers are 3782 822463 10005 or 378282246310005. Note that American Express card numbers are 15 digits, not 16 like Visa and Mastercard.
Discover test cards typically start with 6. A common Discover test number is 6011 1111 1111 1117.
These patterns reflect the real card number ranges that each network uses in production. However, the specific test numbers you should use depend on your payment processor, not on the card network alone. Always refer to your processor's documentation for the exact numbers to use.
Common mistakes when using test card numbers
The most common mistake is using a test card number in production. If you leave test card numbers in your code or configuration and deploy to production, real customers will see transactions fail when they try to pay with those numbers. This breaks your checkout flow and damages trust.
The second common mistake is using the wrong test card number for your processor. A Stripe test card will not work in a Square sandbox, and a developer who copies a test number from one processor's documentation and tries to use it in another will see failures and waste time debugging.
A third mistake is using real card numbers in sandbox environments. This is a security and compliance violation. Real card numbers should never be entered into test systems, even if those systems are isolated. If you need to test with a real card, do so in production with a small amount, or use your processor's staging environment if one is available.
A fourth mistake is assuming test card numbers work the same way across all processors. The expiration date, CVC, billing address, and other details required vary by processor. Some processors are lenient and accept any future date and any three-digit CVC; others require specific values. Check your processor's documentation for the exact requirements.
Where to find test card numbers for your payment processor
Test card numbers are published in the developer documentation for each payment processor. You do not need to search for them or use third-party sources; your processor publishes them officially.
Stripe publishes test cards at stripe.com/docs/testing. The page lists test cards by outcome (successful charge, declined, authentication required, etc.) and by card type.
Square publishes test cards at developer.squareup.com/docs/testing. The page includes test cards for different card types and different outcomes.
PayPal publishes sandbox account setup instructions at developer.paypal.com/docs/platforms/get-started. You create test accounts rather than using individual card numbers.
Braintree publishes test cards at braintree.paypal.com/docs/guides/general/testing. The page lists test cards by card type and outcome.
If you are using a smaller or regional payment processor, check its developer portal or API documentation. The test cards are always in the testing or sandbox section, usually near the API reference or integration guides.
Frequently Asked Questions
Can I use the same test card number across different payment processors?
No. Each processor maintains its own sandbox system and recognizes only its own test card numbers. A Stripe test card will fail in a Square sandbox because Square's sandbox does not recognize Stripe's test numbers. Always use the test cards published by the processor you are integrating with.
What happens if I accidentally use a test card number in production?
The transaction will fail because the payment processor recognizes the test number and rejects it. Your customer will see an error message, and the charge will not go through. This is why it is critical to use different API keys or environments for sandbox versus production — the separation prevents test numbers from reaching production systems.
Do test card numbers expire?
Test card numbers themselves do not expire, but the expiration date you enter when testing does matter. Most processors accept any future expiration date for test cards, but some require specific dates. Check your processor's documentation. In production, real cards do expire and must be updated by the cardholder.
Can I use test card numbers to test recurring billing or subscriptions?
Yes. Test card numbers work with recurring billing systems just as they do with one-time charges. You can create a test subscription, trigger renewals, test failed renewal scenarios, and test cancellation — all without charging real money. This is one of the most important uses for test cards.
What if a test card number is not working in my sandbox?
First, verify that you are using the correct API key for your sandbox environment, not your production key. Second, check that you are using the exact test card number published by your processor — even a single digit difference will cause it to fail. Third, verify the expiration date and CVC match what your processor requires. If all three are correct, contact your processor's support team with the specific error message you are seeing.