summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epirts.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/epirts.js b/epirts.js
index 3db67d0..7053626 100644
--- a/epirts.js
+++ b/epirts.js
@@ -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) {
};