summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-03-15 22:39:52 (EDT)
committer P. J. McDermott <pj@pehjota.net>2015-03-15 22:39:52 (EDT)
commit64d0446f24411746424c4a9f004ace7238c2d3fe (patch)
treed11fbfada4538f63abc2d79eb9a37987b551c25c
parent355d5b64585a99476ea4bff1e48a4b7e7402ea4f (diff)
downloadepirts.js-64d0446f24411746424c4a9f004ace7238c2d3fe.zip
epirts.js-64d0446f24411746424c4a9f004ace7238c2d3fe.tar.gz
epirts.js-64d0446f24411746424c4a9f004ace7238c2d3fe.tar.bz2
Epirts.card.cardType(): Implement
-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;