Last active
December 20, 2015 15:59
-
-
Save JamoCA/6157875 to your computer and use it in GitHub Desktop.
ColdFusion UDF to test if a credit card number matches test card numbers provided by credit card merchants (as opposed to only validating against the Luhn algorithm.) (NOTE: You can test this at CFLive.net)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
function isTestCC(cc){ | |
var testCCs = "135412345678911, 2211000000000001, 2211000000000019, 2211000000000027, | |
2211000000000035, 2211000000000043, 2211000000000050, 304985028090561515, 30569309025904, | |
3111111111111117, 340000000000009, 340682458348749, 342135898797783, 342337649030528, | |
342650299263839, 342781835011463, 342955624318368, 344058488426266, 345672983453416, | |
345796298727014, 347279493269015, 348771682068975, 3530111333300000, 3566002020140006, | |
3566002020360505, 3566111111111113, 3569990000000009, 36438999960016, 370000000000002, | |
370123456789017, 371449635398431, 375529360131002, 378282246310005, 378734493671000, | |
38520000023237, 4000000000000002, 4000000000000010, 4000000000000028, 4000000000000036, | |
4000000000000069, 4000000000000101, 4000000000000119, 4000000000000127, 4000000000000341, | |
4003830171874018, 4007000000027, 4012001036273338, 4012001037141369, 4012001037461114, | |
4012001038443335, 4012001038488884, 4012888888881881, 4024007101934890, 4110716719147654, | |
4111111111111111, 4112296825756779, 4112530021797363, 4112653620165475, 4112836497303994, | |
4113864427850982, 4116196783374209, 4116480559370132, 4116509050569147, 4119692004990226, | |
4119862760338320, 4217651111111119, 4222222222222, 4242424242424242, 4444333322221111, | |
4444444444444422, 4444444444444455, 4444444444446666, 4539785000002517, 4539791001730106, | |
4556761029983886, 4715320629000001, 4917480000000008, 4917484589897107, 5019717010103742, | |
50339619890917, 5040081111111119, 5102580000000098, 5102881917494147, 5105105105105100, | |
5106447623213738, 5111111111111118, 5116381817387388, 5120939736834980, 5122415444933925, | |
5123695007103193, 5152370491539153, 5155239927190195, 5155659853141666, 5184778657904478, | |
5199339067794810, 5200000000000007, 5301250070000050, 5424000000000015, 5496198584584769, | |
5500000000000004, 5555555555554444, 5555555555557777, 5555555555559922, 5555555555559955, | |
5610591081018250, 586824160825533338, 6011000000000004, 6011000000000012, 6011000990139424, | |
6011111111111117, 6011118186183608, 6011191466819647, 6011234567890123, 6011587918359498, | |
6011604410824034, 6011624665174125, 6011648040903965, 6011739196887563, 6011750048255222, | |
6011769851691760, 6011789277338945, 6011976857117225, 6111111111111116, 6304000000000000026, | |
630400000000000018, 63040000000000026, 6304000000000018, 6331101999990016, 6334589898000001, | |
6334971111111114, 6706952343050001161, 6706952343050001237, 6709000000000000026, 6759950000000162, | |
676782009988007706, 76009244561"; | |
cc = reReplace(cc,"[^0-9]","","all"); | |
testCCs = reReplace(testCCs,"[^0-9,]","","all"); | |
return YesNoFormat(listfind(testCCs, cc)); | |
} | |
</cfscript> | |
<CFOUTPUT> | |
4444-3333-2222-1111 = #isTestCC("4444-3333-2222-1111")#<br> | |
1354 1234 5678 911 = #isTestCC("1354 1234 5678 911")#<br> | |
</CFOUTPUT> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment