About The Author Andy is the senior developer at Evoluted New Media and mostly works with CakePHP and Laravel. Before working full-time in the web industry he worked in Quantum … More about Andy Carter …

Testing Credit-Card Numbers In E-Commerce Checkouts (Cheat Sheet)

Smashing Newsletter Every week, we send out useful front-end & UX techniques. Subscribe and get the Smart Interface Design Checklists PDF delivered to your inbox. Your (smashing) email Subscribe →

As a developer, I work a lot with e-commerce websites and, as a result, with a lot of payment gateways. I’m fortunate that I get to work on many different projects for different clients, each with its own unique challenges. I have, therefore, found myself working with a lot of different payment gateways over the years, from the more familiar ones like PayPal and Stripe to some lesser known ones. While I love the variety of my work, I generally find working with payment gateways to be frustrating. I’m sure I’m not alone in this opinion! For many payment gateways, the documentation is poorly written, lengthy and, at times, difficult to find.

As a developer, I work a lot with e-commerce websites and, as a result, with a lot of payment gateways. I’m fortunate that I get to work on many different projects for different clients, each with its own unique challenges. I have, therefore, found myself working with a lot of different payment gateways over the years, from the more familiar ones like PayPal and Stripe to some lesser known ones.

While I love the variety of my work, I generally find working with payment gateways to be frustrating. I’m sure I’m not alone in this opinion! For many payment gateways, the documentation is poorly written, lengthy and, at times, difficult to find.

Further Reading on SmashingMag: Link

Thankfully, libraries such as OmniPay have helped me a lot and bring some consistency to working with the different services. However, while these libraries remove some of the need to check documentation, testing often still requires me to dig it up.

Testing is a crucial part of the development process, from initially setting up a payment system to the continual testing of a checkout process. For each stage, we need to work with test payment cards to run our code through the hoops and ensure the interface works well. I doubt any of us are paid well enough to happily reach for our wallet and put through a genuine payment with our own credit card! So, we look for the test payment card details relevant to the gateway we’re working with.

Even if we’ve already found the appropriate documentation at the beginning of development, what about a month or two later when we need to retest something? How about a year later, when everything has moved around on the official website of the payment gateway? Documentation easily gets misplaced, and we find ourselves hunting around for it. Even once we have our hands on it, locating the test details can be a challenge. Some gateways seem to love providing multiple PDF files, all mysteriously titled, with the test card details buried deep within one of them.

I have been increasingly finding myself in this situation. Moreover, developers aren’t the only ones who need these details in the course of a project. There are project managers, QA testers and the clients themselves. I was getting fed up with searching for card numbers. So, earlier this year, I decided to do something about it.

Back in April, I set up a new repository on GitHub and started compiling a list of all of the payment gateways I’ve used over the years and the test card numbers available for each of them. The idea was simply to create a single accessible resource of card numbers and other relevant details required to put test payments through.

I chose to host the list — or cheat sheet, if you will — on GitHub so that it could easily be maintained and updated. By making it a repository, others can quickly fork and contribute to it themselves, adding other payment gateways to the ones already represented. I released the cheat sheet under a Creative Commons Attribution-ShareAlike license to encourage people to share and adapt the list.

So, here are the test card numbers for some of the major payment gateways and a few lesser known ones.

PayPal

One of the largest online payment companies, PayPal is a popular choice with clients for its recognizable brand (even if it is less popular with those who have to implement it). The following test cards are available in PayPal sandbox mode and can be used with any card expiry date set in the future.

Card type Card number(s) American Express 378282246310005 and 371449635398431 American Express Corporate 378734493671000 BankCard (Australia) 5610591081018250 Diners Club 30569309025904 and 38520000023237 Discover 6011111111111117 and 6011000990139424 JCB 3530111333300000 and 3566002020360505 MasterCard 5555555555554444 and 5105105105105100 Visa 4111111111111111, 4012888888881881 and 4222222222222

Stripe

Stripe is a much younger (and, may I say, trendier?) payment company than PayPal. It has quickly proven to be popular with developers, thanks to its simplicity of implementation and solid documentation, which is always a plus.

All of the following card numbers will produce successful transactions in test mode using any future expiry date.

Card type Card number American Express 378282246310005 and 371449635398431 Diners Club 30569309025904 and 38520000023237 Discover 6011111111111117 and 6011000990139424 JCB 3530111333300000 and 3566002020360505 MasterCard 5555555555554444 MasterCard (debit) 5200828282828210 MasterCard (prepaid) 5105105105105100 Visa 4242424242424242 and 4012888888881881 Visa (debit) 4000056655665556

Full details of Stripe’s test cards can be found on the “Testing” page of its documentation.

Authorize.Net

Like PayPal, Authorize.Net has been around for a while. The following test credit-card numbers will only work in the sandbox. If the card’s CVV2 code is required, use any three-digit combination, except for American Express, which requires a four-digit combination. See the “Testing Guide” for further details.

Card type Card number(s) American Express 370000000000002 Diners Club (Carte Blanche) 38000000000006 Discover 6011000000000012 JCB 3088000000000017 MasterCard 5424000000000015 Visa 4007000000027, 4012888818888 and 4111111111111111

SagePay

SagePay is a popular British payment gateway. A lot of card numbers are available for testing that result in various 3DSecure statuses. All of SagePay’s test cards use the address “88” and postcode “412.”

Card type Card number Issue CVV2 3DS American Express 374200000000004 1234 N/A Diners Club 36000000000008 123 N/A JCB 3569990000000009 123 N/A Laser 6304990000000000044 123 N/A Maestro (UK) 5641820000000005 and 6759000000005 01 123 Y Maestro (Germany) 6705000000008 01 123 Y Maestro (Ireland) 6777000000007 01 123 Y Maestro (Spain) 6766000000000 01 123 Y Maestro (international) 300000000000000004 123 Y MasterCard (credit) 5404000000000001 123 Y MasterCard (credit) 5404000000000043 123 N MasterCard (credit) 5404000000000084 123 U MasterCard (credit) 5404000000000068 123 E MasterCard (debit) 5573470000000001 123 Y Visa 4929000000006 123 Y Visa 4929000005559 123 N Visa 4929000000014 123 U Visa 4929000000022 123 E Visa Corporate 4484000000002 123 N Visa (debit and Delta) 4462000000000003 123 Y Visa Electron 4917300000000008 123 Y

The 3DSecure (3DS) responses are:

Y . Enrolled and will progress to the password page to complete verification

. Enrolled and will progress to the password page to complete verification N . Not enrolled and will return a 3DSecureStatus=NOTAVAILABLE to your system

. Not enrolled and will return a to your system U . Unable to verify enrolment and will return a 3DSecureStatus=NOTAVAILABLE to your system

. Unable to verify enrolment and will return a to your system E. Error occurred during 3D Secure verification, and a 3DSecureStatus=ERROR will be returned to your system

Full details can be found on the “Test Card Details for Your Test Transactions” page.

Braintree

The following card numbers will not trigger errors.

Card type Card number(s) American Express 378282246310005 and 371449635398431 Discover 6011111111111117 JCB 3530111333300000 Maestro 6304000000000000 Mastercard 5555555555554444 Visa 4111111111111111, 4005519200000004, 4009348888881881, 4012000033330026, 4012000077777777, 4012888888881881, 4217651111111119 and 4500600000000061

To trigger an unsuccessful credit-card verification, use one of the following cards:

Card type Card number(s) Verification response American Express 378734493671000 Processor declined Discover 6011000990139424 Processor declined Mastercard 5105105105105100 Processor declined Visa 4000111111111115 Processor declined JCB 3566002020360505 Failed (3000)

Further details about using Braintree’s test payment numbers can be found on its “Testing” page.

Ogone

Card type Card number Visa 4111111111111111

Details about using test cards in Ogone can be found in “Create and Configure Your Ogone Test Account.”

Pay360

Card type Card number 3DS Successful authorization American Express 9905000000005139 Y Y American Express 9905000000000015 N Y American Express 9905000000010253 U Y American Express 9905000000005287 Y N American Express 9905000000000163 N N American Express 9905000000010402 U N Mastercard (debit) 9900000000005159 Y Y Mastercard (debit) 9900000000000010 N Y Mastercard (debit) 9900000000010258 U Y Mastercard (debit) 9900000000005282 Y N Mastercard (debit) 9900000000000168 N N Mastercard (debit) 9900000000010407 U N Mastercard (credit) 9901000000005133 Y Y Mastercard (credit) 9901000000000019 N Y Mastercard (credit) 9901000000010257 U Y Mastercard (credit) 9901000000005281 Y Y Mastercard (credit) 9901000000000167 N Y Mastercard (credit) 9901000000010406 U Y Visa (debit) 9902000000005132 Y Y Visa (debit) 9902000000000018 N Y Visa (debit) 9902000000010256 U Y Visa (debit) 9902000000005280 Y N Visa (debit) 9902000000000166 N N Visa (debit) 9902000000010405 U N Visa (credit) 9903000000005131 Y Y Visa (credit) 9903000000000017 N Y Visa (credit) 9903000000010255 U Y Visa (credit) 9903000000005289 Y N Visa (credit) 9903000000000165 N N Visa (credit) 9903000000010404 U N

The test card details above can be found on Pay360’s “Test Cards” page.

PayPoint

Card type Card number(s) Maestro 491182014295916748 Mastercard (credit) 5555555555554444 and 5105105105105100 Visa 4444333322221111 and 4444444444441111

RedSys

Card Number Expiration CVV2 CIP code 4548812049400004 12/20 123 123456

WePay

Full details of WePay’s test cards can be found on the “Testing” page of its documentation.

Card type Card number CVV2 American Express 378282246310005 and 371449635398431 Any MasterCard 5496198584584769 Any Visa 4003830171874018 Any

WorldPay

WorldPay test cards do not have a verification code or issue number.

Card type Card number(s) AirPlus 122000000000003 American Express 34343434343434 Carte Bleue 5555555555554444 Dankort 5019717010103742 Diners Club 36700102000000 and 36148900647913 Discover 6011000400000000 JCB 3528000700000000 Laser 630495060000000000 and 630490017740292441 Maestro 6759649826438453 and 67999990100000000019 MasterCard 5555555555554444 and 5454545454545454 Visa 4444333322221111, 4911830000000 and 4917610000000000 Visa (debit) 4462030000000000 and 4917610000000000003 Visa Electron (UK only) 4917300800000000 Visa (purchasing) 4484070000000000

Other Resources

If you’re building a website that will take payment details to be passed to the relevant payment gateway, doing some local validation before attempting to process the payment can be useful. This will improve the user experience and speed things up a little. Credit-card numbers can be checked using the Luhn algorithm, and many libraries out there will help you do this. The following JavaScript plugins all provide a simple way to integrate this validation and avoid issues with PCI compliance, because the card details don’t have to be sent to your server to be tested.

jQuery Credit Card Validator, Pawel Decowski jQuery plugin for detecting card types and validating card numbers

Credit Card Validator, Braintree Card number validation from the Braintree payment gateway.

jQuery.payment, Stripe Can be used to validate inputs and to format numbers

Most payment gateways use test card numbers that can be checked using the Luhn algorithm; so, you shouldn’t have any issue validating during testing.

Final Words

Hopefully, the test card numbers presented here will be of use to you. If a payment gateway that you use is missing, feel free to contribute it to the original cheat sheet repository.

Happy testing!