summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-12-03 17:13:25 (EST)
committer P. J. McDermott <pj@pehjota.net>2015-12-03 17:13:25 (EST)
commit5009c93c2dd2d637e27e7895ccc3bf3ecc67595c (patch)
tree9c012d491d86d5d5612c7f812b5e4aa9fc4eb917
parent12b7a1e68cedab0dca50ab0a24368d44d71e5deb (diff)
downloadepirts.js-5009c93c2dd2d637e27e7895ccc3bf3ecc67595c.zip
epirts.js-5009c93c2dd2d637e27e7895ccc3bf3ecc67595c.tar.gz
epirts.js-5009c93c2dd2d637e27e7895ccc3bf3ecc67595c.tar.bz2
Epirts.card.createToken(): Split out JSONP code
-rw-r--r--epirts.js38
1 files changed, 22 insertions, 16 deletions
diff --git a/epirts.js b/epirts.js
index 68f9cbc..82d17e7 100644
--- a/epirts.js
+++ b/epirts.js
@@ -49,9 +49,7 @@ var Stripe = Epirts = (function() {
'address_country'];
var _cb_time = (new Date()).getTime();
- pub.createToken = function(data, arg2, arg3) {
- var callback;
- var amount;
+ _createTokenJSONP = function(data, amount, callback) {
var where;
var script;
var func;
@@ -59,19 +57,6 @@ var Stripe = Epirts = (function() {
var i;
var prop;
- if (!data || typeof data !== 'object') {
- throw new Error("Invalid card");
- } else if (_key === undefined) {
- throw new Error("Publishable key not set");
- }
- if (typeof arg2 === 'function') {
- callback = arg2;
- } else if (typeof arg2 === 'number' ||
- typeof arg2 === 'string') {
- amount = arg2;
- callback = arg3;
- }
-
where = document.getElementsByTagName('script')[0];
script = document.createElement('script');
script.type = 'text/javascript';
@@ -102,6 +87,27 @@ var Stripe = Epirts = (function() {
where.parentNode.insertBefore(script, where);
};
+ pub.createToken = function(data, arg2, arg3) {
+ var callback;
+ var amount;
+
+ if (!data || typeof data !== 'object') {
+ throw new Error("Invalid card");
+ } else if (_key === undefined) {
+ throw new Error("Publishable key not set");
+ }
+ if (typeof arg2 === 'function') {
+ amount = undefined;
+ callback = arg2;
+ } else if (typeof arg2 === 'number' ||
+ typeof arg2 === 'string') {
+ amount = arg2;
+ callback = arg3;
+ }
+
+ _createTokenJSONP(data, amount, callback);
+ };
+
pub.validateCardNumber = function(number) {
number = (number + '').replace(/\s|-/g);
if (number.match(/\D/)) {