braintree-web
Advanced tools
Comparing version
@@ -27,6 +27,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.braintree || (g.braintree = {})).americanExpress = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
* | ||
* americanExpress.create({client: client}, function (err, instance) { | ||
* americanExpress.create({client: clientInstance}, function (createErr, americanExpressInstance) { | ||
* var options = {nonce: existingBraintreeNonce}; | ||
* instance.getRewardsBalance(options, function (err, payload) { | ||
* if (err || payload.error) { | ||
* americanExpressInstance.getRewardsBalance(options, function (getErr, payload) { | ||
* if (getErr || payload.error) { | ||
* // Handle error | ||
@@ -90,6 +90,6 @@ * return; | ||
* | ||
* americanExpress.create({client: client}, function (err, instance) { | ||
* americanExpress.create({client: clientInstance}, function (createErr, americanExpressInstance) { | ||
* var options = {nonce: existingAmericanExpressNonce}; | ||
* instance.getExpressCheckoutProfile(options, function (err, payload) { | ||
* if (err) { | ||
* americanExpressInstance.getExpressCheckoutProfile(options, function (getErr, payload) { | ||
* if (getErr) { | ||
* // Handle error | ||
@@ -152,3 +152,3 @@ * return; | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
var BraintreeError = _dereq_('../lib/error'); | ||
@@ -155,0 +155,0 @@ var AmericanExpress = _dereq_('./american-express'); |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(t.braintree||(t.braintree={})).americanExpress=e()}}(function(){return function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=n[s]={exports:{}};t[s][0].call(p.exports,function(e){var n=t[s][1][e];return o(n?n:e)},p,p.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t,n){"use strict";function r(e){this._client=e.client}var o=e("../lib/error"),i=e("../lib/deferred");r.prototype.getRewardsBalance=function(e,t){if("function"!=typeof t)throw new o({type:o.types.MERCHANT,message:"getRewardsBalance must include a callback function."});return t=i(t),e.nonce?void this._client.request({method:"get",endpoint:"payment_methods/amex_rewards_balance",data:{_meta:{source:"american-express"},paymentMethodNonce:e.nonce}},function(e,n){e?t(new o({type:o.types.NETWORK,message:"A network error occured when getting the American Express rewards balance.",details:{originalError:e}})):t(null,n)}):void t(new o({type:o.types.MERCHANT,message:"getRewardsBalance must be called with a nonce."}))},r.prototype.getExpressCheckoutProfile=function(e,t){if("function"!=typeof t)throw new o({type:o.types.MERCHANT,message:"getExpressCheckoutProfile must include a callback function."});return t=i(t),e.nonce?void this._client.request({method:"get",endpoint:"payment_methods/amex_express_checkout_cards/"+e.nonce,data:{_meta:{source:"american-express"},paymentMethodNonce:e.nonce}},function(e,n){e?t(new o({type:o.types.NETWORK,message:"A network error occured when getting the American Express Checkout nonce profile.",details:{originalError:e}})):t(null,n)}):void t(new o({type:o.types.MERCHANT,message:"getExpressCheckoutProfile must be called with a nonce."}))},t.exports=r},{"../lib/deferred":3,"../lib/error":5}],2:[function(e,t,n){"use strict";function r(e,t){var n;if("function"!=typeof t)throw new i({type:i.types.MERCHANT,message:"create must include a callback function."});return t=a(t),null==e.client?void t(new i({type:i.types.MERCHANT,message:"A Client is required when instantiating American Express."})):(n=e.client.getConfiguration().analyticsMetadata.sdkVersion,n!==o?void t(new i({type:i.types.MERCHANT,message:"Client (version "+n+") and American Express (version "+o+") components must be from the same SDK version."})):void t(null,new s(e)))}var o="3.0.0-beta.8",i=e("../lib/error"),s=e("./american-express"),a=e("../lib/deferred");t.exports={create:r,VERSION:o}},{"../lib/deferred":3,"../lib/error":5,"./american-express":1}],3:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],4:[function(e,t,n){"use strict";function r(e,t){return t=null==t?"":t,e.reduce(function(e,n){return e[n]=t+n,e},{})}t.exports=r},{}],5:[function(e,t,n){"use strict";function r(e){if(!r.types.hasOwnProperty(e.type))throw new Error(e.type+" is not a valid type.");if(!e.message)throw new Error("Error message required.");this.message=e.message,this.type=e.type,this.details=e.details}var o=e("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=o(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),t.exports=r},{"./enumerate":4}]},{},[2])(2)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(t.braintree||(t.braintree={})).americanExpress=e()}}(function(){return function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=n[s]={exports:{}};t[s][0].call(p.exports,function(e){var n=t[s][1][e];return o(n?n:e)},p,p.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t,n){"use strict";function r(e){this._client=e.client}var o=e("../lib/error"),i=e("../lib/deferred");r.prototype.getRewardsBalance=function(e,t){if("function"!=typeof t)throw new o({type:o.types.MERCHANT,message:"getRewardsBalance must include a callback function."});return t=i(t),e.nonce?void this._client.request({method:"get",endpoint:"payment_methods/amex_rewards_balance",data:{_meta:{source:"american-express"},paymentMethodNonce:e.nonce}},function(e,n){e?t(new o({type:o.types.NETWORK,message:"A network error occured when getting the American Express rewards balance.",details:{originalError:e}})):t(null,n)}):void t(new o({type:o.types.MERCHANT,message:"getRewardsBalance must be called with a nonce."}))},r.prototype.getExpressCheckoutProfile=function(e,t){if("function"!=typeof t)throw new o({type:o.types.MERCHANT,message:"getExpressCheckoutProfile must include a callback function."});return t=i(t),e.nonce?void this._client.request({method:"get",endpoint:"payment_methods/amex_express_checkout_cards/"+e.nonce,data:{_meta:{source:"american-express"},paymentMethodNonce:e.nonce}},function(e,n){e?t(new o({type:o.types.NETWORK,message:"A network error occured when getting the American Express Checkout nonce profile.",details:{originalError:e}})):t(null,n)}):void t(new o({type:o.types.MERCHANT,message:"getExpressCheckoutProfile must be called with a nonce."}))},t.exports=r},{"../lib/deferred":3,"../lib/error":5}],2:[function(e,t,n){"use strict";function r(e,t){var n;if("function"!=typeof t)throw new i({type:i.types.MERCHANT,message:"create must include a callback function."});return t=a(t),null==e.client?void t(new i({type:i.types.MERCHANT,message:"A Client is required when instantiating American Express."})):(n=e.client.getConfiguration().analyticsMetadata.sdkVersion,n!==o?void t(new i({type:i.types.MERCHANT,message:"Client (version "+n+") and American Express (version "+o+") components must be from the same SDK version."})):void t(null,new s(e)))}var o="3.0.0-beta.9",i=e("../lib/error"),s=e("./american-express"),a=e("../lib/deferred");t.exports={create:r,VERSION:o}},{"../lib/deferred":3,"../lib/error":5,"./american-express":1}],3:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],4:[function(e,t,n){"use strict";function r(e,t){return t=null==t?"":t,e.reduce(function(e,n){return e[n]=t+n,e},{})}t.exports=r},{}],5:[function(e,t,n){"use strict";function r(e){if(!r.types.hasOwnProperty(e.type))throw new Error(e.type+" is not a valid type.");if(!e.message)throw new Error("Error message required.");this.message=e.message,this.type=e.type,this.details=e.details}var o=e("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=o(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),t.exports=r},{"./enumerate":4}]},{},[2])(2)}); |
CHANGELOG | ||
========= | ||
## 3.0.0-beta.9 | ||
* No longer throws exceptions when using `require('braintree-web')` during server-side rendering with libraries such as React.js. | ||
* `index.js` and `debug.js` in the npm/bower modules no longer reference `package.json`. | ||
* Ajax errors in IE9 now report as general error instead of an empty string. It is impossible to get details additional about network errors in IE9 XDomainRequests. | ||
* UnionPay | ||
* Expiration date or month/year together are now optional as some UnionPay cards do not have expiration dates. | ||
* PayPal | ||
* All `create` options aside from `client` have now moved to `tokenize`. See __BREAKING CHANGES__. | ||
* For one-time checkout, add `intent` option which can be `sale` or `authorize` | ||
* HTTPS is no longer required | ||
* Add `offerCredit` as an option to `tokenize` for offering customers PayPal Credit as a form of payment | ||
__BREAKING CHANGES__ | ||
* PayPal's `create` options have moved to `tokenize`. Deferring these options to tokenization time allows greater flexibility in your checkout experience. | ||
``` | ||
braintree.paypal.create({ | ||
client: clientInstance | ||
}, function (err, paypalInstance) { | ||
paypalInstance.tokenize({ | ||
flow: 'checkout', | ||
amount: '10.00', | ||
currency: 'USD' | ||
}, function (tokenizeErr, payload) { | ||
// ... | ||
}); | ||
}); | ||
``` | ||
## 3.0.0-beta.8 | ||
@@ -5,0 +35,0 @@ |
@@ -86,4 +86,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.braintree || (g.braintree = {})).client = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
* createClient({ | ||
* authorization: CLIENT_TOKEN | ||
* }, function (err, client) { | ||
* authorization: CLIENT_AUTHORIZATION | ||
* }, function (createErr, clientInstance) { | ||
* var form = document.getElementById('my-form-id'); | ||
@@ -104,8 +104,8 @@ * var data = { | ||
* // For an alternative to the following, use Hosted Fields. | ||
* client.request({ | ||
* clientInstance.request({ | ||
* endpoint: 'payment_methods/credit_cards', | ||
* method: 'post', | ||
* data: data | ||
* }, function (err, response) { | ||
* if (err) { throw new Error(err); } | ||
* }, function (requestErr, response) { | ||
* if (requestErr) { throw new Error(requestErr); } | ||
* | ||
@@ -212,3 +212,3 @@ * console.log('Got nonce:', response.creditCards[0].nonce); | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"../lib/constants":13,"../lib/create-authorization-data":14,"../lib/error":17,"../lib/uuid":22,"./request":7}],3:[function(_dereq_,module,exports){ | ||
},{"../lib/constants":13,"../lib/create-authorization-data":14,"../lib/error":17,"../lib/uuid":23,"./request":7}],3:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -219,3 +219,3 @@ | ||
var getConfiguration = _dereq_('./get-configuration').getConfiguration; | ||
var packageVersion = "3.0.0-beta.8"; | ||
var packageVersion = "3.0.0-beta.9"; | ||
var deferred = _dereq_('../lib/deferred'); | ||
@@ -236,4 +236,4 @@ | ||
* createClient({ | ||
* authorization: CLIENT_TOKEN | ||
* }, function (err, client) { | ||
* authorization: CLIENT_AUTHORIZATION | ||
* }, function (createErr, clientInstance) { | ||
* ... | ||
@@ -294,2 +294,3 @@ * }); | ||
var querystring = _dereq_('../../lib/querystring'); | ||
var once = _dereq_('../../lib/once'); | ||
var prepBody = _dereq_('./prep-body'); | ||
@@ -304,3 +305,3 @@ var parseBody = _dereq_('./parse-body'); | ||
function request(options, callback) { | ||
function request(options, cb) { | ||
var status, resBody; | ||
@@ -312,5 +313,4 @@ var method = (options.method || 'GET').toUpperCase(); | ||
var req = getRequestObject(); | ||
var callback = once(cb || Function.prototype); | ||
callback = callback || function () {}; | ||
if (method === 'GET') { | ||
@@ -340,3 +340,3 @@ url = querystring.queryify(url, body); | ||
req.onerror = function () { | ||
callback(req.responseText, null, req.status); | ||
callback(constants.errors.UNKNOWN_ERROR, null, req.status); | ||
}; | ||
@@ -359,5 +359,5 @@ | ||
setTimeout(function () { | ||
try { | ||
req.send(prepBody(method, body)); | ||
}, 1); | ||
} catch (e) { /* ignored */ } | ||
} | ||
@@ -370,3 +370,3 @@ | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"../../lib/querystring":21,"./constants":5,"./parse-body":10,"./prep-body":11}],5:[function(_dereq_,module,exports){ | ||
},{"../../lib/once":20,"../../lib/querystring":22,"./constants":5,"./parse-body":10,"./prep-body":11}],5:[function(_dereq_,module,exports){ | ||
module.exports={ | ||
@@ -378,3 +378,3 @@ "errors": { | ||
} | ||
}; | ||
} | ||
@@ -393,2 +393,3 @@ },{}],6:[function(_dereq_,module,exports){ | ||
var ajaxIsAvaliable; | ||
var JSONPDriver = _dereq_('./jsonp-driver'); | ||
@@ -398,14 +399,17 @@ var AJAXDriver = _dereq_('./ajax-driver'); | ||
var isHTTP = _dereq_('./is-http'); | ||
var ajaxIsAvaliable = !(isHTTP() && /MSIE\s(8|9)/.test(getUserAgent())); | ||
if (ajaxIsAvaliable) { | ||
module.exports = function () { | ||
AJAXDriver.request.apply(null, arguments); | ||
}; | ||
} else { | ||
module.exports = function () { | ||
JSONPDriver.request.apply(null, arguments); | ||
}; | ||
function isAjaxAvailable() { | ||
if (ajaxIsAvaliable == null) { | ||
ajaxIsAvaliable = !(isHTTP() && /MSIE\s(8|9)/.test(getUserAgent())); | ||
} | ||
return ajaxIsAvaliable; | ||
} | ||
module.exports = function () { | ||
var request = isAjaxAvailable() ? AJAXDriver.request : JSONPDriver.request; | ||
request.apply(null, arguments); | ||
}; | ||
},{"./ajax-driver":4,"./get-user-agent":6,"./is-http":8,"./jsonp-driver":9}],8:[function(_dereq_,module,exports){ | ||
@@ -537,3 +541,3 @@ (function (global){ | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"../../lib/querystring":21,"../../lib/uuid":22,"./constants":5}],10:[function(_dereq_,module,exports){ | ||
},{"../../lib/querystring":22,"../../lib/uuid":23,"./constants":5}],10:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -601,3 +605,3 @@ | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
var PLATFORM = 'web'; | ||
@@ -664,3 +668,3 @@ | ||
},{"../lib/polyfill":20}],15:[function(_dereq_,module,exports){ | ||
},{"../lib/polyfill":21}],15:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -761,3 +765,3 @@ | ||
var parser = document.createElement('a'); | ||
var parser; | ||
var legalHosts = { | ||
@@ -779,2 +783,3 @@ 'paypal.com': 1, | ||
parser = parser || document.createElement('a'); | ||
parser.href = url; | ||
@@ -797,2 +802,18 @@ pieces = parser.hostname.split('.'); | ||
},{}],20:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
function once(fn) { | ||
var called = false; | ||
return function () { | ||
if (!called) { | ||
called = true; | ||
fn.apply(null, arguments); | ||
} | ||
}; | ||
} | ||
module.exports = once; | ||
},{}],21:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -836,3 +857,3 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],21:[function(_dereq_,module,exports){ | ||
},{}],22:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -928,3 +949,3 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],22:[function(_dereq_,module,exports){ | ||
},{}],23:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -931,0 +952,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(e.braintree||(e.braintree={})).client=t()}}(function(){return function t(e,n,o){function r(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return r(n?n:t)},c,c.exports,t,e,n,o)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<o.length;a++)r(o[a]);return r}({1:[function(t,e,n){"use strict";function o(t){var e,n;if(t=t||{},e=JSON.stringify(t),n=t.gatewayConfiguration,!n)throw new a({type:a.types.INTERNAL,message:"Missing gatewayConfiguration."});["assetsUrl","clientApiUrl","configUrl"].forEach(function(t){if(t in n&&!i(n[t]))throw new a({type:a.types.MERCHANT,message:"Invalid "+t+"."})}),this.getConfiguration=function(){return JSON.parse(e)},this._request=r,this._baseUrl=t.gatewayConfiguration.clientApiUrl+"/v1/",this._configuration=this.getConfiguration(),this.toJSON=this.getConfiguration}var r=t("./request"),i=t("../lib/is-whitelisted-domain"),a=t("../lib/error"),s=t("../lib/add-metadata"),u=t("../lib/deferred");o.prototype.request=function(t,e){var n;return t.method?t.endpoint||(n="options.endpoint is required."):n="options.method is required.",n?(e=u(e),void e(new a({type:a.types.MERCHANT,message:n}))):void this._request({url:this._baseUrl+t.endpoint,method:t.method,data:s(this._configuration,t.data),timeout:t.timeout},e)},e.exports=o},{"../lib/add-metadata":12,"../lib/deferred":15,"../lib/error":17,"../lib/is-whitelisted-domain":18,"./request":7}],2:[function(t,e,n){(function(n){"use strict";function o(t,e){var o,f,c,l,d=a(),p={merchantAppId:n.location.host,platform:s.PLATFORM,sdkVersion:s.VERSION,source:s.SOURCE,integration:s.INTEGRATION,integrationType:s.INTEGRATION,sessionId:d};try{f=u(t.authorization)}catch(y){return void e(new r({type:r.types.MERCHANT,message:"Authorization is invalid. Make sure your client token or tokenization key is valid."}))}c=f.attrs,l=f.configUrl,c._meta=p,c.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION,i({url:l,method:"GET",data:c},function(n,i){return n?void e(new r({type:r.types.NETWORK,message:"Cannot contact the gateway at this time.",details:n})):(o={authorization:t.authorization,analyticsMetadata:p,gatewayConfiguration:i},void e(null,o))})}var r=t("../lib/error"),i=t("./request"),a=t("../lib/uuid"),s=t("../lib/constants"),u=t("../lib/create-authorization-data");e.exports={getConfiguration:o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../lib/constants":13,"../lib/create-authorization-data":14,"../lib/error":17,"../lib/uuid":22,"./request":7}],3:[function(t,e,n){"use strict";function o(t,e){if("function"!=typeof e)throw new r({type:r.types.MERCHANT,message:"create must include a callback function."});return e=u(e),t.authorization?void a(t,function(t,n){var o;if(t)return void e(t);try{o=new i(n)}catch(r){return void e(r)}e(null,o)}):void e(new r({type:r.types.MERCHANT,message:"options.authorization is required."}))}var r=t("../lib/error"),i=t("./client"),a=t("./get-configuration").getConfiguration,s="3.0.0-beta.8",u=t("../lib/deferred");e.exports={create:o,VERSION:s}},{"../lib/deferred":15,"../lib/error":17,"./client":1,"./get-configuration":2}],4:[function(t,e,n){(function(n){"use strict";function o(){return f?new XMLHttpRequest:new XDomainRequest}function r(t,e){var n,r,c=(t.method||"GET").toUpperCase(),l=t.url,d=t.data||{},p=null==t.timeout?6e4:t.timeout,y=o();e=e||function(){},"GET"===c&&(l=i.queryify(l,d),d=null),f?y.onreadystatechange=function(){4===y.readyState&&(n=y.status,r=s(y.responseText),n>=400||0===n?e(r||{errors:u.errors.UNKNOWN_ERROR},null,500):n>0&&e(null,r,n))}:(y.onload=function(){e(null,s(y.responseText),y.status)},y.onerror=function(){e(y.responseText,null,y.status)},y.onprogress=function(){},y.ontimeout=function(){e(u.errors.TIMEOUT_ERROR,null,500)}),y.open(c,l,!0),y.timeout=p,f&&"POST"===c&&y.setRequestHeader("Content-Type","application/json"),setTimeout(function(){y.send(a(c,d))},1)}var i=t("../../lib/querystring"),a=t("./prep-body"),s=t("./parse-body"),u=t("./constants"),f=n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest;e.exports={request:r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/querystring":21,"./constants":5,"./parse-body":10,"./prep-body":11}],5:[function(t,e,n){e.exports={errors:{UNKNOWN_ERROR:"Unknown error",TIMEOUT_ERROR:"Request timed out waiting for a reply",INVALID_TIMEOUT:"Timeout must be a number"}}},{}],6:[function(t,e,n){(function(t){"use strict";e.exports=function(){return t.navigator.userAgent}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],7:[function(t,e,n){"use strict";var o=t("./jsonp-driver"),r=t("./ajax-driver"),i=t("./get-user-agent"),a=t("./is-http"),s=!(a()&&/MSIE\s(8|9)/.test(i()));s?e.exports=function(){r.request.apply(null,arguments)}:e.exports=function(){o.request.apply(null,arguments)}},{"./ajax-driver":4,"./get-user-agent":6,"./is-http":8,"./jsonp-driver":9}],8:[function(t,e,n){(function(t){"use strict";e.exports=function(){return"http:"===t.location.protocol}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(t,e,n){(function(n){"use strict";function o(){}function r(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function i(t,e){var o=document.createElement("script"),r=!1;return o.src=t,o.async=!0,o.onerror=function(){n[e]({message:l.errors.UNKNOWN_ERROR,status:500})},o.onload=o.onreadystatechange=function(){r||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState||(r=!0,o.onload=o.onreadystatechange=null)},o}function a(t){try{delete n[t]}catch(e){n[t]=null}}function s(t,e){y[e]=setTimeout(function(){y[e]=null,n[e]({error:l.errors.TIMEOUT_ERROR,status:500}),n[e]=function(){a(e)}},t)}function u(t,e,i){e=e||o,n[i]=function(n){var o=n.status||500,s=null,u=null;delete n.status,o>=400?s=n:u=n,a(i),r(t),clearTimeout(y[i]),e(s,u,o)}}function f(t,e){var n,o="callback_json_"+d().replace(/-/g,""),r=t.url,a=t.data,f=(t.method||"GET").toUpperCase(),l=null==t.timeout?6e4:t.timeout;r=p.queryify(r,a),r=p.queryify(r,{_method:f,callback:o}),n=i(r,o),u(n,e,o),s(l,o),c||(c=document.getElementsByTagName("head")[0]),c.appendChild(n)}var c,l=t("./constants"),d=t("../../lib/uuid"),p=t("../../lib/querystring"),y={};e.exports={request:f}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/querystring":21,"../../lib/uuid":22,"./constants":5}],10:[function(t,e,n){"use strict";e.exports=function(t){try{t=JSON.parse(t)}catch(e){}return t}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){if("string"!=typeof t)throw new Error("Method must be a string");return"get"!==t.toLowerCase()&&null!=e&&(e="string"==typeof e?e:JSON.stringify(e)),e}},{}],12:[function(t,e,n){"use strict";function o(t,e){var n,o=e?i(e):{},s=r(t.authorization).attrs,u=i(t.analyticsMetadata);o.braintreeLibraryVersion=a.BRAINTREE_LIBRARY_VERSION;for(n in o._meta)o._meta.hasOwnProperty(n)&&(u[n]=o._meta[n]);return o._meta=u,s.tokenizationKey?o.tokenizationKey=s.tokenizationKey:o.authorizationFingerprint=s.authorizationFingerprint,o}var r=t("./create-authorization-data"),i=t("./json-clone"),a=t("./constants");e.exports=o},{"./constants":13,"./create-authorization-data":14,"./json-clone":19}],13:[function(t,e,n){"use strict";var o="3.0.0-beta.8",r="web";e.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:o,INTEGRATION:"custom",SOURCE:"client",PLATFORM:r,BRAINTREE_LIBRARY_VERSION:"braintree/"+r+"/"+o}},{}],14:[function(t,e,n){"use strict";function o(t){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(t)}function r(t){var e=t.split("_"),n=e[0],o=e.slice(2).join("_");return{merchantId:o,environment:n}}function i(t){var e,n,i={attrs:{},configUrl:""};return o(t)?(n=r(t),i.attrs.tokenizationKey=t,i.configUrl=s[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(e=JSON.parse(a(t)),i.attrs.authorizationFingerprint=e.authorizationFingerprint,i.configUrl=e.configUrl),i}var a=t("../lib/polyfill").atob,s={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};e.exports=i},{"../lib/polyfill":20}],15:[function(t,e,n){"use strict";e.exports=function(t){return function(){var e=arguments;setTimeout(function(){t.apply(null,e)},1)}}},{}],16:[function(t,e,n){"use strict";function o(t,e){return e=null==e?"":e,t.reduce(function(t,n){return t[n]=e+n,t},{})}e.exports=o},{}],17:[function(t,e,n){"use strict";function o(t){if(!o.types.hasOwnProperty(t.type))throw new Error(t.type+" is not a valid type.");if(!t.message)throw new Error("Error message required.");this.message=t.message,this.type=t.type,this.details=t.details}var r=t("./enumerate");o.prototype=Object.create(Error.prototype),o.prototype.constructor=o,o.types=r(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),e.exports=o},{"./enumerate":16}],18:[function(t,e,n){"use strict";function o(t){var e,n;return t=t.toLowerCase(),/^https:/.test(t)?(r.href=t,e=r.hostname.split("."),n=e.slice(-2).join("."),i.hasOwnProperty(n)):!1}var r=document.createElement("a"),i={"paypal.com":1,"braintreepayments.com":1,"braintreegateway.com":1,localhost:1};e.exports=o},{}],19:[function(t,e,n){"use strict";e.exports=function(t){return JSON.parse(JSON.stringify(t))}},{}],20:[function(t,e,n){(function(t){"use strict";function n(t){var e,n,o,r,i,a,s,u,f=new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="";if(!f.test(t))throw new Error("Non base64 encoded input passed to window.atob polyfill");u=0;do r=c.indexOf(t.charAt(u++)),i=c.indexOf(t.charAt(u++)),a=c.indexOf(t.charAt(u++)),s=c.indexOf(t.charAt(u++)),e=(63&r)<<2|i>>4&3,n=(15&i)<<4|a>>2&15,o=(3&a)<<6|63&s,l+=String.fromCharCode(e)+(n?String.fromCharCode(n):"")+(o?String.fromCharCode(o):"");while(u<t.length);return l}var o="function"==typeof t.atob?t.atob:n;e.exports={atob:o,_atob:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],21:[function(t,e,n){(function(t){"use strict";function n(t){var e;for(e in t)if(t.hasOwnProperty(e))return!0;return!1}function o(t){return t&&"object"==typeof t&&"number"==typeof t.length&&"[object Array]"===Object.prototype.toString.call(t)||!1}function r(e){var n,o;return e=e||t.location.href,/\?/.test(e)?(n=e.replace(/#.*$/,"").replace(/^.*\?/,"").split("&"),o=n.reduce(function(t,e){var n=e.split("="),o=decodeURIComponent(n[0]),r=decodeURIComponent(n[1]);return t[o]=r,t},{})):{}}function i(t,e){var n,r,a,s=[];for(a in t)t.hasOwnProperty(a)&&(r=t[a],n=e?o(t)?e+"[]":e+"["+a+"]":a,"object"==typeof r?s.push(i(r,n)):s.push(encodeURIComponent(n)+"="+encodeURIComponent(r)));return s.join("&")}function a(t,e){return t=t||"",null!=e&&"object"==typeof e&&n(e)&&(t+=-1===t.indexOf("?")?"?":"",t+=-1!==t.indexOf("=")?"&":"",t+=i(e)),t}e.exports={parse:r,stringify:i,queryify:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],22:[function(t,e,n){"use strict";function o(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})}e.exports=o},{}]},{},[3])(3)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(e.braintree||(e.braintree={})).client=t()}}(function(){return function t(e,n,r){function o(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[a]={exports:{}};e[a][0].call(f.exports,function(t){var n=e[a][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(t,e,n){"use strict";function r(t){var e,n;if(t=t||{},e=JSON.stringify(t),n=t.gatewayConfiguration,!n)throw new a({type:a.types.INTERNAL,message:"Missing gatewayConfiguration."});["assetsUrl","clientApiUrl","configUrl"].forEach(function(t){if(t in n&&!i(n[t]))throw new a({type:a.types.MERCHANT,message:"Invalid "+t+"."})}),this.getConfiguration=function(){return JSON.parse(e)},this._request=o,this._baseUrl=t.gatewayConfiguration.clientApiUrl+"/v1/",this._configuration=this.getConfiguration(),this.toJSON=this.getConfiguration}var o=t("./request"),i=t("../lib/is-whitelisted-domain"),a=t("../lib/error"),s=t("../lib/add-metadata"),u=t("../lib/deferred");r.prototype.request=function(t,e){var n;return t.method?t.endpoint||(n="options.endpoint is required."):n="options.method is required.",n?(e=u(e),void e(new a({type:a.types.MERCHANT,message:n}))):void this._request({url:this._baseUrl+t.endpoint,method:t.method,data:s(this._configuration,t.data),timeout:t.timeout},e)},e.exports=r},{"../lib/add-metadata":12,"../lib/deferred":15,"../lib/error":17,"../lib/is-whitelisted-domain":18,"./request":7}],2:[function(t,e,n){(function(n){"use strict";function r(t,e){var r,c,f,l,d=a(),p={merchantAppId:n.location.host,platform:s.PLATFORM,sdkVersion:s.VERSION,source:s.SOURCE,integration:s.INTEGRATION,integrationType:s.INTEGRATION,sessionId:d};try{c=u(t.authorization)}catch(y){return void e(new o({type:o.types.MERCHANT,message:"Authorization is invalid. Make sure your client token or tokenization key is valid."}))}f=c.attrs,l=c.configUrl,f._meta=p,f.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION,i({url:l,method:"GET",data:f},function(n,i){return n?void e(new o({type:o.types.NETWORK,message:"Cannot contact the gateway at this time.",details:n})):(r={authorization:t.authorization,analyticsMetadata:p,gatewayConfiguration:i},void e(null,r))})}var o=t("../lib/error"),i=t("./request"),a=t("../lib/uuid"),s=t("../lib/constants"),u=t("../lib/create-authorization-data");e.exports={getConfiguration:r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../lib/constants":13,"../lib/create-authorization-data":14,"../lib/error":17,"../lib/uuid":23,"./request":7}],3:[function(t,e,n){"use strict";function r(t,e){if("function"!=typeof e)throw new o({type:o.types.MERCHANT,message:"create must include a callback function."});return e=u(e),t.authorization?void a(t,function(t,n){var r;if(t)return void e(t);try{r=new i(n)}catch(o){return void e(o)}e(null,r)}):void e(new o({type:o.types.MERCHANT,message:"options.authorization is required."}))}var o=t("../lib/error"),i=t("./client"),a=t("./get-configuration").getConfiguration,s="3.0.0-beta.9",u=t("../lib/deferred");e.exports={create:r,VERSION:s}},{"../lib/deferred":15,"../lib/error":17,"./client":1,"./get-configuration":2}],4:[function(t,e,n){(function(n){"use strict";function r(){return f?new XMLHttpRequest:new XDomainRequest}function o(t,e){var n,o,l=(t.method||"GET").toUpperCase(),d=t.url,p=t.data||{},y=null==t.timeout?6e4:t.timeout,g=r(),h=a(e||Function.prototype);"GET"===l&&(d=i.queryify(d,p),p=null),f?g.onreadystatechange=function(){4===g.readyState&&(n=g.status,o=u(g.responseText),n>=400||0===n?h(o||{errors:c.errors.UNKNOWN_ERROR},null,500):n>0&&h(null,o,n))}:(g.onload=function(){h(null,u(g.responseText),g.status)},g.onerror=function(){h(c.errors.UNKNOWN_ERROR,null,g.status)},g.onprogress=function(){},g.ontimeout=function(){h(c.errors.TIMEOUT_ERROR,null,500)}),g.open(l,d,!0),g.timeout=y,f&&"POST"===l&&g.setRequestHeader("Content-Type","application/json");try{g.send(s(l,p))}catch(m){}}var i=t("../../lib/querystring"),a=t("../../lib/once"),s=t("./prep-body"),u=t("./parse-body"),c=t("./constants"),f=n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest;e.exports={request:o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/once":20,"../../lib/querystring":22,"./constants":5,"./parse-body":10,"./prep-body":11}],5:[function(t,e,n){e.exports={errors:{UNKNOWN_ERROR:"Unknown error",TIMEOUT_ERROR:"Request timed out waiting for a reply",INVALID_TIMEOUT:"Timeout must be a number"}}},{}],6:[function(t,e,n){(function(t){"use strict";e.exports=function(){return t.navigator.userAgent}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],7:[function(t,e,n){"use strict";function r(){return null==o&&(o=!(u()&&/MSIE\s(8|9)/.test(s()))),o}var o,i=t("./jsonp-driver"),a=t("./ajax-driver"),s=t("./get-user-agent"),u=t("./is-http");e.exports=function(){var t=r()?a.request:i.request;t.apply(null,arguments)}},{"./ajax-driver":4,"./get-user-agent":6,"./is-http":8,"./jsonp-driver":9}],8:[function(t,e,n){(function(t){"use strict";e.exports=function(){return"http:"===t.location.protocol}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(t,e,n){(function(n){"use strict";function r(){}function o(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function i(t,e){var r=document.createElement("script"),o=!1;return r.src=t,r.async=!0,r.onerror=function(){n[e]({message:l.errors.UNKNOWN_ERROR,status:500})},r.onload=r.onreadystatechange=function(){o||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState||(o=!0,r.onload=r.onreadystatechange=null)},r}function a(t){try{delete n[t]}catch(e){n[t]=null}}function s(t,e){y[e]=setTimeout(function(){y[e]=null,n[e]({error:l.errors.TIMEOUT_ERROR,status:500}),n[e]=function(){a(e)}},t)}function u(t,e,i){e=e||r,n[i]=function(n){var r=n.status||500,s=null,u=null;delete n.status,r>=400?s=n:u=n,a(i),o(t),clearTimeout(y[i]),e(s,u,r)}}function c(t,e){var n,r="callback_json_"+d().replace(/-/g,""),o=t.url,a=t.data,c=(t.method||"GET").toUpperCase(),l=null==t.timeout?6e4:t.timeout;o=p.queryify(o,a),o=p.queryify(o,{_method:c,callback:r}),n=i(o,r),u(n,e,r),s(l,r),f||(f=document.getElementsByTagName("head")[0]),f.appendChild(n)}var f,l=t("./constants"),d=t("../../lib/uuid"),p=t("../../lib/querystring"),y={};e.exports={request:c}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/querystring":22,"../../lib/uuid":23,"./constants":5}],10:[function(t,e,n){"use strict";e.exports=function(t){try{t=JSON.parse(t)}catch(e){}return t}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){if("string"!=typeof t)throw new Error("Method must be a string");return"get"!==t.toLowerCase()&&null!=e&&(e="string"==typeof e?e:JSON.stringify(e)),e}},{}],12:[function(t,e,n){"use strict";function r(t,e){var n,r=e?i(e):{},s=o(t.authorization).attrs,u=i(t.analyticsMetadata);r.braintreeLibraryVersion=a.BRAINTREE_LIBRARY_VERSION;for(n in r._meta)r._meta.hasOwnProperty(n)&&(u[n]=r._meta[n]);return r._meta=u,s.tokenizationKey?r.tokenizationKey=s.tokenizationKey:r.authorizationFingerprint=s.authorizationFingerprint,r}var o=t("./create-authorization-data"),i=t("./json-clone"),a=t("./constants");e.exports=r},{"./constants":13,"./create-authorization-data":14,"./json-clone":19}],13:[function(t,e,n){"use strict";var r="3.0.0-beta.9",o="web";e.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:o,BRAINTREE_LIBRARY_VERSION:"braintree/"+o+"/"+r}},{}],14:[function(t,e,n){"use strict";function r(t){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(t)}function o(t){var e=t.split("_"),n=e[0],r=e.slice(2).join("_");return{merchantId:r,environment:n}}function i(t){var e,n,i={attrs:{},configUrl:""};return r(t)?(n=o(t),i.attrs.tokenizationKey=t,i.configUrl=s[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(e=JSON.parse(a(t)),i.attrs.authorizationFingerprint=e.authorizationFingerprint,i.configUrl=e.configUrl),i}var a=t("../lib/polyfill").atob,s={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};e.exports=i},{"../lib/polyfill":21}],15:[function(t,e,n){"use strict";e.exports=function(t){return function(){var e=arguments;setTimeout(function(){t.apply(null,e)},1)}}},{}],16:[function(t,e,n){"use strict";function r(t,e){return e=null==e?"":e,t.reduce(function(t,n){return t[n]=e+n,t},{})}e.exports=r},{}],17:[function(t,e,n){"use strict";function r(t){if(!r.types.hasOwnProperty(t.type))throw new Error(t.type+" is not a valid type.");if(!t.message)throw new Error("Error message required.");this.message=t.message,this.type=t.type,this.details=t.details}var o=t("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=o(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),e.exports=r},{"./enumerate":16}],18:[function(t,e,n){"use strict";function r(t){var e,n;return t=t.toLowerCase(),/^https:/.test(t)?(o=o||document.createElement("a"),o.href=t,e=o.hostname.split("."),n=e.slice(-2).join("."),i.hasOwnProperty(n)):!1}var o,i={"paypal.com":1,"braintreepayments.com":1,"braintreegateway.com":1,localhost:1};e.exports=r},{}],19:[function(t,e,n){"use strict";e.exports=function(t){return JSON.parse(JSON.stringify(t))}},{}],20:[function(t,e,n){"use strict";function r(t){var e=!1;return function(){e||(e=!0,t.apply(null,arguments))}}e.exports=r},{}],21:[function(t,e,n){(function(t){"use strict";function n(t){var e,n,r,o,i,a,s,u,c=new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$"),f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="";if(!c.test(t))throw new Error("Non base64 encoded input passed to window.atob polyfill");u=0;do o=f.indexOf(t.charAt(u++)),i=f.indexOf(t.charAt(u++)),a=f.indexOf(t.charAt(u++)),s=f.indexOf(t.charAt(u++)),e=(63&o)<<2|i>>4&3,n=(15&i)<<4|a>>2&15,r=(3&a)<<6|63&s,l+=String.fromCharCode(e)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(u<t.length);return l}var r="function"==typeof t.atob?t.atob:n;e.exports={atob:r,_atob:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],22:[function(t,e,n){(function(t){"use strict";function n(t){var e;for(e in t)if(t.hasOwnProperty(e))return!0;return!1}function r(t){return t&&"object"==typeof t&&"number"==typeof t.length&&"[object Array]"===Object.prototype.toString.call(t)||!1}function o(e){var n,r;return e=e||t.location.href,/\?/.test(e)?(n=e.replace(/#.*$/,"").replace(/^.*\?/,"").split("&"),r=n.reduce(function(t,e){var n=e.split("="),r=decodeURIComponent(n[0]),o=decodeURIComponent(n[1]);return t[r]=o,t},{})):{}}function i(t,e){var n,o,a,s=[];for(a in t)t.hasOwnProperty(a)&&(o=t[a],n=e?r(t)?e+"[]":e+"["+a+"]":a,"object"==typeof o?s.push(i(o,n)):s.push(encodeURIComponent(n)+"="+encodeURIComponent(o)));return s.join("&")}function a(t,e){return t=t||"",null!=e&&"object"==typeof e&&n(e)&&(t+=-1===t.indexOf("?")?"?":"",t+=-1!==t.indexOf("=")?"&":"",t+=i(e)),t}e.exports={parse:o,stringify:i,queryify:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],23:[function(t,e,n){"use strict";function r(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})}e.exports=r},{}]},{},[3])(3)}); |
@@ -172,3 +172,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.braintree || (g.braintree = {})).dataCollector = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
var convertMethodsToError = _dereq_('../lib/convert-methods-to-error'); | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
var deferred = _dereq_('../lib/deferred'); | ||
@@ -175,0 +175,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(e.braintree||(e.braintree={})).dataCollector=t()}}(function(){var t;return function e(t,n,r){function i(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var d=n[a]={exports:{}};t[a][0].call(d.exports,function(e){var n=t[a][1][e];return i(n?n:e)},d,d.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e,n){},{}],2:[function(e,n,r){"use strict";function i(t){throw t}function o(t,e,n){4!==e.length&&i(new p.exception.invalid("invalid aes block size"));var r=t.b[n],o=e[0]^r[0],a=e[n?3:1]^r[1],s=e[2]^r[2];e=e[n?1:3]^r[3];var c,h,d,u,l=r.length/4-2,f=4,m=[0,0,0,0];c=t.k[n],t=c[0];var y=c[1],g=c[2],v=c[3],b=c[4];for(u=0;l>u;u++)c=t[o>>>24]^y[a>>16&255]^g[s>>8&255]^v[255&e]^r[f],h=t[a>>>24]^y[s>>16&255]^g[e>>8&255]^v[255&o]^r[f+1],d=t[s>>>24]^y[e>>16&255]^g[o>>8&255]^v[255&a]^r[f+2],e=t[e>>>24]^y[o>>16&255]^g[a>>8&255]^v[255&s]^r[f+3],f+=4,o=c,a=h,s=d;for(u=0;4>u;u++)m[n?3&-u:u]=b[o>>>24]<<24^b[a>>16&255]<<16^b[s>>8&255]<<8^b[255&e]^r[f++],c=o,o=a,a=s,s=e,e=c;return m}function a(t,e){var n,r,i,o=e.slice(0),a=t.r,s=t.b,c=a[0],h=a[1],d=a[2],u=a[3],l=a[4],f=a[5],p=a[6],m=a[7];for(n=0;64>n;n++)16>n?r=o[n]:(r=o[n+1&15],i=o[n+14&15],r=o[15&n]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+o[15&n]+o[n+9&15]|0),r=r+m+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(p^l&(f^p))+s[n],m=p,p=f,f=l,l=u+r|0,u=d,d=h,h=c,c=r+(h&d^u&(h^d))+(h>>>2^h>>>13^h>>>22^h<<30^h<<19^h<<10)|0;a[0]=a[0]+c|0,a[1]=a[1]+h|0,a[2]=a[2]+d|0,a[3]=a[3]+u|0,a[4]=a[4]+l|0,a[5]=a[5]+f|0,a[6]=a[6]+p|0,a[7]=a[7]+m|0}function s(t,e){var n,r=p.random.w[t],i=[];for(n in r)r.hasOwnProperty(n)&&i.push(r[n]);for(n=0;n<i.length;n++)i[n](e)}function c(t){"undefined"!=typeof window&&window.performance&&"function"==typeof window.performance.now?p.random.addEntropy(window.performance.now(),t,"loadtime"):p.random.addEntropy((new Date).valueOf(),t,"loadtime")}function h(t){t.b=d(t).concat(d(t)),t.A=new p.cipher.aes(t.b)}function d(t){for(var e=0;4>e&&(t.f[e]=t.f[e]+1|0,!t.f[e]);e++);return t.A.encrypt(t.f)}function u(t,e){return function(){e.apply(t,arguments)}}var l=void 0,f=!1,p={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};"undefined"!=typeof n&&n.exports&&(n.exports=p),"function"==typeof t&&t([],function(){return p}),p.cipher.aes=function(t){this.k[0][0][0]||this.D();var e,n,r,o,a=this.k[0][4],s=this.k[1];e=t.length;var c=1;for(4!==e&&6!==e&&8!==e&&i(new p.exception.invalid("invalid aes key size")),this.b=[r=t.slice(0),o=[]],t=e;4*e+28>t;t++)n=r[t-1],(0===t%e||8===e&&4===t%e)&&(n=a[n>>>24]<<24^a[n>>16&255]<<16^a[n>>8&255]<<8^a[255&n],0===t%e&&(n=n<<8^n>>>24^c<<24,c=c<<1^283*(c>>7))),r[t]=r[t-e]^n;for(e=0;t;e++,t--)n=r[3&e?t:t-4],o[e]=4>=t||4>e?n:s[0][a[n>>>24]]^s[1][a[n>>16&255]]^s[2][a[n>>8&255]]^s[3][a[255&n]]},p.cipher.aes.prototype={encrypt:function(t){return o(this,t,0)},decrypt:function(t){return o(this,t,1)},k:[[[],[],[],[],[]],[[],[],[],[],[]]],D:function(){var t,e,n,r,i,o,a,s=this.k[0],c=this.k[1],h=s[4],d=c[4],u=[],l=[];for(t=0;256>t;t++)l[(u[t]=t<<1^283*(t>>7))^t]=t;for(e=n=0;!h[e];e^=r||1,n=l[n]||1)for(o=n^n<<1^n<<2^n<<3^n<<4,o=o>>8^255&o^99,h[e]=o,d[o]=e,i=u[t=u[r=u[e]]],a=16843009*i^65537*t^257*r^16843008*e,i=257*u[o]^16843008*o,t=0;4>t;t++)s[t][e]=i=i<<24^i>>>8,c[t][o]=a=a<<24^a>>>8;for(t=0;5>t;t++)s[t]=s[t].slice(0),c[t]=c[t].slice(0)}},p.bitArray={bitSlice:function(t,e,n){return t=p.bitArray.P(t.slice(e/32),32-(31&e)).slice(1),n===l?t:p.bitArray.clamp(t,n-e)},extract:function(t,e,n){var r=Math.floor(-e-n&31);return(-32&(e+n-1^e)?t[e/32|0]<<32-r^t[e/32+1|0]>>>r:t[e/32|0]>>>r)&(1<<n)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var n=t[t.length-1],r=p.bitArray.getPartial(n);return 32===r?t.concat(e):p.bitArray.P(e,r,0|n,t.slice(0,t.length-1))},bitLength:function(t){var e=t.length;return 0===e?0:32*(e-1)+p.bitArray.getPartial(t[e-1])},clamp:function(t,e){if(32*t.length<e)return t;t=t.slice(0,Math.ceil(e/32));var n=t.length;return e&=31,n>0&&e&&(t[n-1]=p.bitArray.partial(e,t[n-1]&2147483648>>e-1,1)),t},partial:function(t,e,n){return 32===t?e:(n?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(p.bitArray.bitLength(t)!==p.bitArray.bitLength(e))return f;var n,r=0;for(n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r},P:function(t,e,n,r){var i;for(i=0,r===l&&(r=[]);e>=32;e-=32)r.push(n),n=0;if(0===e)return r.concat(t);for(i=0;i<t.length;i++)r.push(n|t[i]>>>e),n=t[i]<<32-e;return i=t.length?t[t.length-1]:0,t=p.bitArray.getPartial(i),r.push(p.bitArray.partial(e+t&31,e+t>32?n:r.pop(),1)),r},l:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,n;for(e=0;e<t.length;++e)n=t[e],t[e]=n>>>24|n>>>8&65280|(65280&n)<<8|n<<24;return t}},p.codec.utf8String={fromBits:function(t){var e,n,r="",i=p.bitArray.bitLength(t);for(e=0;i/8>e;e++)0===(3&e)&&(n=t[e/4]),r+=String.fromCharCode(n>>>24),n<<=8;return decodeURIComponent(escape(r))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,n=[],r=0;for(e=0;e<t.length;e++)r=r<<8|t.charCodeAt(e),3===(3&e)&&(n.push(r),r=0);return 3&e&&n.push(p.bitArray.partial(8*(3&e),r)),n}},p.codec.hex={fromBits:function(t){var e,n="";for(e=0;e<t.length;e++)n+=((0|t[e])+0xf00000000000).toString(16).substr(4);return n.substr(0,p.bitArray.bitLength(t)/4)},toBits:function(t){var e,n,r=[];for(t=t.replace(/\s|0x/g,""),n=t.length,t+="00000000",e=0;e<t.length;e+=8)r.push(0^parseInt(t.substr(e,8),16));return p.bitArray.clamp(r,4*n)}},p.codec.base64={J:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,n){var r="",i=0,o=p.codec.base64.J,a=0,s=p.bitArray.bitLength(t);for(n&&(o=o.substr(0,62)+"-_"),n=0;6*r.length<s;)r+=o.charAt((a^t[n]>>>i)>>>26),6>i?(a=t[n]<<6-i,i+=26,n++):(a<<=6,i-=6);for(;3&r.length&&!e;)r+="=";return r},toBits:function(t,e){t=t.replace(/\s|=/g,"");var n,r,o=[],a=0,s=p.codec.base64.J,c=0;for(e&&(s=s.substr(0,62)+"-_"),n=0;n<t.length;n++)r=s.indexOf(t.charAt(n)),0>r&&i(new p.exception.invalid("this isn't base64!")),a>26?(a-=26,o.push(c^r>>>a),c=r<<32-a):(a+=6,c^=r<<32-a);return 56&a&&o.push(p.bitArray.partial(56&a,c,1)),o}},p.codec.base64url={fromBits:function(t){return p.codec.base64.fromBits(t,1,1)},toBits:function(t){return p.codec.base64.toBits(t,1)}},p.hash.sha256=function(t){this.b[0]||this.D(),t?(this.r=t.r.slice(0),this.o=t.o.slice(0),this.h=t.h):this.reset()},p.hash.sha256.hash=function(t){return(new p.hash.sha256).update(t).finalize()},p.hash.sha256.prototype={blockSize:512,reset:function(){return this.r=this.N.slice(0),this.o=[],this.h=0,this},update:function(t){"string"==typeof t&&(t=p.codec.utf8String.toBits(t));var e,n=this.o=p.bitArray.concat(this.o,t);for(e=this.h,t=this.h=e+p.bitArray.bitLength(t),e=512+e&-512;t>=e;e+=512)a(this,n.splice(0,16));return this},finalize:function(){var t,e=this.o,n=this.r,e=p.bitArray.concat(e,[p.bitArray.partial(1,1)]);for(t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.h/4294967296)),e.push(0|this.h);e.length;)a(this,e.splice(0,16));return this.reset(),n},N:[],b:[],D:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,n=0,r=2;t:for(;64>n;r++){for(e=2;r>=e*e;e++)if(0===r%e)continue t;8>n&&(this.N[n]=t(Math.pow(r,.5))),this.b[n]=t(Math.pow(r,1/3)),n++}}},p.mode.ccm={name:"ccm",encrypt:function(t,e,n,r,o){var a,s=e.slice(0),c=p.bitArray,h=c.bitLength(n)/8,d=c.bitLength(s)/8;for(o=o||64,r=r||[],7>h&&i(new p.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&d>>>8*a;a++);return 15-h>a&&(a=15-h),n=c.clamp(n,8*(15-a)),e=p.mode.ccm.L(t,e,n,r,o,a),s=p.mode.ccm.p(t,s,n,e,o,a),c.concat(s.data,s.tag)},decrypt:function(t,e,n,r,o){o=o||64,r=r||[];var a=p.bitArray,s=a.bitLength(n)/8,c=a.bitLength(e),h=a.clamp(e,c-o),d=a.bitSlice(e,c-o),c=(c-o)/8;for(7>s&&i(new p.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&c>>>8*e;e++);return 15-s>e&&(e=15-s),n=a.clamp(n,8*(15-e)),h=p.mode.ccm.p(t,h,n,d,o,e),t=p.mode.ccm.L(t,h.data,n,r,o,e),a.equal(h.tag,t)||i(new p.exception.corrupt("ccm: tag doesn't match")),h.data},L:function(t,e,n,r,o,a){var s=[],c=p.bitArray,h=c.l;if(o/=8,(o%2||4>o||o>16)&&i(new p.exception.invalid("ccm: invalid tag length")),(4294967295<r.length||4294967295<e.length)&&i(new p.exception.bug("ccm: can't deal with 4GiB or more data")),a=[c.partial(8,(r.length?64:0)|o-2<<2|a-1)],a=c.concat(a,n),a[3]|=c.bitLength(e)/8,a=t.encrypt(a),r.length)for(n=c.bitLength(r)/8,65279>=n?s=[c.partial(16,n)]:4294967295>=n&&(s=c.concat([c.partial(16,65534)],[n])),s=c.concat(s,r),r=0;r<s.length;r+=4)a=t.encrypt(h(a,s.slice(r,r+4).concat([0,0,0])));for(r=0;r<e.length;r+=4)a=t.encrypt(h(a,e.slice(r,r+4).concat([0,0,0])));return c.clamp(a,8*o)},p:function(t,e,n,r,i,o){var a,s=p.bitArray;a=s.l;var c=e.length,h=s.bitLength(e);if(n=s.concat([s.partial(8,o-1)],n).concat([0,0,0]).slice(0,4),r=s.bitSlice(a(r,t.encrypt(n)),0,i),!c)return{tag:r,data:[]};for(a=0;c>a;a+=4)n[3]++,i=t.encrypt(n),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:r,data:s.clamp(e,h)}}},p.mode.ocb2={name:"ocb2",encrypt:function(t,e,n,r,o,a){128!==p.bitArray.bitLength(n)&&i(new p.exception.invalid("ocb iv must be 128 bits"));var s,c=p.mode.ocb2.H,h=p.bitArray,d=h.l,u=[0,0,0,0];n=c(t.encrypt(n));var l,f=[];for(r=r||[],o=o||64,s=0;s+4<e.length;s+=4)l=e.slice(s,s+4),u=d(u,l),f=f.concat(d(n,t.encrypt(d(n,l)))),n=c(n);return l=e.slice(s),e=h.bitLength(l),s=t.encrypt(d(n,[0,0,0,e])),l=h.clamp(d(l.concat([0,0,0]),s),e),u=d(u,d(l.concat([0,0,0]),s)),u=t.encrypt(d(u,d(n,c(n)))),r.length&&(u=d(u,a?r:p.mode.ocb2.pmac(t,r))),f.concat(h.concat(l,h.clamp(u,o)))},decrypt:function(t,e,n,r,o,a){128!==p.bitArray.bitLength(n)&&i(new p.exception.invalid("ocb iv must be 128 bits")),o=o||64;var s,c,h=p.mode.ocb2.H,d=p.bitArray,u=d.l,l=[0,0,0,0],f=h(t.encrypt(n)),m=p.bitArray.bitLength(e)-o,y=[];for(r=r||[],n=0;m/32>n+4;n+=4)s=u(f,t.decrypt(u(f,e.slice(n,n+4)))),l=u(l,s),y=y.concat(s),f=h(f);return c=m-32*n,s=t.encrypt(u(f,[0,0,0,c])),s=u(s,d.clamp(e.slice(n),c).concat([0,0,0])),l=u(l,s),l=t.encrypt(u(l,u(f,h(f)))),r.length&&(l=u(l,a?r:p.mode.ocb2.pmac(t,r))),d.equal(d.clamp(l,o),d.bitSlice(e,m))||i(new p.exception.corrupt("ocb: tag doesn't match")),y.concat(d.clamp(s,c))},pmac:function(t,e){var n,r=p.mode.ocb2.H,i=p.bitArray,o=i.l,a=[0,0,0,0],s=t.encrypt([0,0,0,0]),s=o(s,r(r(s)));for(n=0;n+4<e.length;n+=4)s=r(s),a=o(a,t.encrypt(o(s,e.slice(n,n+4))));return n=e.slice(n),128>i.bitLength(n)&&(s=o(s,r(s)),n=i.concat(n,[-2147483648,0,0,0])),a=o(a,n),t.encrypt(o(r(o(s,r(s))),a))},H:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},p.mode.gcm={name:"gcm",encrypt:function(t,e,n,r,i){var o=e.slice(0);return e=p.bitArray,r=r||[],t=p.mode.gcm.p(!0,t,o,r,n,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,n,r,o){var a=e.slice(0),s=p.bitArray,c=s.bitLength(a);return o=o||128,r=r||[],c>=o?(e=s.bitSlice(a,c-o),a=s.bitSlice(a,0,c-o)):(e=a,a=[]),t=p.mode.gcm.p(f,t,a,r,n,o),s.equal(t.tag,e)||i(new p.exception.corrupt("gcm: tag doesn't match")),t.data},Z:function(t,e){var n,r,i,o,a,s=p.bitArray.l;for(i=[0,0,0,0],o=e.slice(0),n=0;128>n;n++){for((r=0!==(t[Math.floor(n/32)]&1<<31-n%32))&&(i=s(i,o)),a=0!==(1&o[3]),r=3;r>0;r--)o[r]=o[r]>>>1|(1&o[r-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},g:function(t,e,n){var r,i=n.length;for(e=e.slice(0),r=0;i>r;r+=4)e[0]^=4294967295&n[r],e[1]^=4294967295&n[r+1],e[2]^=4294967295&n[r+2],e[3]^=4294967295&n[r+3],e=p.mode.gcm.Z(e,t);return e},p:function(t,e,n,r,i,o){var a,s,c,h,d,u,l,f,m=p.bitArray;for(u=n.length,l=m.bitLength(n),f=m.bitLength(r),s=m.bitLength(i),a=e.encrypt([0,0,0,0]),96===s?(i=i.slice(0),i=m.concat(i,[1])):(i=p.mode.gcm.g(a,[0,0,0,0],i),i=p.mode.gcm.g(a,i,[0,0,Math.floor(s/4294967296),4294967295&s])),s=p.mode.gcm.g(a,[0,0,0,0],r),d=i.slice(0),r=s.slice(0),t||(r=p.mode.gcm.g(a,s,n)),h=0;u>h;h+=4)d[3]++,c=e.encrypt(d),n[h]^=c[0],n[h+1]^=c[1],n[h+2]^=c[2],n[h+3]^=c[3];return n=m.clamp(n,l),t&&(r=p.mode.gcm.g(a,s,n)),t=[Math.floor(f/4294967296),4294967295&f,Math.floor(l/4294967296),4294967295&l],r=p.mode.gcm.g(a,r,t),c=e.encrypt(i),r[0]^=c[0],r[1]^=c[1],r[2]^=c[2],r[3]^=c[3],{tag:m.bitSlice(r,0,o),data:n}}},p.misc.hmac=function(t,e){this.M=e=e||p.hash.sha256;var n,r=[[],[]],i=e.prototype.blockSize/32;for(this.n=[new e,new e],t.length>i&&(t=e.hash(t)),n=0;i>n;n++)r[0][n]=909522486^t[n],r[1][n]=1549556828^t[n];this.n[0].update(r[0]),this.n[1].update(r[1]),this.G=new e(this.n[0])},p.misc.hmac.prototype.encrypt=p.misc.hmac.prototype.mac=function(t){return this.Q&&i(new p.exception.invalid("encrypt on already updated hmac called!")),this.update(t),this.digest(t)},p.misc.hmac.prototype.reset=function(){this.G=new this.M(this.n[0]),this.Q=f},p.misc.hmac.prototype.update=function(t){this.Q=!0,this.G.update(t)},p.misc.hmac.prototype.digest=function(){var t=this.G.finalize(),t=new this.M(this.n[1]).update(t).finalize();return this.reset(),t},p.misc.pbkdf2=function(t,e,n,r,o){n=n||1e3,(0>r||0>n)&&i(p.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=p.codec.utf8String.toBits(t)),"string"==typeof e&&(e=p.codec.utf8String.toBits(e)),o=o||p.misc.hmac,t=new o(t);var a,s,c,h,d=[],u=p.bitArray;for(h=1;32*d.length<(r||1);h++){for(o=a=t.encrypt(u.concat(e,[h])),s=1;n>s;s++)for(a=t.encrypt(a),c=0;c<a.length;c++)o[c]^=a[c];d=d.concat(o)}return r&&(d=u.clamp(d,r)),d},p.prng=function(t){this.c=[new p.hash.sha256],this.i=[0],this.F=0,this.s={},this.C=0,this.K={},this.O=this.d=this.j=this.W=0,this.b=[0,0,0,0,0,0,0,0],this.f=[0,0,0,0],this.A=l,this.B=t,this.q=f,this.w={progress:{},seeded:{}},this.m=this.V=0,this.t=1,this.u=2,this.S=65536,this.I=[0,48,64,96,128,192,256,384,512,768,1024],this.T=3e4,this.R=80},p.prng.prototype={randomWords:function(t,e){var n,r=[];n=this.isReady(e);var o;if(n===this.m&&i(new p.exception.notReady("generator isn't seeded")),n&this.u){n=!(n&this.t),o=[];var a,s=0;for(this.O=o[0]=(new Date).valueOf()+this.T,a=0;16>a;a++)o.push(4294967296*Math.random()|0);for(a=0;a<this.c.length&&(o=o.concat(this.c[a].finalize()),s+=this.i[a],this.i[a]=0,!(!n&&this.F&1<<a));a++);for(this.F>=1<<this.c.length&&(this.c.push(new p.hash.sha256),this.i.push(0)),this.d-=s,s>this.j&&(this.j=s),this.F++,this.b=p.hash.sha256.hash(this.b.concat(o)),this.A=new p.cipher.aes(this.b),n=0;4>n&&(this.f[n]=this.f[n]+1|0,!this.f[n]);n++);}for(n=0;t>n;n+=4)0===(n+1)%this.S&&h(this),o=d(this),r.push(o[0],o[1],o[2],o[3]);return h(this),r.slice(0,t)},setDefaultParanoia:function(t,e){0===t&&"Setting paranoia=0 will ruin your security; use it only for testing"!==e&&i("Setting paranoia=0 will ruin your security; use it only for testing"),this.B=t},addEntropy:function(t,e,n){n=n||"user";var r,o,a=(new Date).valueOf(),c=this.s[n],h=this.isReady(),d=0;switch(r=this.K[n],r===l&&(r=this.K[n]=this.W++),c===l&&(c=this.s[n]=0),this.s[n]=(this.s[n]+1)%this.c.length,typeof t){case"number":e===l&&(e=1),this.c[c].update([r,this.C++,1,e,a,1,0|t]);break;case"object":if(n=Object.prototype.toString.call(t),"[object Uint32Array]"===n){for(o=[],n=0;n<t.length;n++)o.push(t[n]);t=o}else for("[object Array]"!==n&&(d=1),n=0;n<t.length&&!d;n++)"number"!=typeof t[n]&&(d=1);if(!d){if(e===l)for(n=e=0;n<t.length;n++)for(o=t[n];o>0;)e++,o>>>=1;this.c[c].update([r,this.C++,2,e,a,t.length].concat(t))}break;case"string":e===l&&(e=t.length),this.c[c].update([r,this.C++,3,e,a,t.length]),this.c[c].update(t);break;default:d=1}d&&i(new p.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.i[c]+=e,this.d+=e,h===this.m&&(this.isReady()!==this.m&&s("seeded",Math.max(this.j,this.d)),s("progress",this.getProgress()))},isReady:function(t){return t=this.I[t!==l?t:this.B],this.j&&this.j>=t?this.i[0]>this.R&&(new Date).valueOf()>this.O?this.u|this.t:this.t:this.d>=t?this.u|this.m:this.m},getProgress:function(t){return t=this.I[t?t:this.B],this.j>=t?1:this.d>t?1:this.d/t},startCollectors:function(){this.q||(this.a={loadTimeCollector:u(this,this.aa),mouseCollector:u(this,this.ba),keyboardCollector:u(this,this.$),accelerometerCollector:u(this,this.U),touchCollector:u(this,this.da)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,f),window.addEventListener("mousemove",this.a.mouseCollector,f),window.addEventListener("keypress",this.a.keyboardCollector,f),window.addEventListener("devicemotion",this.a.accelerometerCollector,f),window.addEventListener("touchmove",this.a.touchCollector,f)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):i(new p.exception.bug("can't attach event")),this.q=!0)},stopCollectors:function(){this.q&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,f),window.removeEventListener("mousemove",this.a.mouseCollector,f),window.removeEventListener("keypress",this.a.keyboardCollector,f),window.removeEventListener("devicemotion",this.a.accelerometerCollector,f),window.removeEventListener("touchmove",this.a.touchCollector,f)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.q=f)},addEventListener:function(t,e){this.w[t][this.V++]=e},removeEventListener:function(t,e){var n,r,i=this.w[t],o=[];for(r in i)i.hasOwnProperty(r)&&i[r]===e&&o.push(r);for(n=0;n<o.length;n++)r=o[n],delete i[r]},$:function(){c(1)},ba:function(t){var e,n;try{e=t.x||t.clientX||t.offsetX||0,n=t.y||t.clientY||t.offsetY||0}catch(r){n=e=0}0!=e&&0!=n&&p.random.addEntropy([e,n],2,"mouse"),c(0)},da:function(t){t=t.touches[0]||t.changedTouches[0],p.random.addEntropy([t.pageX||t.clientX,t.pageY||t.clientY],1,"touch"),c(0)},aa:function(){c(2)},U:function(t){if(t=t.accelerationIncludingGravity.x||t.accelerationIncludingGravity.y||t.accelerationIncludingGravity.z,window.orientation){var e=window.orientation;"number"==typeof e&&p.random.addEntropy(e,1,"accelerometer")}t&&p.random.addEntropy(t,2,"accelerometer"),c(0)}},p.random=new p.prng(6);t:try{var m,y,g,v;if(v="undefined"!=typeof n){var b;if(b=n.exports){var w;try{w=e("crypto")}catch(E){w=null}b=(y=w)&&y.randomBytes}v=b}if(v)m=y.randomBytes(128),m=new Uint32Array(new Uint8Array(m).buffer),p.random.addEntropy(m,1024,"crypto['randomBytes']");else if("undefined"!=typeof window&&"undefined"!=typeof Uint32Array){if(g=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(g);else{if(!window.msCrypto||!window.msCrypto.getRandomValues)break t;window.msCrypto.getRandomValues(g)}p.random.addEntropy(g,1024,"crypto['getRandomValues']")}}catch(k){"undefined"!=typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(k))}p.json={defaults:{v:1,iter:1e3,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},Y:function(t,e,n,r){n=n||{},r=r||{};var o,a=p.json,s=a.e({iv:p.random.randomWords(4,0)},a.defaults);return a.e(s,n),n=s.adata,"string"==typeof s.salt&&(s.salt=p.codec.base64.toBits(s.salt)),"string"==typeof s.iv&&(s.iv=p.codec.base64.toBits(s.iv)),(!p.mode[s.mode]||!p.cipher[s.cipher]||"string"==typeof t&&100>=s.iter||64!==s.ts&&96!==s.ts&&128!==s.ts||128!==s.ks&&192!==s.ks&&256!==s.ks||2>s.iv.length||4<s.iv.length)&&i(new p.exception.invalid("json encrypt: invalid parameters")),"string"==typeof t?(o=p.misc.cachedPbkdf2(t,s),t=o.key.slice(0,s.ks/32),s.salt=o.salt):p.ecc&&t instanceof p.ecc.elGamal.publicKey&&(o=t.kem(),s.kemtag=o.tag,t=o.key.slice(0,s.ks/32)),"string"==typeof e&&(e=p.codec.utf8String.toBits(e)),"string"==typeof n&&(s.adata=n=p.codec.utf8String.toBits(n)),o=new p.cipher[s.cipher](t),a.e(r,s),r.key=t,s.ct=p.mode[s.mode].encrypt(o,e,s.iv,n,s.ts),s},encrypt:function(t,e,n,r){var i=p.json,o=i.Y.apply(i,arguments);return i.encode(o)},X:function(t,e,n,r){n=n||{},r=r||{};var o=p.json;e=o.e(o.e(o.e({},o.defaults),e),n,!0);var a,s;return a=e.adata,"string"==typeof e.salt&&(e.salt=p.codec.base64.toBits(e.salt)),"string"==typeof e.iv&&(e.iv=p.codec.base64.toBits(e.iv)),(!p.mode[e.mode]||!p.cipher[e.cipher]||"string"==typeof t&&100>=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||4<e.iv.length)&&i(new p.exception.invalid("json decrypt: invalid parameters")),"string"==typeof t?(s=p.misc.cachedPbkdf2(t,e),t=s.key.slice(0,e.ks/32),e.salt=s.salt):p.ecc&&t instanceof p.ecc.elGamal.secretKey&&(t=t.unkem(p.codec.base64.toBits(e.kemtag)).slice(0,e.ks/32)),"string"==typeof a&&(a=p.codec.utf8String.toBits(a)),s=new p.cipher[e.cipher](t),a=p.mode[e.mode].decrypt(s,e.ct,e.iv,a,e.ts),o.e(r,e),r.key=t,1===n.raw?a:p.codec.utf8String.fromBits(a)},decrypt:function(t,e,n,r){var i=p.json;return i.X(t,i.decode(e),n,r)},encode:function(t){var e,n="{",r="";for(e in t)if(t.hasOwnProperty(e))switch(e.match(/^[a-z0-9]+$/i)||i(new p.exception.invalid("json encode: invalid property name")),n+=r+'"'+e+'":',r=",",typeof t[e]){case"number":case"boolean":n+=t[e];break;case"string":n+='"'+escape(t[e])+'"';break;case"object":n+='"'+p.codec.base64.fromBits(t[e],0)+'"';break;default:i(new p.exception.bug("json encode: unsupported type"))}return n+"}"},decode:function(t){t=t.replace(/\s/g,""),t.match(/^\{.*\}$/)||i(new p.exception.invalid("json decode: this isn't json!")),t=t.replace(/^\{|\}$/g,"").split(/,/);var e,n,r={};for(e=0;e<t.length;e++)(n=t[e].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i))||i(new p.exception.invalid("json decode: this isn't json!")),n[3]?r[n[2]]=parseInt(n[3],10):n[4]?r[n[2]]=n[2].match(/^(ct|adata|salt|iv)$/)?p.codec.base64.toBits(n[4]):unescape(n[4]):n[5]&&(r[n[2]]="true"===n[5]);return r},e:function(t,e,n){if(t===l&&(t={}),e===l)return t;for(var r in e)e.hasOwnProperty(r)&&(n&&t[r]!==l&&t[r]!==e[r]&&i(new p.exception.invalid("required parameter overridden")),t[r]=e[r]);return t},fa:function(t,e){var n,r={};for(n in t)t.hasOwnProperty(n)&&t[n]!==e[n]&&(r[n]=t[n]);return r},ea:function(t,e){var n,r={};for(n=0;n<e.length;n++)t[e[n]]!==l&&(r[e[n]]=t[e[n]]);return r}},p.encrypt=p.json.encrypt,p.decrypt=p.json.decrypt,p.misc.ca={},p.misc.cachedPbkdf2=function(t,e){var n,r=p.misc.ca;return e=e||{},n=e.iter||1e3,r=r[t]=r[t]||{},n=r[n]=r[n]||{firstSalt:e.salt&&e.salt.length?e.salt.slice(0):p.random.randomWords(2,0)},r=e.salt===l?n.firstSalt:e.salt,n[r]=n[r]||p.misc.pbkdf2(t,r,e.iter),{key:n[r].slice(0),salt:r.slice(0)}}},{crypto:1}],3:[function(t,e,n){"use strict";function r(){return new i}function i(){this.sessionId=o(),this._beaconId=a(this.sessionId),this._parameterBlock=s(this.sessionId,this._beaconId),this._thirdPartyBlock=c()}function o(){var t,e="";for(t=0;32>t;t++)e+=Math.floor(16*Math.random()).toString(16);return e}function a(t){var e=(new Date).getTime()/1e3;return"https://b.stats.paypal.com/counter.cgi?i=127.0.0.1&p="+t+"&t="+e+"&a=14"}function s(t,e){var n=document.body.appendChild(document.createElement("script"));return n.type="application/json",n.setAttribute("fncls","fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99"),n.text=JSON.stringify({f:t,s:"BRAINTREE_SIGNIN",b:e}),n}function c(){function t(){n._l()}var e,n,r="https://www.paypalobjects.com/webstatic/r/fb/",i=document.createElement("iframe");i.src="about:blank",i.title="",i.role="presentation",(i.frameElement||i).style.cssText="width: 0; height: 0; border: 0",document.body.appendChild(i);try{n=i.contentWindow.document}catch(o){e=document.domain,i.src='javascript:var d=document.open();d.domain="'+e+'";void(0);',n=i.contentWindow.document}return n.open()._l=function(){var t=this.createElement("script");e&&(this.domain=e),t.id="js-iframe-async",t.src=r+"fb-all-prod.pp.min.js",this.body.appendChild(t)},i.addEventListener?i.addEventListener("load",t,!1):i.attachEvent?i.attachEvent("onload",t):n.write('<body onload="document._l();">'),n.close(),i}i.prototype.teardown=function(){this._thirdPartyBlock.parentNode.removeChild(this._thirdPartyBlock)},e.exports={setup:r}},{}],4:[function(t,e,n){"use strict";function r(t,e){function n(t){var e;for(e=0;e<y.length;e++)y[e].teardown();c(f,s(f)),t&&(t=d(t))()}var r,u,l,f,p,m,y=[];if("function"!=typeof e)throw new a({type:a.types.MERCHANT,message:"create must include a callback function."});if(e=d(e),null==t.client)return void e(new a({type:a.types.MERCHANT,message:"options.client is required when instantiating Data Collector."}));if(p=t.client.getConfiguration(),m=p.analyticsMetadata.sdkVersion,m!==h)return void e(new a({type:a.types.MERCHANT,message:"Client (version "+m+") and Data Collector (version "+h+") components must be from the same SDK version."}));if(t.kount===!0){if(!p.gatewayConfiguration.kount)return void e(new a({type:a.types.MERCHANT,message:"Kount is not enabled for this merchant."}));try{u=i.setup({environment:p.gatewayConfiguration.environment,merchantId:p.gatewayConfiguration.kount.kountMerchantId})}catch(g){return void e(new a({message:g.message,type:a.types.MERCHANT}))}r=u.deviceData,y.push(u)}else r={};if(t.paypal===!0){if(p.gatewayConfiguration.paypalEnabled!==!0)return void e(new a({type:a.types.MERCHANT,message:"PayPal is not enabled for this merchant."}));l=o.setup(),r.correlation_id=l.sessionId,y.push(l)}return 0===y.length?void e(new a({type:a.types.MERCHANT,message:"Data Collector must be created with Kount and/or PayPal."})):(f={deviceData:JSON.stringify(r),teardown:n},void e(null,f))}var i=t("./kount"),o=t("./fraudnet"),a=t("../lib/error"),s=t("../lib/methods"),c=t("../lib/convert-methods-to-error"),h="3.0.0-beta.8",d=t("../lib/deferred");e.exports={create:r,VERSION:h}},{"../lib/convert-methods-to-error":6,"../lib/deferred":7,"../lib/error":9,"../lib/methods":10,"./fraudnet":3,"./kount":5}],5:[function(t,e,n){"use strict";function r(t){var e=null!=t?t:{};return new i(e)}function i(t){o.random.startCollectors(),this._currentEnvironment=this._initializeEnvironment(t),this._deviceSessionId=this._generateDeviceSessionId(),this.deviceData=this._getDeviceData(),this._iframe=this._setupIFrame()}var o=t("sjcl"),a="https://assets.qa.braintreepayments.com/data",s="braintreeDataFrame",c={development:a,qa:a,sandbox:"https://assets.braintreegateway.com/sandbox/data",production:"https://assets.braintreegateway.com/data"};i.prototype.teardown=function(){o.random.stopCollectors(),this._removeIframe()},i.prototype._removeIframe=function(){this._iframe.parentNode.removeChild(this._iframe)},i.prototype._getDeviceData=function(){return{device_session_id:this._deviceSessionId,fraud_merchant_id:this._currentEnvironment.id}},i.prototype._generateDeviceSessionId=function(){var t,e;return t=o.random.randomWords(4,0),e=o.codec.hex.fromBits(t)},i.prototype._setupIFrame=function(){var t,e=this,n=document.getElementById(s);return null!=n?n:(t="?m="+this._currentEnvironment.id+"&s="+this._deviceSessionId,n=document.createElement("iframe"),n.width=1,n.id=s,n.height=1,n.frameBorder=0,n.scrolling="no",document.body.appendChild(n),setTimeout(function(){n.src=e._currentEnvironment.url+"/logo.htm"+t,n.innerHTML='<img src="'+e._currentEnvironment.url+"/logo.gif"+t+'" />'},10),n)},i.prototype._initializeEnvironment=function(t){var e=c[t.environment];if(null==e)throw new Error(t.environment+" is not a valid environment for kount.environment");return{url:e,name:t.environment,id:t.merchantId}},e.exports={setup:r,Kount:i,environmentUrls:c}},{sjcl:2}],6:[function(t,e,n){"use strict";var r=t("./error");e.exports=function(t,e){e.forEach(function(e){t[e]=function(){throw new r({type:r.types.MERCHANT,message:e+" cannot be called after teardown."})}})}},{"./error":9}],7:[function(t,e,n){"use strict";e.exports=function(t){return function(){var e=arguments;setTimeout(function(){t.apply(null,e)},1)}}},{}],8:[function(t,e,n){"use strict";function r(t,e){return e=null==e?"":e,t.reduce(function(t,n){return t[n]=e+n,t},{})}e.exports=r},{}],9:[function(t,e,n){"use strict";function r(t){if(!r.types.hasOwnProperty(t.type))throw new Error(t.type+" is not a valid type.");if(!t.message)throw new Error("Error message required.");this.message=t.message,this.type=t.type,this.details=t.details}var i=t("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=i(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),e.exports=r},{"./enumerate":8}],10:[function(t,e,n){"use strict";e.exports=function(t){return Object.keys(t).filter(function(e){return"function"==typeof t[e]})}},{}]},{},[4])(4)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(e.braintree||(e.braintree={})).dataCollector=t()}}(function(){var t;return function e(t,n,r){function i(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var d=n[a]={exports:{}};t[a][0].call(d.exports,function(e){var n=t[a][1][e];return i(n?n:e)},d,d.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e,n){},{}],2:[function(e,n,r){"use strict";function i(t){throw t}function o(t,e,n){4!==e.length&&i(new p.exception.invalid("invalid aes block size"));var r=t.b[n],o=e[0]^r[0],a=e[n?3:1]^r[1],s=e[2]^r[2];e=e[n?1:3]^r[3];var c,h,d,u,l=r.length/4-2,f=4,m=[0,0,0,0];c=t.k[n],t=c[0];var y=c[1],g=c[2],v=c[3],b=c[4];for(u=0;l>u;u++)c=t[o>>>24]^y[a>>16&255]^g[s>>8&255]^v[255&e]^r[f],h=t[a>>>24]^y[s>>16&255]^g[e>>8&255]^v[255&o]^r[f+1],d=t[s>>>24]^y[e>>16&255]^g[o>>8&255]^v[255&a]^r[f+2],e=t[e>>>24]^y[o>>16&255]^g[a>>8&255]^v[255&s]^r[f+3],f+=4,o=c,a=h,s=d;for(u=0;4>u;u++)m[n?3&-u:u]=b[o>>>24]<<24^b[a>>16&255]<<16^b[s>>8&255]<<8^b[255&e]^r[f++],c=o,o=a,a=s,s=e,e=c;return m}function a(t,e){var n,r,i,o=e.slice(0),a=t.r,s=t.b,c=a[0],h=a[1],d=a[2],u=a[3],l=a[4],f=a[5],p=a[6],m=a[7];for(n=0;64>n;n++)16>n?r=o[n]:(r=o[n+1&15],i=o[n+14&15],r=o[15&n]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+o[15&n]+o[n+9&15]|0),r=r+m+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(p^l&(f^p))+s[n],m=p,p=f,f=l,l=u+r|0,u=d,d=h,h=c,c=r+(h&d^u&(h^d))+(h>>>2^h>>>13^h>>>22^h<<30^h<<19^h<<10)|0;a[0]=a[0]+c|0,a[1]=a[1]+h|0,a[2]=a[2]+d|0,a[3]=a[3]+u|0,a[4]=a[4]+l|0,a[5]=a[5]+f|0,a[6]=a[6]+p|0,a[7]=a[7]+m|0}function s(t,e){var n,r=p.random.w[t],i=[];for(n in r)r.hasOwnProperty(n)&&i.push(r[n]);for(n=0;n<i.length;n++)i[n](e)}function c(t){"undefined"!=typeof window&&window.performance&&"function"==typeof window.performance.now?p.random.addEntropy(window.performance.now(),t,"loadtime"):p.random.addEntropy((new Date).valueOf(),t,"loadtime")}function h(t){t.b=d(t).concat(d(t)),t.A=new p.cipher.aes(t.b)}function d(t){for(var e=0;4>e&&(t.f[e]=t.f[e]+1|0,!t.f[e]);e++);return t.A.encrypt(t.f)}function u(t,e){return function(){e.apply(t,arguments)}}var l=void 0,f=!1,p={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};"undefined"!=typeof n&&n.exports&&(n.exports=p),"function"==typeof t&&t([],function(){return p}),p.cipher.aes=function(t){this.k[0][0][0]||this.D();var e,n,r,o,a=this.k[0][4],s=this.k[1];e=t.length;var c=1;for(4!==e&&6!==e&&8!==e&&i(new p.exception.invalid("invalid aes key size")),this.b=[r=t.slice(0),o=[]],t=e;4*e+28>t;t++)n=r[t-1],(0===t%e||8===e&&4===t%e)&&(n=a[n>>>24]<<24^a[n>>16&255]<<16^a[n>>8&255]<<8^a[255&n],0===t%e&&(n=n<<8^n>>>24^c<<24,c=c<<1^283*(c>>7))),r[t]=r[t-e]^n;for(e=0;t;e++,t--)n=r[3&e?t:t-4],o[e]=4>=t||4>e?n:s[0][a[n>>>24]]^s[1][a[n>>16&255]]^s[2][a[n>>8&255]]^s[3][a[255&n]]},p.cipher.aes.prototype={encrypt:function(t){return o(this,t,0)},decrypt:function(t){return o(this,t,1)},k:[[[],[],[],[],[]],[[],[],[],[],[]]],D:function(){var t,e,n,r,i,o,a,s=this.k[0],c=this.k[1],h=s[4],d=c[4],u=[],l=[];for(t=0;256>t;t++)l[(u[t]=t<<1^283*(t>>7))^t]=t;for(e=n=0;!h[e];e^=r||1,n=l[n]||1)for(o=n^n<<1^n<<2^n<<3^n<<4,o=o>>8^255&o^99,h[e]=o,d[o]=e,i=u[t=u[r=u[e]]],a=16843009*i^65537*t^257*r^16843008*e,i=257*u[o]^16843008*o,t=0;4>t;t++)s[t][e]=i=i<<24^i>>>8,c[t][o]=a=a<<24^a>>>8;for(t=0;5>t;t++)s[t]=s[t].slice(0),c[t]=c[t].slice(0)}},p.bitArray={bitSlice:function(t,e,n){return t=p.bitArray.P(t.slice(e/32),32-(31&e)).slice(1),n===l?t:p.bitArray.clamp(t,n-e)},extract:function(t,e,n){var r=Math.floor(-e-n&31);return(-32&(e+n-1^e)?t[e/32|0]<<32-r^t[e/32+1|0]>>>r:t[e/32|0]>>>r)&(1<<n)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var n=t[t.length-1],r=p.bitArray.getPartial(n);return 32===r?t.concat(e):p.bitArray.P(e,r,0|n,t.slice(0,t.length-1))},bitLength:function(t){var e=t.length;return 0===e?0:32*(e-1)+p.bitArray.getPartial(t[e-1])},clamp:function(t,e){if(32*t.length<e)return t;t=t.slice(0,Math.ceil(e/32));var n=t.length;return e&=31,n>0&&e&&(t[n-1]=p.bitArray.partial(e,t[n-1]&2147483648>>e-1,1)),t},partial:function(t,e,n){return 32===t?e:(n?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(p.bitArray.bitLength(t)!==p.bitArray.bitLength(e))return f;var n,r=0;for(n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r},P:function(t,e,n,r){var i;for(i=0,r===l&&(r=[]);e>=32;e-=32)r.push(n),n=0;if(0===e)return r.concat(t);for(i=0;i<t.length;i++)r.push(n|t[i]>>>e),n=t[i]<<32-e;return i=t.length?t[t.length-1]:0,t=p.bitArray.getPartial(i),r.push(p.bitArray.partial(e+t&31,e+t>32?n:r.pop(),1)),r},l:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,n;for(e=0;e<t.length;++e)n=t[e],t[e]=n>>>24|n>>>8&65280|(65280&n)<<8|n<<24;return t}},p.codec.utf8String={fromBits:function(t){var e,n,r="",i=p.bitArray.bitLength(t);for(e=0;i/8>e;e++)0===(3&e)&&(n=t[e/4]),r+=String.fromCharCode(n>>>24),n<<=8;return decodeURIComponent(escape(r))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,n=[],r=0;for(e=0;e<t.length;e++)r=r<<8|t.charCodeAt(e),3===(3&e)&&(n.push(r),r=0);return 3&e&&n.push(p.bitArray.partial(8*(3&e),r)),n}},p.codec.hex={fromBits:function(t){var e,n="";for(e=0;e<t.length;e++)n+=((0|t[e])+0xf00000000000).toString(16).substr(4);return n.substr(0,p.bitArray.bitLength(t)/4)},toBits:function(t){var e,n,r=[];for(t=t.replace(/\s|0x/g,""),n=t.length,t+="00000000",e=0;e<t.length;e+=8)r.push(0^parseInt(t.substr(e,8),16));return p.bitArray.clamp(r,4*n)}},p.codec.base64={J:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,n){var r="",i=0,o=p.codec.base64.J,a=0,s=p.bitArray.bitLength(t);for(n&&(o=o.substr(0,62)+"-_"),n=0;6*r.length<s;)r+=o.charAt((a^t[n]>>>i)>>>26),6>i?(a=t[n]<<6-i,i+=26,n++):(a<<=6,i-=6);for(;3&r.length&&!e;)r+="=";return r},toBits:function(t,e){t=t.replace(/\s|=/g,"");var n,r,o=[],a=0,s=p.codec.base64.J,c=0;for(e&&(s=s.substr(0,62)+"-_"),n=0;n<t.length;n++)r=s.indexOf(t.charAt(n)),0>r&&i(new p.exception.invalid("this isn't base64!")),a>26?(a-=26,o.push(c^r>>>a),c=r<<32-a):(a+=6,c^=r<<32-a);return 56&a&&o.push(p.bitArray.partial(56&a,c,1)),o}},p.codec.base64url={fromBits:function(t){return p.codec.base64.fromBits(t,1,1)},toBits:function(t){return p.codec.base64.toBits(t,1)}},p.hash.sha256=function(t){this.b[0]||this.D(),t?(this.r=t.r.slice(0),this.o=t.o.slice(0),this.h=t.h):this.reset()},p.hash.sha256.hash=function(t){return(new p.hash.sha256).update(t).finalize()},p.hash.sha256.prototype={blockSize:512,reset:function(){return this.r=this.N.slice(0),this.o=[],this.h=0,this},update:function(t){"string"==typeof t&&(t=p.codec.utf8String.toBits(t));var e,n=this.o=p.bitArray.concat(this.o,t);for(e=this.h,t=this.h=e+p.bitArray.bitLength(t),e=512+e&-512;t>=e;e+=512)a(this,n.splice(0,16));return this},finalize:function(){var t,e=this.o,n=this.r,e=p.bitArray.concat(e,[p.bitArray.partial(1,1)]);for(t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.h/4294967296)),e.push(0|this.h);e.length;)a(this,e.splice(0,16));return this.reset(),n},N:[],b:[],D:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,n=0,r=2;t:for(;64>n;r++){for(e=2;r>=e*e;e++)if(0===r%e)continue t;8>n&&(this.N[n]=t(Math.pow(r,.5))),this.b[n]=t(Math.pow(r,1/3)),n++}}},p.mode.ccm={name:"ccm",encrypt:function(t,e,n,r,o){var a,s=e.slice(0),c=p.bitArray,h=c.bitLength(n)/8,d=c.bitLength(s)/8;for(o=o||64,r=r||[],7>h&&i(new p.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&d>>>8*a;a++);return 15-h>a&&(a=15-h),n=c.clamp(n,8*(15-a)),e=p.mode.ccm.L(t,e,n,r,o,a),s=p.mode.ccm.p(t,s,n,e,o,a),c.concat(s.data,s.tag)},decrypt:function(t,e,n,r,o){o=o||64,r=r||[];var a=p.bitArray,s=a.bitLength(n)/8,c=a.bitLength(e),h=a.clamp(e,c-o),d=a.bitSlice(e,c-o),c=(c-o)/8;for(7>s&&i(new p.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&c>>>8*e;e++);return 15-s>e&&(e=15-s),n=a.clamp(n,8*(15-e)),h=p.mode.ccm.p(t,h,n,d,o,e),t=p.mode.ccm.L(t,h.data,n,r,o,e),a.equal(h.tag,t)||i(new p.exception.corrupt("ccm: tag doesn't match")),h.data},L:function(t,e,n,r,o,a){var s=[],c=p.bitArray,h=c.l;if(o/=8,(o%2||4>o||o>16)&&i(new p.exception.invalid("ccm: invalid tag length")),(4294967295<r.length||4294967295<e.length)&&i(new p.exception.bug("ccm: can't deal with 4GiB or more data")),a=[c.partial(8,(r.length?64:0)|o-2<<2|a-1)],a=c.concat(a,n),a[3]|=c.bitLength(e)/8,a=t.encrypt(a),r.length)for(n=c.bitLength(r)/8,65279>=n?s=[c.partial(16,n)]:4294967295>=n&&(s=c.concat([c.partial(16,65534)],[n])),s=c.concat(s,r),r=0;r<s.length;r+=4)a=t.encrypt(h(a,s.slice(r,r+4).concat([0,0,0])));for(r=0;r<e.length;r+=4)a=t.encrypt(h(a,e.slice(r,r+4).concat([0,0,0])));return c.clamp(a,8*o)},p:function(t,e,n,r,i,o){var a,s=p.bitArray;a=s.l;var c=e.length,h=s.bitLength(e);if(n=s.concat([s.partial(8,o-1)],n).concat([0,0,0]).slice(0,4),r=s.bitSlice(a(r,t.encrypt(n)),0,i),!c)return{tag:r,data:[]};for(a=0;c>a;a+=4)n[3]++,i=t.encrypt(n),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:r,data:s.clamp(e,h)}}},p.mode.ocb2={name:"ocb2",encrypt:function(t,e,n,r,o,a){128!==p.bitArray.bitLength(n)&&i(new p.exception.invalid("ocb iv must be 128 bits"));var s,c=p.mode.ocb2.H,h=p.bitArray,d=h.l,u=[0,0,0,0];n=c(t.encrypt(n));var l,f=[];for(r=r||[],o=o||64,s=0;s+4<e.length;s+=4)l=e.slice(s,s+4),u=d(u,l),f=f.concat(d(n,t.encrypt(d(n,l)))),n=c(n);return l=e.slice(s),e=h.bitLength(l),s=t.encrypt(d(n,[0,0,0,e])),l=h.clamp(d(l.concat([0,0,0]),s),e),u=d(u,d(l.concat([0,0,0]),s)),u=t.encrypt(d(u,d(n,c(n)))),r.length&&(u=d(u,a?r:p.mode.ocb2.pmac(t,r))),f.concat(h.concat(l,h.clamp(u,o)))},decrypt:function(t,e,n,r,o,a){128!==p.bitArray.bitLength(n)&&i(new p.exception.invalid("ocb iv must be 128 bits")),o=o||64;var s,c,h=p.mode.ocb2.H,d=p.bitArray,u=d.l,l=[0,0,0,0],f=h(t.encrypt(n)),m=p.bitArray.bitLength(e)-o,y=[];for(r=r||[],n=0;m/32>n+4;n+=4)s=u(f,t.decrypt(u(f,e.slice(n,n+4)))),l=u(l,s),y=y.concat(s),f=h(f);return c=m-32*n,s=t.encrypt(u(f,[0,0,0,c])),s=u(s,d.clamp(e.slice(n),c).concat([0,0,0])),l=u(l,s),l=t.encrypt(u(l,u(f,h(f)))),r.length&&(l=u(l,a?r:p.mode.ocb2.pmac(t,r))),d.equal(d.clamp(l,o),d.bitSlice(e,m))||i(new p.exception.corrupt("ocb: tag doesn't match")),y.concat(d.clamp(s,c))},pmac:function(t,e){var n,r=p.mode.ocb2.H,i=p.bitArray,o=i.l,a=[0,0,0,0],s=t.encrypt([0,0,0,0]),s=o(s,r(r(s)));for(n=0;n+4<e.length;n+=4)s=r(s),a=o(a,t.encrypt(o(s,e.slice(n,n+4))));return n=e.slice(n),128>i.bitLength(n)&&(s=o(s,r(s)),n=i.concat(n,[-2147483648,0,0,0])),a=o(a,n),t.encrypt(o(r(o(s,r(s))),a))},H:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},p.mode.gcm={name:"gcm",encrypt:function(t,e,n,r,i){var o=e.slice(0);return e=p.bitArray,r=r||[],t=p.mode.gcm.p(!0,t,o,r,n,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,n,r,o){var a=e.slice(0),s=p.bitArray,c=s.bitLength(a);return o=o||128,r=r||[],c>=o?(e=s.bitSlice(a,c-o),a=s.bitSlice(a,0,c-o)):(e=a,a=[]),t=p.mode.gcm.p(f,t,a,r,n,o),s.equal(t.tag,e)||i(new p.exception.corrupt("gcm: tag doesn't match")),t.data},Z:function(t,e){var n,r,i,o,a,s=p.bitArray.l;for(i=[0,0,0,0],o=e.slice(0),n=0;128>n;n++){for((r=0!==(t[Math.floor(n/32)]&1<<31-n%32))&&(i=s(i,o)),a=0!==(1&o[3]),r=3;r>0;r--)o[r]=o[r]>>>1|(1&o[r-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},g:function(t,e,n){var r,i=n.length;for(e=e.slice(0),r=0;i>r;r+=4)e[0]^=4294967295&n[r],e[1]^=4294967295&n[r+1],e[2]^=4294967295&n[r+2],e[3]^=4294967295&n[r+3],e=p.mode.gcm.Z(e,t);return e},p:function(t,e,n,r,i,o){var a,s,c,h,d,u,l,f,m=p.bitArray;for(u=n.length,l=m.bitLength(n),f=m.bitLength(r),s=m.bitLength(i),a=e.encrypt([0,0,0,0]),96===s?(i=i.slice(0),i=m.concat(i,[1])):(i=p.mode.gcm.g(a,[0,0,0,0],i),i=p.mode.gcm.g(a,i,[0,0,Math.floor(s/4294967296),4294967295&s])),s=p.mode.gcm.g(a,[0,0,0,0],r),d=i.slice(0),r=s.slice(0),t||(r=p.mode.gcm.g(a,s,n)),h=0;u>h;h+=4)d[3]++,c=e.encrypt(d),n[h]^=c[0],n[h+1]^=c[1],n[h+2]^=c[2],n[h+3]^=c[3];return n=m.clamp(n,l),t&&(r=p.mode.gcm.g(a,s,n)),t=[Math.floor(f/4294967296),4294967295&f,Math.floor(l/4294967296),4294967295&l],r=p.mode.gcm.g(a,r,t),c=e.encrypt(i),r[0]^=c[0],r[1]^=c[1],r[2]^=c[2],r[3]^=c[3],{tag:m.bitSlice(r,0,o),data:n}}},p.misc.hmac=function(t,e){this.M=e=e||p.hash.sha256;var n,r=[[],[]],i=e.prototype.blockSize/32;for(this.n=[new e,new e],t.length>i&&(t=e.hash(t)),n=0;i>n;n++)r[0][n]=909522486^t[n],r[1][n]=1549556828^t[n];this.n[0].update(r[0]),this.n[1].update(r[1]),this.G=new e(this.n[0])},p.misc.hmac.prototype.encrypt=p.misc.hmac.prototype.mac=function(t){return this.Q&&i(new p.exception.invalid("encrypt on already updated hmac called!")),this.update(t),this.digest(t)},p.misc.hmac.prototype.reset=function(){this.G=new this.M(this.n[0]),this.Q=f},p.misc.hmac.prototype.update=function(t){this.Q=!0,this.G.update(t)},p.misc.hmac.prototype.digest=function(){var t=this.G.finalize(),t=new this.M(this.n[1]).update(t).finalize();return this.reset(),t},p.misc.pbkdf2=function(t,e,n,r,o){n=n||1e3,(0>r||0>n)&&i(p.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=p.codec.utf8String.toBits(t)),"string"==typeof e&&(e=p.codec.utf8String.toBits(e)),o=o||p.misc.hmac,t=new o(t);var a,s,c,h,d=[],u=p.bitArray;for(h=1;32*d.length<(r||1);h++){for(o=a=t.encrypt(u.concat(e,[h])),s=1;n>s;s++)for(a=t.encrypt(a),c=0;c<a.length;c++)o[c]^=a[c];d=d.concat(o)}return r&&(d=u.clamp(d,r)),d},p.prng=function(t){this.c=[new p.hash.sha256],this.i=[0],this.F=0,this.s={},this.C=0,this.K={},this.O=this.d=this.j=this.W=0,this.b=[0,0,0,0,0,0,0,0],this.f=[0,0,0,0],this.A=l,this.B=t,this.q=f,this.w={progress:{},seeded:{}},this.m=this.V=0,this.t=1,this.u=2,this.S=65536,this.I=[0,48,64,96,128,192,256,384,512,768,1024],this.T=3e4,this.R=80},p.prng.prototype={randomWords:function(t,e){var n,r=[];n=this.isReady(e);var o;if(n===this.m&&i(new p.exception.notReady("generator isn't seeded")),n&this.u){n=!(n&this.t),o=[];var a,s=0;for(this.O=o[0]=(new Date).valueOf()+this.T,a=0;16>a;a++)o.push(4294967296*Math.random()|0);for(a=0;a<this.c.length&&(o=o.concat(this.c[a].finalize()),s+=this.i[a],this.i[a]=0,!(!n&&this.F&1<<a));a++);for(this.F>=1<<this.c.length&&(this.c.push(new p.hash.sha256),this.i.push(0)),this.d-=s,s>this.j&&(this.j=s),this.F++,this.b=p.hash.sha256.hash(this.b.concat(o)),this.A=new p.cipher.aes(this.b),n=0;4>n&&(this.f[n]=this.f[n]+1|0,!this.f[n]);n++);}for(n=0;t>n;n+=4)0===(n+1)%this.S&&h(this),o=d(this),r.push(o[0],o[1],o[2],o[3]);return h(this),r.slice(0,t)},setDefaultParanoia:function(t,e){0===t&&"Setting paranoia=0 will ruin your security; use it only for testing"!==e&&i("Setting paranoia=0 will ruin your security; use it only for testing"),this.B=t},addEntropy:function(t,e,n){n=n||"user";var r,o,a=(new Date).valueOf(),c=this.s[n],h=this.isReady(),d=0;switch(r=this.K[n],r===l&&(r=this.K[n]=this.W++),c===l&&(c=this.s[n]=0),this.s[n]=(this.s[n]+1)%this.c.length,typeof t){case"number":e===l&&(e=1),this.c[c].update([r,this.C++,1,e,a,1,0|t]);break;case"object":if(n=Object.prototype.toString.call(t),"[object Uint32Array]"===n){for(o=[],n=0;n<t.length;n++)o.push(t[n]);t=o}else for("[object Array]"!==n&&(d=1),n=0;n<t.length&&!d;n++)"number"!=typeof t[n]&&(d=1);if(!d){if(e===l)for(n=e=0;n<t.length;n++)for(o=t[n];o>0;)e++,o>>>=1;this.c[c].update([r,this.C++,2,e,a,t.length].concat(t))}break;case"string":e===l&&(e=t.length),this.c[c].update([r,this.C++,3,e,a,t.length]),this.c[c].update(t);break;default:d=1}d&&i(new p.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.i[c]+=e,this.d+=e,h===this.m&&(this.isReady()!==this.m&&s("seeded",Math.max(this.j,this.d)),s("progress",this.getProgress()))},isReady:function(t){return t=this.I[t!==l?t:this.B],this.j&&this.j>=t?this.i[0]>this.R&&(new Date).valueOf()>this.O?this.u|this.t:this.t:this.d>=t?this.u|this.m:this.m},getProgress:function(t){return t=this.I[t?t:this.B],this.j>=t?1:this.d>t?1:this.d/t},startCollectors:function(){this.q||(this.a={loadTimeCollector:u(this,this.aa),mouseCollector:u(this,this.ba),keyboardCollector:u(this,this.$),accelerometerCollector:u(this,this.U),touchCollector:u(this,this.da)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,f),window.addEventListener("mousemove",this.a.mouseCollector,f),window.addEventListener("keypress",this.a.keyboardCollector,f),window.addEventListener("devicemotion",this.a.accelerometerCollector,f),window.addEventListener("touchmove",this.a.touchCollector,f)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):i(new p.exception.bug("can't attach event")),this.q=!0)},stopCollectors:function(){this.q&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,f),window.removeEventListener("mousemove",this.a.mouseCollector,f),window.removeEventListener("keypress",this.a.keyboardCollector,f),window.removeEventListener("devicemotion",this.a.accelerometerCollector,f),window.removeEventListener("touchmove",this.a.touchCollector,f)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.q=f)},addEventListener:function(t,e){this.w[t][this.V++]=e},removeEventListener:function(t,e){var n,r,i=this.w[t],o=[];for(r in i)i.hasOwnProperty(r)&&i[r]===e&&o.push(r);for(n=0;n<o.length;n++)r=o[n],delete i[r]},$:function(){c(1)},ba:function(t){var e,n;try{e=t.x||t.clientX||t.offsetX||0,n=t.y||t.clientY||t.offsetY||0}catch(r){n=e=0}0!=e&&0!=n&&p.random.addEntropy([e,n],2,"mouse"),c(0)},da:function(t){t=t.touches[0]||t.changedTouches[0],p.random.addEntropy([t.pageX||t.clientX,t.pageY||t.clientY],1,"touch"),c(0)},aa:function(){c(2)},U:function(t){if(t=t.accelerationIncludingGravity.x||t.accelerationIncludingGravity.y||t.accelerationIncludingGravity.z,window.orientation){var e=window.orientation;"number"==typeof e&&p.random.addEntropy(e,1,"accelerometer")}t&&p.random.addEntropy(t,2,"accelerometer"),c(0)}},p.random=new p.prng(6);t:try{var m,y,g,v;if(v="undefined"!=typeof n){var b;if(b=n.exports){var w;try{w=e("crypto")}catch(E){w=null}b=(y=w)&&y.randomBytes}v=b}if(v)m=y.randomBytes(128),m=new Uint32Array(new Uint8Array(m).buffer),p.random.addEntropy(m,1024,"crypto['randomBytes']");else if("undefined"!=typeof window&&"undefined"!=typeof Uint32Array){if(g=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(g);else{if(!window.msCrypto||!window.msCrypto.getRandomValues)break t;window.msCrypto.getRandomValues(g)}p.random.addEntropy(g,1024,"crypto['getRandomValues']")}}catch(k){"undefined"!=typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(k))}p.json={defaults:{v:1,iter:1e3,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},Y:function(t,e,n,r){n=n||{},r=r||{};var o,a=p.json,s=a.e({iv:p.random.randomWords(4,0)},a.defaults);return a.e(s,n),n=s.adata,"string"==typeof s.salt&&(s.salt=p.codec.base64.toBits(s.salt)),"string"==typeof s.iv&&(s.iv=p.codec.base64.toBits(s.iv)),(!p.mode[s.mode]||!p.cipher[s.cipher]||"string"==typeof t&&100>=s.iter||64!==s.ts&&96!==s.ts&&128!==s.ts||128!==s.ks&&192!==s.ks&&256!==s.ks||2>s.iv.length||4<s.iv.length)&&i(new p.exception.invalid("json encrypt: invalid parameters")),"string"==typeof t?(o=p.misc.cachedPbkdf2(t,s),t=o.key.slice(0,s.ks/32),s.salt=o.salt):p.ecc&&t instanceof p.ecc.elGamal.publicKey&&(o=t.kem(),s.kemtag=o.tag,t=o.key.slice(0,s.ks/32)),"string"==typeof e&&(e=p.codec.utf8String.toBits(e)),"string"==typeof n&&(s.adata=n=p.codec.utf8String.toBits(n)),o=new p.cipher[s.cipher](t),a.e(r,s),r.key=t,s.ct=p.mode[s.mode].encrypt(o,e,s.iv,n,s.ts),s},encrypt:function(t,e,n,r){var i=p.json,o=i.Y.apply(i,arguments);return i.encode(o)},X:function(t,e,n,r){n=n||{},r=r||{};var o=p.json;e=o.e(o.e(o.e({},o.defaults),e),n,!0);var a,s;return a=e.adata,"string"==typeof e.salt&&(e.salt=p.codec.base64.toBits(e.salt)),"string"==typeof e.iv&&(e.iv=p.codec.base64.toBits(e.iv)),(!p.mode[e.mode]||!p.cipher[e.cipher]||"string"==typeof t&&100>=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||4<e.iv.length)&&i(new p.exception.invalid("json decrypt: invalid parameters")),"string"==typeof t?(s=p.misc.cachedPbkdf2(t,e),t=s.key.slice(0,e.ks/32),e.salt=s.salt):p.ecc&&t instanceof p.ecc.elGamal.secretKey&&(t=t.unkem(p.codec.base64.toBits(e.kemtag)).slice(0,e.ks/32)),"string"==typeof a&&(a=p.codec.utf8String.toBits(a)),s=new p.cipher[e.cipher](t),a=p.mode[e.mode].decrypt(s,e.ct,e.iv,a,e.ts),o.e(r,e),r.key=t,1===n.raw?a:p.codec.utf8String.fromBits(a)},decrypt:function(t,e,n,r){var i=p.json;return i.X(t,i.decode(e),n,r)},encode:function(t){var e,n="{",r="";for(e in t)if(t.hasOwnProperty(e))switch(e.match(/^[a-z0-9]+$/i)||i(new p.exception.invalid("json encode: invalid property name")),n+=r+'"'+e+'":',r=",",typeof t[e]){case"number":case"boolean":n+=t[e];break;case"string":n+='"'+escape(t[e])+'"';break;case"object":n+='"'+p.codec.base64.fromBits(t[e],0)+'"';break;default:i(new p.exception.bug("json encode: unsupported type"))}return n+"}"},decode:function(t){t=t.replace(/\s/g,""),t.match(/^\{.*\}$/)||i(new p.exception.invalid("json decode: this isn't json!")),t=t.replace(/^\{|\}$/g,"").split(/,/);var e,n,r={};for(e=0;e<t.length;e++)(n=t[e].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i))||i(new p.exception.invalid("json decode: this isn't json!")),n[3]?r[n[2]]=parseInt(n[3],10):n[4]?r[n[2]]=n[2].match(/^(ct|adata|salt|iv)$/)?p.codec.base64.toBits(n[4]):unescape(n[4]):n[5]&&(r[n[2]]="true"===n[5]);return r},e:function(t,e,n){if(t===l&&(t={}),e===l)return t;for(var r in e)e.hasOwnProperty(r)&&(n&&t[r]!==l&&t[r]!==e[r]&&i(new p.exception.invalid("required parameter overridden")),t[r]=e[r]);return t},fa:function(t,e){var n,r={};for(n in t)t.hasOwnProperty(n)&&t[n]!==e[n]&&(r[n]=t[n]);return r},ea:function(t,e){var n,r={};for(n=0;n<e.length;n++)t[e[n]]!==l&&(r[e[n]]=t[e[n]]);return r}},p.encrypt=p.json.encrypt,p.decrypt=p.json.decrypt,p.misc.ca={},p.misc.cachedPbkdf2=function(t,e){var n,r=p.misc.ca;return e=e||{},n=e.iter||1e3,r=r[t]=r[t]||{},n=r[n]=r[n]||{firstSalt:e.salt&&e.salt.length?e.salt.slice(0):p.random.randomWords(2,0)},r=e.salt===l?n.firstSalt:e.salt,n[r]=n[r]||p.misc.pbkdf2(t,r,e.iter),{key:n[r].slice(0),salt:r.slice(0)}}},{crypto:1}],3:[function(t,e,n){"use strict";function r(){return new i}function i(){this.sessionId=o(),this._beaconId=a(this.sessionId),this._parameterBlock=s(this.sessionId,this._beaconId),this._thirdPartyBlock=c()}function o(){var t,e="";for(t=0;32>t;t++)e+=Math.floor(16*Math.random()).toString(16);return e}function a(t){var e=(new Date).getTime()/1e3;return"https://b.stats.paypal.com/counter.cgi?i=127.0.0.1&p="+t+"&t="+e+"&a=14"}function s(t,e){var n=document.body.appendChild(document.createElement("script"));return n.type="application/json",n.setAttribute("fncls","fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99"),n.text=JSON.stringify({f:t,s:"BRAINTREE_SIGNIN",b:e}),n}function c(){function t(){n._l()}var e,n,r="https://www.paypalobjects.com/webstatic/r/fb/",i=document.createElement("iframe");i.src="about:blank",i.title="",i.role="presentation",(i.frameElement||i).style.cssText="width: 0; height: 0; border: 0",document.body.appendChild(i);try{n=i.contentWindow.document}catch(o){e=document.domain,i.src='javascript:var d=document.open();d.domain="'+e+'";void(0);',n=i.contentWindow.document}return n.open()._l=function(){var t=this.createElement("script");e&&(this.domain=e),t.id="js-iframe-async",t.src=r+"fb-all-prod.pp.min.js",this.body.appendChild(t)},i.addEventListener?i.addEventListener("load",t,!1):i.attachEvent?i.attachEvent("onload",t):n.write('<body onload="document._l();">'),n.close(),i}i.prototype.teardown=function(){this._thirdPartyBlock.parentNode.removeChild(this._thirdPartyBlock)},e.exports={setup:r}},{}],4:[function(t,e,n){"use strict";function r(t,e){function n(t){var e;for(e=0;e<y.length;e++)y[e].teardown();c(f,s(f)),t&&(t=d(t))()}var r,u,l,f,p,m,y=[];if("function"!=typeof e)throw new a({type:a.types.MERCHANT,message:"create must include a callback function."});if(e=d(e),null==t.client)return void e(new a({type:a.types.MERCHANT,message:"options.client is required when instantiating Data Collector."}));if(p=t.client.getConfiguration(),m=p.analyticsMetadata.sdkVersion,m!==h)return void e(new a({type:a.types.MERCHANT,message:"Client (version "+m+") and Data Collector (version "+h+") components must be from the same SDK version."}));if(t.kount===!0){if(!p.gatewayConfiguration.kount)return void e(new a({type:a.types.MERCHANT,message:"Kount is not enabled for this merchant."}));try{u=i.setup({environment:p.gatewayConfiguration.environment,merchantId:p.gatewayConfiguration.kount.kountMerchantId})}catch(g){return void e(new a({message:g.message,type:a.types.MERCHANT}))}r=u.deviceData,y.push(u)}else r={};if(t.paypal===!0){if(p.gatewayConfiguration.paypalEnabled!==!0)return void e(new a({type:a.types.MERCHANT,message:"PayPal is not enabled for this merchant."}));l=o.setup(),r.correlation_id=l.sessionId,y.push(l)}return 0===y.length?void e(new a({type:a.types.MERCHANT,message:"Data Collector must be created with Kount and/or PayPal."})):(f={deviceData:JSON.stringify(r),teardown:n},void e(null,f))}var i=t("./kount"),o=t("./fraudnet"),a=t("../lib/error"),s=t("../lib/methods"),c=t("../lib/convert-methods-to-error"),h="3.0.0-beta.9",d=t("../lib/deferred");e.exports={create:r,VERSION:h}},{"../lib/convert-methods-to-error":6,"../lib/deferred":7,"../lib/error":9,"../lib/methods":10,"./fraudnet":3,"./kount":5}],5:[function(t,e,n){"use strict";function r(t){var e=null!=t?t:{};return new i(e)}function i(t){o.random.startCollectors(),this._currentEnvironment=this._initializeEnvironment(t),this._deviceSessionId=this._generateDeviceSessionId(),this.deviceData=this._getDeviceData(),this._iframe=this._setupIFrame()}var o=t("sjcl"),a="https://assets.qa.braintreepayments.com/data",s="braintreeDataFrame",c={development:a,qa:a,sandbox:"https://assets.braintreegateway.com/sandbox/data",production:"https://assets.braintreegateway.com/data"};i.prototype.teardown=function(){o.random.stopCollectors(),this._removeIframe()},i.prototype._removeIframe=function(){this._iframe.parentNode.removeChild(this._iframe)},i.prototype._getDeviceData=function(){return{device_session_id:this._deviceSessionId,fraud_merchant_id:this._currentEnvironment.id}},i.prototype._generateDeviceSessionId=function(){var t,e;return t=o.random.randomWords(4,0),e=o.codec.hex.fromBits(t)},i.prototype._setupIFrame=function(){var t,e=this,n=document.getElementById(s);return null!=n?n:(t="?m="+this._currentEnvironment.id+"&s="+this._deviceSessionId,n=document.createElement("iframe"),n.width=1,n.id=s,n.height=1,n.frameBorder=0,n.scrolling="no",document.body.appendChild(n),setTimeout(function(){n.src=e._currentEnvironment.url+"/logo.htm"+t,n.innerHTML='<img src="'+e._currentEnvironment.url+"/logo.gif"+t+'" />'},10),n)},i.prototype._initializeEnvironment=function(t){var e=c[t.environment];if(null==e)throw new Error(t.environment+" is not a valid environment for kount.environment");return{url:e,name:t.environment,id:t.merchantId}},e.exports={setup:r,Kount:i,environmentUrls:c}},{sjcl:2}],6:[function(t,e,n){"use strict";var r=t("./error");e.exports=function(t,e){e.forEach(function(e){t[e]=function(){throw new r({type:r.types.MERCHANT,message:e+" cannot be called after teardown."})}})}},{"./error":9}],7:[function(t,e,n){"use strict";e.exports=function(t){return function(){var e=arguments;setTimeout(function(){t.apply(null,e)},1)}}},{}],8:[function(t,e,n){"use strict";function r(t,e){return e=null==e?"":e,t.reduce(function(t,n){return t[n]=e+n,t},{})}e.exports=r},{}],9:[function(t,e,n){"use strict";function r(t){if(!r.types.hasOwnProperty(t.type))throw new Error(t.type+" is not a valid type.");if(!t.message)throw new Error("Error message required.");this.message=t.message,this.type=t.type,this.details=t.details}var i=t("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=i(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),e.exports=r},{"./enumerate":8}],10:[function(t,e,n){"use strict";e.exports=function(t){return Object.keys(t).filter(function(e){return"function"==typeof t[e]})}},{}]},{},[4])(4)}); |
@@ -9,3 +9,2 @@ 'use strict'; | ||
var unionpay = require('./unionpay.debug'); | ||
var packageVersion = require('./package.json').version; | ||
@@ -19,3 +18,3 @@ module.exports = { | ||
unionpay: unionpay, | ||
VERSION: packageVersion | ||
VERSION: "3.0.0-beta.9" | ||
}; |
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.braintree || (g.braintree = {})).hostedFields = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
'use strict'; | ||
(function (root, factory) { | ||
if (typeof exports === 'object' && typeof module !== 'undefined') { | ||
module.exports = factory(); | ||
module.exports = factory(typeof global === 'undefined' ? root : global); | ||
} else if (typeof define === 'function' && define.amd) { | ||
define([], factory); | ||
define([], function () { return factory(root); }); | ||
} else { | ||
root.framebus = factory(); | ||
root.framebus = factory(root); | ||
} | ||
})(this, function () { // eslint-disable-line no-invalid-this | ||
})(this, function (root) { // eslint-disable-line no-invalid-this | ||
var win, framebus; | ||
@@ -152,3 +153,3 @@ var popups = []; | ||
if (win) { return; } | ||
win = w || window; | ||
win = w || root; | ||
@@ -278,2 +279,3 @@ if (win.addEventListener) { | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],2:[function(_dereq_,module,exports){ | ||
@@ -380,3 +382,3 @@ 'use strict'; | ||
var whitelistedFields = constants.whitelistedFields; | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
var methods = _dereq_('../../lib/methods'); | ||
@@ -472,4 +474,4 @@ var convertMethodsToError = _dereq_('../../lib/convert-methods-to-error'); | ||
* <caption>Listening to a Hosted Field event, in this case 'focus'</caption> | ||
* hostedFields.create({ ... }, function (err, instance) { | ||
* instance.on('focus', function (event) { | ||
* hostedFields.create({ ... }, function (createErr, hostedFieldsInstance) { | ||
* hostedFieldsInstance.on('focus', function (event) { | ||
* console.log(event.emittedBy, 'has been focused'); | ||
@@ -490,4 +492,4 @@ * }); | ||
* | ||
* hostedFields.create({ ... }, function (err, instance) { | ||
* instance.on('inputSubmitRequest', function () { | ||
* hostedFields.create({ ... }, function (createErr, hostedFieldsInstance) { | ||
* hostedFieldsInstance.on('inputSubmitRequest', function () { | ||
* // User requested submission, e.g. by pressing Enter or equivalent | ||
@@ -505,4 +507,4 @@ * submitButton.click(); | ||
* <caption>Listening to an empty event</caption> | ||
* hostedFields.create({ ... }, function (err, instance) { | ||
* instance.on('empty', function (event) { | ||
* hostedFields.create({ ... }, function (createErr, hostedFieldsInstance) { | ||
* hostedFieldsInstance.on('empty', function (event) { | ||
* console.log(event.emittedBy, 'is now empty'); | ||
@@ -519,4 +521,4 @@ * }); | ||
* <caption>Listening to an notEmpty event</caption> | ||
* hostedFields.create({ ... }, function (err, instance) { | ||
* instance.on('notEmpty', function (event) { | ||
* hostedFields.create({ ... }, function (createErr, hostedFieldsInstance) { | ||
* hostedFieldsInstance.on('notEmpty', function (event) { | ||
* console.log(event.emittedBy, 'is now not empty'); | ||
@@ -533,4 +535,4 @@ * }); | ||
* <caption>Listening to a blur event</caption> | ||
* hostedFields.create({ ... }, function (err, instance) { | ||
* instance.on('blur', function (event) { | ||
* hostedFields.create({ ... }, function (createErr, hostedFieldsInstance) { | ||
* hostedFieldsInstance.on('blur', function (event) { | ||
* console.log(event.emittedBy, 'lost focus'); | ||
@@ -547,4 +549,4 @@ * }); | ||
* <caption>Listening to a focus event</caption> | ||
* hostedFields.create({ ... }, function (err, instance) { | ||
* instance.on('focus', function (event) { | ||
* hostedFields.create({ ... }, function (createErr, hostedFieldsInstance) { | ||
* hostedFieldsInstance.on('focus', function (event) { | ||
* console.log(event.emittedBy, 'gained focus'); | ||
@@ -561,4 +563,4 @@ * }); | ||
* <caption>Listening to a cardTypeChange event</caption> | ||
* hostedFields.create({ ... }, function (err, instance) { | ||
* instance.on('cardTypeChange', function (event) { | ||
* hostedFields.create({ ... }, function (createErr, hostedFieldsInstance) { | ||
* hosteFieldsInstance.on('cardTypeChange', function (event) { | ||
* if (event.cards.length === 1) { | ||
@@ -579,4 +581,4 @@ * console.log(event.cards[0].type); | ||
* <caption>Listening to a validityChange event</caption> | ||
* hostedFields.create({ ... }, function (err, instance) { | ||
* instance.on('validityChange', function (event) { | ||
* hostedFields.create({ ... }, function (createErr, hostedFieldsInstance) { | ||
* hostedFieldsInstance.on('validityChange', function (event) { | ||
* var field = event.fields[event.emittedBy]; | ||
@@ -807,4 +809,4 @@ * | ||
* @example | ||
* hostedFieldsInstance.teardown(function (err) { | ||
* if (err) { | ||
* hostedFieldsInstance.teardown(function (teardownErr) { | ||
* if (teardownErr) { | ||
* console.error('Could not tear down Hosted Fields!'); | ||
@@ -835,5 +837,5 @@ * } else { | ||
* @example | ||
* hostedFieldsInstance.tokenize(function (err, payload) { | ||
* if (err) { | ||
* console.error(err); | ||
* hostedFieldsInstance.tokenize(function (tokenizeErr, payload) { | ||
* if (tokenizeErr) { | ||
* console.error(tokenizeErr); | ||
* } else { | ||
@@ -866,5 +868,5 @@ * console.log('Got nonce:', payload.nonce); | ||
* @example | ||
* hostedFieldsInstance.setPlaceholder('number', '4111 1111 1111 1111', function (err) { | ||
* if (err) { | ||
* console.error(err); | ||
* hostedFieldsInstance.setPlaceholder('number', '4111 1111 1111 1111', function (placeholderErr) { | ||
* if (placeholderErr) { | ||
* console.error(placeholderErr); | ||
* } | ||
@@ -877,6 +879,6 @@ * }); | ||
* if (event.cards.length === 1) { | ||
* hostedFields.setPlaceholder('cvv', event.cards[0].code.name, function (err) { | ||
* if (err) { | ||
* hostedFields.setPlaceholder('cvv', event.cards[0].code.name, function (placeholderErr) { | ||
* if (placeholderErr) { | ||
* // Handle errors, such as invalid field name | ||
* console.error(err); | ||
* console.error(placeholderErr); | ||
* } | ||
@@ -918,5 +920,5 @@ * }); | ||
* @example | ||
* hostedFieldsInstance.clear('number', function (err) { | ||
* if (err) { | ||
* console.error(err); | ||
* hostedFieldsInstance.clear('number', function (clearErr) { | ||
* if (clearErr) { | ||
* console.error(clearErr); | ||
* } | ||
@@ -955,3 +957,3 @@ * }); | ||
},{"../../lib/analytics":13,"../../lib/bus":17,"../../lib/classlist":18,"../../lib/constants":19,"../../lib/convert-methods-to-error":20,"../../lib/deferred":22,"../../lib/destructor":23,"../../lib/error":25,"../../lib/event-emitter":26,"../../lib/is-ios":27,"../../lib/methods":29,"../../lib/uuid":31,"../shared/constants":10,"../shared/find-parent-tags":11,"./compose-url":6,"./inject-frame":8,"iframer":2}],8:[function(_dereq_,module,exports){ | ||
},{"../../lib/analytics":13,"../../lib/bus":17,"../../lib/classlist":18,"../../lib/constants":19,"../../lib/convert-methods-to-error":20,"../../lib/deferred":22,"../../lib/destructor":23,"../../lib/error":25,"../../lib/event-emitter":26,"../../lib/is-ios":27,"../../lib/methods":29,"../../lib/uuid":32,"../shared/constants":10,"../shared/find-parent-tags":11,"./compose-url":6,"./inject-frame":8,"iframer":2}],8:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -977,3 +979,3 @@ | ||
var HostedFields = _dereq_('./external/hosted-fields'); | ||
var packageVersion = "3.0.0-beta.8"; | ||
var packageVersion = "3.0.0-beta.9"; | ||
var deferred = _dereq_('../lib/deferred'); | ||
@@ -1024,3 +1026,3 @@ var BraintreeError = _dereq_('../lib/error'); | ||
* braintree.hostedFields.create({ | ||
* client: client, | ||
* client: clientInstance, | ||
* styles: { | ||
@@ -1085,3 +1087,3 @@ * 'input': { | ||
var enumerate = _dereq_('../../lib/enumerate'); | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
@@ -1273,2 +1275,4 @@ var constants = { | ||
var once = _dereq_('./once'); | ||
function call(fn, callback) { | ||
@@ -1285,13 +1289,2 @@ var isSync = fn.length === 0; | ||
function once(fn) { | ||
var called = false; | ||
return function () { | ||
if (!called) { | ||
called = true; | ||
fn.apply(null, arguments); | ||
} | ||
}; | ||
} | ||
module.exports = function (functions, cb) { | ||
@@ -1325,3 +1318,3 @@ var i; | ||
},{}],15:[function(_dereq_,module,exports){ | ||
},{"./once":30}],15:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1535,3 +1528,3 @@ | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
var PLATFORM = 'web'; | ||
@@ -1614,3 +1607,3 @@ | ||
},{"../lib/polyfill":30}],22:[function(_dereq_,module,exports){ | ||
},{"../lib/polyfill":31}],22:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1800,2 +1793,18 @@ | ||
},{}],30:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
function once(fn) { | ||
var called = false; | ||
return function () { | ||
if (!called) { | ||
called = true; | ||
fn.apply(null, arguments); | ||
} | ||
}; | ||
} | ||
module.exports = once; | ||
},{}],31:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -1839,3 +1848,3 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],31:[function(_dereq_,module,exports){ | ||
},{}],32:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1842,0 +1851,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(e.braintree||(e.braintree={})).hostedFields=t()}}(function(){var t;return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return i(n?n:e)},u,u.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,n,r){"use strict";!function(e,i){"object"==typeof r&&"undefined"!=typeof n?n.exports=i():"function"==typeof t&&t.amd?t([],i):e.framebus=i()}(this,function(){function t(t){return null==t?!1:null==t.Window?!1:t.constructor!==t.Window?!1:(x.push(t),!0)}function e(t){var e,n={};for(e in v)v.hasOwnProperty(e)&&(n[e]=v[e]);return n._origin=t||"*",n}function n(t){var e,n,r=o(this);return s(t)?!1:s(r)?!1:(n=Array.prototype.slice.call(arguments,1),e=a(t,n,r),e===!1?!1:(h(b.top,e,r),!0))}function r(t,e){var n=o(this);return g(t,e,n)?!1:(_[n]=_[n]||{},_[n][t]=_[n][t]||[],_[n][t].push(e),!0)}function i(t,e){var n,r,i=o(this);if(g(t,e,i))return!1;if(r=_[i]&&_[i][t],!r)return!1;for(n=0;n<r.length;n++)if(r[n]===e)return r.splice(n,1),!0;return!1}function o(t){return t&&t._origin||"*"}function s(t){return"string"!=typeof t}function a(t,e,n){var r=!1,i={event:t,origin:n},o=e[e.length-1];"function"==typeof o&&(i.reply=m(o,n),e=e.slice(0,-1)),i.args=e;try{r=E+JSON.stringify(i)}catch(s){throw new Error("Could not stringify event: "+s.message)}return r}function c(t){var e,n,r,i;if(t.data.slice(0,E.length)!==E)return!1;try{e=JSON.parse(t.data.slice(E.length))}catch(o){return!1}return null!=e.reply&&(n=t.origin,r=t.source,i=e.reply,e.reply=function(t){var e=a(i,[t],n);return e===!1?!1:void r.postMessage(e,n)},e.args.push(e.reply)),e}function l(t){b||(b=t||window,b.addEventListener?b.addEventListener("message",f,!1):b.attachEvent?b.attachEvent("onmessage",f):null===b.onmessage?b.onmessage=f:b=null)}function u(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})}function f(t){var e;s(t.data)||(e=c(t),e&&(d("*",e.event,e.args,t),d(t.origin,e.event,e.args,t),y(t.data,e.origin,t.source)))}function d(t,e,n,r){var i;if(_[t]&&_[t][e])for(i=0;i<_[t][e].length;i++)_[t][e][i].apply(r,n)}function p(t){return t.top!==t?!1:null==t.opener?!1:t.opener===t?!1:t.opener.closed===!0?!1:!0}function h(t,e,n){var r;try{for(t.postMessage(e,n),p(t)&&h(t.opener.top,e,n),r=0;r<t.frames.length;r++)h(t.frames[r],e,n)}catch(i){}}function y(t,e,n){var r,i;for(r=x.length-1;r>=0;r--)i=x[r],i.closed===!0?x=x.slice(r,1):n!==i&&h(i.top,t,e)}function m(t,e){function n(i,o){t(i,o),v.target(e).unsubscribe(r,n)}var r=u();return v.target(e).subscribe(r,n),r}function g(t,e,n){return s(t)?!0:"function"!=typeof e?!0:s(n)?!0:!1}var b,v,x=[],_={},E="/*framebus*/";return l(),v={target:e,include:t,publish:n,pub:n,trigger:n,emit:n,subscribe:r,sub:r,on:r,unsubscribe:i,unsub:i,off:i}})},{}],2:[function(t,e,n){"use strict";var r=t("./lib/set-attributes"),i=t("./lib/default-attributes"),o=t("./lib/assign");e.exports=function(t){var e=document.createElement("iframe"),n=o({},i,t);return n.style&&"string"!=typeof n.style&&(o(e.style,n.style),delete n.style),r(e,n),e.getAttribute("id")||(e.id=e.name),e}},{"./lib/assign":3,"./lib/default-attributes":4,"./lib/set-attributes":5}],3:[function(t,e,n){"use strict";e.exports=function(t){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(e){"object"==typeof e&&Object.keys(e).forEach(function(n){t[n]=e[n]})}),t}},{}],4:[function(t,e,n){e.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],5:[function(t,e,n){"use strict";e.exports=function(t,e){var n;for(var r in e)e.hasOwnProperty(r)&&(n=e[r],null==n?t.removeAttribute(r):t.setAttribute(r,n))}},{}],6:[function(t,e,n){"use strict";var r=t("../shared/constants");e.exports=function(t,e){return t+"/web/"+r.VERSION+"/html/hosted-fields-frame.min.html#"+e}},{"../shared/constants":10}],7:[function(t,e,n){"use strict";function r(t){return function(e){var n,r=e.merchantPayload,i=r.emittedBy,o=t[i].containerElement;Object.keys(r.fields).forEach(function(e){r.fields[e].container=t[e].containerElement}),n=r.fields[i],s.toggle(o,f.externalClasses.FOCUSED,n.isFocused),s.toggle(o,f.externalClasses.VALID,n.isValid),n.isStrictlyValidating?s.toggle(o,f.externalClasses.INVALID,!n.isValid):s.toggle(o,f.externalClasses.INVALID,!n.isPotentiallyValid),this._emit(e.type,r)}}function i(t){var e,n,h,y,x,N,T=this,A={},C=0,O=p();if(!t.client)throw new l({type:l.types.MERCHANT,message:"You must specify a client when initializing Hosted Fields."});if(N=t.client.getConfiguration().analyticsMetadata.sdkVersion,N!==_)throw new l({type:l.types.MERCHANT,message:"Client (version "+N+") and Hosted Fields (version "+_+") components must be from the same SDK version."});if(!t.fields)throw new l({type:l.types.MERCHANT,message:"You must specify fields when initializing Hosted Fields."});g.call(this),this._injectedNodes=[],this._destructor=new o,this._fields=A,this._bus=new c({channel:O,merchantUrl:location.href}),this._destructor.registerFunctionForTeardown(function(){T._bus.teardown()}),this._client=t.client,v.sendEvent(this._client,"web.custom.hosted-fields.initialized");for(y in f.whitelistedFields)if(f.whitelistedFields.hasOwnProperty(y)){if(e=t.fields[y],!e)continue;if(n=document.querySelector(e.selector),!n)throw new l({type:l.types.MERCHANT,message:"Selector does not reference a valid DOM node.",details:{fieldSelector:e.selector,fieldKey:y}});if(n.querySelector('iframe[name^="braintree-"]'))throw new l({type:l.types.MERCHANT,message:"Element already contains a Braintree iframe.",details:{fieldSelector:e.selector,fieldKey:y}});h=a({type:y,name:"braintree-hosted-field-"+y,style:f.defaultIFrameStyle}),this._injectedNodes=this._injectedNodes.concat(b(h,n)),this._setupLabelFocus(y,n),A[y]={frameElement:h,containerElement:n},C++,setTimeout(function(t){return function(){t.src=u(T._client.getConfiguration().gatewayConfiguration.assetsUrl,O)}}(h),0)}x=setTimeout(function(){v.sendEvent(T._client,"web.custom.hosted-fields.load.timed-out")},d),this._bus.on(m.FRAME_READY,function(e){C--,0===C&&(clearTimeout(x),e(t),T._emit("ready"))}),this._bus.on(m.INPUT_EVENT,r(A).bind(this)),this._destructor.registerFunctionForTeardown(function(){var t,e,n;for(t=0;t<T._injectedNodes.length;t++)e=T._injectedNodes[t],n=e.parentNode,n.removeChild(e),s.remove(n,f.externalClasses.FOCUSED,f.externalClasses.INVALID,f.externalClasses.VALID)}),this._destructor.registerFunctionForTeardown(function(){var t=E(i.prototype).concat(E(g.prototype));w(T,t)})}var o=t("../../lib/destructor"),s=t("../../lib/classlist"),a=t("iframer"),c=t("../../lib/bus"),l=t("../../lib/error"),u=t("./compose-url"),f=t("../shared/constants"),d=t("../../lib/constants").INTEGRATION_TIMEOUT_MS,p=t("../../lib/uuid"),h=t("../shared/find-parent-tags"),y=t("../../lib/is-ios"),m=f.events,g=t("../../lib/event-emitter"),b=t("./inject-frame"),v=t("../../lib/analytics"),x=f.whitelistedFields,_="3.0.0-beta.8",E=t("../../lib/methods"),w=t("../../lib/convert-methods-to-error"),N=t("../../lib/deferred");i.prototype=Object.create(g.prototype,{constructor:i}),i.prototype._setupLabelFocus=function(t,e){function n(){s.emit(m.TRIGGER_INPUT_FOCUS,t)}var r,i,o=y(),s=this._bus;if(!o&&null!=e.id){for(r=Array.prototype.slice.call(document.querySelectorAll('label[for="'+e.id+'"]')),r=r.concat(h(e,"label")),i=0;i<r.length;i++)r[i].addEventListener("click",n,!1);this._destructor.registerFunctionForTeardown(function(){for(i=0;i<r.length;i++)r[i].removeEventListener("click",n,!1)})}},i.prototype.teardown=function(t){var e=this._client;this._destructor.teardown(function(n){v.sendEvent(e,"web.custom.hosted-fields.teardown-completed"),"function"==typeof t&&(t=N(t))(n)})},i.prototype.tokenize=function(t){if("function"!=typeof t)throw new l({type:l.types.MERCHANT,message:"tokenize must include a callback function."});this._bus.emit(m.TOKENIZATION_REQUEST,function(e){t.apply(null,e)})},i.prototype.setPlaceholder=function(t,e,n){var r;x.hasOwnProperty(t)?this._fields.hasOwnProperty(t)?this._bus.emit(m.SET_PLACEHOLDER,t,e):r=new l({type:l.types.MERCHANT,message:'Cannot set placeholder for "'+t+'" field because it is not part of the current Hosted Fields options.'}):r=new l({type:l.types.MERCHANT,message:'"'+t+'" is not a valid field. You must use a valid field option when setting a placeholder.'}),"function"==typeof n&&(n=N(n))(r)},i.prototype.clear=function(t,e){var n;x.hasOwnProperty(t)?this._fields.hasOwnProperty(t)?this._bus.emit(m.CLEAR_FIELD,t):n=new l({type:l.types.MERCHANT,message:'Cannot clear "'+t+'" field because it is not part of the current Hosted Fields options.'}):n=new l({type:l.types.MERCHANT,message:'"'+t+'" is not a valid field. You must use a valid field option when clearing a field.'}),"function"==typeof e&&(e=N(e))(n)},e.exports=i},{"../../lib/analytics":13,"../../lib/bus":17,"../../lib/classlist":18,"../../lib/constants":19,"../../lib/convert-methods-to-error":20,"../../lib/deferred":22,"../../lib/destructor":23,"../../lib/error":25,"../../lib/event-emitter":26,"../../lib/is-ios":27,"../../lib/methods":29,"../../lib/uuid":31,"../shared/constants":10,"../shared/find-parent-tags":11,"./compose-url":6,"./inject-frame":8,iframer:2}],8:[function(t,e,n){"use strict";e.exports=function(t,e){var n=document.createElement("div"),r=document.createDocumentFragment();return n.style.clear="both",r.appendChild(t),r.appendChild(n),e.appendChild(r),[t,n]}},{}],9:[function(t,e,n){"use strict";var r=t("./external/hosted-fields"),i="3.0.0-beta.8",o=t("../lib/deferred"),s=t("../lib/error");e.exports={create:function(t,e){var n;if("function"!=typeof e)throw new s({type:s.types.MERCHANT,message:"create must include a callback function."});try{n=new r(t)}catch(i){return e=o(e),void e(i)}n.on("ready",function(){e(null,n)})},VERSION:i}},{"../lib/deferred":22,"../lib/error":25,"./external/hosted-fields":7}],10:[function(t,e,n){"use strict";var r=t("../../lib/enumerate"),i="3.0.0-beta.8",o={VERSION:i,externalEvents:{FOCUS:"focus",BLUR:"blur",EMPTY:"empty",NOT_EMPTY:"notEmpty",VALIDITY_CHANGE:"validityChange",CARD_TYPE_CHANGE:"cardTypeChange"},defaultMaxLengths:{number:19,postalCode:8,expirationDate:7,expirationMonth:2,expirationYear:4,cvv:3},externalClasses:{FOCUSED:"braintree-hosted-fields-focused",INVALID:"braintree-hosted-fields-invalid",VALID:"braintree-hosted-fields-valid"},defaultIFrameStyle:{border:"none",width:"100%",height:"100%","float":"left"},whitelistedStyles:["-moz-osx-font-smoothing","-moz-tap-highlight-color","-moz-transition","-webkit-font-smoothing","-webkit-tap-highlight-color","-webkit-transition","color","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-weight","line-height","opacity","outline","text-shadow","transition"],whitelistedFields:{number:{name:"credit-card-number",label:"Credit Card Number"},cvv:{name:"cvv",label:"CVV"},expirationDate:{name:"expiration",label:"Expiration Date"},expirationMonth:{name:"expiration-month",label:"Expiration Month"},expirationYear:{name:"expiration-year",label:"Expiration Year"},postalCode:{name:"postal-code",label:"Postal Code"}}};o.events=r(["FRAME_READY","VALIDATE_STRICT","CONFIGURATION","TOKENIZATION_REQUEST","INPUT_EVENT","TRIGGER_INPUT_FOCUS","SET_PLACEHOLDER","CLEAR_FIELD"],"hosted-fields:"),e.exports=o},{"../../lib/enumerate":24}],11:[function(t,e,n){"use strict";function r(t,e){for(var n=t.parentNode,r=[];null!=n;)null!=n.tagName&&n.tagName.toLowerCase()===e&&r.push(n),n=n.parentNode;return r}e.exports=r},{}],12:[function(t,e,n){"use strict";function r(t,e){var n,r=e?o(e):{},a=i(t.authorization).attrs,c=o(t.analyticsMetadata);r.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION;for(n in r._meta)r._meta.hasOwnProperty(n)&&(c[n]=r._meta[n]);return r._meta=c,a.tokenizationKey?r.tokenizationKey=a.tokenizationKey:r.authorizationFingerprint=a.authorizationFingerprint,r}var i=t("./create-authorization-data"),o=t("./json-clone"),s=t("./constants");e.exports=r},{"./constants":19,"./create-authorization-data":21,"./json-clone":28}],13:[function(t,e,n){"use strict";function r(t){return Math.floor(t/1e3)}function i(t,e,n){var i=t.getConfiguration(),a=t._request,c=r(Date.now()),l=i.gatewayConfiguration.analytics.url,u={analytics:[{kind:e,timestamp:c}]};a({url:l,method:"post",data:s(i,u),timeout:o.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var o=t("./constants"),s=t("./add-metadata");e.exports={sendEvent:i}},{"./add-metadata":12,"./constants":19}],14:[function(t,e,n){"use strict";function r(t,e){var n=0===t.length;n?(t(),e(null)):t(e)}function i(t){var e=!1;return function(){e||(e=!0,t.apply(null,arguments))}}e.exports=function(t,e){function n(t){return t?void c(t):(a-=1,void(0===a&&c(null)))}var o,s=t.length,a=s,c=i(e);if(0===s)return void c(null);for(o=0;s>o;o++)r(t[o],n)}},{}],15:[function(t,e,n){"use strict";function r(t,e){var n,r,o=document.createElement("a");return o.href=e,r="https:"===o.protocol?o.host.replace(/:443$/,""):"http:"===o.protocol?o.host.replace(/:80$/,""):o.host,n=o.protocol+"//"+r,n===t||i.test(t)}var i=/^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/;e.exports={checkOrigin:r}},{}],16:[function(t,e,n){"use strict";var r=t("../enumerate");e.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":24}],17:[function(t,e,n){"use strict";function r(t){if(t=t||{},this.channel=t.channel,!this.channel)throw new a({type:a.types.INTERNAL,message:"Channel ID must be specified."});this.merchantUrl=t.merchantUrl,this._isDestroyed=!1,this._isVerbose=!1,this._listeners=[],this._log("new bus on channel "+this.channel,[location.href])}var i=t("framebus"),o=t("./events"),s=t("./check-origin").checkOrigin,a=t("../error");r.prototype.on=function(t,e){var n,r,o=e,a=this;this._isDestroyed||(this.merchantUrl&&(o=function(){s(this.origin,a.merchantUrl)&&e.apply(this,arguments)}),n=this._namespaceEvent(t),r=Array.prototype.slice.call(arguments),r[0]=n,r[1]=o,this._log("on",r),i.on.apply(i,r),this._listeners.push({eventName:t,handler:o,originalHandler:e}))},r.prototype.emit=function(t){var e;this._isDestroyed||(e=Array.prototype.slice.call(arguments),e[0]=this._namespaceEvent(t),this._log("emit",e),i.emit.apply(i,e))},r.prototype._offDirect=function(t){var e=Array.prototype.slice.call(arguments);this._isDestroyed||(e[0]=this._namespaceEvent(t),this._log("off",e),i.off.apply(i,e))},r.prototype.off=function(t,e){var n,r,i=e;if(!this._isDestroyed){if(this.merchantUrl)for(n=0;n<this._listeners.length;n++)r=this._listeners[n],r.originalHandler===e&&(i=r.handler);this._offDirect(t,i)}},r.prototype._namespaceEvent=function(t){return["braintree",this.channel,t].join(":")},r.prototype.teardown=function(){var t,e;for(e=0;e<this._listeners.length;e++)t=this._listeners[e],this._offDirect(t.eventName,t.handler);this._listeners.length=0,this._isDestroyed=!0},r.prototype._log=function(t,e){this._isVerbose&&console.log(t,e)},r.events=o,e.exports=r},{"../error":25,"./check-origin":15,"./events":16,framebus:1}],18:[function(t,e,n){"use strict";function r(t){return t.className.trim().split(/\s+/)}function i(t){var e=Array.prototype.slice.call(arguments,1),n=r(t).filter(function(t){return-1===e.indexOf(t)}).concat(e).join(" ");t.className=n}function o(t){var e=Array.prototype.slice.call(arguments,1),n=r(t).filter(function(t){return-1===e.indexOf(t)}).join(" ");t.className=n}function s(t,e,n){n?i(t,e):o(t,e)}e.exports={add:i,remove:o,toggle:s}},{}],19:[function(t,e,n){"use strict";var r="3.0.0-beta.8",i="web";e.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:i,BRAINTREE_LIBRARY_VERSION:"braintree/"+i+"/"+r}},{}],20:[function(t,e,n){"use strict";var r=t("./error");e.exports=function(t,e){e.forEach(function(e){t[e]=function(){throw new r({type:r.types.MERCHANT,message:e+" cannot be called after teardown."})}})}},{"./error":25}],21:[function(t,e,n){"use strict";function r(t){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(t)}function i(t){var e=t.split("_"),n=e[0],r=e.slice(2).join("_");return{merchantId:r,environment:n}}function o(t){var e,n,o={attrs:{},configUrl:""};return r(t)?(n=i(t),o.attrs.tokenizationKey=t,o.configUrl=a[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(e=JSON.parse(s(t)),o.attrs.authorizationFingerprint=e.authorizationFingerprint,o.configUrl=e.configUrl),o}var s=t("../lib/polyfill").atob,a={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};e.exports=o},{"../lib/polyfill":30}],22:[function(t,e,n){"use strict";e.exports=function(t){return function(){var e=arguments;setTimeout(function(){t.apply(null,e)},1)}}},{}],23:[function(t,e,n){"use strict";function r(){this._teardownRegistry=[],this._isTearingDown=!1}var i=t("./batch-execute-functions");r.prototype.registerFunctionForTeardown=function(t){"function"==typeof t&&this._teardownRegistry.push(t)},r.prototype.teardown=function(t){return this._isTearingDown?void t(new Error("Destructor is already tearing down")):(this._isTearingDown=!0,void i(this._teardownRegistry,function(e){this._teardownRegistry=[],this._isTearingDown=!1,"function"==typeof t&&t(e)}.bind(this)))},e.exports=r},{"./batch-execute-functions":14}],24:[function(t,e,n){"use strict";function r(t,e){return e=null==e?"":e,t.reduce(function(t,n){return t[n]=e+n,t},{})}e.exports=r},{}],25:[function(t,e,n){"use strict";function r(t){if(!r.types.hasOwnProperty(t.type))throw new Error(t.type+" is not a valid type.");if(!t.message)throw new Error("Error message required.");this.message=t.message,this.type=t.type,this.details=t.details}var i=t("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=i(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),e.exports=r},{"./enumerate":24}],26:[function(t,e,n){"use strict";function r(){this._events={}}r.prototype.on=function(t,e){this._events[t]?this._events[t].push(e):this._events[t]=[e]},r.prototype._emit=function(t){var e,n,r=this._events[t];if(r)for(n=Array.prototype.slice.call(arguments,1),e=0;e<r.length;e++)r[e].apply(null,n)},e.exports=r},{}],27:[function(t,e,n){"use strict";e.exports=function(t){return t=t||navigator.userAgent,/(iPad|iPhone|iPod)/i.test(t)}},{}],28:[function(t,e,n){"use strict";e.exports=function(t){return JSON.parse(JSON.stringify(t))}},{}],29:[function(t,e,n){"use strict";e.exports=function(t){return Object.keys(t).filter(function(e){return"function"==typeof t[e]})}},{}],30:[function(t,e,n){(function(t){"use strict";function n(t){var e,n,r,i,o,s,a,c,l=new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$"),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="";if(!l.test(t))throw new Error("Non base64 encoded input passed to window.atob polyfill");c=0;do i=u.indexOf(t.charAt(c++)),o=u.indexOf(t.charAt(c++)),s=u.indexOf(t.charAt(c++)),a=u.indexOf(t.charAt(c++)),e=(63&i)<<2|o>>4&3,n=(15&o)<<4|s>>2&15,r=(3&s)<<6|63&a,f+=String.fromCharCode(e)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(c<t.length);return f}var r="function"==typeof t.atob?t.atob:n;e.exports={atob:r,_atob:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],31:[function(t,e,n){"use strict";function r(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})}e.exports=r},{}]},{},[9])(9)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(e.braintree||(e.braintree={})).hostedFields=t()}}(function(){var t;return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return i(n?n:e)},u,u.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,n,r){(function(e){"use strict";!function(i,o){"object"==typeof r&&"undefined"!=typeof n?n.exports=o("undefined"==typeof e?i:e):"function"==typeof t&&t.amd?t([],function(){return o(i)}):i.framebus=o(i)}(this,function(t){function e(t){return null==t?!1:null==t.Window?!1:t.constructor!==t.Window?!1:(_.push(t),!0)}function n(t){var e,n={};for(e in x)x.hasOwnProperty(e)&&(n[e]=x[e]);return n._origin=t||"*",n}function r(t){var e,n,r=s(this);return a(t)?!1:a(r)?!1:(n=Array.prototype.slice.call(arguments,1),e=c(t,n,r),e===!1?!1:(y(v.top,e,r),!0))}function i(t,e){var n=s(this);return b(t,e,n)?!1:(E[n]=E[n]||{},E[n][t]=E[n][t]||[],E[n][t].push(e),!0)}function o(t,e){var n,r,i=s(this);if(b(t,e,i))return!1;if(r=E[i]&&E[i][t],!r)return!1;for(n=0;n<r.length;n++)if(r[n]===e)return r.splice(n,1),!0;return!1}function s(t){return t&&t._origin||"*"}function a(t){return"string"!=typeof t}function c(t,e,n){var r=!1,i={event:t,origin:n},o=e[e.length-1];"function"==typeof o&&(i.reply=g(o,n),e=e.slice(0,-1)),i.args=e;try{r=w+JSON.stringify(i)}catch(s){throw new Error("Could not stringify event: "+s.message)}return r}function l(t){var e,n,r,i;if(t.data.slice(0,w.length)!==w)return!1;try{e=JSON.parse(t.data.slice(w.length))}catch(o){return!1}return null!=e.reply&&(n=t.origin,r=t.source,i=e.reply,e.reply=function(t){var e=c(i,[t],n);return e===!1?!1:void r.postMessage(e,n)},e.args.push(e.reply)),e}function u(e){v||(v=e||t,v.addEventListener?v.addEventListener("message",d,!1):v.attachEvent?v.attachEvent("onmessage",d):null===v.onmessage?v.onmessage=d:v=null)}function f(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})}function d(t){var e;a(t.data)||(e=l(t),e&&(p("*",e.event,e.args,t),p(t.origin,e.event,e.args,t),m(t.data,e.origin,t.source)))}function p(t,e,n,r){var i;if(E[t]&&E[t][e])for(i=0;i<E[t][e].length;i++)E[t][e][i].apply(r,n)}function h(t){return t.top!==t?!1:null==t.opener?!1:t.opener===t?!1:t.opener.closed===!0?!1:!0}function y(t,e,n){var r;try{for(t.postMessage(e,n),h(t)&&y(t.opener.top,e,n),r=0;r<t.frames.length;r++)y(t.frames[r],e,n)}catch(i){}}function m(t,e,n){var r,i;for(r=_.length-1;r>=0;r--)i=_[r],i.closed===!0?_=_.slice(r,1):n!==i&&y(i.top,t,e)}function g(t,e){function n(i,o){t(i,o),x.target(e).unsubscribe(r,n)}var r=f();return x.target(e).subscribe(r,n),r}function b(t,e,n){return a(t)?!0:"function"!=typeof e?!0:a(n)?!0:!1}var v,x,_=[],E={},w="/*framebus*/";return u(),x={target:n,include:e,publish:r,pub:r,trigger:r,emit:r,subscribe:i,sub:i,on:i,unsubscribe:o,unsub:o,off:o}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,n){"use strict";var r=t("./lib/set-attributes"),i=t("./lib/default-attributes"),o=t("./lib/assign");e.exports=function(t){var e=document.createElement("iframe"),n=o({},i,t);return n.style&&"string"!=typeof n.style&&(o(e.style,n.style),delete n.style),r(e,n),e.getAttribute("id")||(e.id=e.name),e}},{"./lib/assign":3,"./lib/default-attributes":4,"./lib/set-attributes":5}],3:[function(t,e,n){"use strict";e.exports=function(t){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(e){"object"==typeof e&&Object.keys(e).forEach(function(n){t[n]=e[n]})}),t}},{}],4:[function(t,e,n){e.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],5:[function(t,e,n){"use strict";e.exports=function(t,e){var n;for(var r in e)e.hasOwnProperty(r)&&(n=e[r],null==n?t.removeAttribute(r):t.setAttribute(r,n))}},{}],6:[function(t,e,n){"use strict";var r=t("../shared/constants");e.exports=function(t,e){return t+"/web/"+r.VERSION+"/html/hosted-fields-frame.min.html#"+e}},{"../shared/constants":10}],7:[function(t,e,n){"use strict";function r(t){return function(e){var n,r=e.merchantPayload,i=r.emittedBy,o=t[i].containerElement;Object.keys(r.fields).forEach(function(e){r.fields[e].container=t[e].containerElement}),n=r.fields[i],s.toggle(o,f.externalClasses.FOCUSED,n.isFocused),s.toggle(o,f.externalClasses.VALID,n.isValid),n.isStrictlyValidating?s.toggle(o,f.externalClasses.INVALID,!n.isValid):s.toggle(o,f.externalClasses.INVALID,!n.isPotentiallyValid),this._emit(e.type,r)}}function i(t){var e,n,h,y,x,N,T=this,A={},C=0,O=p();if(!t.client)throw new l({type:l.types.MERCHANT,message:"You must specify a client when initializing Hosted Fields."});if(N=t.client.getConfiguration().analyticsMetadata.sdkVersion,N!==_)throw new l({type:l.types.MERCHANT,message:"Client (version "+N+") and Hosted Fields (version "+_+") components must be from the same SDK version."});if(!t.fields)throw new l({type:l.types.MERCHANT,message:"You must specify fields when initializing Hosted Fields."});g.call(this),this._injectedNodes=[],this._destructor=new o,this._fields=A,this._bus=new c({channel:O,merchantUrl:location.href}),this._destructor.registerFunctionForTeardown(function(){T._bus.teardown()}),this._client=t.client,v.sendEvent(this._client,"web.custom.hosted-fields.initialized");for(y in f.whitelistedFields)if(f.whitelistedFields.hasOwnProperty(y)){if(e=t.fields[y],!e)continue;if(n=document.querySelector(e.selector),!n)throw new l({type:l.types.MERCHANT,message:"Selector does not reference a valid DOM node.",details:{fieldSelector:e.selector,fieldKey:y}});if(n.querySelector('iframe[name^="braintree-"]'))throw new l({type:l.types.MERCHANT,message:"Element already contains a Braintree iframe.",details:{fieldSelector:e.selector,fieldKey:y}});h=a({type:y,name:"braintree-hosted-field-"+y,style:f.defaultIFrameStyle}),this._injectedNodes=this._injectedNodes.concat(b(h,n)),this._setupLabelFocus(y,n),A[y]={frameElement:h,containerElement:n},C++,setTimeout(function(t){return function(){t.src=u(T._client.getConfiguration().gatewayConfiguration.assetsUrl,O)}}(h),0)}x=setTimeout(function(){v.sendEvent(T._client,"web.custom.hosted-fields.load.timed-out")},d),this._bus.on(m.FRAME_READY,function(e){C--,0===C&&(clearTimeout(x),e(t),T._emit("ready"))}),this._bus.on(m.INPUT_EVENT,r(A).bind(this)),this._destructor.registerFunctionForTeardown(function(){var t,e,n;for(t=0;t<T._injectedNodes.length;t++)e=T._injectedNodes[t],n=e.parentNode,n.removeChild(e),s.remove(n,f.externalClasses.FOCUSED,f.externalClasses.INVALID,f.externalClasses.VALID)}),this._destructor.registerFunctionForTeardown(function(){var t=E(i.prototype).concat(E(g.prototype));w(T,t)})}var o=t("../../lib/destructor"),s=t("../../lib/classlist"),a=t("iframer"),c=t("../../lib/bus"),l=t("../../lib/error"),u=t("./compose-url"),f=t("../shared/constants"),d=t("../../lib/constants").INTEGRATION_TIMEOUT_MS,p=t("../../lib/uuid"),h=t("../shared/find-parent-tags"),y=t("../../lib/is-ios"),m=f.events,g=t("../../lib/event-emitter"),b=t("./inject-frame"),v=t("../../lib/analytics"),x=f.whitelistedFields,_="3.0.0-beta.9",E=t("../../lib/methods"),w=t("../../lib/convert-methods-to-error"),N=t("../../lib/deferred");i.prototype=Object.create(g.prototype,{constructor:i}),i.prototype._setupLabelFocus=function(t,e){function n(){s.emit(m.TRIGGER_INPUT_FOCUS,t)}var r,i,o=y(),s=this._bus;if(!o&&null!=e.id){for(r=Array.prototype.slice.call(document.querySelectorAll('label[for="'+e.id+'"]')),r=r.concat(h(e,"label")),i=0;i<r.length;i++)r[i].addEventListener("click",n,!1);this._destructor.registerFunctionForTeardown(function(){for(i=0;i<r.length;i++)r[i].removeEventListener("click",n,!1)})}},i.prototype.teardown=function(t){var e=this._client;this._destructor.teardown(function(n){v.sendEvent(e,"web.custom.hosted-fields.teardown-completed"),"function"==typeof t&&(t=N(t))(n)})},i.prototype.tokenize=function(t){if("function"!=typeof t)throw new l({type:l.types.MERCHANT,message:"tokenize must include a callback function."});this._bus.emit(m.TOKENIZATION_REQUEST,function(e){t.apply(null,e)})},i.prototype.setPlaceholder=function(t,e,n){var r;x.hasOwnProperty(t)?this._fields.hasOwnProperty(t)?this._bus.emit(m.SET_PLACEHOLDER,t,e):r=new l({type:l.types.MERCHANT,message:'Cannot set placeholder for "'+t+'" field because it is not part of the current Hosted Fields options.'}):r=new l({type:l.types.MERCHANT,message:'"'+t+'" is not a valid field. You must use a valid field option when setting a placeholder.'}),"function"==typeof n&&(n=N(n))(r)},i.prototype.clear=function(t,e){var n;x.hasOwnProperty(t)?this._fields.hasOwnProperty(t)?this._bus.emit(m.CLEAR_FIELD,t):n=new l({type:l.types.MERCHANT,message:'Cannot clear "'+t+'" field because it is not part of the current Hosted Fields options.'}):n=new l({type:l.types.MERCHANT,message:'"'+t+'" is not a valid field. You must use a valid field option when clearing a field.'}),"function"==typeof e&&(e=N(e))(n)},e.exports=i},{"../../lib/analytics":13,"../../lib/bus":17,"../../lib/classlist":18,"../../lib/constants":19,"../../lib/convert-methods-to-error":20,"../../lib/deferred":22,"../../lib/destructor":23,"../../lib/error":25,"../../lib/event-emitter":26,"../../lib/is-ios":27,"../../lib/methods":29,"../../lib/uuid":32,"../shared/constants":10,"../shared/find-parent-tags":11,"./compose-url":6,"./inject-frame":8,iframer:2}],8:[function(t,e,n){"use strict";e.exports=function(t,e){var n=document.createElement("div"),r=document.createDocumentFragment();return n.style.clear="both",r.appendChild(t),r.appendChild(n),e.appendChild(r),[t,n]}},{}],9:[function(t,e,n){"use strict";var r=t("./external/hosted-fields"),i="3.0.0-beta.9",o=t("../lib/deferred"),s=t("../lib/error");e.exports={create:function(t,e){var n;if("function"!=typeof e)throw new s({type:s.types.MERCHANT,message:"create must include a callback function."});try{n=new r(t)}catch(i){return e=o(e),void e(i)}n.on("ready",function(){e(null,n)})},VERSION:i}},{"../lib/deferred":22,"../lib/error":25,"./external/hosted-fields":7}],10:[function(t,e,n){"use strict";var r=t("../../lib/enumerate"),i="3.0.0-beta.9",o={VERSION:i,externalEvents:{FOCUS:"focus",BLUR:"blur",EMPTY:"empty",NOT_EMPTY:"notEmpty",VALIDITY_CHANGE:"validityChange",CARD_TYPE_CHANGE:"cardTypeChange"},defaultMaxLengths:{number:19,postalCode:8,expirationDate:7,expirationMonth:2,expirationYear:4,cvv:3},externalClasses:{FOCUSED:"braintree-hosted-fields-focused",INVALID:"braintree-hosted-fields-invalid",VALID:"braintree-hosted-fields-valid"},defaultIFrameStyle:{border:"none",width:"100%",height:"100%","float":"left"},whitelistedStyles:["-moz-osx-font-smoothing","-moz-tap-highlight-color","-moz-transition","-webkit-font-smoothing","-webkit-tap-highlight-color","-webkit-transition","color","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-weight","line-height","opacity","outline","text-shadow","transition"],whitelistedFields:{number:{name:"credit-card-number",label:"Credit Card Number"},cvv:{name:"cvv",label:"CVV"},expirationDate:{name:"expiration",label:"Expiration Date"},expirationMonth:{name:"expiration-month",label:"Expiration Month"},expirationYear:{name:"expiration-year",label:"Expiration Year"},postalCode:{name:"postal-code",label:"Postal Code"}}};o.events=r(["FRAME_READY","VALIDATE_STRICT","CONFIGURATION","TOKENIZATION_REQUEST","INPUT_EVENT","TRIGGER_INPUT_FOCUS","SET_PLACEHOLDER","CLEAR_FIELD"],"hosted-fields:"),e.exports=o},{"../../lib/enumerate":24}],11:[function(t,e,n){"use strict";function r(t,e){for(var n=t.parentNode,r=[];null!=n;)null!=n.tagName&&n.tagName.toLowerCase()===e&&r.push(n),n=n.parentNode;return r}e.exports=r},{}],12:[function(t,e,n){"use strict";function r(t,e){var n,r=e?o(e):{},a=i(t.authorization).attrs,c=o(t.analyticsMetadata);r.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION;for(n in r._meta)r._meta.hasOwnProperty(n)&&(c[n]=r._meta[n]);return r._meta=c,a.tokenizationKey?r.tokenizationKey=a.tokenizationKey:r.authorizationFingerprint=a.authorizationFingerprint,r}var i=t("./create-authorization-data"),o=t("./json-clone"),s=t("./constants");e.exports=r},{"./constants":19,"./create-authorization-data":21,"./json-clone":28}],13:[function(t,e,n){"use strict";function r(t){return Math.floor(t/1e3)}function i(t,e,n){var i=t.getConfiguration(),a=t._request,c=r(Date.now()),l=i.gatewayConfiguration.analytics.url,u={analytics:[{kind:e,timestamp:c}]};a({url:l,method:"post",data:s(i,u),timeout:o.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var o=t("./constants"),s=t("./add-metadata");e.exports={sendEvent:i}},{"./add-metadata":12,"./constants":19}],14:[function(t,e,n){"use strict";function r(t,e){var n=0===t.length;n?(t(),e(null)):t(e)}var i=t("./once");e.exports=function(t,e){function n(t){return t?void c(t):(a-=1,void(0===a&&c(null)))}var o,s=t.length,a=s,c=i(e);if(0===s)return void c(null);for(o=0;s>o;o++)r(t[o],n)}},{"./once":30}],15:[function(t,e,n){"use strict";function r(t,e){var n,r,o=document.createElement("a");return o.href=e,r="https:"===o.protocol?o.host.replace(/:443$/,""):"http:"===o.protocol?o.host.replace(/:80$/,""):o.host,n=o.protocol+"//"+r,n===t||i.test(t)}var i=/^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/;e.exports={checkOrigin:r}},{}],16:[function(t,e,n){"use strict";var r=t("../enumerate");e.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":24}],17:[function(t,e,n){"use strict";function r(t){if(t=t||{},this.channel=t.channel,!this.channel)throw new a({type:a.types.INTERNAL,message:"Channel ID must be specified."});this.merchantUrl=t.merchantUrl,this._isDestroyed=!1,this._isVerbose=!1,this._listeners=[],this._log("new bus on channel "+this.channel,[location.href])}var i=t("framebus"),o=t("./events"),s=t("./check-origin").checkOrigin,a=t("../error");r.prototype.on=function(t,e){var n,r,o=e,a=this;this._isDestroyed||(this.merchantUrl&&(o=function(){s(this.origin,a.merchantUrl)&&e.apply(this,arguments)}),n=this._namespaceEvent(t),r=Array.prototype.slice.call(arguments),r[0]=n,r[1]=o,this._log("on",r),i.on.apply(i,r),this._listeners.push({eventName:t,handler:o,originalHandler:e}))},r.prototype.emit=function(t){var e;this._isDestroyed||(e=Array.prototype.slice.call(arguments),e[0]=this._namespaceEvent(t),this._log("emit",e),i.emit.apply(i,e))},r.prototype._offDirect=function(t){var e=Array.prototype.slice.call(arguments);this._isDestroyed||(e[0]=this._namespaceEvent(t),this._log("off",e),i.off.apply(i,e))},r.prototype.off=function(t,e){var n,r,i=e;if(!this._isDestroyed){if(this.merchantUrl)for(n=0;n<this._listeners.length;n++)r=this._listeners[n],r.originalHandler===e&&(i=r.handler);this._offDirect(t,i)}},r.prototype._namespaceEvent=function(t){return["braintree",this.channel,t].join(":")},r.prototype.teardown=function(){var t,e;for(e=0;e<this._listeners.length;e++)t=this._listeners[e],this._offDirect(t.eventName,t.handler);this._listeners.length=0,this._isDestroyed=!0},r.prototype._log=function(t,e){this._isVerbose&&console.log(t,e)},r.events=o,e.exports=r},{"../error":25,"./check-origin":15,"./events":16,framebus:1}],18:[function(t,e,n){"use strict";function r(t){return t.className.trim().split(/\s+/)}function i(t){var e=Array.prototype.slice.call(arguments,1),n=r(t).filter(function(t){return-1===e.indexOf(t)}).concat(e).join(" ");t.className=n}function o(t){var e=Array.prototype.slice.call(arguments,1),n=r(t).filter(function(t){return-1===e.indexOf(t)}).join(" ");t.className=n}function s(t,e,n){n?i(t,e):o(t,e)}e.exports={add:i,remove:o,toggle:s}},{}],19:[function(t,e,n){"use strict";var r="3.0.0-beta.9",i="web";e.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:i,BRAINTREE_LIBRARY_VERSION:"braintree/"+i+"/"+r}},{}],20:[function(t,e,n){"use strict";var r=t("./error");e.exports=function(t,e){e.forEach(function(e){t[e]=function(){throw new r({type:r.types.MERCHANT,message:e+" cannot be called after teardown."})}})}},{"./error":25}],21:[function(t,e,n){"use strict";function r(t){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(t)}function i(t){var e=t.split("_"),n=e[0],r=e.slice(2).join("_");return{merchantId:r,environment:n}}function o(t){var e,n,o={attrs:{},configUrl:""};return r(t)?(n=i(t),o.attrs.tokenizationKey=t,o.configUrl=a[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(e=JSON.parse(s(t)),o.attrs.authorizationFingerprint=e.authorizationFingerprint,o.configUrl=e.configUrl),o}var s=t("../lib/polyfill").atob,a={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};e.exports=o},{"../lib/polyfill":31}],22:[function(t,e,n){"use strict";e.exports=function(t){return function(){var e=arguments;setTimeout(function(){t.apply(null,e)},1)}}},{}],23:[function(t,e,n){"use strict";function r(){this._teardownRegistry=[],this._isTearingDown=!1}var i=t("./batch-execute-functions");r.prototype.registerFunctionForTeardown=function(t){"function"==typeof t&&this._teardownRegistry.push(t)},r.prototype.teardown=function(t){return this._isTearingDown?void t(new Error("Destructor is already tearing down")):(this._isTearingDown=!0,void i(this._teardownRegistry,function(e){this._teardownRegistry=[],this._isTearingDown=!1,"function"==typeof t&&t(e)}.bind(this)))},e.exports=r},{"./batch-execute-functions":14}],24:[function(t,e,n){"use strict";function r(t,e){return e=null==e?"":e,t.reduce(function(t,n){return t[n]=e+n,t},{})}e.exports=r},{}],25:[function(t,e,n){"use strict";function r(t){if(!r.types.hasOwnProperty(t.type))throw new Error(t.type+" is not a valid type.");if(!t.message)throw new Error("Error message required.");this.message=t.message,this.type=t.type,this.details=t.details}var i=t("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=i(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),e.exports=r},{"./enumerate":24}],26:[function(t,e,n){"use strict";function r(){this._events={}}r.prototype.on=function(t,e){this._events[t]?this._events[t].push(e):this._events[t]=[e]},r.prototype._emit=function(t){var e,n,r=this._events[t];if(r)for(n=Array.prototype.slice.call(arguments,1),e=0;e<r.length;e++)r[e].apply(null,n)},e.exports=r},{}],27:[function(t,e,n){"use strict";e.exports=function(t){return t=t||navigator.userAgent,/(iPad|iPhone|iPod)/i.test(t)}},{}],28:[function(t,e,n){"use strict";e.exports=function(t){return JSON.parse(JSON.stringify(t))}},{}],29:[function(t,e,n){"use strict";e.exports=function(t){return Object.keys(t).filter(function(e){return"function"==typeof t[e]})}},{}],30:[function(t,e,n){"use strict";function r(t){var e=!1;return function(){e||(e=!0,t.apply(null,arguments))}}e.exports=r},{}],31:[function(t,e,n){(function(t){"use strict";function n(t){var e,n,r,i,o,s,a,c,l=new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$"),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="";if(!l.test(t))throw new Error("Non base64 encoded input passed to window.atob polyfill");c=0;do i=u.indexOf(t.charAt(c++)),o=u.indexOf(t.charAt(c++)),s=u.indexOf(t.charAt(c++)),a=u.indexOf(t.charAt(c++)),e=(63&i)<<2|o>>4&3,n=(15&o)<<4|s>>2&15,r=(3&s)<<6|63&a,f+=String.fromCharCode(e)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(c<t.length);return f}var r="function"==typeof t.atob?t.atob:n;e.exports={atob:r,_atob:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],32:[function(t,e,n){"use strict";function r(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})}e.exports=r},{}]},{},[9])(9)}); |
@@ -9,3 +9,2 @@ 'use strict'; | ||
var unionpay = require('./unionpay'); | ||
var packageVersion = require('./package.json').version; | ||
@@ -19,3 +18,3 @@ module.exports = { | ||
unionpay: unionpay, | ||
VERSION: packageVersion | ||
VERSION: "3.0.0-beta.9" | ||
}; |
{ | ||
"name": "braintree-web", | ||
"description": "A suite of tools for integrating Braintree in the browser", | ||
"version": "3.0.0-beta.8", | ||
"version": "3.0.0-beta.9", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "repository": { |
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.braintree || (g.braintree = {})).paypal = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
'use strict'; | ||
(function (root, factory) { | ||
if (typeof exports === 'object' && typeof module !== 'undefined') { | ||
module.exports = factory(); | ||
module.exports = factory(typeof global === 'undefined' ? root : global); | ||
} else if (typeof define === 'function' && define.amd) { | ||
define([], factory); | ||
define([], function () { return factory(root); }); | ||
} else { | ||
root.framebus = factory(); | ||
root.framebus = factory(root); | ||
} | ||
})(this, function () { // eslint-disable-line no-invalid-this | ||
})(this, function (root) { // eslint-disable-line no-invalid-this | ||
var win, framebus; | ||
@@ -152,3 +153,3 @@ var popups = []; | ||
if (win) { return; } | ||
win = w || window; | ||
win = w || root; | ||
@@ -278,2 +279,3 @@ if (win.addEventListener) { | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],2:[function(_dereq_,module,exports){ | ||
@@ -434,12 +436,5 @@ 'use strict'; | ||
function isHTTPS(protocol) { | ||
protocol = protocol || global.location.protocol; | ||
return protocol === 'https:'; | ||
} | ||
module.exports = { | ||
isOperaMini: isOperaMini, | ||
getIEVersion: getIEVersion, | ||
isHTTPS: isHTTPS | ||
getIEVersion: getIEVersion | ||
}; | ||
@@ -618,3 +613,3 @@ | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
var PLATFORM = 'web'; | ||
@@ -697,3 +692,3 @@ | ||
},{"../lib/polyfill":28}],15:[function(_dereq_,module,exports){ | ||
},{"../lib/polyfill":29}],15:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -804,8 +799,8 @@ | ||
'name', | ||
'url', | ||
'landingFrameHTML' | ||
'dispatchFrameUrl', | ||
'openFrameUrl' | ||
]; | ||
function _validateFrameConfiguration(frameConfiguration) { | ||
if (!frameConfiguration) { | ||
function _validateFrameConfiguration(options) { | ||
if (!options) { | ||
throw new Error('Valid configuration is required'); | ||
@@ -815,3 +810,3 @@ } | ||
REQUIRED_CONFIG_KEYS.forEach(function (key) { | ||
if (!frameConfiguration.hasOwnProperty(key)) { | ||
if (!options.hasOwnProperty(key)) { | ||
throw new Error('A valid frame ' + key + ' must be provided'); | ||
@@ -821,3 +816,3 @@ } | ||
if (!(/^[\w_]+$/.test(frameConfiguration.name))) { // eslint-disable-line | ||
if (!(/^[\w_]+$/.test(options.name))) { // eslint-disable-line | ||
throw new Error('A valid frame name must be provided'); | ||
@@ -827,13 +822,13 @@ } | ||
function FrameService(componentConfiguration, frameConfiguration) { | ||
_validateFrameConfiguration(frameConfiguration); | ||
function FrameService(options) { | ||
_validateFrameConfiguration(options); | ||
this._serviceId = uuid().replace(/-/g, ''); | ||
this._frameConfiguration = { | ||
name: frameConfiguration.name + '_' + this._serviceId, | ||
url: frameConfiguration.url, | ||
landingFrameHTML: frameConfiguration.landingFrameHTML | ||
this._options = { | ||
name: options.name + '_' + this._serviceId, | ||
dispatchFrameUrl: options.dispatchFrameUrl, | ||
openFrameUrl: options.openFrameUrl | ||
}; | ||
this._componentConfiguration = componentConfiguration; | ||
this._state = options.state; | ||
@@ -856,3 +851,3 @@ this._bus = new Bus({channel: this._serviceId}); | ||
var frameName = constants.DISPATCH_FRAME_NAME + '_' + this._serviceId; | ||
var frameSrc = this._frameConfiguration.url + '/html/dispatch-frame.html'; | ||
var frameSrc = this._options.dispatchFrameUrl; | ||
@@ -881,3 +876,3 @@ this._dispatchFrame = iFramer({ | ||
this._bus.on(Bus.events.CONFIGURATION_REQUEST, function (reply) { | ||
reply(this._componentConfiguration); | ||
reply(this._state); | ||
}.bind(this)); | ||
@@ -889,10 +884,10 @@ }; | ||
this._frame = popup.open(this._frameConfiguration); | ||
this._frame = popup.open(this._options); | ||
this._pollForPopupClose(); | ||
}; | ||
return { | ||
close: function () { | ||
this._frame.close(); | ||
}.bind(this) | ||
}; | ||
FrameService.prototype.redirect = function (url) { | ||
if (this._frame && !this.isFrameClosed()) { | ||
this._frame.location.href = url; | ||
} | ||
}; | ||
@@ -911,5 +906,2 @@ | ||
this._cleanupFrame(); | ||
if (this._onCompleteCallback) { | ||
this._onCompleteCallback(); | ||
} | ||
}; | ||
@@ -945,3 +937,3 @@ | ||
},{"../../bus":11,"../../error":17,"../../uuid":29,"../shared/constants":24,"../shared/events":25,"./popup":21,"iframer":2}],19:[function(_dereq_,module,exports){ | ||
},{"../../bus":11,"../../error":17,"../../uuid":30,"../shared/constants":24,"../shared/events":25,"./popup":21,"iframer":2}],19:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -952,4 +944,4 @@ | ||
module.exports = { | ||
create: function createFrameService(componentConfiguration, frameConfiguration, callback) { | ||
var frameService = new FrameService(componentConfiguration, frameConfiguration); | ||
create: function createFrameService(options, callback) { | ||
var frameService = new FrameService(options); | ||
@@ -989,6 +981,6 @@ frameService.initialize(function () { | ||
module.exports = function openPopup(frameConfiguration) { | ||
module.exports = function openPopup(options) { | ||
return global.open( | ||
frameConfiguration.url + frameConfiguration.landingFrameHTML, | ||
frameConfiguration.name, | ||
options.openFrameUrl, | ||
options.name, | ||
composeOptions() | ||
@@ -1074,2 +1066,18 @@ ); | ||
},{}],28:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
function once(fn) { | ||
var called = false; | ||
return function () { | ||
if (!called) { | ||
called = true; | ||
fn.apply(null, arguments); | ||
} | ||
}; | ||
} | ||
module.exports = once; | ||
},{}],29:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -1113,3 +1121,3 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],29:[function(_dereq_,module,exports){ | ||
},{}],30:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1128,3 +1136,3 @@ | ||
},{}],30:[function(_dereq_,module,exports){ | ||
},{}],31:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1134,3 +1142,4 @@ | ||
var BraintreeError = _dereq_('../../lib/error'); | ||
var VERSION = "3.0.0-beta.8"; | ||
var once = _dereq_('../../lib/once'); | ||
var VERSION = "3.0.0-beta.9"; | ||
var constants = _dereq_('../shared/constants'); | ||
@@ -1141,2 +1150,3 @@ var INTEGRATION_TIMEOUT_MS = _dereq_('../../lib/constants').INTEGRATION_TIMEOUT_MS; | ||
var deferred = _dereq_('../../lib/deferred'); | ||
var getCountry = _dereq_('../shared/get-country'); | ||
var convertMethodsToError = _dereq_('../../lib/convert-methods-to-error'); | ||
@@ -1171,7 +1181,7 @@ | ||
* @class | ||
* @param {module:braintree-web/paypal~createOptions} options see {@link module:braintree-web/paypal.create|paypal.create} | ||
* @param {object} options see {@link module:braintree-web/paypal.create|paypal.create} | ||
* @classdesc This class represents a PayPal component. Instances of this class have methods for launching auth dialogs and other programmatic interactions with the PayPal component. | ||
*/ | ||
function PayPal(options) { | ||
this._options = options; | ||
this._client = options.client; | ||
this._assetsUrl = options.client.getConfiguration().gatewayConfiguration.paypal.assetsUrl + '/web/' + VERSION; | ||
@@ -1182,21 +1192,17 @@ this._authorizationInProgress = false; | ||
PayPal.prototype._initialize = function (callback) { | ||
var options = this._options; | ||
var client = this._client; | ||
var failureTimeout = setTimeout(function () { | ||
analytics.sendEvent(options.client, 'web.paypal.load.timed-out'); | ||
analytics.sendEvent(client, 'web.paypal.load.timed-out'); | ||
}, INTEGRATION_TIMEOUT_MS); | ||
frameService.create( | ||
this._options, | ||
{ | ||
name: constants.LANDING_FRAME_NAME, | ||
url: this._assetsUrl, | ||
landingFrameHTML: '/html/paypal-landing-frame.html' | ||
}, | ||
function (service) { | ||
this._frameService = service; | ||
clearTimeout(failureTimeout); | ||
analytics.sendEvent(options.client, 'web.paypal.load.succeeded'); | ||
callback(); | ||
}.bind(this) | ||
); | ||
frameService.create({ | ||
name: constants.LANDING_FRAME_NAME, | ||
dispatchFrameUrl: this._assetsUrl + '/html/dispatch-frame.html', | ||
openFrameUrl: this._assetsUrl + '/html/paypal-landing-frame.html' | ||
}, function (service) { | ||
this._frameService = service; | ||
clearTimeout(failureTimeout); | ||
analytics.sendEvent(client, 'web.paypal.load.succeeded'); | ||
callback(); | ||
}.bind(this)); | ||
}; | ||
@@ -1207,7 +1213,30 @@ | ||
* @public | ||
* @param {object} options All tokenization options for the PayPal component. | ||
* @param {string} options.flow Set to 'checkout' for one-time payment flow, or 'vault' for Vault flow. | ||
* @param {string} [options.intent=authorize] | ||
* Checkout flows only. | ||
* * `authorize` - Submits the transaction for authorization but not settlement. | ||
* * `sale` - Payment will be immediately submitted for settlement upon creating a transaction. | ||
* @param {boolean} [options.offerCredit=false] Offers the customer PayPal Credit if they qualify. Checkout flows only. | ||
* @param {string|number} [options.amount] The amount of the transaction. Required when using the Checkout flow. | ||
* @param {string} [options.currency] The currency code of the amount, such as 'USD'. Required when using the Checkout flow. | ||
* @param {string} [options.displayName] The merchant name displayed inside of the PayPal lightbox; defaults to the company name on your Braintree account | ||
* @param {string} [options.locale=en_us] Use this option to change the language, links, and terminology used in the PayPal flow to suit the country and language of your customer. | ||
* @param {boolean} [options.enableShippingAddress=false] Returns a shipping address object in {@link PayPal#tokenize}. | ||
* @param {object} [options.shippingAddressOverride] Allows you to pass a shipping address you have already collected into the PayPal payment flow. | ||
* @param {string} options.shippingAddressOverride.line1 Street address. | ||
* @param {string} [options.shippingAddressOverride.line2] Street address (extended). | ||
* @param {string} options.shippingAddressOverride.city City. | ||
* @param {string} options.shippingAddressOverride.state State. | ||
* @param {string} options.shippingAddressOverride.postalCode Postal code. | ||
* @param {string} options.shippingAddressOverride.countryCode Country. | ||
* @param {string} [options.shippingAddressOverride.phone] Phone number. | ||
* @param {string} [options.shippingAddressOverride.recipientName] Recipient's name. | ||
* @param {boolean} [options.shippingAddressEditable=true] Set to false to disable user editing of the shipping address. | ||
* @param {boolean} [options.billingAgreementsDescription] Use this option to set the description of the preapproved payment agreement visible to customers in their PayPal profile. Max 255 characters. | ||
* @param {callback} callback The second argument, <code>data</code>, is a {@link PayPal~tokenizePayload|tokenizePayload}. | ||
* @returns {PayPal~tokenizeReturn} A handle to close the PayPal checkout frame. | ||
*/ | ||
PayPal.prototype.tokenize = function (callback) { | ||
var client; | ||
PayPal.prototype.tokenize = function (options, callback) { | ||
var client = this._client; | ||
@@ -1221,4 +1250,3 @@ if (typeof callback !== 'function') { | ||
client = this._options.client; | ||
callback = deferred(callback); | ||
callback = once(deferred(callback)); | ||
@@ -1236,18 +1264,5 @@ if (this._authorizationInProgress) { | ||
analytics.sendEvent(client, 'web.paypal.tokenization.opened'); | ||
this._frameService.open(function (err) { | ||
if (err) { | ||
if (err.message === constants.FRAME_CLOSED_ERROR_MESSAGE) { | ||
analytics.sendEvent(client, 'web.paypal.tokenization.closed.by-user'); | ||
} else { | ||
analytics.sendEvent(client, 'web.paypal.tokenization.failed'); | ||
} | ||
} else { | ||
analytics.sendEvent(client, 'web.paypal.tokenization.success'); | ||
} | ||
this._authorizationInProgress = false; | ||
callback.apply(null, arguments); | ||
}.bind(this)); | ||
this._navigateFrameToAuth(options, callback); | ||
// This MUST happen after _navigateFrameToAuth for Metro browsers to work. | ||
this._frameService.open(this._createFrameServiceCallback(options, callback)); | ||
} | ||
@@ -1263,2 +1278,165 @@ | ||
PayPal.prototype._createFrameServiceCallback = function (options, callback) { | ||
var client = this._client; | ||
return function (err, params) { | ||
this._authorizationInProgress = false; | ||
if (err) { | ||
if (err.message === constants.FRAME_CLOSED_ERROR_MESSAGE) { | ||
analytics.sendEvent(client, 'web.paypal.tokenization.closed.by-user'); | ||
} | ||
callback(err); | ||
} else { | ||
this._tokenizePayPal(options, params, callback); | ||
} | ||
}.bind(this); | ||
}; | ||
PayPal.prototype._tokenizePayPal = function (options, params, callback) { | ||
var client = this._client; | ||
client.request({ | ||
endpoint: 'payment_methods/paypal_accounts', | ||
method: 'post', | ||
data: this._formatTokenizeData(options, params) | ||
}, function (err, response) { | ||
if (err) { | ||
analytics.sendEvent(client, 'web.paypal.tokenization.failed'); | ||
callback(err instanceof BraintreeError ? err : new BraintreeError({ | ||
type: BraintreeError.types.NETWORK, | ||
message: 'Could not tokenize user\'s PayPal account.', | ||
details: err | ||
})); | ||
} else { | ||
analytics.sendEvent(client, 'web.paypal.tokenization.success'); | ||
callback(null, this._formatTokenizePayload(response)); | ||
} | ||
}.bind(this)); | ||
}; | ||
PayPal.prototype._formatTokenizePayload = function (response) { | ||
var payload; | ||
var account = {}; | ||
if (response.paypalAccounts) { | ||
account = response.paypalAccounts[0]; | ||
} | ||
payload = { | ||
nonce: account.nonce, | ||
details: {} | ||
}; | ||
if (account.details && account.details.payerInfo) { | ||
payload.details = account.details.payerInfo; | ||
} | ||
return payload; | ||
}; | ||
PayPal.prototype._formatTokenizeData = function (options, params) { | ||
var gatewayConfiguration = this._client.getConfiguration().gatewayConfiguration; | ||
var data = { | ||
paypalAccount: {correlationId: this._frameService._serviceId} | ||
}; | ||
if (params.ba_token) { | ||
data.paypalAccount.billingAgreementToken = params.ba_token; | ||
} else { | ||
data.paypalAccount.paymentToken = params.paymentId; | ||
data.paypalAccount.payerId = params.PayerID; | ||
data.paypalAccount.unilateral = gatewayConfiguration.paypal.unvettedMerchant; | ||
if (options.hasOwnProperty('intent')) { | ||
data.paypalAccount.intent = options.intent; | ||
} | ||
} | ||
return data; | ||
}; | ||
PayPal.prototype._navigateFrameToAuth = function (options, callback) { | ||
var client = this._client; | ||
var endpoint = 'paypal_hermes/'; | ||
if (options.flow === 'checkout') { | ||
endpoint += 'create_payment_resource'; | ||
} else if (options.flow === 'vault') { | ||
endpoint += 'setup_billing_agreement'; | ||
} else { | ||
callback(new BraintreeError({ | ||
type: BraintreeError.types.MERCHANT, | ||
message: 'PayPal flow property is invalid or missing.' | ||
})); | ||
return; | ||
} | ||
client.request({ | ||
endpoint: endpoint, | ||
method: 'post', | ||
data: this._formatPaymentResourceData(options) | ||
}, function (err, response) { | ||
var redirectUrl; | ||
if (err) { | ||
callback(err instanceof BraintreeError ? err : new BraintreeError({ | ||
type: BraintreeError.types.NETWORK, | ||
message: constants.AUTH_INIT_ERROR_MESSSAGE, | ||
details: err | ||
})); | ||
this._frameService.close(); | ||
} else { | ||
if (options.flow === 'checkout') { | ||
redirectUrl = response.paymentResource.redirectUrl; | ||
} else { | ||
redirectUrl = response.agreementSetup.approvalUrl; | ||
} | ||
this._frameService.redirect(redirectUrl); | ||
} | ||
}.bind(this)); | ||
}; | ||
PayPal.prototype._formatPaymentResourceData = function (options) { | ||
var key; | ||
var gatewayConfiguration = this._client.getConfiguration().gatewayConfiguration; | ||
var serviceId = this._frameService._serviceId; | ||
var paymentResource = { | ||
returnUrl: gatewayConfiguration.paypal.assetsUrl + '/web/' + VERSION + '/html/paypal-redirect-frame.html?channel=' + serviceId, | ||
cancelUrl: gatewayConfiguration.paypal.assetsUrl + '/web/' + VERSION + '/html/paypal-cancel-frame.html?channel=' + serviceId, | ||
correlationId: serviceId, | ||
experienceProfile: { | ||
brandName: options.displayName || gatewayConfiguration.paypal.displayName, | ||
localeCode: getCountry(options.locale), | ||
noShipping: (!options.enableShippingAddress).toString(), | ||
addressOverride: options.shippingAddressEditable === false | ||
} | ||
}; | ||
if (options.flow === 'checkout') { | ||
paymentResource.amount = parseFloat(options.amount).toFixed(2); | ||
paymentResource.currencyIsoCode = options.currency; | ||
paymentResource.offerPaypalCredit = options.offerCredit === true; | ||
if (options.hasOwnProperty('intent')) { | ||
paymentResource.intent = options.intent; | ||
} | ||
for (key in options.shippingAddressOverride) { | ||
if (options.shippingAddressOverride.hasOwnProperty(key)) { | ||
paymentResource[key] = options.shippingAddressOverride[key]; | ||
} | ||
} | ||
} else { | ||
paymentResource.shippingAddress = options.shippingAddressOverride; | ||
if (options.billingAgreementDescription) { | ||
paymentResource.description = options.billingAgreementDescription; | ||
} | ||
} | ||
return paymentResource; | ||
}; | ||
/** | ||
@@ -1275,3 +1453,3 @@ * Cleanly tear down anything set up by {@link module:braintree-web/paypal.create|create}. | ||
analytics.sendEvent(this._options.client, 'web.paypal.teardown-completed'); | ||
analytics.sendEvent(this._client, 'web.paypal.teardown-completed'); | ||
@@ -1286,11 +1464,6 @@ if (typeof callback === 'function') { | ||
},{"../../lib/analytics":7,"../../lib/constants":12,"../../lib/convert-methods-to-error":13,"../../lib/deferred":15,"../../lib/error":17,"../../lib/frame-service/external":19,"../../lib/methods":27,"../shared/constants":32}],31:[function(_dereq_,module,exports){ | ||
},{"../../lib/analytics":7,"../../lib/constants":12,"../../lib/convert-methods-to-error":13,"../../lib/deferred":15,"../../lib/error":17,"../../lib/frame-service/external":19,"../../lib/methods":27,"../../lib/once":28,"../shared/constants":33,"../shared/get-country":34}],32:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
/** @module braintree-web/paypal */ | ||
/** | ||
* Options for {@link module:braintree-web/paypal.create|create} | ||
* @typedef {object} createOptions | ||
*/ | ||
var PayPal = _dereq_('./external/paypal'); | ||
@@ -1301,3 +1474,3 @@ var browserDetection = _dereq_('../lib/browser-detection'); | ||
var deferred = _dereq_('../lib/deferred'); | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
@@ -1307,2 +1480,9 @@ function create(options, callback) { | ||
if (!callback) { | ||
throw new BraintreeError({ | ||
type: BraintreeError.types.MERCHANT, | ||
message: 'create must include a callback function.' | ||
}); | ||
} | ||
callback = deferred(callback); | ||
@@ -1345,10 +1525,2 @@ | ||
if (!browserDetection.isHTTPS()) { | ||
callback(new BraintreeError({ | ||
type: BraintreeError.types.MERCHANT, | ||
message: 'PayPal requires HTTPS.' | ||
})); | ||
return; | ||
} | ||
analytics.sendEvent(options.client, 'web.paypal.initialized'); | ||
@@ -1372,19 +1544,2 @@ | ||
* @param {Client} options.client A {@link Client} instance. | ||
* @param {string} options.flow Set to 'checkout' for one-time payment flow, or 'vault' for Vault flow. | ||
* @param {string|number} [options.amount] The amount of the transaction. Required when using the Checkout flow. | ||
* @param {string} [options.currency] The currency code of the amount, such as 'USD'. Required when using the Checkout flow. | ||
* @param {string} [options.displayName] The merchant name displayed inside of the PayPal lightbox; defaults to the company name on your Braintree account | ||
* @param {string} [options.locale=en_us] Use this option to change the language, links, and terminology used in the PayPal flow to suit the country and language of your customer. | ||
* @param {boolean} [options.enableShippingAddress=false] Returns a shipping address object in {@link PayPal#tokenize}. | ||
* @param {object=} options.shippingAddressOverride Allows you to pass a shipping address you have already collected into the PayPal payment flow. | ||
* @param {string} options.shippingAddressOverride.line1 Street address. | ||
* @param {string=} options.shippingAddressOverride.line2 Street address (extended). | ||
* @param {string} options.shippingAddressOverride.city City. | ||
* @param {string} options.shippingAddressOverride.state State. | ||
* @param {string} options.shippingAddressOverride.postalCode Postal code. | ||
* @param {string} options.shippingAddressOverride.countryCode Country. | ||
* @param {string=} options.shippingAddressOverride.phone Phone number. | ||
* @param {string=} options.shippingAddressOverride.recipientName Recipient's name. | ||
* @param {boolean} [options.shippingAddressEditable=true] Set to false to disable user editing of the shipping address. | ||
* @param {boolean} [options.billingAgreementsDescription] Use this option to set the description of the preapproved payment agreement visible to customers in their PayPal profile. Max 255 characters. | ||
* @param {callback} callback The second argument, <code>data</code>, is the {@link PayPal} instance. | ||
@@ -1401,3 +1556,3 @@ * @returns {void} | ||
},{"../lib/analytics":7,"../lib/browser-detection":8,"../lib/deferred":15,"../lib/error":17,"./external/paypal":30}],32:[function(_dereq_,module,exports){ | ||
},{"../lib/analytics":7,"../lib/browser-detection":8,"../lib/deferred":15,"../lib/error":17,"./external/paypal":31}],33:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1417,3 +1572,53 @@ | ||
},{}]},{},[31])(31) | ||
},{}],34:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var lookupTable = { | ||
us: 'en_us', | ||
gb: 'en_uk', | ||
uk: 'en_uk', | ||
de: 'de_de', | ||
fr: 'fr_fr', | ||
it: 'it_it', | ||
es: 'es_es', | ||
ca: 'en_ca', | ||
au: 'en_au', | ||
at: 'de_de', | ||
be: 'en_us', | ||
ch: 'de_de', | ||
dk: 'da_dk', | ||
nl: 'nl_nl', | ||
no: 'no_no', | ||
pl: 'pl_pl', | ||
se: 'sv_se', | ||
tr: 'tr_tr', | ||
bg: 'en_us', | ||
cy: 'en_us', | ||
hr: 'en_us', | ||
is: 'en_us', | ||
kh: 'en_us', | ||
mt: 'en_us', | ||
my: 'en_us', | ||
ru: 'ru_ru' | ||
}; | ||
function getCountry(code) { | ||
var country = code ? code.toLowerCase().replace(/-/g, '_') : 'us'; | ||
if (country.indexOf('_') !== -1) { | ||
country = country.split('_')[1]; | ||
} | ||
country = lookupTable[country] ? country : 'us'; | ||
if (country === 'uk') { | ||
country = 'gb'; | ||
} | ||
return country; | ||
} | ||
module.exports = getCountry; | ||
},{}]},{},[32])(32) | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(e.braintree||(e.braintree={})).paypal=t()}}(function(){var t;return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n?n:e)},l,l.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,n,r){"use strict";!function(e,i){"object"==typeof r&&"undefined"!=typeof n?n.exports=i():"function"==typeof t&&t.amd?t([],i):e.framebus=i()}(this,function(){function t(t){return null==t?!1:null==t.Window?!1:t.constructor!==t.Window?!1:(v.push(t),!0)}function e(t){var e,n={};for(e in g)g.hasOwnProperty(e)&&(n[e]=g[e]);return n._origin=t||"*",n}function n(t){var e,n,r=o(this);return s(t)?!1:s(r)?!1:(n=Array.prototype.slice.call(arguments,1),e=a(t,n,r),e===!1?!1:(d(b.top,e,r),!0))}function r(t,e){var n=o(this);return _(t,e,n)?!1:(E[n]=E[n]||{},E[n][t]=E[n][t]||[],E[n][t].push(e),!0)}function i(t,e){var n,r,i=o(this);if(_(t,e,i))return!1;if(r=E[i]&&E[i][t],!r)return!1;for(n=0;n<r.length;n++)if(r[n]===e)return r.splice(n,1),!0;return!1}function o(t){return t&&t._origin||"*"}function s(t){return"string"!=typeof t}function a(t,e,n){var r=!1,i={event:t,origin:n},o=e[e.length-1];"function"==typeof o&&(i.reply=y(o,n),e=e.slice(0,-1)),i.args=e;try{r=x+JSON.stringify(i)}catch(s){throw new Error("Could not stringify event: "+s.message)}return r}function c(t){var e,n,r,i;if(t.data.slice(0,x.length)!==x)return!1;try{e=JSON.parse(t.data.slice(x.length))}catch(o){return!1}return null!=e.reply&&(n=t.origin,r=t.source,i=e.reply,e.reply=function(t){var e=a(i,[t],n);return e===!1?!1:void r.postMessage(e,n)},e.args.push(e.reply)),e}function u(t){b||(b=t||window,b.addEventListener?b.addEventListener("message",p,!1):b.attachEvent?b.attachEvent("onmessage",p):null===b.onmessage?b.onmessage=p:b=null)}function l(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})}function p(t){var e;s(t.data)||(e=c(t),e&&(f("*",e.event,e.args,t),f(t.origin,e.event,e.args,t),m(t.data,e.origin,t.source)))}function f(t,e,n,r){var i;if(E[t]&&E[t][e])for(i=0;i<E[t][e].length;i++)E[t][e][i].apply(r,n)}function h(t){return t.top!==t?!1:null==t.opener?!1:t.opener===t?!1:t.opener.closed===!0?!1:!0}function d(t,e,n){var r;try{for(t.postMessage(e,n),h(t)&&d(t.opener.top,e,n),r=0;r<t.frames.length;r++)d(t.frames[r],e,n)}catch(i){}}function m(t,e,n){var r,i;for(r=v.length-1;r>=0;r--)i=v[r],i.closed===!0?v=v.slice(r,1):n!==i&&d(i.top,t,e)}function y(t,e){function n(i,o){t(i,o),g.target(e).unsubscribe(r,n)}var r=l();return g.target(e).subscribe(r,n),r}function _(t,e,n){return s(t)?!0:"function"!=typeof e?!0:s(n)?!0:!1}var b,g,v=[],E={},x="/*framebus*/";return u(),g={target:e,include:t,publish:n,pub:n,trigger:n,emit:n,subscribe:r,sub:r,on:r,unsubscribe:i,unsub:i,off:i}})},{}],2:[function(t,e,n){"use strict";var r=t("./lib/set-attributes"),i=t("./lib/default-attributes"),o=t("./lib/assign");e.exports=function(t){var e=document.createElement("iframe"),n=o({},i,t);return n.style&&"string"!=typeof n.style&&(o(e.style,n.style),delete n.style),r(e,n),e.getAttribute("id")||(e.id=e.name),e}},{"./lib/assign":3,"./lib/default-attributes":4,"./lib/set-attributes":5}],3:[function(t,e,n){"use strict";e.exports=function(t){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(e){"object"==typeof e&&Object.keys(e).forEach(function(n){t[n]=e[n]})}),t}},{}],4:[function(t,e,n){e.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],5:[function(t,e,n){"use strict";e.exports=function(t,e){var n;for(var r in e)e.hasOwnProperty(r)&&(n=e[r],null==n?t.removeAttribute(r):t.setAttribute(r,n))}},{}],6:[function(t,e,n){"use strict";function r(t,e){var n,r=e?o(e):{},a=i(t.authorization).attrs,c=o(t.analyticsMetadata);r.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION;for(n in r._meta)r._meta.hasOwnProperty(n)&&(c[n]=r._meta[n]);return r._meta=c,a.tokenizationKey?r.tokenizationKey=a.tokenizationKey:r.authorizationFingerprint=a.authorizationFingerprint,r}var i=t("./create-authorization-data"),o=t("./json-clone"),s=t("./constants");e.exports=r},{"./constants":12,"./create-authorization-data":14,"./json-clone":26}],7:[function(t,e,n){"use strict";function r(t){return Math.floor(t/1e3)}function i(t,e,n){var i=t.getConfiguration(),a=t._request,c=r(Date.now()),u=i.gatewayConfiguration.analytics.url,l={analytics:[{kind:e,timestamp:c}]};a({url:u,method:"post",data:s(i,l),timeout:o.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var o=t("./constants"),s=t("./add-metadata");e.exports={sendEvent:i}},{"./add-metadata":6,"./constants":12}],8:[function(t,e,n){(function(t){"use strict";function n(e){return e=e||t.navigator.userAgent,e.indexOf("Opera Mini")>-1}function r(e){return e=e||t.navigator.userAgent,-1!==e.indexOf("MSIE")?parseInt(e.replace(/.*MSIE ([0-9]+)\..*/,"$1"),10):/Trident.*rv:11/.test(e)?11:null}function i(e){return e=e||t.location.protocol,"https:"===e}e.exports={isOperaMini:n,getIEVersion:r,isHTTPS:i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(t,e,n){"use strict";function r(t,e){var n,r,o=document.createElement("a");return o.href=e,r="https:"===o.protocol?o.host.replace(/:443$/,""):"http:"===o.protocol?o.host.replace(/:80$/,""):o.host,n=o.protocol+"//"+r,n===t||i.test(t)}var i=/^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/;e.exports={checkOrigin:r}},{}],10:[function(t,e,n){"use strict";var r=t("../enumerate");e.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":16}],11:[function(t,e,n){"use strict";function r(t){if(t=t||{},this.channel=t.channel,!this.channel)throw new a({type:a.types.INTERNAL,message:"Channel ID must be specified."});this.merchantUrl=t.merchantUrl,this._isDestroyed=!1,this._isVerbose=!1,this._listeners=[],this._log("new bus on channel "+this.channel,[location.href])}var i=t("framebus"),o=t("./events"),s=t("./check-origin").checkOrigin,a=t("../error");r.prototype.on=function(t,e){var n,r,o=e,a=this;this._isDestroyed||(this.merchantUrl&&(o=function(){s(this.origin,a.merchantUrl)&&e.apply(this,arguments)}),n=this._namespaceEvent(t),r=Array.prototype.slice.call(arguments),r[0]=n,r[1]=o,this._log("on",r),i.on.apply(i,r),this._listeners.push({eventName:t,handler:o,originalHandler:e}))},r.prototype.emit=function(t){var e;this._isDestroyed||(e=Array.prototype.slice.call(arguments),e[0]=this._namespaceEvent(t),this._log("emit",e),i.emit.apply(i,e))},r.prototype._offDirect=function(t){var e=Array.prototype.slice.call(arguments);this._isDestroyed||(e[0]=this._namespaceEvent(t),this._log("off",e),i.off.apply(i,e))},r.prototype.off=function(t,e){var n,r,i=e;if(!this._isDestroyed){if(this.merchantUrl)for(n=0;n<this._listeners.length;n++)r=this._listeners[n],r.originalHandler===e&&(i=r.handler);this._offDirect(t,i)}},r.prototype._namespaceEvent=function(t){return["braintree",this.channel,t].join(":")},r.prototype.teardown=function(){var t,e;for(e=0;e<this._listeners.length;e++)t=this._listeners[e],this._offDirect(t.eventName,t.handler);this._listeners.length=0,this._isDestroyed=!0},r.prototype._log=function(t,e){this._isVerbose&&console.log(t,e)},r.events=o,e.exports=r},{"../error":17,"./check-origin":9,"./events":10,framebus:1}],12:[function(t,e,n){"use strict";var r="3.0.0-beta.8",i="web";e.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:i,BRAINTREE_LIBRARY_VERSION:"braintree/"+i+"/"+r}},{}],13:[function(t,e,n){"use strict";var r=t("./error");e.exports=function(t,e){e.forEach(function(e){t[e]=function(){throw new r({type:r.types.MERCHANT,message:e+" cannot be called after teardown."})}})}},{"./error":17}],14:[function(t,e,n){"use strict";function r(t){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(t)}function i(t){var e=t.split("_"),n=e[0],r=e.slice(2).join("_");return{merchantId:r,environment:n}}function o(t){var e,n,o={attrs:{},configUrl:""};return r(t)?(n=i(t),o.attrs.tokenizationKey=t,o.configUrl=a[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(e=JSON.parse(s(t)),o.attrs.authorizationFingerprint=e.authorizationFingerprint,o.configUrl=e.configUrl),o}var s=t("../lib/polyfill").atob,a={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};e.exports=o},{"../lib/polyfill":28}],15:[function(t,e,n){"use strict";e.exports=function(t){return function(){var e=arguments;setTimeout(function(){t.apply(null,e)},1)}}},{}],16:[function(t,e,n){"use strict";function r(t,e){return e=null==e?"":e,t.reduce(function(t,n){return t[n]=e+n,t},{})}e.exports=r},{}],17:[function(t,e,n){"use strict";function r(t){if(!r.types.hasOwnProperty(t.type))throw new Error(t.type+" is not a valid type.");if(!t.message)throw new Error("Error message required.");this.message=t.message,this.type=t.type,this.details=t.details}var i=t("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=i(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),e.exports=r},{"./enumerate":16}],18:[function(t,e,n){"use strict";function r(t){if(!t)throw new Error("Valid configuration is required");if(f.forEach(function(e){if(!t.hasOwnProperty(e))throw new Error("A valid frame "+e+" must be provided")}),!/^[\w_]+$/.test(t.name))throw new Error("A valid frame name must be provided")}function i(t,e){r(e),this._serviceId=u().replace(/-/g,""),this._frameConfiguration={name:e.name+"_"+this._serviceId,url:e.url,landingFrameHTML:e.landingFrameHTML},this._componentConfiguration=t,this._bus=new s({channel:this._serviceId}),this._setBusEvents()}var o=t("./popup"),s=t("../../bus"),a=t("../shared/events"),c=t("../shared/constants"),u=t("../../uuid"),l=t("iframer"),p=t("../../error"),f=["name","url","landingFrameHTML"];i.prototype.initialize=function(t){var e=function(){t(),this._bus.off(a.DISPATCH_FRAME_READY,e)}.bind(this);this._bus.on(a.DISPATCH_FRAME_READY,e),this._writeDispatchFrame()},i.prototype._writeDispatchFrame=function(){var t=c.DISPATCH_FRAME_NAME+"_"+this._serviceId,e=this._frameConfiguration.url+"/html/dispatch-frame.min.html";this._dispatchFrame=l({name:t,src:e,height:0,width:0}),document.body.appendChild(this._dispatchFrame)},i.prototype._setBusEvents=function(){this._bus.on(a.DISPATCH_FRAME_REPORT,function(t){this.close(),this._onCompleteCallback&&this._onCompleteCallback.call(null,t.err,t.payload),this._onCompleteCallback=null}.bind(this)),this._bus.on(s.events.CONFIGURATION_REQUEST,function(t){t(this._componentConfiguration)}.bind(this))},i.prototype.open=function(t){return this._onCompleteCallback=t,this._frame=o.open(this._frameConfiguration),this._pollForPopupClose(),{close:function(){this._frame.close()}.bind(this)}},i.prototype.close=function(){this.isFrameClosed()||this._frame.close()},i.prototype.teardown=function(){this.close(),this._dispatchFrame.parentNode.removeChild(this._dispatchFrame),this._dispatchFrame=null,this._cleanupFrame(),this._onCompleteCallback&&this._onCompleteCallback()},i.prototype.isFrameClosed=function(){return null==this._frame||this._frame.closed},i.prototype._cleanupFrame=function(){this._frame=null,clearInterval(this._popupInterval),this._popupInterval=null},i.prototype._pollForPopupClose=function(){return this._popupInterval=setInterval(function(){this.isFrameClosed()&&(this._cleanupFrame(),this._onCompleteCallback&&this._onCompleteCallback(new p({type:p.types.CUSTOMER,message:c.FRAME_CLOSED_ERROR_MESSAGE})))}.bind(this),c.POPUP_POLL_INTERVAL),this._popupInterval},e.exports=i},{"../../bus":11,"../../error":17,"../../uuid":29,"../shared/constants":24,"../shared/events":25,"./popup":21,iframer:2}],19:[function(t,e,n){"use strict";var r=t("./frame-service");e.exports={create:function(t,e,n){var i=new r(t,e);i.initialize(function(){n(i)})}}},{"./frame-service":18}],20:[function(t,e,n){"use strict";var r=t("../../shared/constants"),i=t("./position");e.exports=function(){return[r.POPUP_BASE_OPTIONS,"top="+i.top(),"left="+i.left()].join(",")}},{"../../shared/constants":24,"./position":23}],21:[function(t,e,n){"use strict";e.exports={open:t("./open")}},{"./open":22}],22:[function(t,e,n){(function(n){"use strict";var r=t("./compose-options");e.exports=function(t){return n.open(t.url+t.landingFrameHTML,t.name,r())}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./compose-options":20}],23:[function(t,e,n){(function(n){"use strict";function r(){var t=n.outerHeight||document.documentElement.clientHeight,e=null==n.screenY?n.screenTop:n.screenY;return o(t,s.POPUP_HEIGHT,e)}function i(){var t=n.outerWidth||document.documentElement.clientWidth,e=null==n.screenX?n.screenLeft:n.screenX;return o(t,s.POPUP_WIDTH,e)}function o(t,e,n){return(t-e)/2+n}var s=t("../../shared/constants");e.exports={top:r,left:i,center:o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../shared/constants":24}],24:[function(t,e,n){"use strict";var r=535,i=450;e.exports={DISPATCH_FRAME_NAME:"dispatch",FRAME_CLOSED_ERROR_MESSAGE:"Frame closed before tokenization could occur.",POPUP_BASE_OPTIONS:"resizable,scrollbars,height="+r+",width="+i,POPUP_WIDTH:i,POPUP_HEIGHT:r,POPUP_POLL_INTERVAL:100,POPUP_CLOSE_TIMEOUT:100}},{}],25:[function(t,e,n){"use strict";var r=t("../../enumerate");e.exports=r(["DISPATCH_FRAME_READY","DISPATCH_FRAME_REPORT"],"frameService:")},{"../../enumerate":16}],26:[function(t,e,n){"use strict";e.exports=function(t){return JSON.parse(JSON.stringify(t))}},{}],27:[function(t,e,n){"use strict";e.exports=function(t){return Object.keys(t).filter(function(e){return"function"==typeof t[e]})}},{}],28:[function(t,e,n){(function(t){"use strict";function n(t){var e,n,r,i,o,s,a,c,u=new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p="";if(!u.test(t))throw new Error("Non base64 encoded input passed to window.atob polyfill");c=0;do i=l.indexOf(t.charAt(c++)),o=l.indexOf(t.charAt(c++)),s=l.indexOf(t.charAt(c++)),a=l.indexOf(t.charAt(c++)),e=(63&i)<<2|o>>4&3,n=(15&o)<<4|s>>2&15,r=(3&s)<<6|63&a,p+=String.fromCharCode(e)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(c<t.length);return p}var r="function"==typeof t.atob?t.atob:n;e.exports={atob:r,_atob:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],29:[function(t,e,n){"use strict";function r(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})}e.exports=r},{}],30:[function(t,e,n){"use strict";function r(t){this._options=t,this._assetsUrl=t.client.getConfiguration().gatewayConfiguration.paypal.assetsUrl+"/web/"+s,this._authorizationInProgress=!1}var i=t("../../lib/frame-service/external"),o=t("../../lib/error"),s="3.0.0-beta.8",a=t("../shared/constants"),c=t("../../lib/constants").INTEGRATION_TIMEOUT_MS,u=t("../../lib/analytics"),l=t("../../lib/methods"),p=t("../../lib/deferred"),f=t("../../lib/convert-methods-to-error");r.prototype._initialize=function(t){var e=this._options,n=setTimeout(function(){u.sendEvent(e.client,"web.paypal.load.timed-out")},c);i.create(this._options,{name:a.LANDING_FRAME_NAME,url:this._assetsUrl,landingFrameHTML:"/html/paypal-landing-frame.min.html"},function(r){this._frameService=r,clearTimeout(n),u.sendEvent(e.client,"web.paypal.load.succeeded"),t()}.bind(this))},r.prototype.tokenize=function(t){var e;if("function"!=typeof t)throw new o({type:o.types.MERCHANT,message:"tokenize must include a callback function."});return e=this._options.client,t=p(t),this._authorizationInProgress?(u.sendEvent(e,"web.paypal.tokenization.error.already-opened"),t(new o({type:o.types.MERCHANT,message:"Another tokenization request is active."}))):(this._authorizationInProgress=!0,u.sendEvent(e,"web.paypal.tokenization.opened"),this._frameService.open(function(n){n?n.message===a.FRAME_CLOSED_ERROR_MESSAGE?u.sendEvent(e,"web.paypal.tokenization.closed.by-user"):u.sendEvent(e,"web.paypal.tokenization.failed"):u.sendEvent(e,"web.paypal.tokenization.success"),this._authorizationInProgress=!1,t.apply(null,arguments)}.bind(this))),{close:function(){u.sendEvent(e,"web.paypal.tokenization.closed.by-merchant"),this._frameService.close()}.bind(this)}},r.prototype.teardown=function(t){this._frameService.teardown(),f(this,l(r.prototype)),u.sendEvent(this._options.client,"web.paypal.teardown-completed"),"function"==typeof t&&(t=p(t))()},e.exports=r},{"../../lib/analytics":7,"../../lib/constants":12,"../../lib/convert-methods-to-error":13,"../../lib/deferred":15,"../../lib/error":17,"../../lib/frame-service/external":19,"../../lib/methods":27,"../shared/constants":32}],31:[function(t,e,n){"use strict";function r(t,e){var n,r,p;return e=u(e),null==t.client?void e(new a({type:a.types.MERCHANT,message:"options.client is required when instantiating PayPal."})):(n=t.client.getConfiguration(),p=n.analyticsMetadata.sdkVersion,p!==l?void e(new a({type:a.types.MERCHANT,message:"Client (version "+p+") and PayPal (version "+l+") components must be from the same SDK version."})):n.gatewayConfiguration.paypalEnabled!==!0?void e(new a({type:a.types.MERCHANT,message:"PayPal is not enabled for this merchant."})):i()?s.isHTTPS()?(c.sendEvent(t.client,"web.paypal.initialized"),r=new o(t),void r._initialize(function(){e(null,r)})):void e(new a({type:a.types.MERCHANT,message:"PayPal requires HTTPS."})):void e(new a({type:a.types.CUSTOMER,message:"Browser is not supported."})))}function i(){return!s.isOperaMini()}var o=t("./external/paypal"),s=t("../lib/browser-detection"),a=t("../lib/error"),c=t("../lib/analytics"),u=t("../lib/deferred"),l="3.0.0-beta.8";e.exports={create:r,VERSION:l}},{"../lib/analytics":7,"../lib/browser-detection":8,"../lib/deferred":15,"../lib/error":17,"./external/paypal":30}],32:[function(t,e,n){"use strict";var r=535,i=450;e.exports={AUTH_INIT_ERROR_MESSSAGE:"Could not initialize PayPal flow.",LANDING_FRAME_NAME:"braintreepaypallanding",POPUP_BASE_OPTIONS:"resizable,scrollbars,height="+r+",width="+i,POPUP_WIDTH:i,POPUP_HEIGHT:r,POPUP_POLL_INTERVAL:100}},{}]},{},[31])(31)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(t.braintree||(t.braintree={})).paypal=e()}}(function(){var e;return function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n?n:t)},u,u.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,n,r){(function(t){"use strict";!function(i,o){"object"==typeof r&&"undefined"!=typeof n?n.exports=o("undefined"==typeof t?i:t):"function"==typeof e&&e.amd?e([],function(){return o(i)}):i.framebus=o(i)}(this,function(e){function t(e){return null==e?!1:null==e.Window?!1:e.constructor!==e.Window?!1:(E.push(e),!0)}function n(e){var t,n={};for(t in b)b.hasOwnProperty(t)&&(n[t]=b[t]);return n._origin=e||"*",n}function r(e){var t,n,r=a(this);return s(e)?!1:s(r)?!1:(n=Array.prototype.slice.call(arguments,1),t=c(e,n,r),t===!1?!1:(y(v.top,t,r),!0))}function i(e,t){var n=a(this);return g(e,t,n)?!1:(w[n]=w[n]||{},w[n][e]=w[n][e]||[],w[n][e].push(t),!0)}function o(e,t){var n,r,i=a(this);if(g(e,t,i))return!1;if(r=w[i]&&w[i][e],!r)return!1;for(n=0;n<r.length;n++)if(r[n]===t)return r.splice(n,1),!0;return!1}function a(e){return e&&e._origin||"*"}function s(e){return"string"!=typeof e}function c(e,t,n){var r=!1,i={event:e,origin:n},o=t[t.length-1];"function"==typeof o&&(i.reply=m(o,n),t=t.slice(0,-1)),i.args=t;try{r=x+JSON.stringify(i)}catch(a){throw new Error("Could not stringify event: "+a.message)}return r}function l(e){var t,n,r,i;if(e.data.slice(0,x.length)!==x)return!1;try{t=JSON.parse(e.data.slice(x.length))}catch(o){return!1}return null!=t.reply&&(n=e.origin,r=e.source,i=t.reply,t.reply=function(e){var t=c(i,[e],n);return t===!1?!1:void r.postMessage(t,n)},t.args.push(t.reply)),t}function u(t){v||(v=t||e,v.addEventListener?v.addEventListener("message",f,!1):v.attachEvent?v.attachEvent("onmessage",f):null===v.onmessage?v.onmessage=f:v=null)}function p(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)})}function f(e){var t;s(e.data)||(t=l(e),t&&(d("*",t.event,t.args,e),d(e.origin,t.event,t.args,e),_(e.data,t.origin,e.source)))}function d(e,t,n,r){var i;if(w[e]&&w[e][t])for(i=0;i<w[e][t].length;i++)w[e][t][i].apply(r,n)}function h(e){return e.top!==e?!1:null==e.opener?!1:e.opener===e?!1:e.opener.closed===!0?!1:!0}function y(e,t,n){var r;try{for(e.postMessage(t,n),h(e)&&y(e.opener.top,t,n),r=0;r<e.frames.length;r++)y(e.frames[r],t,n)}catch(i){}}function _(e,t,n){var r,i;for(r=E.length-1;r>=0;r--)i=E[r],i.closed===!0?E=E.slice(r,1):n!==i&&y(i.top,e,t)}function m(e,t){function n(i,o){e(i,o),b.target(t).unsubscribe(r,n)}var r=p();return b.target(t).subscribe(r,n),r}function g(e,t,n){return s(e)?!0:"function"!=typeof t?!0:s(n)?!0:!1}var v,b,E=[],w={},x="/*framebus*/";return u(),b={target:n,include:t,publish:r,pub:r,trigger:r,emit:r,subscribe:i,sub:i,on:i,unsubscribe:o,unsub:o,off:o}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){"use strict";var r=e("./lib/set-attributes"),i=e("./lib/default-attributes"),o=e("./lib/assign");t.exports=function(e){var t=document.createElement("iframe"),n=o({},i,e);return n.style&&"string"!=typeof n.style&&(o(t.style,n.style),delete n.style),r(t,n),t.getAttribute("id")||(t.id=t.name),t}},{"./lib/assign":3,"./lib/default-attributes":4,"./lib/set-attributes":5}],3:[function(e,t,n){"use strict";t.exports=function(e){var t=Array.prototype.slice.call(arguments,1);return t.forEach(function(t){"object"==typeof t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}},{}],4:[function(e,t,n){t.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],5:[function(e,t,n){"use strict";t.exports=function(e,t){var n;for(var r in t)t.hasOwnProperty(r)&&(n=t[r],null==n?e.removeAttribute(r):e.setAttribute(r,n))}},{}],6:[function(e,t,n){"use strict";function r(e,t){var n,r=t?o(t):{},s=i(e.authorization).attrs,c=o(e.analyticsMetadata);r.braintreeLibraryVersion=a.BRAINTREE_LIBRARY_VERSION;for(n in r._meta)r._meta.hasOwnProperty(n)&&(c[n]=r._meta[n]);return r._meta=c,s.tokenizationKey?r.tokenizationKey=s.tokenizationKey:r.authorizationFingerprint=s.authorizationFingerprint,r}var i=e("./create-authorization-data"),o=e("./json-clone"),a=e("./constants");t.exports=r},{"./constants":12,"./create-authorization-data":14,"./json-clone":26}],7:[function(e,t,n){"use strict";function r(e){return Math.floor(e/1e3)}function i(e,t,n){var i=e.getConfiguration(),s=e._request,c=r(Date.now()),l=i.gatewayConfiguration.analytics.url,u={analytics:[{kind:t,timestamp:c}]};s({url:l,method:"post",data:a(i,u),timeout:o.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var o=e("./constants"),a=e("./add-metadata");t.exports={sendEvent:i}},{"./add-metadata":6,"./constants":12}],8:[function(e,t,n){(function(e){"use strict";function n(t){return t=t||e.navigator.userAgent,t.indexOf("Opera Mini")>-1}function r(t){return t=t||e.navigator.userAgent,-1!==t.indexOf("MSIE")?parseInt(t.replace(/.*MSIE ([0-9]+)\..*/,"$1"),10):/Trident.*rv:11/.test(t)?11:null}t.exports={isOperaMini:n,getIEVersion:r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,t,n){"use strict";function r(e,t){var n,r,o=document.createElement("a");return o.href=t,r="https:"===o.protocol?o.host.replace(/:443$/,""):"http:"===o.protocol?o.host.replace(/:80$/,""):o.host,n=o.protocol+"//"+r,n===e||i.test(e)}var i=/^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/;t.exports={checkOrigin:r}},{}],10:[function(e,t,n){"use strict";var r=e("../enumerate");t.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":16}],11:[function(e,t,n){"use strict";function r(e){if(e=e||{},this.channel=e.channel,!this.channel)throw new s({type:s.types.INTERNAL,message:"Channel ID must be specified."});this.merchantUrl=e.merchantUrl,this._isDestroyed=!1,this._isVerbose=!1,this._listeners=[],this._log("new bus on channel "+this.channel,[location.href])}var i=e("framebus"),o=e("./events"),a=e("./check-origin").checkOrigin,s=e("../error");r.prototype.on=function(e,t){var n,r,o=t,s=this;this._isDestroyed||(this.merchantUrl&&(o=function(){a(this.origin,s.merchantUrl)&&t.apply(this,arguments)}),n=this._namespaceEvent(e),r=Array.prototype.slice.call(arguments),r[0]=n,r[1]=o,this._log("on",r),i.on.apply(i,r),this._listeners.push({eventName:e,handler:o,originalHandler:t}))},r.prototype.emit=function(e){var t;this._isDestroyed||(t=Array.prototype.slice.call(arguments),t[0]=this._namespaceEvent(e),this._log("emit",t),i.emit.apply(i,t))},r.prototype._offDirect=function(e){var t=Array.prototype.slice.call(arguments);this._isDestroyed||(t[0]=this._namespaceEvent(e),this._log("off",t),i.off.apply(i,t))},r.prototype.off=function(e,t){var n,r,i=t;if(!this._isDestroyed){if(this.merchantUrl)for(n=0;n<this._listeners.length;n++)r=this._listeners[n],r.originalHandler===t&&(i=r.handler);this._offDirect(e,i)}},r.prototype._namespaceEvent=function(e){return["braintree",this.channel,e].join(":")},r.prototype.teardown=function(){var e,t;for(t=0;t<this._listeners.length;t++)e=this._listeners[t],this._offDirect(e.eventName,e.handler);this._listeners.length=0,this._isDestroyed=!0},r.prototype._log=function(e,t){this._isVerbose&&console.log(e,t)},r.events=o,t.exports=r},{"../error":17,"./check-origin":9,"./events":10,framebus:1}],12:[function(e,t,n){"use strict";var r="3.0.0-beta.9",i="web";t.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:i,BRAINTREE_LIBRARY_VERSION:"braintree/"+i+"/"+r}},{}],13:[function(e,t,n){"use strict";var r=e("./error");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new r({type:r.types.MERCHANT,message:t+" cannot be called after teardown."})}})}},{"./error":17}],14:[function(e,t,n){"use strict";function r(e){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(e)}function i(e){var t=e.split("_"),n=t[0],r=t.slice(2).join("_");return{merchantId:r,environment:n}}function o(e){var t,n,o={attrs:{},configUrl:""};return r(e)?(n=i(e),o.attrs.tokenizationKey=e,o.configUrl=s[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(a(e)),o.attrs.authorizationFingerprint=t.authorizationFingerprint,o.configUrl=t.configUrl),o}var a=e("../lib/polyfill").atob,s={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=o},{"../lib/polyfill":29}],15:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],16:[function(e,t,n){"use strict";function r(e,t){return t=null==t?"":t,e.reduce(function(e,n){return e[n]=t+n,e},{})}t.exports=r},{}],17:[function(e,t,n){"use strict";function r(e){if(!r.types.hasOwnProperty(e.type))throw new Error(e.type+" is not a valid type.");if(!e.message)throw new Error("Error message required.");this.message=e.message,this.type=e.type,this.details=e.details}var i=e("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=i(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),t.exports=r},{"./enumerate":16}],18:[function(e,t,n){"use strict";function r(e){if(!e)throw new Error("Valid configuration is required");if(f.forEach(function(t){if(!e.hasOwnProperty(t))throw new Error("A valid frame "+t+" must be provided")}),!/^[\w_]+$/.test(e.name))throw new Error("A valid frame name must be provided")}function i(e){r(e),this._serviceId=l().replace(/-/g,""),this._options={name:e.name+"_"+this._serviceId,dispatchFrameUrl:e.dispatchFrameUrl,openFrameUrl:e.openFrameUrl},this._state=e.state,this._bus=new a({channel:this._serviceId}),this._setBusEvents()}var o=e("./popup"),a=e("../../bus"),s=e("../shared/events"),c=e("../shared/constants"),l=e("../../uuid"),u=e("iframer"),p=e("../../error"),f=["name","dispatchFrameUrl","openFrameUrl"];i.prototype.initialize=function(e){var t=function(){e(),this._bus.off(s.DISPATCH_FRAME_READY,t)}.bind(this);this._bus.on(s.DISPATCH_FRAME_READY,t),this._writeDispatchFrame()},i.prototype._writeDispatchFrame=function(){var e=c.DISPATCH_FRAME_NAME+"_"+this._serviceId,t=this._options.dispatchFrameUrl;this._dispatchFrame=u({name:e,src:t,height:0,width:0}),document.body.appendChild(this._dispatchFrame)},i.prototype._setBusEvents=function(){this._bus.on(s.DISPATCH_FRAME_REPORT,function(e){this.close(),this._onCompleteCallback&&this._onCompleteCallback.call(null,e.err,e.payload),this._onCompleteCallback=null}.bind(this)),this._bus.on(a.events.CONFIGURATION_REQUEST,function(e){e(this._state)}.bind(this))},i.prototype.open=function(e){this._onCompleteCallback=e,this._frame=o.open(this._options),this._pollForPopupClose()},i.prototype.redirect=function(e){this._frame&&!this.isFrameClosed()&&(this._frame.location.href=e)},i.prototype.close=function(){this.isFrameClosed()||this._frame.close()},i.prototype.teardown=function(){this.close(),this._dispatchFrame.parentNode.removeChild(this._dispatchFrame),this._dispatchFrame=null,this._cleanupFrame()},i.prototype.isFrameClosed=function(){return null==this._frame||this._frame.closed},i.prototype._cleanupFrame=function(){this._frame=null,clearInterval(this._popupInterval),this._popupInterval=null},i.prototype._pollForPopupClose=function(){return this._popupInterval=setInterval(function(){this.isFrameClosed()&&(this._cleanupFrame(),this._onCompleteCallback&&this._onCompleteCallback(new p({type:p.types.CUSTOMER,message:c.FRAME_CLOSED_ERROR_MESSAGE})))}.bind(this),c.POPUP_POLL_INTERVAL),this._popupInterval},t.exports=i},{"../../bus":11,"../../error":17,"../../uuid":30,"../shared/constants":24,"../shared/events":25,"./popup":21,iframer:2}],19:[function(e,t,n){"use strict";var r=e("./frame-service");t.exports={create:function(e,t){var n=new r(e);n.initialize(function(){t(n)})}}},{"./frame-service":18}],20:[function(e,t,n){"use strict";var r=e("../../shared/constants"),i=e("./position");t.exports=function(){return[r.POPUP_BASE_OPTIONS,"top="+i.top(),"left="+i.left()].join(",")}},{"../../shared/constants":24,"./position":23}],21:[function(e,t,n){"use strict";t.exports={open:e("./open")}},{"./open":22}],22:[function(e,t,n){(function(n){"use strict";var r=e("./compose-options");t.exports=function(e){return n.open(e.openFrameUrl,e.name,r())}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./compose-options":20}],23:[function(e,t,n){(function(n){"use strict";function r(){var e=n.outerHeight||document.documentElement.clientHeight,t=null==n.screenY?n.screenTop:n.screenY;return o(e,a.POPUP_HEIGHT,t)}function i(){var e=n.outerWidth||document.documentElement.clientWidth,t=null==n.screenX?n.screenLeft:n.screenX;return o(e,a.POPUP_WIDTH,t)}function o(e,t,n){return(e-t)/2+n}var a=e("../../shared/constants");t.exports={top:r,left:i,center:o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../shared/constants":24}],24:[function(e,t,n){"use strict";var r=535,i=450;t.exports={DISPATCH_FRAME_NAME:"dispatch",FRAME_CLOSED_ERROR_MESSAGE:"Frame closed before tokenization could occur.",POPUP_BASE_OPTIONS:"resizable,scrollbars,height="+r+",width="+i,POPUP_WIDTH:i,POPUP_HEIGHT:r,POPUP_POLL_INTERVAL:100,POPUP_CLOSE_TIMEOUT:100}},{}],25:[function(e,t,n){"use strict";var r=e("../../enumerate");t.exports=r(["DISPATCH_FRAME_READY","DISPATCH_FRAME_REPORT"],"frameService:")},{"../../enumerate":16}],26:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],27:[function(e,t,n){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],28:[function(e,t,n){"use strict";function r(e){var t=!1;return function(){t||(t=!0,e.apply(null,arguments))}}t.exports=r},{}],29:[function(e,t,n){(function(e){"use strict";function n(e){var t,n,r,i,o,a,s,c,l=new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$"),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p="";if(!l.test(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");c=0;do i=u.indexOf(e.charAt(c++)),o=u.indexOf(e.charAt(c++)),a=u.indexOf(e.charAt(c++)),s=u.indexOf(e.charAt(c++)),t=(63&i)<<2|o>>4&3,n=(15&o)<<4|a>>2&15,r=(3&a)<<6|63&s,p+=String.fromCharCode(t)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(c<e.length);return p}var r="function"==typeof e.atob?e.atob:n;t.exports={atob:r,_atob:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],30:[function(e,t,n){"use strict";function r(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)})}t.exports=r},{}],31:[function(e,t,n){"use strict";function r(e){this._client=e.client,this._assetsUrl=e.client.getConfiguration().gatewayConfiguration.paypal.assetsUrl+"/web/"+s,this._authorizationInProgress=!1}var i=e("../../lib/frame-service/external"),o=e("../../lib/error"),a=e("../../lib/once"),s="3.0.0-beta.9",c=e("../shared/constants"),l=e("../../lib/constants").INTEGRATION_TIMEOUT_MS,u=e("../../lib/analytics"),p=e("../../lib/methods"),f=e("../../lib/deferred"),d=e("../shared/get-country"),h=e("../../lib/convert-methods-to-error");r.prototype._initialize=function(e){var t=this._client,n=setTimeout(function(){u.sendEvent(t,"web.paypal.load.timed-out")},l);i.create({name:c.LANDING_FRAME_NAME,dispatchFrameUrl:this._assetsUrl+"/html/dispatch-frame.min.html",openFrameUrl:this._assetsUrl+"/html/paypal-landing-frame.min.html"},function(r){this._frameService=r,clearTimeout(n),u.sendEvent(t,"web.paypal.load.succeeded"),e()}.bind(this))},r.prototype.tokenize=function(e,t){var n=this._client;if("function"!=typeof t)throw new o({type:o.types.MERCHANT,message:"tokenize must include a callback function."});return t=a(f(t)),this._authorizationInProgress?(u.sendEvent(n,"web.paypal.tokenization.error.already-opened"),t(new o({type:o.types.MERCHANT,message:"Another tokenization request is active."}))):(this._authorizationInProgress=!0,u.sendEvent(n,"web.paypal.tokenization.opened"),this._navigateFrameToAuth(e,t),this._frameService.open(this._createFrameServiceCallback(e,t))),{close:function(){u.sendEvent(n,"web.paypal.tokenization.closed.by-merchant"),this._frameService.close()}.bind(this)}},r.prototype._createFrameServiceCallback=function(e,t){var n=this._client;return function(r,i){this._authorizationInProgress=!1,r?(r.message===c.FRAME_CLOSED_ERROR_MESSAGE&&u.sendEvent(n,"web.paypal.tokenization.closed.by-user"),t(r)):this._tokenizePayPal(e,i,t)}.bind(this)},r.prototype._tokenizePayPal=function(e,t,n){var r=this._client;r.request({endpoint:"payment_methods/paypal_accounts",method:"post",data:this._formatTokenizeData(e,t)},function(e,t){e?(u.sendEvent(r,"web.paypal.tokenization.failed"),n(e instanceof o?e:new o({type:o.types.NETWORK,message:"Could not tokenize user's PayPal account.",details:e}))):(u.sendEvent(r,"web.paypal.tokenization.success"),n(null,this._formatTokenizePayload(t)))}.bind(this))},r.prototype._formatTokenizePayload=function(e){var t,n={};return e.paypalAccounts&&(n=e.paypalAccounts[0]),t={nonce:n.nonce,details:{}},n.details&&n.details.payerInfo&&(t.details=n.details.payerInfo),t},r.prototype._formatTokenizeData=function(e,t){var n=this._client.getConfiguration().gatewayConfiguration,r={paypalAccount:{correlationId:this._frameService._serviceId}};return t.ba_token?r.paypalAccount.billingAgreementToken=t.ba_token:(r.paypalAccount.paymentToken=t.paymentId,r.paypalAccount.payerId=t.PayerID,r.paypalAccount.unilateral=n.paypal.unvettedMerchant,e.hasOwnProperty("intent")&&(r.paypalAccount.intent=e.intent)),r},r.prototype._navigateFrameToAuth=function(e,t){var n=this._client,r="paypal_hermes/";if("checkout"===e.flow)r+="create_payment_resource";else{if("vault"!==e.flow)return void t(new o({type:o.types.MERCHANT,message:"PayPal flow property is invalid or missing."}));r+="setup_billing_agreement"}n.request({endpoint:r,method:"post",data:this._formatPaymentResourceData(e)},function(n,r){var i;n?(t(n instanceof o?n:new o({type:o.types.NETWORK,message:c.AUTH_INIT_ERROR_MESSSAGE,details:n})),this._frameService.close()):(i="checkout"===e.flow?r.paymentResource.redirectUrl:r.agreementSetup.approvalUrl,this._frameService.redirect(i))}.bind(this))},r.prototype._formatPaymentResourceData=function(e){var t,n=this._client.getConfiguration().gatewayConfiguration,r=this._frameService._serviceId,i={returnUrl:n.paypal.assetsUrl+"/web/"+s+"/html/paypal-redirect-frame.min.html?channel="+r,cancelUrl:n.paypal.assetsUrl+"/web/"+s+"/html/paypal-cancel-frame.min.html?channel="+r,correlationId:r,experienceProfile:{brandName:e.displayName||n.paypal.displayName,localeCode:d(e.locale),noShipping:(!e.enableShippingAddress).toString(),addressOverride:e.shippingAddressEditable===!1}};if("checkout"===e.flow){i.amount=parseFloat(e.amount).toFixed(2),i.currencyIsoCode=e.currency,i.offerPaypalCredit=e.offerCredit===!0,e.hasOwnProperty("intent")&&(i.intent=e.intent);for(t in e.shippingAddressOverride)e.shippingAddressOverride.hasOwnProperty(t)&&(i[t]=e.shippingAddressOverride[t])}else i.shippingAddress=e.shippingAddressOverride,e.billingAgreementDescription&&(i.description=e.billingAgreementDescription);return i},r.prototype.teardown=function(e){this._frameService.teardown(),h(this,p(r.prototype)),u.sendEvent(this._client,"web.paypal.teardown-completed"),"function"==typeof e&&(e=f(e))()},t.exports=r},{"../../lib/analytics":7,"../../lib/constants":12,"../../lib/convert-methods-to-error":13,"../../lib/deferred":15,"../../lib/error":17,"../../lib/frame-service/external":19,"../../lib/methods":27,"../../lib/once":28,"../shared/constants":33,"../shared/get-country":34}],32:[function(e,t,n){"use strict";function r(e,t){var n,r,a;if(!t)throw new s({type:s.types.MERCHANT,message:"create must include a callback function."});return t=l(t),null==e.client?void t(new s({type:s.types.MERCHANT,message:"options.client is required when instantiating PayPal."})):(n=e.client.getConfiguration(),a=n.analyticsMetadata.sdkVersion,a!==u?void t(new s({type:s.types.MERCHANT,message:"Client (version "+a+") and PayPal (version "+u+") components must be from the same SDK version."})):n.gatewayConfiguration.paypalEnabled!==!0?void t(new s({type:s.types.MERCHANT,message:"PayPal is not enabled for this merchant."})):i()?(c.sendEvent(e.client,"web.paypal.initialized"),r=new o(e),void r._initialize(function(){t(null,r)})):void t(new s({type:s.types.CUSTOMER,message:"Browser is not supported."})))}function i(){return!a.isOperaMini()}var o=e("./external/paypal"),a=e("../lib/browser-detection"),s=e("../lib/error"),c=e("../lib/analytics"),l=e("../lib/deferred"),u="3.0.0-beta.9";t.exports={create:r,VERSION:u}},{"../lib/analytics":7,"../lib/browser-detection":8,"../lib/deferred":15,"../lib/error":17,"./external/paypal":31}],33:[function(e,t,n){"use strict";var r=535,i=450;t.exports={AUTH_INIT_ERROR_MESSSAGE:"Could not initialize PayPal flow.",LANDING_FRAME_NAME:"braintreepaypallanding",POPUP_BASE_OPTIONS:"resizable,scrollbars,height="+r+",width="+i,POPUP_WIDTH:i,POPUP_HEIGHT:r,POPUP_POLL_INTERVAL:100}},{}],34:[function(e,t,n){"use strict";function r(e){var t=e?e.toLowerCase().replace(/-/g,"_"):"us";return-1!==t.indexOf("_")&&(t=t.split("_")[1]),t=i[t]?t:"us","uk"===t&&(t="gb"),t}var i={us:"en_us",gb:"en_uk",uk:"en_uk",de:"de_de",fr:"fr_fr",it:"it_it",es:"es_es",ca:"en_ca",au:"en_au",at:"de_de",be:"en_us",ch:"de_de",dk:"da_dk",nl:"nl_nl",no:"no_no",pl:"pl_pl",se:"sv_se",tr:"tr_tr",bg:"en_us",cy:"en_us",hr:"en_us",is:"en_us",kh:"en_us",mt:"en_us",my:"en_us",ru:"ru_ru"};t.exports=r},{}]},{},[32])(32)}); |
@@ -14,7 +14,7 @@ braintree-web | ||
``` | ||
npm install braintree-web@3.0.0-beta.8 | ||
npm install braintree-web@3.0.0-beta.9 | ||
``` | ||
``` | ||
bower install braintree-web@3.0.0-beta.8 | ||
bower install braintree-web@3.0.0-beta.9 | ||
``` | ||
@@ -21,0 +21,0 @@ |
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.braintree || (g.braintree = {})).unionpay = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
'use strict'; | ||
(function (root, factory) { | ||
if (typeof exports === 'object' && typeof module !== 'undefined') { | ||
module.exports = factory(); | ||
module.exports = factory(typeof global === 'undefined' ? root : global); | ||
} else if (typeof define === 'function' && define.amd) { | ||
define([], factory); | ||
define([], function () { return factory(root); }); | ||
} else { | ||
root.framebus = factory(); | ||
root.framebus = factory(root); | ||
} | ||
})(this, function () { // eslint-disable-line no-invalid-this | ||
})(this, function (root) { // eslint-disable-line no-invalid-this | ||
var win, framebus; | ||
@@ -152,3 +153,3 @@ var popups = []; | ||
if (win) { return; } | ||
win = w || window; | ||
win = w || root; | ||
@@ -278,2 +279,3 @@ if (win.addEventListener) { | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],2:[function(_dereq_,module,exports){ | ||
@@ -583,3 +585,3 @@ 'use strict'; | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
var PLATFORM = 'web'; | ||
@@ -828,3 +830,3 @@ | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
var UnionPay = _dereq_('./shared/unionpay'); | ||
@@ -886,5 +888,5 @@ var BraintreeError = _dereq_('../lib/error'); | ||
* @example | ||
* braintree.unionpay.create({ client: clientInstance }, function (err, unionpayInstance) { | ||
* if (err) { | ||
* console.error(err); | ||
* braintree.unionpay.create({ client: clientInstance }, function (createErr, unionpayInstance) { | ||
* if (createErr) { | ||
* console.error(createErr); | ||
* return; | ||
@@ -933,3 +935,3 @@ * } | ||
var convertMethodsToError = _dereq_('../../lib/convert-methods-to-error'); | ||
var VERSION = "3.0.0-beta.8"; | ||
var VERSION = "3.0.0-beta.9"; | ||
var constants = _dereq_('./constants'); | ||
@@ -970,5 +972,5 @@ var events = constants.events; | ||
* } | ||
* }, function (err, cardCapabilities) { | ||
* if (err) { | ||
* console.error(err); | ||
* }, function (fetchErr, cardCapabilities) { | ||
* if (fetchErr) { | ||
* console.error(fetchErr); | ||
* return; | ||
@@ -996,5 +998,5 @@ * } | ||
* hostedFields: hostedFieldsInstance | ||
* }, function (err, cardCapabilities) { | ||
* if (err) { | ||
* console.error(err); | ||
* }, function (fetchErr, cardCapabilities) { | ||
* if (fetchErr) { | ||
* console.error(fetchErr); | ||
* return; | ||
@@ -1100,4 +1102,5 @@ * } | ||
* @param {string} options.card.number The card number. | ||
* @param {string} options.card.expirationMonth The card's expiration month. | ||
* @param {string} options.card.expirationYear The card's expiration year. | ||
* @param {string} [options.card.expirationDate] The card's expiration date. May be in the form `MM/YY` or `MM/YYYY`. When defined `expirationMonth` and `expirationYear` are ignored. | ||
* @param {string} [options.card.expirationMonth] The card's expiration month. This should be used with the `expirationYear` parameter. When `expirationDate` is defined this parameter is ignored. | ||
* @param {string} [options.card.expirationYear] The card's expiration year. This should be used with the `expirationMonth` parameter. When `expirationDate` is defined this parameter is ignored. | ||
* @param {HostedFields} [options.hostedFields] The Hosted Fields instance used to collect card data. Required if you are not using the `card` option. | ||
@@ -1119,5 +1122,5 @@ * @param {object} options.mobile The mobile information collected from the customer. | ||
* } | ||
* }, function (err, response) { | ||
* if (err) { | ||
* console.error(err); | ||
* }, function (enrollErr, response) { | ||
* if (enrollErr) { | ||
* console.error(enrollErr); | ||
* return; | ||
@@ -1136,5 +1139,5 @@ * } | ||
* } | ||
* }, function (err, response) { | ||
* if (err) { | ||
* console.error(err); | ||
* }, function (enrollErr, response) { | ||
* if (enrollErr) { | ||
* console.error(enrollErr); | ||
* return; | ||
@@ -1200,3 +1203,5 @@ * } | ||
if (card.expirationMonth || card.expirationYear) { | ||
if (card.expirationDate) { | ||
data.unionPayEnrollment.expirationDate = card.expirationDate; | ||
} else if (card.expirationMonth || card.expirationYear) { | ||
if (card.expirationMonth && card.expirationYear) { | ||
@@ -1269,4 +1274,5 @@ data.unionPayEnrollment.expirationYear = card.expirationYear; | ||
* @param {string} options.card.number The card number. | ||
* @param {string} options.card.expirationMonth The card's expiration month. | ||
* @param {string} options.card.expirationYear The card's expiration year. | ||
* @param {string} [options.card.expirationDate] The card's expiration date. May be in the form `MM/YY` or `MM/YYYY`. When defined `expirationMonth` and `expirationYear` are ignored. | ||
* @param {string} [options.card.expirationMonth] The card's expiration month. This should be used with the `expirationYear` parameter. When `expirationDate` is defined this parameter is ignored. | ||
* @param {string} [options.card.expirationYear] The card's expiration year. This should be used with the `expirationMonth` parameter. When `expirationDate` is defined this parameter is ignored. | ||
* @param {string} [options.card.cvv] The card's security number. | ||
@@ -1287,5 +1293,5 @@ * @param {HostedFields} [options.hostedFields] The Hosted Fields instance used to collect card data. Required if you are not using the `card` option. | ||
* smsCode: '11111' // Sent to customer's phone | ||
* }, function (err, response) { | ||
* if (err) { | ||
* console.error(err); | ||
* }, function (tokenizeErr, response) { | ||
* if (tokenizeErr) { | ||
* console.error(tokenizeErr); | ||
* return; | ||
@@ -1301,5 +1307,5 @@ * } | ||
* smsCode: '11111' // Sent to customer's phone | ||
* }, function (err, response) { | ||
* if (err) { | ||
* console.error(err); | ||
* }, function (tokenizeErr, response) { | ||
* if (tokenizeErr) { | ||
* console.error(tokenizeErr); | ||
* return; | ||
@@ -1331,4 +1337,2 @@ * } | ||
number: options.card.number, | ||
expirationMonth: options.card.expirationMonth, | ||
expirationYear: options.card.expirationYear, | ||
options: { | ||
@@ -1343,2 +1347,9 @@ unionPayEnrollment: { | ||
if (card.expirationDate) { | ||
data.creditCard.expirationDate = card.expirationDate; | ||
} else if (card.expirationMonth && card.expirationYear) { | ||
data.creditCard.expirationYear = card.expirationYear; | ||
data.creditCard.expirationMonth = card.expirationMonth; | ||
} | ||
if (options.card.cvv) { | ||
@@ -1418,4 +1429,4 @@ data.creditCard.cvv = options.card.cvv; | ||
* @example | ||
* unionpayInstance.teardown(function (err) { | ||
* if (err) { | ||
* unionpayInstance.teardown(function (teardownErr) { | ||
* if (teardownErr) { | ||
* console.error('Could not tear down UnionPay.'); | ||
@@ -1422,0 +1433,0 @@ * } else { |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(t.braintree||(t.braintree={})).unionpay=e()}}(function(){var e;return function t(e,n,r){function i(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};e[s][0].call(l.exports,function(t){var n=e[s][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,n,r){"use strict";!function(t,i){"object"==typeof r&&"undefined"!=typeof n?n.exports=i():"function"==typeof e&&e.amd?e([],i):t.framebus=i()}(this,function(){function e(e){return null==e?!1:null==e.Window?!1:e.constructor!==e.Window?!1:(v.push(e),!0)}function t(e){var t,n={};for(t in b)b.hasOwnProperty(t)&&(n[t]=b[t]);return n._origin=e||"*",n}function n(e){var t,n,r=o(this);return s(e)?!1:s(r)?!1:(n=Array.prototype.slice.call(arguments,1),t=a(e,n,r),t===!1?!1:(h(m.top,t,r),!0))}function r(e,t){var n=o(this);return _(e,t,n)?!1:(g[n]=g[n]||{},g[n][e]=g[n][e]||[],g[n][e].push(t),!0)}function i(e,t){var n,r,i=o(this);if(_(e,t,i))return!1;if(r=g[i]&&g[i][e],!r)return!1;for(n=0;n<r.length;n++)if(r[n]===t)return r.splice(n,1),!0;return!1}function o(e){return e&&e._origin||"*"}function s(e){return"string"!=typeof e}function a(e,t,n){var r=!1,i={event:e,origin:n},o=t[t.length-1];"function"==typeof o&&(i.reply=E(o,n),t=t.slice(0,-1)),i.args=t;try{r=x+JSON.stringify(i)}catch(s){throw new Error("Could not stringify event: "+s.message)}return r}function u(e){var t,n,r,i;if(e.data.slice(0,x.length)!==x)return!1;try{t=JSON.parse(e.data.slice(x.length))}catch(o){return!1}return null!=t.reply&&(n=e.origin,r=e.source,i=t.reply,t.reply=function(e){var t=a(i,[e],n);return t===!1?!1:void r.postMessage(t,n)},t.args.push(t.reply)),t}function c(e){m||(m=e||window,m.addEventListener?m.addEventListener("message",d,!1):m.attachEvent?m.attachEvent("onmessage",d):null===m.onmessage?m.onmessage=d:m=null)}function l(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)})}function d(e){var t;s(e.data)||(t=u(e),t&&(p("*",t.event,t.args,e),p(e.origin,t.event,t.args,e),y(e.data,t.origin,e.source)))}function p(e,t,n,r){var i;if(g[e]&&g[e][t])for(i=0;i<g[e][t].length;i++)g[e][t][i].apply(r,n)}function f(e){return e.top!==e?!1:null==e.opener?!1:e.opener===e?!1:e.opener.closed===!0?!1:!0}function h(e,t,n){var r;try{for(e.postMessage(t,n),f(e)&&h(e.opener.top,t,n),r=0;r<e.frames.length;r++)h(e.frames[r],t,n)}catch(i){}}function y(e,t,n){var r,i;for(r=v.length-1;r>=0;r--)i=v[r],i.closed===!0?v=v.slice(r,1):n!==i&&h(i.top,e,t)}function E(e,t){function n(i,o){e(i,o),b.target(t).unsubscribe(r,n)}var r=l();return b.target(t).subscribe(r,n),r}function _(e,t,n){return s(e)?!0:"function"!=typeof t?!0:s(n)?!0:!1}var m,b,v=[],g={},x="/*framebus*/";return c(),b={target:t,include:e,publish:n,pub:n,trigger:n,emit:n,subscribe:r,sub:r,on:r,unsubscribe:i,unsub:i,off:i}})},{}],2:[function(e,t,n){"use strict";var r=e("./lib/set-attributes"),i=e("./lib/default-attributes"),o=e("./lib/assign");t.exports=function(e){var t=document.createElement("iframe"),n=o({},i,e);return n.style&&"string"!=typeof n.style&&(o(t.style,n.style),delete n.style),r(t,n),t.getAttribute("id")||(t.id=t.name),t}},{"./lib/assign":3,"./lib/default-attributes":4,"./lib/set-attributes":5}],3:[function(e,t,n){"use strict";t.exports=function(e){var t=Array.prototype.slice.call(arguments,1);return t.forEach(function(t){"object"==typeof t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}},{}],4:[function(e,t,n){t.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],5:[function(e,t,n){"use strict";t.exports=function(e,t){var n;for(var r in t)t.hasOwnProperty(r)&&(n=t[r],null==n?e.removeAttribute(r):e.setAttribute(r,n))}},{}],6:[function(e,t,n){"use strict";function r(e,t){var n,r=t?o(t):{},a=i(e.authorization).attrs,u=o(e.analyticsMetadata);r.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION;for(n in r._meta)r._meta.hasOwnProperty(n)&&(u[n]=r._meta[n]);return r._meta=u,a.tokenizationKey?r.tokenizationKey=a.tokenizationKey:r.authorizationFingerprint=a.authorizationFingerprint,r}var i=e("./create-authorization-data"),o=e("./json-clone"),s=e("./constants");t.exports=r},{"./constants":11,"./create-authorization-data":13,"./json-clone":17}],7:[function(e,t,n){"use strict";function r(e){return Math.floor(e/1e3)}function i(e,t,n){var i=e.getConfiguration(),a=e._request,u=r(Date.now()),c=i.gatewayConfiguration.analytics.url,l={analytics:[{kind:t,timestamp:u}]};a({url:c,method:"post",data:s(i,l),timeout:o.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var o=e("./constants"),s=e("./add-metadata");t.exports={sendEvent:i}},{"./add-metadata":6,"./constants":11}],8:[function(e,t,n){"use strict";function r(e,t){var n,r,o=document.createElement("a");return o.href=t,r="https:"===o.protocol?o.host.replace(/:443$/,""):"http:"===o.protocol?o.host.replace(/:80$/,""):o.host,n=o.protocol+"//"+r,n===e||i.test(e)}var i=/^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/;t.exports={checkOrigin:r}},{}],9:[function(e,t,n){"use strict";var r=e("../enumerate");t.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":15}],10:[function(e,t,n){"use strict";function r(e){if(e=e||{},this.channel=e.channel,!this.channel)throw new a({type:a.types.INTERNAL,message:"Channel ID must be specified."});this.merchantUrl=e.merchantUrl,this._isDestroyed=!1,this._isVerbose=!1,this._listeners=[],this._log("new bus on channel "+this.channel,[location.href])}var i=e("framebus"),o=e("./events"),s=e("./check-origin").checkOrigin,a=e("../error");r.prototype.on=function(e,t){var n,r,o=t,a=this;this._isDestroyed||(this.merchantUrl&&(o=function(){s(this.origin,a.merchantUrl)&&t.apply(this,arguments)}),n=this._namespaceEvent(e),r=Array.prototype.slice.call(arguments),r[0]=n,r[1]=o,this._log("on",r),i.on.apply(i,r),this._listeners.push({eventName:e,handler:o,originalHandler:t}))},r.prototype.emit=function(e){var t;this._isDestroyed||(t=Array.prototype.slice.call(arguments),t[0]=this._namespaceEvent(e),this._log("emit",t),i.emit.apply(i,t))},r.prototype._offDirect=function(e){var t=Array.prototype.slice.call(arguments);this._isDestroyed||(t[0]=this._namespaceEvent(e),this._log("off",t),i.off.apply(i,t))},r.prototype.off=function(e,t){var n,r,i=t;if(!this._isDestroyed){if(this.merchantUrl)for(n=0;n<this._listeners.length;n++)r=this._listeners[n],r.originalHandler===t&&(i=r.handler);this._offDirect(e,i)}},r.prototype._namespaceEvent=function(e){return["braintree",this.channel,e].join(":")},r.prototype.teardown=function(){var e,t;for(t=0;t<this._listeners.length;t++)e=this._listeners[t],this._offDirect(e.eventName,e.handler);this._listeners.length=0,this._isDestroyed=!0},r.prototype._log=function(e,t){this._isVerbose&&console.log(e,t)},r.events=o,t.exports=r},{"../error":16,"./check-origin":8,"./events":9,framebus:1}],11:[function(e,t,n){"use strict";var r="3.0.0-beta.8",i="web";t.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:i,BRAINTREE_LIBRARY_VERSION:"braintree/"+i+"/"+r}},{}],12:[function(e,t,n){"use strict";var r=e("./error");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new r({type:r.types.MERCHANT,message:t+" cannot be called after teardown."})}})}},{"./error":16}],13:[function(e,t,n){"use strict";function r(e){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(e)}function i(e){var t=e.split("_"),n=t[0],r=t.slice(2).join("_");return{merchantId:r,environment:n}}function o(e){var t,n,o={attrs:{},configUrl:""};return r(e)?(n=i(e),o.attrs.tokenizationKey=e,o.configUrl=a[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(s(e)),o.attrs.authorizationFingerprint=t.authorizationFingerprint,o.configUrl=t.configUrl),o}var s=e("../lib/polyfill").atob,a={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=o},{"../lib/polyfill":19}],14:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],15:[function(e,t,n){"use strict";function r(e,t){return t=null==t?"":t,e.reduce(function(e,n){return e[n]=t+n,e},{})}t.exports=r},{}],16:[function(e,t,n){"use strict";function r(e){if(!r.types.hasOwnProperty(e.type))throw new Error(e.type+" is not a valid type.");if(!e.message)throw new Error("Error message required.");this.message=e.message,this.type=e.type,this.details=e.details}var i=e("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=i(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),t.exports=r},{"./enumerate":15}],17:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],18:[function(e,t,n){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],19:[function(e,t,n){(function(e){"use strict";function n(e){var t,n,r,i,o,s,a,u,c=new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d="";if(!c.test(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");u=0;do i=l.indexOf(e.charAt(u++)),o=l.indexOf(e.charAt(u++)),s=l.indexOf(e.charAt(u++)),a=l.indexOf(e.charAt(u++)),t=(63&i)<<2|o>>4&3,n=(15&o)<<4|s>>2&15,r=(3&s)<<6|63&a,d+=String.fromCharCode(t)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(u<e.length);return d}var r="function"==typeof e.atob?e.atob:n;t.exports={atob:r,_atob:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],20:[function(e,t,n){"use strict";function r(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)})}t.exports=r},{}],21:[function(e,t,n){"use strict";function r(e,t){var n,r;if("function"!=typeof t)throw new s({type:s.types.MERCHANT,message:"UnionPay creation requires a callback."});return t=u(t),null==e.client?void t(new s({type:s.types.MERCHANT,message:"options.client is required when instantiating UnionPay."})):(n=e.client.getConfiguration(),r=n.analyticsMetadata.sdkVersion,r!==i?void t(new s({type:s.types.MERCHANT,message:"Client (version "+r+") and UnionPay (version "+i+") components must be from the same SDK version."})):n.gatewayConfiguration.unionPay&&n.gatewayConfiguration.unionPay.enabled===!0?(a.sendEvent(e.client,"web.unionpay.initialized"),void t(null,new o(e))):void t(new s({type:s.types.MERCHANT,message:"UnionPay is not enabled for this merchant."})))}var i="3.0.0-beta.8",o=e("./shared/unionpay"),s=e("../lib/error"),a=e("../lib/analytics"),u=e("../lib/deferred");t.exports={create:r,VERSION:i}},{"../lib/analytics":7,"../lib/deferred":14,"../lib/error":16,"./shared/unionpay":23}],22:[function(e,t,n){"use strict";var r=e("../../lib/enumerate");t.exports={events:r(["HOSTED_FIELDS_FETCH_CAPABILITIES","HOSTED_FIELDS_ENROLL","HOSTED_FIELDS_TOKENIZE"],"union-pay:"),HOSTED_FIELDS_FRAME_NAME:"braintreeunionpayhostedfields",INVALID_HOSTED_FIELDS_ERROR_MESSAGE:"Found an invalid Hosted Fields instance. Please use a valid Hosted Fields instance.",CARD_OR_HOSTED_FIELDS_REQUIRED_ERROR_MESSAGE:"A card or a Hosted Fields instance is required. Please supply a card or a Hosted Fields instance.",CARD_AND_HOSTED_FIELDS_ERROR_MESSAGE:"Please supply either a card or a Hosted Fields instance, not both.",NO_HOSTED_FIELDS_ERROR_MESSAGE:"Could not find the Hosted Fields instance."}},{"../../lib/enumerate":15}],23:[function(e,t,n){"use strict";function r(e){this._options=e}var i=e("../../lib/error"),o=e("../../lib/bus"),s=e("../../lib/analytics"),a=e("iframer"),u=e("../../lib/uuid"),c=e("../../lib/methods"),l=e("../../lib/deferred"),d=e("../../lib/convert-methods-to-error"),p="3.0.0-beta.8",f=e("./constants"),h=f.events;r.prototype.fetchCapabilities=function(e,t){var n=this._options.client,r=e.card?e.card.number:null,o=e.hostedFields;if(t=l(t),r&&o)return void t(new i({type:i.types.MERCHANT,message:f.CARD_AND_HOSTED_FIELDS_ERROR_MESSAGE}));if(r)n.request({method:"get",endpoint:"payment_methods/credit_cards/capabilities",data:{_meta:{source:"unionpay"},creditCard:{number:r}}},function(e,r){return e?(t(new i({type:i.types.NETWORK,message:"Fetch capabilities network error.",details:{originalError:e}})),void s.sendEvent(n,"web.unionpay.capabilities-failed")):(s.sendEvent(n,"web.unionpay.capabilities-received"),void t(null,r))});else{if(!o)return void t(new i({type:i.types.MERCHANT,message:f.CARD_OR_HOSTED_FIELDS_REQUIRED_ERROR_MESSAGE}));if(!o._bus)return void t(new i({type:i.types.MERCHANT,message:f.INVALID_HOSTED_FIELDS_ERROR_MESSAGE}));this._initializeHostedFields(function(){this._bus.emit(h.HOSTED_FIELDS_FETCH_CAPABILITIES,{hostedFields:o},function(e){return e.err?void t(new i(e.err)):void t(null,e.payload)})}.bind(this))}},r.prototype.enroll=function(e,t){var n,r=this._options.client,o=e.card,a=e.mobile,u=e.hostedFields;if(t=l(t),!a)return void t(new i({type:i.types.MERCHANT,message:"A `mobile` with `countryCode` and `number` is required."}));if(u){if(!u._bus)return void t(new i({type:i.types.MERCHANT,message:f.INVALID_HOSTED_FIELDS_ERROR_MESSAGE}));if(o)return void t(new i({type:i.types.MERCHANT,message:f.CARD_AND_HOSTED_FIELDS_ERROR_MESSAGE}));this._initializeHostedFields(function(){this._bus.emit(h.HOSTED_FIELDS_ENROLL,{hostedFields:u,mobile:a},function(e){return e.err?void t(new i(e.err)):void t(null,e.payload)})}.bind(this))}else{if(!o||!o.number)return void t(new i({type:i.types.MERCHANT,message:f.CARD_OR_HOSTED_FIELDS_REQUIRED_ERROR_MESSAGE}));if(n={_meta:{source:"unionpay"},unionPayEnrollment:{number:o.number,mobileCountryCode:a.countryCode,mobileNumber:a.number}},o.expirationMonth||o.expirationYear){if(!o.expirationMonth||!o.expirationYear)return void t(new i({type:i.types.MERCHANT,message:"You must supply expiration month and year or neither."}));n.unionPayEnrollment.expirationYear=o.expirationYear,n.unionPayEnrollment.expirationMonth=o.expirationMonth}r.request({method:"post",endpoint:"union_pay_enrollments",data:n},function(e,n,o){var a,u;return e?(500>o?(u=i.types.CUSTOMER,a="Enrollment invalid due to customer input error."):(u=i.types.NETWORK,a="An enrollment network error occurred."),s.sendEvent(r,"web.unionpay.enrollment-failed"),void t(new i({type:u,message:a,details:{originalError:e}}))):(s.sendEvent(r,"web.unionpay.enrollment-succeeded"),void t(null,{enrollmentId:n.unionPayEnrollmentId}))})}},r.prototype.tokenize=function(e,t){var n,r,o=this._options.client,a=e.card,u=e.hostedFields;if(t=l(t),a&&u)return void t(new i({type:i.types.MERCHANT,message:f.CARD_AND_HOSTED_FIELDS_ERROR_MESSAGE}));if(a)n={_meta:{source:"unionpay"},creditCard:{number:e.card.number,expirationMonth:e.card.expirationMonth,expirationYear:e.card.expirationYear,options:{unionPayEnrollment:{id:e.enrollmentId,smsCode:e.smsCode}}}},e.card.cvv&&(n.creditCard.cvv=e.card.cvv),o.request({method:"post",endpoint:"payment_methods/credit_cards",data:n},function(e,n,a){return e?(s.sendEvent(o,"web.unionpay.nonce-failed"),void t(500>a?new i({type:i.types.CUSTOMER,message:"The supplied card data failed tokenization.",details:{originalError:e}}):new i({type:i.types.NETWORK,message:"A tokenization network error occurred.",details:{originalError:e}}))):(r=n.creditCards[0],delete r.consumed,delete r.threeDSecureInfo,delete r.type,s.sendEvent(o,"web.unionpay.nonce-received"),void t(null,r))});else{if(!u)return void t(new i({type:i.types.MERCHANT,message:f.CARD_OR_HOSTED_FIELDS_REQUIRED_ERROR_MESSAGE}));if(!u._bus)return void t(new i({type:i.types.MERCHANT,message:f.INVALID_HOSTED_FIELDS_ERROR_MESSAGE}));this._initializeHostedFields(function(){this._bus.emit(h.HOSTED_FIELDS_TOKENIZE,e,function(e){return e.err?void t(new i(e.err)):void t(null,e.payload)})}.bind(this))}},r.prototype.teardown=function(e){this._bus&&(this._hostedFieldsFrame.parentNode.removeChild(this._hostedFieldsFrame),this._bus.teardown()),d(this,c(r.prototype)),"function"==typeof e&&(e=l(e))()},r.prototype._initializeHostedFields=function(e){var t=u();return this._bus?void e():(this._bus=new o({channel:t,merchantUrl:location.href}),this._hostedFieldsFrame=a({name:f.HOSTED_FIELDS_FRAME_NAME+"_"+t,src:this._options.client.getConfiguration().gatewayConfiguration.assetsUrl+"/web/"+p+"/html/unionpay-hosted-fields-frame.min.html",height:0,width:0}),this._bus.on(o.events.CONFIGURATION_REQUEST,function(t){t(this._options.client),e()}.bind(this)),void document.body.appendChild(this._hostedFieldsFrame))},t.exports=r},{"../../lib/analytics":7,"../../lib/bus":10,"../../lib/convert-methods-to-error":12,"../../lib/deferred":14,"../../lib/error":16,"../../lib/methods":18,"../../lib/uuid":20,"./constants":22,iframer:2}]},{},[21])(21)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(t.braintree||(t.braintree={})).unionpay=e()}}(function(){var e;return function t(e,n,r){function i(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,n,r){(function(t){"use strict";!function(i,o){"object"==typeof r&&"undefined"!=typeof n?n.exports=o("undefined"==typeof t?i:t):"function"==typeof e&&e.amd?e([],function(){return o(i)}):i.framebus=o(i)}(this,function(e){function t(e){return null==e?!1:null==e.Window?!1:e.constructor!==e.Window?!1:(g.push(e),!0)}function n(e){var t,n={};for(t in v)v.hasOwnProperty(t)&&(n[t]=v[t]);return n._origin=e||"*",n}function r(e){var t,n,r=s(this);return a(e)?!1:a(r)?!1:(n=Array.prototype.slice.call(arguments,1),t=u(e,n,r),t===!1?!1:(y(b.top,t,r),!0))}function i(e,t){var n=s(this);return m(e,t,n)?!1:(x[n]=x[n]||{},x[n][e]=x[n][e]||[],x[n][e].push(t),!0)}function o(e,t){var n,r,i=s(this);if(m(e,t,i))return!1;if(r=x[i]&&x[i][e],!r)return!1;for(n=0;n<r.length;n++)if(r[n]===t)return r.splice(n,1),!0;return!1}function s(e){return e&&e._origin||"*"}function a(e){return"string"!=typeof e}function u(e,t,n){var r=!1,i={event:e,origin:n},o=t[t.length-1];"function"==typeof o&&(i.reply=_(o,n),t=t.slice(0,-1)),i.args=t;try{r=R+JSON.stringify(i)}catch(s){throw new Error("Could not stringify event: "+s.message)}return r}function l(e){var t,n,r,i;if(e.data.slice(0,R.length)!==R)return!1;try{t=JSON.parse(e.data.slice(R.length))}catch(o){return!1}return null!=t.reply&&(n=e.origin,r=e.source,i=t.reply,t.reply=function(e){var t=u(i,[e],n);return t===!1?!1:void r.postMessage(t,n)},t.args.push(t.reply)),t}function c(t){b||(b=t||e,b.addEventListener?b.addEventListener("message",p,!1):b.attachEvent?b.attachEvent("onmessage",p):null===b.onmessage?b.onmessage=p:b=null)}function d(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)})}function p(e){var t;a(e.data)||(t=l(e),t&&(f("*",t.event,t.args,e),f(e.origin,t.event,t.args,e),E(e.data,t.origin,e.source)))}function f(e,t,n,r){var i;if(x[e]&&x[e][t])for(i=0;i<x[e][t].length;i++)x[e][t][i].apply(r,n)}function h(e){return e.top!==e?!1:null==e.opener?!1:e.opener===e?!1:e.opener.closed===!0?!1:!0}function y(e,t,n){var r;try{for(e.postMessage(t,n),h(e)&&y(e.opener.top,t,n),r=0;r<e.frames.length;r++)y(e.frames[r],t,n)}catch(i){}}function E(e,t,n){var r,i;for(r=g.length-1;r>=0;r--)i=g[r],i.closed===!0?g=g.slice(r,1):n!==i&&y(i.top,e,t)}function _(e,t){function n(i,o){e(i,o),v.target(t).unsubscribe(r,n)}var r=d();return v.target(t).subscribe(r,n),r}function m(e,t,n){return a(e)?!0:"function"!=typeof t?!0:a(n)?!0:!1}var b,v,g=[],x={},R="/*framebus*/";return c(),v={target:n,include:t,publish:r,pub:r,trigger:r,emit:r,subscribe:i,sub:i,on:i,unsubscribe:o,unsub:o,off:o}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){"use strict";var r=e("./lib/set-attributes"),i=e("./lib/default-attributes"),o=e("./lib/assign");t.exports=function(e){var t=document.createElement("iframe"),n=o({},i,e);return n.style&&"string"!=typeof n.style&&(o(t.style,n.style),delete n.style),r(t,n),t.getAttribute("id")||(t.id=t.name),t}},{"./lib/assign":3,"./lib/default-attributes":4,"./lib/set-attributes":5}],3:[function(e,t,n){"use strict";t.exports=function(e){var t=Array.prototype.slice.call(arguments,1);return t.forEach(function(t){"object"==typeof t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}},{}],4:[function(e,t,n){t.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],5:[function(e,t,n){"use strict";t.exports=function(e,t){var n;for(var r in t)t.hasOwnProperty(r)&&(n=t[r],null==n?e.removeAttribute(r):e.setAttribute(r,n))}},{}],6:[function(e,t,n){"use strict";function r(e,t){var n,r=t?o(t):{},a=i(e.authorization).attrs,u=o(e.analyticsMetadata);r.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION;for(n in r._meta)r._meta.hasOwnProperty(n)&&(u[n]=r._meta[n]);return r._meta=u,a.tokenizationKey?r.tokenizationKey=a.tokenizationKey:r.authorizationFingerprint=a.authorizationFingerprint,r}var i=e("./create-authorization-data"),o=e("./json-clone"),s=e("./constants");t.exports=r},{"./constants":11,"./create-authorization-data":13,"./json-clone":17}],7:[function(e,t,n){"use strict";function r(e){return Math.floor(e/1e3)}function i(e,t,n){var i=e.getConfiguration(),a=e._request,u=r(Date.now()),l=i.gatewayConfiguration.analytics.url,c={analytics:[{kind:t,timestamp:u}]};a({url:l,method:"post",data:s(i,c),timeout:o.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var o=e("./constants"),s=e("./add-metadata");t.exports={sendEvent:i}},{"./add-metadata":6,"./constants":11}],8:[function(e,t,n){"use strict";function r(e,t){var n,r,o=document.createElement("a");return o.href=t,r="https:"===o.protocol?o.host.replace(/:443$/,""):"http:"===o.protocol?o.host.replace(/:80$/,""):o.host,n=o.protocol+"//"+r,n===e||i.test(e)}var i=/^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/;t.exports={checkOrigin:r}},{}],9:[function(e,t,n){"use strict";var r=e("../enumerate");t.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":15}],10:[function(e,t,n){"use strict";function r(e){if(e=e||{},this.channel=e.channel,!this.channel)throw new a({type:a.types.INTERNAL,message:"Channel ID must be specified."});this.merchantUrl=e.merchantUrl,this._isDestroyed=!1,this._isVerbose=!1,this._listeners=[],this._log("new bus on channel "+this.channel,[location.href])}var i=e("framebus"),o=e("./events"),s=e("./check-origin").checkOrigin,a=e("../error");r.prototype.on=function(e,t){var n,r,o=t,a=this;this._isDestroyed||(this.merchantUrl&&(o=function(){s(this.origin,a.merchantUrl)&&t.apply(this,arguments)}),n=this._namespaceEvent(e),r=Array.prototype.slice.call(arguments),r[0]=n,r[1]=o,this._log("on",r),i.on.apply(i,r),this._listeners.push({eventName:e,handler:o,originalHandler:t}))},r.prototype.emit=function(e){var t;this._isDestroyed||(t=Array.prototype.slice.call(arguments),t[0]=this._namespaceEvent(e),this._log("emit",t),i.emit.apply(i,t))},r.prototype._offDirect=function(e){var t=Array.prototype.slice.call(arguments);this._isDestroyed||(t[0]=this._namespaceEvent(e),this._log("off",t),i.off.apply(i,t))},r.prototype.off=function(e,t){var n,r,i=t;if(!this._isDestroyed){if(this.merchantUrl)for(n=0;n<this._listeners.length;n++)r=this._listeners[n],r.originalHandler===t&&(i=r.handler);this._offDirect(e,i)}},r.prototype._namespaceEvent=function(e){return["braintree",this.channel,e].join(":")},r.prototype.teardown=function(){var e,t;for(t=0;t<this._listeners.length;t++)e=this._listeners[t],this._offDirect(e.eventName,e.handler);this._listeners.length=0,this._isDestroyed=!0},r.prototype._log=function(e,t){this._isVerbose&&console.log(e,t)},r.events=o,t.exports=r},{"../error":16,"./check-origin":8,"./events":9,framebus:1}],11:[function(e,t,n){"use strict";var r="3.0.0-beta.9",i="web";t.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:i,BRAINTREE_LIBRARY_VERSION:"braintree/"+i+"/"+r}},{}],12:[function(e,t,n){"use strict";var r=e("./error");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new r({type:r.types.MERCHANT,message:t+" cannot be called after teardown."})}})}},{"./error":16}],13:[function(e,t,n){"use strict";function r(e){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(e)}function i(e){var t=e.split("_"),n=t[0],r=t.slice(2).join("_");return{merchantId:r,environment:n}}function o(e){var t,n,o={attrs:{},configUrl:""};return r(e)?(n=i(e),o.attrs.tokenizationKey=e,o.configUrl=a[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(s(e)),o.attrs.authorizationFingerprint=t.authorizationFingerprint,o.configUrl=t.configUrl),o}var s=e("../lib/polyfill").atob,a={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=o},{"../lib/polyfill":19}],14:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],15:[function(e,t,n){"use strict";function r(e,t){return t=null==t?"":t,e.reduce(function(e,n){return e[n]=t+n,e},{})}t.exports=r},{}],16:[function(e,t,n){"use strict";function r(e){if(!r.types.hasOwnProperty(e.type))throw new Error(e.type+" is not a valid type.");if(!e.message)throw new Error("Error message required.");this.message=e.message,this.type=e.type,this.details=e.details}var i=e("./enumerate");r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.types=i(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),t.exports=r},{"./enumerate":15}],17:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],18:[function(e,t,n){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],19:[function(e,t,n){(function(e){"use strict";function n(e){var t,n,r,i,o,s,a,u,l=new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d="";if(!l.test(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");u=0;do i=c.indexOf(e.charAt(u++)),o=c.indexOf(e.charAt(u++)),s=c.indexOf(e.charAt(u++)),a=c.indexOf(e.charAt(u++)),t=(63&i)<<2|o>>4&3,n=(15&o)<<4|s>>2&15,r=(3&s)<<6|63&a,d+=String.fromCharCode(t)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(u<e.length);return d}var r="function"==typeof e.atob?e.atob:n;t.exports={atob:r,_atob:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],20:[function(e,t,n){"use strict";function r(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)})}t.exports=r},{}],21:[function(e,t,n){"use strict";function r(e,t){var n,r;if("function"!=typeof t)throw new s({type:s.types.MERCHANT,message:"UnionPay creation requires a callback."});return t=u(t),null==e.client?void t(new s({type:s.types.MERCHANT,message:"options.client is required when instantiating UnionPay."})):(n=e.client.getConfiguration(),r=n.analyticsMetadata.sdkVersion,r!==i?void t(new s({type:s.types.MERCHANT,message:"Client (version "+r+") and UnionPay (version "+i+") components must be from the same SDK version."})):n.gatewayConfiguration.unionPay&&n.gatewayConfiguration.unionPay.enabled===!0?(a.sendEvent(e.client,"web.unionpay.initialized"),void t(null,new o(e))):void t(new s({type:s.types.MERCHANT,message:"UnionPay is not enabled for this merchant."})))}var i="3.0.0-beta.9",o=e("./shared/unionpay"),s=e("../lib/error"),a=e("../lib/analytics"),u=e("../lib/deferred");t.exports={create:r,VERSION:i}},{"../lib/analytics":7,"../lib/deferred":14,"../lib/error":16,"./shared/unionpay":23}],22:[function(e,t,n){"use strict";var r=e("../../lib/enumerate");t.exports={events:r(["HOSTED_FIELDS_FETCH_CAPABILITIES","HOSTED_FIELDS_ENROLL","HOSTED_FIELDS_TOKENIZE"],"union-pay:"),HOSTED_FIELDS_FRAME_NAME:"braintreeunionpayhostedfields",INVALID_HOSTED_FIELDS_ERROR_MESSAGE:"Found an invalid Hosted Fields instance. Please use a valid Hosted Fields instance.",CARD_OR_HOSTED_FIELDS_REQUIRED_ERROR_MESSAGE:"A card or a Hosted Fields instance is required. Please supply a card or a Hosted Fields instance.",CARD_AND_HOSTED_FIELDS_ERROR_MESSAGE:"Please supply either a card or a Hosted Fields instance, not both.",NO_HOSTED_FIELDS_ERROR_MESSAGE:"Could not find the Hosted Fields instance."}},{"../../lib/enumerate":15}],23:[function(e,t,n){"use strict";function r(e){this._options=e}var i=e("../../lib/error"),o=e("../../lib/bus"),s=e("../../lib/analytics"),a=e("iframer"),u=e("../../lib/uuid"),l=e("../../lib/methods"),c=e("../../lib/deferred"),d=e("../../lib/convert-methods-to-error"),p="3.0.0-beta.9",f=e("./constants"),h=f.events;r.prototype.fetchCapabilities=function(e,t){var n=this._options.client,r=e.card?e.card.number:null,o=e.hostedFields;if(t=c(t),r&&o)return void t(new i({type:i.types.MERCHANT,message:f.CARD_AND_HOSTED_FIELDS_ERROR_MESSAGE}));if(r)n.request({method:"get",endpoint:"payment_methods/credit_cards/capabilities",data:{_meta:{source:"unionpay"},creditCard:{number:r}}},function(e,r){return e?(t(new i({type:i.types.NETWORK,message:"Fetch capabilities network error.",details:{originalError:e}})),void s.sendEvent(n,"web.unionpay.capabilities-failed")):(s.sendEvent(n,"web.unionpay.capabilities-received"),void t(null,r))});else{if(!o)return void t(new i({type:i.types.MERCHANT,message:f.CARD_OR_HOSTED_FIELDS_REQUIRED_ERROR_MESSAGE}));if(!o._bus)return void t(new i({type:i.types.MERCHANT,message:f.INVALID_HOSTED_FIELDS_ERROR_MESSAGE}));this._initializeHostedFields(function(){this._bus.emit(h.HOSTED_FIELDS_FETCH_CAPABILITIES,{hostedFields:o},function(e){return e.err?void t(new i(e.err)):void t(null,e.payload)})}.bind(this))}},r.prototype.enroll=function(e,t){var n,r=this._options.client,o=e.card,a=e.mobile,u=e.hostedFields;if(t=c(t),!a)return void t(new i({type:i.types.MERCHANT,message:"A `mobile` with `countryCode` and `number` is required."}));if(u){if(!u._bus)return void t(new i({type:i.types.MERCHANT,message:f.INVALID_HOSTED_FIELDS_ERROR_MESSAGE}));if(o)return void t(new i({type:i.types.MERCHANT,message:f.CARD_AND_HOSTED_FIELDS_ERROR_MESSAGE}));this._initializeHostedFields(function(){this._bus.emit(h.HOSTED_FIELDS_ENROLL,{hostedFields:u,mobile:a},function(e){return e.err?void t(new i(e.err)):void t(null,e.payload)})}.bind(this))}else{if(!o||!o.number)return void t(new i({type:i.types.MERCHANT,message:f.CARD_OR_HOSTED_FIELDS_REQUIRED_ERROR_MESSAGE}));if(n={_meta:{source:"unionpay"},unionPayEnrollment:{number:o.number,mobileCountryCode:a.countryCode,mobileNumber:a.number}},o.expirationDate)n.unionPayEnrollment.expirationDate=o.expirationDate;else if(o.expirationMonth||o.expirationYear){if(!o.expirationMonth||!o.expirationYear)return void t(new i({type:i.types.MERCHANT,message:"You must supply expiration month and year or neither."}));n.unionPayEnrollment.expirationYear=o.expirationYear,n.unionPayEnrollment.expirationMonth=o.expirationMonth}r.request({method:"post",endpoint:"union_pay_enrollments",data:n},function(e,n,o){var a,u;return e?(500>o?(u=i.types.CUSTOMER,a="Enrollment invalid due to customer input error."):(u=i.types.NETWORK,a="An enrollment network error occurred."),s.sendEvent(r,"web.unionpay.enrollment-failed"),void t(new i({type:u,message:a,details:{originalError:e}}))):(s.sendEvent(r,"web.unionpay.enrollment-succeeded"),void t(null,{enrollmentId:n.unionPayEnrollmentId}))})}},r.prototype.tokenize=function(e,t){var n,r,o=this._options.client,a=e.card,u=e.hostedFields;if(t=c(t),a&&u)return void t(new i({type:i.types.MERCHANT,message:f.CARD_AND_HOSTED_FIELDS_ERROR_MESSAGE}));if(a)n={_meta:{source:"unionpay"},creditCard:{number:e.card.number,options:{unionPayEnrollment:{id:e.enrollmentId,smsCode:e.smsCode}}}},a.expirationDate?n.creditCard.expirationDate=a.expirationDate:a.expirationMonth&&a.expirationYear&&(n.creditCard.expirationYear=a.expirationYear,n.creditCard.expirationMonth=a.expirationMonth),e.card.cvv&&(n.creditCard.cvv=e.card.cvv),o.request({method:"post",endpoint:"payment_methods/credit_cards",data:n},function(e,n,a){return e?(s.sendEvent(o,"web.unionpay.nonce-failed"),void t(500>a?new i({type:i.types.CUSTOMER,message:"The supplied card data failed tokenization.",details:{originalError:e}}):new i({type:i.types.NETWORK,message:"A tokenization network error occurred.",details:{originalError:e}}))):(r=n.creditCards[0],delete r.consumed,delete r.threeDSecureInfo,delete r.type,s.sendEvent(o,"web.unionpay.nonce-received"),void t(null,r))});else{if(!u)return void t(new i({type:i.types.MERCHANT,message:f.CARD_OR_HOSTED_FIELDS_REQUIRED_ERROR_MESSAGE}));if(!u._bus)return void t(new i({type:i.types.MERCHANT,message:f.INVALID_HOSTED_FIELDS_ERROR_MESSAGE}));this._initializeHostedFields(function(){this._bus.emit(h.HOSTED_FIELDS_TOKENIZE,e,function(e){return e.err?void t(new i(e.err)):void t(null,e.payload)})}.bind(this))}},r.prototype.teardown=function(e){this._bus&&(this._hostedFieldsFrame.parentNode.removeChild(this._hostedFieldsFrame),this._bus.teardown()),d(this,l(r.prototype)),"function"==typeof e&&(e=c(e))()},r.prototype._initializeHostedFields=function(e){var t=u();return this._bus?void e():(this._bus=new o({channel:t,merchantUrl:location.href}),this._hostedFieldsFrame=a({name:f.HOSTED_FIELDS_FRAME_NAME+"_"+t,src:this._options.client.getConfiguration().gatewayConfiguration.assetsUrl+"/web/"+p+"/html/unionpay-hosted-fields-frame.min.html",height:0,width:0}),this._bus.on(o.events.CONFIGURATION_REQUEST,function(t){t(this._options.client),e()}.bind(this)),void document.body.appendChild(this._hostedFieldsFrame))},t.exports=r},{"../../lib/analytics":7,"../../lib/bus":10,"../../lib/convert-methods-to-error":12,"../../lib/deferred":14,"../../lib/error":16,"../../lib/methods":18,"../../lib/uuid":20,"./constants":22,iframer:2}]},{},[21])(21)}); |
338057
4.38%5956
3.82%