This is an industry standard algorithm I ported to python. It works on all major credit cards. You pass in the credit card number as a string and it returns 1 for a valid card or 0 for an invalid card
Python, 18 lines
This recipe was originally written for a now-defunct e-commerce application used within Zope.
It will save you time and money before trying to process a bad card with your credit card vendor, because you won't waste money trying to authorize a bad card with your credit card processing vendor.
The full suite of creditValidation methods are available here: