diff options
-rw-r--r-- | epirts.js | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -44,6 +44,25 @@ var Stripe = Epirts = (function() { pub.validateCardNumber = function(number) { }; + pub.luhnCheck = function(number) { + var i; + var digit; + var sum; + + number += ''; + sum = 0; + for (i = 0; i < number.length; ++i) { + digit = number.charAt(number.length - 1 - i); + digit = parseInt(digit); + digit *= i % 2 + 1; + if (digit > 9) { + digit -= 9; + } + sum += digit; + } + return sum % 10 === 0; + }; + pub.validateExpiry = function(month, year) { }; |