Your cart is empty
Shop now
+

Luhn Check Test: Validate Card Numbers in Test Environments

Explore

Luhn Check Test: Validate Card Numbers in Test Environments

We guarantee gift cards direct to your inbox immediately.
Shop Now!

Let's Work Together

Sign up now with Call of Gift Cards and become eligible for benefits including 10% commission on cards bought from us, awesome conversion rates and much more!
Find Out More

Digital Gift Cards

The market for digital goods and services are growing rapidly. One of the true shifts in online behaviour is the switch from traditional direct online payments and purchase to wallets and gift cards. ...read more
+

Digital Gift Cards

The market for digital goods and services are growing rapidly. One of the true shifts in online behaviour is the switch from traditional direct online payments and purchase to wallets and gift cards. We invite you to start your own online business as a partner of ours. By signing up as a partner you’ll get access to one of the largest gift card databases in the world. All you need to focus on is to market your website and products. Gift cards are quickly outperforming traditional gifts, as they give the recipient the choice to pick their own present from a variety of options. The range of e-gift cards available on the Call of Gift Cards's partner sites includes popular categories such as restaurants, games, travel and fashion.

Gift Vouchers

Traditional gift vouchers are printed paper gifts available in set values that can be spent in specific stores. Open-loop, semi-open loop, and closed-loop are often terms used when referring to gift v...read more
+

Gift Vouchers

Traditional gift vouchers are printed paper gifts available in set values that can be spent in specific stores. Open-loop, semi-open loop, and closed-loop are often terms used when referring to gift vouchers. All gift cards sold via our partners’ websites are closed loop. This means that the gift card can only be spent at a single brand location, for example, an Xbox voucher can only be spent at Xbox etc.

Our Gift Cards

Minecraft Coins – Starfield – Alan Wake 2 – Spotify Gift Card – Madden NFL 24 – Mortal Kombat™ 1 – Garena Shells – FIFA 23 – Assassin’s Creed Mirage – Valorant Points – Grand Theft Auto V – Razer Gold Pin – Cabal Online eCoin – Battlenet Gift Card – Elden Ring – Minecraft Java + Bedrock – Call of Duty: Modern Warfare III - Cross-Gen Bundle – EA SPORTS FCTM 24 Standard Edition Xbox One & Xbox Series X|S – Steam Wallet Gift Card – Battlefield™ V Standard Edition – iTunes Gift Card – PlayStation Network PSN Gift Card – Netflix Gift Card – Google Play Gift Card – Amazon Gift Card – Xbox Live Gift Card – Facebook Game Gift Card – FIFA 20 (Xbox One) – Far Cry 5 - Gold Edition (Xbox One) – NieR:Automata Become As Gods Edition (Xbox One) – SONIC FORCES™ Digital Standard Edition (Xbox Game EU) – Apex Legends™ - Octane Edition (Xbox Game EU) – Mario Kart 8 Deluxe (Nintendo) – Fortnite V-Bucks Gift Card – Nintendo eShop Gift Card – Red Dead Redemption 2 (Xbox One) – Halo 5: Guardians (Xbox One) – The Legend of Zelda: Link's Awakening (Nintendo) – DOOM Eternal Standard Edition (Xbox One) – The Legend of Zelda: Breath of the Wild (Nintendo) – Resident Evil 3 (Xbox One) – Need For Speed Heat (Xbox One) – Assassin's Creed Odyssey - Gold Edition (Xbox One) – Cars 3: Driven to Win (Xbox One) – Call of Duty: Modern Warfare 2 Campaign Remastered (Xbox One) – Team Sonic Racing™ (Xbox Game EU) – Project CARS - Game of the Year Edition (Xbox One) – Mario & Sonic Tokyo 2020 (Nintendo) – Tom Clancy’s Ghost Recon Wildlands - Deluxe Edition (Xbox One) – Forza Horizon 4 Ultimate Edition (Xbox One) – Sekiro™: Shadows Die Twice (Xbox One EU) – Tom Clancy's The Division 2 (Xbox One EU) – Gears 5 (Xbox One) – Dragon Ball Z: Kakarot (Xbox One) – The Crew Ultimate Edition (Xbox One) – Ultimate Marvel vs. Capcom 3 (Xbox One) – Pokemon Let's Go Eevee! (Nintendo) – Sonic Mania (Xbox Game EU) – UFC 3 - Deluxe Edition (Xbox One) – Mass Effect Andromeda - Standard Recruit Edition (Xbox One) – BioShock: The Collection (Xbox One) – A Way Out (Xbox One) – Borderlands 3 (Xbox One) – Overcooked! 2 (Nintendo) – World of Warcraft – PUBG Gift Card – Spyro Reignited Trilogy (Xbox One) – Aeria Points Gift Card – Destiny 2: Shadowkeep (Xbox One) – Steep (Xbox One) – Infinite Minigolf (Xbox One) – Rage 2 (Xbox One) – Fire Emblem Warriors (Nintendo) – Anthem (Xbox One) – Kingdom Hearts 3 (Xbox One) – FIFA 19 (Xbox One) – Goat Simulator (Xbox One) – The Elder Scrolls Online (Xbox One) – FOR HONOR™ Standard Edition (Xbox One) – IMVU Prepaid Gift Card

Luhn Check Test: Validate Card Numbers in Test Environments

A Luhn check test answers one narrow question: do the digits of a number satisfy the mod 10 checksum used by payment cards, IMEI numbers, and several national identifier formats? Passing means the number is self-consistent and free of common transcription typos. It says nothing about whether an account is open, funded, or real. Treat the check as a format filter inside test environments, feed it synthetic numbers from processor sandbox documentation, and never route live cardholder data through a test harness.

What the check proves and what it does not

The algorithm, described in ISO/IEC 7812 for payment card numbering, reads the digits from the right. The final digit is a check digit. Moving right to left, every second digit is doubled, results above 9 have 9 subtracted, all values are summed, and the number passes when the total is a multiple of 10.

That is the entire test. It is a typo detector and an input filter. Fraud screening, issuer verification, and account status require an authorization request across a payment network, which no checksum can replace.

Steps to run the test

  1. Strip spaces, hyphens, and other separators from the input string.
  2. Reject anything that is not a digit, and reject empty input.
  3. Apply length bounds before the checksum so out-of-range strings fail early.
  4. Start at the rightmost digit, set it aside as the check digit, then double every second digit to its left.
  5. Subtract 9 from each doubled value greater than 9, sum every digit, and compare the total mod 10 to zero.

What to look for in a validator or library

  • Documented handling of separators and whitespace.
  • Configurable length bounds instead of a hardcoded 16 digits.
  • Return values that separate "not numeric" from "checksum failed" so logs show the difference.
  • No network calls. A checksum function should be pure and offline.
  • A test suite that covers the odd edge cases, including all-zero strings and single-digit input.

Parameter bands worth setting

  • Length: accept 12 to 19 digits for primary account numbers under ISO/IEC 7812. Some card products sit above or below the familiar 16.
  • Doubling position: double digits at even offsets counted from the right, excluding the check digit. Counting from the left flips the result for odd-length input.
  • Doubled value rule: subtract 9 when the product exceeds 9, which matches summing the two digits of the product.
  • Character set: ASCII digits only. Unicode digit characters need normalization or an explicit rejection.
  • Volume: the routine costs constant time per digit, so fixture batches of 100,000 numbers are cheap to run in continuous integration.

Pitfalls that produce false results

  1. Doubling from the left instead of the right, which fails valid odd-length numbers.
  2. Doubling the check digit, which shifts the sequence and reports false negatives.
  3. Reading a pass as proof of a live account. Anyone can generate Luhn-valid digits.
  4. Testing against production data. Rules for card data handling forbid using real account numbers outside approved environments.
  5. Skipping length checks. A two-digit string can clear the checksum math in naive implementations.

FAQ

Does a passing Luhn check test mean the card is live?

No. The check verifies digit structure only. Account status comes from the issuer through an authorization request.

Can I use real card numbers in my tests?

No. Use the fixed test numbers published in processor sandbox documentation. They are built to pass or fail intended cases and carry no account behind them.

Why do some made-up numbers fail the check?

Because the final digit is a checksum over the preceding digits. Change any digit without recomputing the check digit and the number fails.

Does Luhn apply outside payments?

Yes. IMEI numbers use a Luhn check digit, and the algorithm shows up in several government identifier formats. The math is identical; only the length rules change.

What's New

Why I Can't Write a CVV Buying Guide

I can't write a buying guide for CVVs or stolen card data. I can help with card-fraud prevention, PCI DSS, and payment-security content instead.

Read our complete guide: What to Know Before You Buy CVV: Prices, Scams, and Legal Risks