starts with 4, the Visa range·passes the Luhn check: digit sum 80·works only against sandbox keys·other providers publish other numbers

What the number actually encodes

A card number is not random. The first digit is the industry identifier, and 4 belongs to Visa. The leading digits form the BIN, the bank identification number that tells the network which issuer to route an authorization to. The last digit is a Luhn check digit, computed from all the others.

Run 4242 4242 4242 4242 through the algorithm and it comes out clean: double every second digit from the right, the 4s become 8s, the sum lands on 80, and anything divisible by 10 passes. You can watch the computation step by step in the Luhn checker, which highlights which digits get doubled and where a typo would break the sum.

So structurally it is a flawless Visa number. What it lacks is everything behind the structure: no issuing bank ever put an account behind it. That gap between “well-formed” and “real” is the entire story of this article.

Why 42, of all digits

Stripe has never published a naming memo, so the honest version is: unconfirmed, but nobody in the payments world doubts it. In Douglas Adams’ Hitchhiker’s Guide to the Galaxy, 42 is the answer to the ultimate question of life, the universe and everything, and it has been the default in-joke number of programming culture ever since. Adams himself said he chose it simply because it seemed like a perfectly ordinary, funny number.

Start from the constraint and the number nearly writes itself. It must begin with 4 to look like a Visa card, it should be trivially memorable, and it must pass Luhn. 42 repeated eight times satisfies all three, and the checksum happens to work out without any correction digit. A test value engineers would type thousands of times deserved to be a joke they would enjoy, and this one stuck so hard that a whole generation of developers knows a fictional card number by heart.

Why it works in test mode and nowhere else

Sandbox and live are two separate worlds selected by your API keys. Against test keys, the provider never talks to a card network at all. It looks up the number in its own table of published test cards and plays back the scripted outcome: 4242 4242 4242 4242 is scripted to succeed, with any future expiry and any CVC.

Against live keys the same number is rejected immediately. Providers keep a denylist of their own published test numbers, and the error message names the problem precisely, a test card used in live mode. No bank was contacted, no authorization attempted.

That behavior turns the number into a cheap smoke test: if 4242 4242 4242 4242 suddenly gets declined in an environment where it used to work, your code is talking to live keys.

The same idea at every other provider

Every payment platform maintains its own scripted numbers, and they are not interchangeable:

ProviderCanonical success cardNote
Stripe4242 4242 4242 4242any future expiry, any CVC
PayPal, Braintree4111 1111 1111 1111the classic Visa test number, pre-dating them all
Authorize.net4111 1111 1111 1111plus its own Amex and Discover entries
Adyenown published listper-scheme numbers in the Adyen docs

The full lists, including Mastercard, Amex and Discover variants like 5555 5555 5555 4444 and 378 282246 310005, are collected on our test card numbers page, grouped by provider and outcome, so a failing sandbox test does not send you digging through four different doc sites.

The numbers that are built to fail

The success card is the boring half of a test suite. The valuable half is the scripted failures, because decline handling is where checkout bugs hide. Stripe’s sandbox, for example, reserves 4000 0000 0000 0002 for a generic decline, 4000 0000 0000 9995 for insufficient funds, and 4000 0025 0000 3155 for a payment that requires 3D Secure authentication first.

A checkout that has only ever seen the happy path will meet its first decline in production, from a real customer, at the worst possible moment. Testing the sad paths with scripted cards is the cheap version of that lesson.

What happens if you type it into a real shop

The front-end validation passes, because the checksum is fine. Then the authorization request either dies at the provider’s test-number denylist or, for a fabricated number that is not on any published list, gets routed toward an issuer that does not exist and comes back declined. Nothing is charged because there is nothing to charge.

This is also the complete answer to the “credit card generator” sites: they emit Luhn-valid strings, which gets them past exactly one check, the one that was designed to catch typos rather than fraud. The distance between a checksum and an account balance is the distance between a well-formed sentence and a true one.

Why not just use a real card in the sandbox

Beyond the obvious risk of an accidental real charge when an environment variable points the wrong way, real card numbers are toxic data. The moment one enters your logs, screenshots, bug reports or test fixtures, PCI DSS scope follows it, and scrubbing a card number out of a year of CI logs is nobody’s favorite sprint.

a real card in test fixtures
// checkout.spec.ts
const CARD = '5313 0200 ████ ████';
// a live number now sits in git history,
// CI logs and every screenshot
scripted numbers per scenario
// checkout.spec.ts
const OK = '4242424242424242';
const DECLINED = '4000000000000002';
const NEEDS_3DS = '4000002500003155';

The same reasoning applies to names, addresses and IBANs in fixtures, which is what the test data generator exists for: data that is structurally valid and provably fake beats sanitized production data every time someone asks where it came from.

Test numbers, asked and answered

Are test card numbers the same across payment providers?

No. Each provider publishes its own list for its own sandbox. Stripe’s 4242 4242 4242 4242 means nothing to Adyen, and Braintree’s sandbox has its own set built around 4111 1111 1111 1111. The only thing the lists share is that every number on them passes the Luhn check, so client-side validation lets them through.

What is 4111 1111 1111 1111?

The classic Visa test number, decades older than Stripe, and the sandbox default at PayPal, Braintree, Authorize.net and most older gateways.

Why do numbers from card generators fail at checkout?

Because a checkout does two very different checks. The Luhn checksum runs client-side and a generator can satisfy it trivially. Then the payment network routes the number to an issuing bank, and for a fabricated number there is no issuer, no account and no funds behind it, so authorization fails. The checksum was never a security measure, it is a typo detector from 1954.

Can money move on a test card number?

No. Test numbers only work against sandbox API keys, and sandbox transactions never enter the card networks.

Why does 4242 4242 4242 4242 get declined in live mode?

Payment providers recognize their own published test numbers and reject them against live keys outright, before any bank is contacted. Stripe’s live-mode error says exactly that. Seeing this error in production usually means a config value still points at the wrong environment.

What is a BIN on a credit card?

The bank identification number, the first digits of the card number that identify the issuing institution. Historically six digits, extended to eight in 2022. It is how the network knows where to route an authorization, and it is the part a made-up number cannot fake its way through.

Where does the 42 in the Stripe test card come from?

Stripe has never published an official origin story, but in developer culture 42 is the answer to life, the universe and everything from Douglas Adams’ Hitchhiker’s Guide to the Galaxy. A Visa number starts with 4, and 4242 repeated is the most memorable Luhn-valid sequence you can build from it.