summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epirts.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/epirts.js b/epirts.js
index ad3044f..c7d4712 100644
--- a/epirts.js
+++ b/epirts.js
@@ -94,6 +94,19 @@ var Stripe = Epirts = (function() {
};
pub.cardType = function(number) {
+ var p;
+ var i;
+
+ /* Approximate IIN prefixes */
+ p = {};
+ for (i = 40; i <= 49; ++i) p[i] = 'Visa';
+ for (i = 51; i <= 55; ++i) p[i] = 'MasterCard';
+ p[34] = p[37] = 'American Express';
+ p[35] = 'JCB';
+ p[60] = p[62] = p[64] = p[65] = 'Discover';
+ p[30] = p[36] = p[38] = p[39] = 'Diners Club';
+
+ return p[(number + '').slice(0, 2)] || 'Unknown';
};
return pub;