A test card is a fake credit card number that a payment processor publishes for use in a sandbox or test environment. It passes the same format checks as a real card, so it can complete a simulated checkout, but it cannot move real money. Developers use test cards to verify payment flows before a site accepts live transactions.
What makes a number a valid test card?
A test card must pass the Luhn check, the checksum that flags typos in card numbers. Test numbers also carry a real card brand prefix, so a Visa test card starts with 4 and a Mastercard test card starts with 5 or 2.
The most widely used example is 4242 4242 4242 4242, a Visa number that Stripe and many other gateways accept in test mode. American Express test numbers follow the 15-digit format, such as 3782 822463 10005.
How do test card numbers work in a sandbox?
A sandbox is a separate copy of the payment system that talks to no bank and no card network. When you submit a test card there, the gateway reads the number and returns whatever result that number is programmed to produce.
Most processors assign a specific outcome to each test number. One number always approves, another always declines, and others trigger errors such as insufficient funds, expired card, or a failed postal code check.
Why do payment processors publish test cards?
Published test numbers let developers build and debug checkout pages without risking real charges. They also let a team reproduce edge cases on demand instead of waiting for a real customer to hit them.
- Approval and decline paths can be tested in seconds.
- 3D Secure and authentication steps can be simulated.
- Refunds, voids, and subscriptions can run against fake transactions.
What can you test with a test card?
Test cards cover far more than a simple approval. A complete test plan usually includes the scenarios below.
- Successful charge with a matching billing address.
- Generic decline, usually triggered by a dedicated decline number.
- Insufficient funds and expired card responses.
- CVV mismatch and ZIP code mismatch.
- 3D Secure challenge flow and authentication failure.
- Refund and partial refund of a test charge.
Are test cards legal to use?
Using a published test card inside a sandbox is normal development work. Using that same number against a live payment page is card fraud, even though the number is not tied to any real account.
Test cards also have no value outside a sandbox. They carry no credit limit, no balance, and no link to a cardholder, so they cannot fund a purchase anywhere.
How should you handle test card data?
Treat test card numbers as development fixtures, not as secrets, but keep the same habits you use for live data. Store them in your test fixtures or environment files, never in production code paths.
Keep test mode keys and live keys in separate configuration entries. A build that accidentally ships a sandbox key to production will fail every real payment.
Frequently asked questions
What is the most common test card number?
4242 4242 4242 4242 is the best known test card, used across Stripe, PayPal sandbox, and many other gateways for a successful Visa charge.
Do test cards expire?
Most test cards accept any future expiration date, and documentation usually recommends a date far ahead. Some processors still publish fixed dates for specific error scenarios.
Can a test card be charged for real?
No. A test card only resolves inside a sandbox, and a live gateway will reject it or flag the attempt as fraud.
Why does a test card get declined?
A decline usually means the number is programmed to decline, or the sandbox keys are wrong, or the request is hitting a live endpoint by mistake.