braintree-web
Advanced tools
Comparing version 3.0.0-beta.12 to 3.0.0
@@ -54,4 +54,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 = {})).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){ | ||
callback(new BraintreeError({ | ||
type: errors.NONCE_REQUIRED.type, | ||
code: errors.NONCE_REQUIRED.code, | ||
type: errors.AMEX_NONCE_REQUIRED.type, | ||
code: errors.AMEX_NONCE_REQUIRED.code, | ||
message: 'getRewardsBalance must be called with a nonce.' | ||
@@ -120,4 +120,4 @@ })); | ||
callback(new BraintreeError({ | ||
type: errors.NONCE_REQUIRED.type, | ||
code: errors.NONCE_REQUIRED.code, | ||
type: errors.AMEX_NONCE_REQUIRED.type, | ||
code: errors.AMEX_NONCE_REQUIRED.code, | ||
message: 'getExpressCheckoutProfile must be called with a nonce.' | ||
@@ -159,5 +159,5 @@ })); | ||
module.exports = { | ||
NONCE_REQUIRED: { | ||
AMEX_NONCE_REQUIRED: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'NONCE_REQUIRED' | ||
code: 'AMEX_NONCE_REQUIRED' | ||
}, | ||
@@ -181,3 +181,3 @@ AMEX_NETWORK_ERROR: { | ||
var sharedErrors = _dereq_('../errors'); | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
@@ -184,0 +184,0 @@ /** |
@@ -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 r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(r.braintree||(r.braintree={})).americanExpress=e()}}(function(){return function e(r,t,n){function o(s,c){if(!t[s]){if(!r[s]){var a="function"==typeof require&&require;if(!c&&a)return a(s,!0);if(i)return i(s,!0);var E=new Error("Cannot find module '"+s+"'");throw E.code="MODULE_NOT_FOUND",E}var u=t[s]={exports:{}};r[s][0].call(u.exports,function(e){var t=r[s][1][e];return o(t?t:e)},u,u.exports,e,r,t,n)}return t[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(e,r,t){"use strict";function n(e){this._client=e.client}var o=e("../lib/error"),i=e("../lib/deferred"),s=e("./errors"),c=e("../errors");n.prototype.getRewardsBalance=function(e,r){if("function"!=typeof r)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"getRewardsBalance must include a callback function."});return r=i(r),e.nonce?void this._client.request({method:"get",endpoint:"payment_methods/amex_rewards_balance",data:{_meta:{source:"american-express"},paymentMethodNonce:e.nonce}},function(e,t){e?r(new o({type:s.AMEX_NETWORK_ERROR.type,code:s.AMEX_NETWORK_ERROR.code,message:"A network error occurred when getting the American Express rewards balance.",details:{originalError:e}})):r(null,t)}):void r(new o({type:s.NONCE_REQUIRED.type,code:s.NONCE_REQUIRED.code,message:"getRewardsBalance must be called with a nonce."}))},n.prototype.getExpressCheckoutProfile=function(e,r){if("function"!=typeof r)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"getExpressCheckoutProfile must include a callback function."});return r=i(r),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,t){e?r(new o({type:s.AMEX_NETWORK_ERROR.type,code:s.AMEX_NETWORK_ERROR.code,message:"A network error occurred when getting the American Express Checkout nonce profile.",details:{originalError:e}})):r(null,t)}):void r(new o({type:s.NONCE_REQUIRED.type,code:s.NONCE_REQUIRED.code,message:"getExpressCheckoutProfile must be called with a nonce."}))},r.exports=n},{"../errors":4,"../lib/deferred":5,"../lib/error":7,"./errors":2}],2:[function(e,r,t){"use strict";var n=e("../lib/error");r.exports={NONCE_REQUIRED:{type:n.types.MERCHANT,code:"NONCE_REQUIRED"},AMEX_NETWORK_ERROR:{type:n.types.NETWORK,code:"AMEX_NETWORK_ERROR"}}},{"../lib/error":7}],3:[function(e,r,t){"use strict";function n(e,r){var t;if("function"!=typeof r)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return r=s(r),null==e.client?void r(new o({type:c.INSTANTIATION_OPTION_REQUIRED.type,code:c.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating American Express."})):(t=e.client.getConfiguration().analyticsMetadata.sdkVersion,t!==a?void r(new o({type:c.INCOMPATIBLE_VERSIONS.type,code:c.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+t+") and American Express (version "+a+") components must be from the same SDK version."})):void r(null,new i(e)))}var o=e("../lib/error"),i=e("./american-express"),s=e("../lib/deferred"),c=e("../errors"),a="3.0.0-beta.12";r.exports={create:n,VERSION:a}},{"../errors":4,"../lib/deferred":5,"../lib/error":7,"./american-express":1}],4:[function(e,r,t){"use strict";var n=e("./lib/error");r.exports={CALLBACK_REQUIRED:{type:n.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:n.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:n.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:n.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":7}],5:[function(e,r,t){"use strict";r.exports=function(e){return function(){var r=arguments;setTimeout(function(){e.apply(null,r)},1)}}},{}],6:[function(e,r,t){"use strict";function n(e,r){return r=null==r?"":r,e.reduce(function(e,t){return e[t]=r+t,e},{})}r.exports=n},{}],7:[function(e,r,t){"use strict";function n(e){if(!n.types.hasOwnProperty(e.type))throw new Error(e.type+" is not a valid type.");if(!e.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,this.message=e.message,this.type=e.type,this.details=e.details}var o=e("./enumerate");n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n.types=o(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),r.exports=n},{"./enumerate":6}]},{},[3])(3)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(r.braintree||(r.braintree={})).americanExpress=e()}}(function(){return function e(r,t,n){function o(s,c){if(!t[s]){if(!r[s]){var a="function"==typeof require&&require;if(!c&&a)return a(s,!0);if(i)return i(s,!0);var E=new Error("Cannot find module '"+s+"'");throw E.code="MODULE_NOT_FOUND",E}var u=t[s]={exports:{}};r[s][0].call(u.exports,function(e){var t=r[s][1][e];return o(t?t:e)},u,u.exports,e,r,t,n)}return t[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(e,r,t){"use strict";function n(e){this._client=e.client}var o=e("../lib/error"),i=e("../lib/deferred"),s=e("./errors"),c=e("../errors");n.prototype.getRewardsBalance=function(e,r){if("function"!=typeof r)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"getRewardsBalance must include a callback function."});return r=i(r),e.nonce?void this._client.request({method:"get",endpoint:"payment_methods/amex_rewards_balance",data:{_meta:{source:"american-express"},paymentMethodNonce:e.nonce}},function(e,t){e?r(new o({type:s.AMEX_NETWORK_ERROR.type,code:s.AMEX_NETWORK_ERROR.code,message:"A network error occurred when getting the American Express rewards balance.",details:{originalError:e}})):r(null,t)}):void r(new o({type:s.AMEX_NONCE_REQUIRED.type,code:s.AMEX_NONCE_REQUIRED.code,message:"getRewardsBalance must be called with a nonce."}))},n.prototype.getExpressCheckoutProfile=function(e,r){if("function"!=typeof r)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"getExpressCheckoutProfile must include a callback function."});return r=i(r),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,t){e?r(new o({type:s.AMEX_NETWORK_ERROR.type,code:s.AMEX_NETWORK_ERROR.code,message:"A network error occurred when getting the American Express Checkout nonce profile.",details:{originalError:e}})):r(null,t)}):void r(new o({type:s.AMEX_NONCE_REQUIRED.type,code:s.AMEX_NONCE_REQUIRED.code,message:"getExpressCheckoutProfile must be called with a nonce."}))},r.exports=n},{"../errors":4,"../lib/deferred":5,"../lib/error":7,"./errors":2}],2:[function(e,r,t){"use strict";var n=e("../lib/error");r.exports={AMEX_NONCE_REQUIRED:{type:n.types.MERCHANT,code:"AMEX_NONCE_REQUIRED"},AMEX_NETWORK_ERROR:{type:n.types.NETWORK,code:"AMEX_NETWORK_ERROR"}}},{"../lib/error":7}],3:[function(e,r,t){"use strict";function n(e,r){var t;if("function"!=typeof r)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return r=s(r),null==e.client?void r(new o({type:c.INSTANTIATION_OPTION_REQUIRED.type,code:c.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating American Express."})):(t=e.client.getConfiguration().analyticsMetadata.sdkVersion,t!==a?void r(new o({type:c.INCOMPATIBLE_VERSIONS.type,code:c.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+t+") and American Express (version "+a+") components must be from the same SDK version."})):void r(null,new i(e)))}var o=e("../lib/error"),i=e("./american-express"),s=e("../lib/deferred"),c=e("../errors"),a="3.0.0";r.exports={create:n,VERSION:a}},{"../errors":4,"../lib/deferred":5,"../lib/error":7,"./american-express":1}],4:[function(e,r,t){"use strict";var n=e("./lib/error");r.exports={CALLBACK_REQUIRED:{type:n.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:n.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:n.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:n.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":7}],5:[function(e,r,t){"use strict";r.exports=function(e){return function(){var r=arguments;setTimeout(function(){e.apply(null,r)},1)}}},{}],6:[function(e,r,t){"use strict";function n(e,r){return r=null==r?"":r,e.reduce(function(e,t){return e[t]=r+t,e},{})}r.exports=n},{}],7:[function(e,r,t){"use strict";function n(e){if(!n.types.hasOwnProperty(e.type))throw new Error(e.type+" is not a valid type.");if(!e.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,this.message=e.message,this.type=e.type,this.details=e.details}var o=e("./enumerate");n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n.types=o(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),r.exports=n},{"./enumerate":6}]},{},[3])(3)}); |
@@ -295,3 +295,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 = {})).applePay = 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 errors = _dereq_('./errors'); | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
@@ -449,3 +449,3 @@ /** | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
var PLATFORM = 'web'; | ||
@@ -452,0 +452,0 @@ |
@@ -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={})).applePay=e()}}(function(){return function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var p="function"==typeof require&&require;if(!s&&p)return p(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[a]={exports:{}};t[a][0].call(d.exports,function(e){var n=t[a][1][e];return o(n?n:e)},d,d.exports,e,t,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(e,t,n){(function(n){"use strict";function r(e){this._client=e.client}var o=e("../lib/error"),i=e("../lib/analytics"),a=e("../lib/deferred"),s=e("../errors"),p=e("./errors");r.prototype.decoratePaymentRequest=function(e){var t=this._client.getConfiguration().gatewayConfiguration.applePay;return e.countryCode||(e.countryCode=t.countryCode),e.currencyCode||(e.currencyCode=t.currencyCode),e.merchantCapabilities||(e.merchantCapabilities=t.merchantCapabilities),e.supportedNetworks||(e.supportedNetworks=t.supportedNetworks.map(function(e){return"mastercard"===e?"masterCard":e})),e},r.prototype.performValidation=function(e,t){var r;if("function"!=typeof t)throw new o({type:s.CALLBACK_REQUIRED.type,code:s.CALLBACK_REQUIRED.code,message:"performValidation requires a callback."});return t=a(t),e&&e.validationURL?(r={validationUrl:e.validationURL,domainName:e.domainName||n.location.hostname,merchantIdentifier:e.merchantIdentifier||this._client.getConfiguration().gatewayConfiguration.applePay.merchantIdentifier},null!=e.displayName&&(r.displayName=e.displayName),void this._client.request({method:"post",endpoint:"apple_pay_web/sessions",data:{_meta:{source:"apple-pay"},applePayWebSession:r}},function(e,n){e?(t(new o({type:p.APPLE_PAY_MERCHANT_VALIDATION.type,code:p.APPLE_PAY_MERCHANT_VALIDATION.code,message:p.APPLE_PAY_MERCHANT_VALIDATION.message,details:{originalError:e}})),i.sendEvent(this._client,"applepay.performValidation.failed")):(t(null,n),i.sendEvent(this._client,"applepay.performValidation.succeeded"))}.bind(this))):void t(new o(p.APPLE_PAY_VALIDATION_URL_REQUIRED))},r.prototype.tokenize=function(e,t){if("function"!=typeof t)throw new o({type:s.CALLBACK_REQUIRED.type,code:s.CALLBACK_REQUIRED.code,message:"tokenize requires a callback."});return t=a(t),e.token?void this._client.request({method:"post",endpoint:"payment_methods/apple_payment_tokens",data:{_meta:{source:"apple-pay"},applePaymentToken:e.token}},function(e,n){e?(t(new o({type:p.APPLE_PAY_TOKENIZATION.type,code:p.APPLE_PAY_TOKENIZATION.code,message:p.APPLE_PAY_TOKENIZATION.message,details:{originalError:e}})),i.sendEvent(this._client,"applepay.tokenize.failed")):(t(null,n.applePayCards[0]),i.sendEvent(this._client,"applepay.tokenize.succeeded"))}.bind(this)):void t(new o(p.APPLE_PAY_PAYMENT_TOKEN_REQUIRED))},t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":4,"../lib/analytics":6,"../lib/deferred":9,"../lib/error":11,"./errors":2}],2:[function(e,t,n){"use strict";var r=e("../lib/error");t.exports={APPLE_PAY_NOT_ENABLED:{type:r.types.MERCHANT,code:"APPLE_PAY_NOT_ENABLED",message:"Apple Pay is not enabled for this merchant."},APPLE_PAY_VALIDATION_URL_REQUIRED:{type:r.types.MERCHANT,code:"APPLE_PAY_VALIDATION_URL_REQUIRED",message:"performValidation must be called with a validationURL."},APPLE_PAY_MERCHANT_VALIDATION:{type:r.types.NETWORK,code:"APPLE_PAY_MERCHANT_VALIDATION",message:"A network error occurred when validating the Apple Pay merchant."},APPLE_PAY_PAYMENT_TOKEN_REQUIRED:{type:r.types.MERCHANT,code:"APPLE_PAY_PAYMENT_TOKEN_REQUIRED",message:"tokenize must be called with a payment token."},APPLE_PAY_TOKENIZATION:{type:r.types.NETWORK,code:"APPLE_PAY_TOKENIZATION",message:"A network error occurred when processing the Apple Pay payment."}}},{"../lib/error":11}],3:[function(e,t,n){"use strict";function r(e,t){var n;if("function"!=typeof t)throw new o({type:p.CALLBACK_REQUIRED.type,code:p.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return t=s(t),null==e.client?void t(new o({type:p.INSTANTIATION_OPTION_REQUIRED.type,code:p.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating Apple Pay."})):(n=e.client.getConfiguration().analyticsMetadata.sdkVersion,n!==d?void t(new o({type:p.INCOMPATIBLE_VERSIONS.type,code:p.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+n+") and Apple Pay (version "+d+") components must be from the same SDK version."})):e.client.getConfiguration().gatewayConfiguration.applePay?(a.sendEvent(e.client,"web.applepay.initialized"),void t(null,new i(e))):void t(new o(c.APPLE_PAY_NOT_ENABLED)))}var o=e("../lib/error"),i=e("./apple-pay"),a=e("../lib/analytics"),s=e("../lib/deferred"),p=e("../errors"),c=e("./errors"),d="3.0.0-beta.12";t.exports={create:r,VERSION:d}},{"../errors":4,"../lib/analytics":6,"../lib/deferred":9,"../lib/error":11,"./apple-pay":1,"./errors":2}],4:[function(e,t,n){"use strict";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":11}],5:[function(e,t,n){"use strict";function r(e,t){var n,r=t?i(t):{},s=o(e.authorization).attrs,p=i(e.analyticsMetadata);r.braintreeLibraryVersion=a.BRAINTREE_LIBRARY_VERSION;for(n in r._meta)r._meta.hasOwnProperty(n)&&(p[n]=r._meta[n]);return r._meta=p,s.tokenizationKey?r.tokenizationKey=s.tokenizationKey:r.authorizationFingerprint=s.authorizationFingerprint,r}var o=e("./create-authorization-data"),i=e("./json-clone"),a=e("./constants");t.exports=r},{"./constants":7,"./create-authorization-data":8,"./json-clone":12}],6:[function(e,t,n){"use strict";function r(e){return Math.floor(e/1e3)}function o(e,t,n){var o=e.getConfiguration(),s=e._request,p=r(Date.now()),c=o.gatewayConfiguration.analytics.url,d={analytics:[{kind:t,timestamp:p}]};s({url:c,method:"post",data:a(o,d),timeout:i.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var i=e("./constants"),a=e("./add-metadata");t.exports={sendEvent:o}},{"./add-metadata":5,"./constants":7}],7:[function(e,t,n){"use strict";var r="3.0.0-beta.12",o="web";t.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:o,BRAINTREE_LIBRARY_VERSION:"braintree/"+o+"/"+r}},{}],8:[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 o(e){var t=e.split("_"),n=t[0],r=t.slice(2).join("_");return{merchantId:r,environment:n}}function i(e){var t,n,i={attrs:{},configUrl:""};return r(e)?(n=o(e),i.attrs.tokenizationKey=e,i.configUrl=s[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(a(e)),i.attrs.authorizationFingerprint=t.authorizationFingerprint,i.configUrl=t.configUrl),i}var a=e("../lib/polyfill").atob,s={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=i},{"../lib/polyfill":13}],9:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],10:[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},{}],11:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":10}],12:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],13:[function(e,t,n){(function(e){"use strict";function n(e){var t,n,r,o,i,a,s,p,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})?$"),d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="";if(!c.test(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");p=0;do o=d.indexOf(e.charAt(p++)),i=d.indexOf(e.charAt(p++)),a=d.indexOf(e.charAt(p++)),s=d.indexOf(e.charAt(p++)),t=(63&o)<<2|i>>4&3,n=(15&i)<<4|a>>2&15,r=(3&a)<<6|63&s,l+=String.fromCharCode(t)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(p<e.length);return l}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:{})},{}]},{},[3])(3)}); | ||
!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={})).applePay=e()}}(function(){return function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var p="function"==typeof require&&require;if(!s&&p)return p(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[a]={exports:{}};t[a][0].call(d.exports,function(e){var n=t[a][1][e];return o(n?n:e)},d,d.exports,e,t,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(e,t,n){(function(n){"use strict";function r(e){this._client=e.client}var o=e("../lib/error"),i=e("../lib/analytics"),a=e("../lib/deferred"),s=e("../errors"),p=e("./errors");r.prototype.decoratePaymentRequest=function(e){var t=this._client.getConfiguration().gatewayConfiguration.applePay;return e.countryCode||(e.countryCode=t.countryCode),e.currencyCode||(e.currencyCode=t.currencyCode),e.merchantCapabilities||(e.merchantCapabilities=t.merchantCapabilities),e.supportedNetworks||(e.supportedNetworks=t.supportedNetworks.map(function(e){return"mastercard"===e?"masterCard":e})),e},r.prototype.performValidation=function(e,t){var r;if("function"!=typeof t)throw new o({type:s.CALLBACK_REQUIRED.type,code:s.CALLBACK_REQUIRED.code,message:"performValidation requires a callback."});return t=a(t),e&&e.validationURL?(r={validationUrl:e.validationURL,domainName:e.domainName||n.location.hostname,merchantIdentifier:e.merchantIdentifier||this._client.getConfiguration().gatewayConfiguration.applePay.merchantIdentifier},null!=e.displayName&&(r.displayName=e.displayName),void this._client.request({method:"post",endpoint:"apple_pay_web/sessions",data:{_meta:{source:"apple-pay"},applePayWebSession:r}},function(e,n){e?(t(new o({type:p.APPLE_PAY_MERCHANT_VALIDATION.type,code:p.APPLE_PAY_MERCHANT_VALIDATION.code,message:p.APPLE_PAY_MERCHANT_VALIDATION.message,details:{originalError:e}})),i.sendEvent(this._client,"applepay.performValidation.failed")):(t(null,n),i.sendEvent(this._client,"applepay.performValidation.succeeded"))}.bind(this))):void t(new o(p.APPLE_PAY_VALIDATION_URL_REQUIRED))},r.prototype.tokenize=function(e,t){if("function"!=typeof t)throw new o({type:s.CALLBACK_REQUIRED.type,code:s.CALLBACK_REQUIRED.code,message:"tokenize requires a callback."});return t=a(t),e.token?void this._client.request({method:"post",endpoint:"payment_methods/apple_payment_tokens",data:{_meta:{source:"apple-pay"},applePaymentToken:e.token}},function(e,n){e?(t(new o({type:p.APPLE_PAY_TOKENIZATION.type,code:p.APPLE_PAY_TOKENIZATION.code,message:p.APPLE_PAY_TOKENIZATION.message,details:{originalError:e}})),i.sendEvent(this._client,"applepay.tokenize.failed")):(t(null,n.applePayCards[0]),i.sendEvent(this._client,"applepay.tokenize.succeeded"))}.bind(this)):void t(new o(p.APPLE_PAY_PAYMENT_TOKEN_REQUIRED))},t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":4,"../lib/analytics":6,"../lib/deferred":9,"../lib/error":11,"./errors":2}],2:[function(e,t,n){"use strict";var r=e("../lib/error");t.exports={APPLE_PAY_NOT_ENABLED:{type:r.types.MERCHANT,code:"APPLE_PAY_NOT_ENABLED",message:"Apple Pay is not enabled for this merchant."},APPLE_PAY_VALIDATION_URL_REQUIRED:{type:r.types.MERCHANT,code:"APPLE_PAY_VALIDATION_URL_REQUIRED",message:"performValidation must be called with a validationURL."},APPLE_PAY_MERCHANT_VALIDATION:{type:r.types.NETWORK,code:"APPLE_PAY_MERCHANT_VALIDATION",message:"A network error occurred when validating the Apple Pay merchant."},APPLE_PAY_PAYMENT_TOKEN_REQUIRED:{type:r.types.MERCHANT,code:"APPLE_PAY_PAYMENT_TOKEN_REQUIRED",message:"tokenize must be called with a payment token."},APPLE_PAY_TOKENIZATION:{type:r.types.NETWORK,code:"APPLE_PAY_TOKENIZATION",message:"A network error occurred when processing the Apple Pay payment."}}},{"../lib/error":11}],3:[function(e,t,n){"use strict";function r(e,t){var n;if("function"!=typeof t)throw new o({type:p.CALLBACK_REQUIRED.type,code:p.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return t=s(t),null==e.client?void t(new o({type:p.INSTANTIATION_OPTION_REQUIRED.type,code:p.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating Apple Pay."})):(n=e.client.getConfiguration().analyticsMetadata.sdkVersion,n!==d?void t(new o({type:p.INCOMPATIBLE_VERSIONS.type,code:p.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+n+") and Apple Pay (version "+d+") components must be from the same SDK version."})):e.client.getConfiguration().gatewayConfiguration.applePay?(a.sendEvent(e.client,"web.applepay.initialized"),void t(null,new i(e))):void t(new o(c.APPLE_PAY_NOT_ENABLED)))}var o=e("../lib/error"),i=e("./apple-pay"),a=e("../lib/analytics"),s=e("../lib/deferred"),p=e("../errors"),c=e("./errors"),d="3.0.0";t.exports={create:r,VERSION:d}},{"../errors":4,"../lib/analytics":6,"../lib/deferred":9,"../lib/error":11,"./apple-pay":1,"./errors":2}],4:[function(e,t,n){"use strict";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":11}],5:[function(e,t,n){"use strict";function r(e,t){var n,r=t?i(t):{},s=o(e.authorization).attrs,p=i(e.analyticsMetadata);r.braintreeLibraryVersion=a.BRAINTREE_LIBRARY_VERSION;for(n in r._meta)r._meta.hasOwnProperty(n)&&(p[n]=r._meta[n]);return r._meta=p,s.tokenizationKey?r.tokenizationKey=s.tokenizationKey:r.authorizationFingerprint=s.authorizationFingerprint,r}var o=e("./create-authorization-data"),i=e("./json-clone"),a=e("./constants");t.exports=r},{"./constants":7,"./create-authorization-data":8,"./json-clone":12}],6:[function(e,t,n){"use strict";function r(e){return Math.floor(e/1e3)}function o(e,t,n){var o=e.getConfiguration(),s=e._request,p=r(Date.now()),c=o.gatewayConfiguration.analytics.url,d={analytics:[{kind:t,timestamp:p}]};s({url:c,method:"post",data:a(o,d),timeout:i.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var i=e("./constants"),a=e("./add-metadata");t.exports={sendEvent:o}},{"./add-metadata":5,"./constants":7}],7:[function(e,t,n){"use strict";var r="3.0.0",o="web";t.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:o,BRAINTREE_LIBRARY_VERSION:"braintree/"+o+"/"+r}},{}],8:[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 o(e){var t=e.split("_"),n=t[0],r=t.slice(2).join("_");return{merchantId:r,environment:n}}function i(e){var t,n,i={attrs:{},configUrl:""};return r(e)?(n=o(e),i.attrs.tokenizationKey=e,i.configUrl=s[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(a(e)),i.attrs.authorizationFingerprint=t.authorizationFingerprint,i.configUrl=t.configUrl),i}var a=e("../lib/polyfill").atob,s={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=i},{"../lib/polyfill":13}],9:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],10:[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},{}],11:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":10}],12:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],13:[function(e,t,n){(function(e){"use strict";function n(e){var t,n,r,o,i,a,s,p,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})?$"),d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="";if(!c.test(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");p=0;do o=d.indexOf(e.charAt(p++)),i=d.indexOf(e.charAt(p++)),a=d.indexOf(e.charAt(p++)),s=d.indexOf(e.charAt(p++)),t=(63&o)<<2|i>>4&3,n=(15&i)<<4|a>>2&15,r=(3&a)<<6|63&s,l+=String.fromCharCode(t)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(p<e.length);return l}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:{})},{}]},{},[3])(3)}); |
CHANGELOG | ||
========= | ||
## 3.0.0 | ||
* Add prefix to `BraintreeError` codes to prevent namespace collisions | ||
* PayPal | ||
* Return a `PAYPAL_POPUP_CLOSED` error code when the customer closes the popup | ||
* Return a `PAYPAL_INVALID_PAYMENT_OPTION` error code when PayPal options are invalid | ||
* Fix a bug where some locale codes were not accepted | ||
* Fix bug where JPY could not be used as PayPal currency | ||
* vault flows will automatically vault PayPal accounts if client token was generated with a customer id | ||
* Hosted Fields | ||
* Automatic input formatting disabled for iOS and Android | ||
* Apple Pay | ||
* Use error codes | ||
* Some wrapped errors were inconsistently placed under the `err.details` property; they are now under `err.details.originalError` | ||
* Client | ||
* Errors are now always instances of BraintreeError | ||
* UnionPay | ||
* Add `vault` as an option to `tokenize` which allows cards to be vaulted on tokenization | ||
## 3.0.0-beta.12 | ||
@@ -26,2 +45,3 @@ | ||
* Consistently return `BraintreeError` objects when the PayPal flow is cancelled | ||
* Return error during `create` when using a webview | ||
* UnionPay | ||
@@ -28,0 +48,0 @@ * Add `type` to tokenize payload |
@@ -38,3 +38,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 = {})).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){ | ||
if (!gatewayConfiguration) { | ||
throw new BraintreeError(errors.MISSING_GATEWAY_CONFIGURATION); | ||
throw new BraintreeError(errors.CLIENT_MISSING_GATEWAY_CONFIGURATION); | ||
} | ||
@@ -49,4 +49,4 @@ | ||
throw new BraintreeError({ | ||
type: errors.GATEWAY_CONFIGURATION_INVALID_DOMAIN.type, | ||
code: errors.GATEWAY_CONFIGURATION_INVALID_DOMAIN.code, | ||
type: errors.CLIENT_GATEWAY_CONFIGURATION_INVALID_DOMAIN.type, | ||
code: errors.CLIENT_GATEWAY_CONFIGURATION_INVALID_DOMAIN.code, | ||
message: property + ' property is on an invalid domain.' | ||
@@ -128,4 +128,4 @@ }); | ||
callback(new BraintreeError({ | ||
type: errors.OPTION_REQUIRED.type, | ||
code: errors.OPTION_REQUIRED.code, | ||
type: errors.CLIENT_OPTION_REQUIRED.type, | ||
code: errors.CLIENT_OPTION_REQUIRED.code, | ||
message: optionName + ' is required when making a request.' | ||
@@ -141,3 +141,20 @@ })); | ||
timeout: options.timeout | ||
}, callback); | ||
}, function (err, data, status) { | ||
if (status === -1) { | ||
callback(new BraintreeError(errors.CLIENT_REQUEST_TIMEOUT), null, status); | ||
} else if (status === 429) { | ||
callback(new BraintreeError(errors.CLIENT_RATE_LIMITED), null, status); | ||
} else if (status >= 500) { | ||
callback(new BraintreeError(errors.CLIENT_GATEWAY_NETWORK), null, status); | ||
} else if (status < 200 || status >= 400) { | ||
callback(new BraintreeError({ | ||
type: errors.CLIENT_REQUEST_ERROR.type, | ||
code: errors.CLIENT_REQUEST_ERROR.code, | ||
message: errors.CLIENT_REQUEST_ERROR.message, | ||
details: {originalError: err} | ||
}), null, status); | ||
} else { | ||
callback(null, data, status); | ||
} | ||
}); | ||
}; | ||
@@ -147,3 +164,3 @@ | ||
},{"../lib/add-metadata":14,"../lib/deferred":17,"../lib/error":19,"../lib/is-whitelisted-domain":20,"./errors":2,"./request":8}],2:[function(_dereq_,module,exports){ | ||
},{"../lib/add-metadata":13,"../lib/deferred":16,"../lib/error":18,"../lib/is-whitelisted-domain":19,"./errors":2,"./request":7}],2:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -154,28 +171,43 @@ | ||
module.exports = { | ||
GATEWAY_CONFIGURATION_INVALID_DOMAIN: { | ||
CLIENT_GATEWAY_CONFIGURATION_INVALID_DOMAIN: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'GATEWAY_CONFIGURATION_INVALID_DOMAIN' | ||
code: 'CLIENT_GATEWAY_CONFIGURATION_INVALID_DOMAIN' | ||
}, | ||
OPTION_REQUIRED: { | ||
CLIENT_OPTION_REQUIRED: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'OPTION_REQUIRED' | ||
code: 'CLIENT_OPTION_REQUIRED' | ||
}, | ||
MISSING_GATEWAY_CONFIGURATION: { | ||
CLIENT_MISSING_GATEWAY_CONFIGURATION: { | ||
type: BraintreeError.types.INTERNAL, | ||
code: 'MISSING_GATEWAY_CONFIGURATION', | ||
code: 'CLIENT_MISSING_GATEWAY_CONFIGURATION', | ||
message: 'Missing gatewayConfiguration.' | ||
}, | ||
INVALID_AUTHORIZATION: { | ||
CLIENT_INVALID_AUTHORIZATION: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'INVALID_AUTHORIZATION', | ||
code: 'CLIENT_INVALID_AUTHORIZATION', | ||
message: 'Authorization is invalid. Make sure your client token or tokenization key is valid.' | ||
}, | ||
GATEWAY_NETWORK: { | ||
CLIENT_GATEWAY_NETWORK: { | ||
type: BraintreeError.types.NETWORK, | ||
code: 'GATEWAY_NETWORK', | ||
code: 'CLIENT_GATEWAY_NETWORK', | ||
message: 'Cannot contact the gateway at this time.' | ||
}, | ||
CLIENT_REQUEST_TIMEOUT: { | ||
type: BraintreeError.types.NETWORK, | ||
code: 'CLIENT_REQUEST_TIMEOUT', | ||
message: 'Request timed out waiting for a reply.' | ||
}, | ||
CLIENT_REQUEST_ERROR: { | ||
type: BraintreeError.types.NETWORK, | ||
code: 'CLIENT_REQUEST_ERROR', | ||
message: 'There was a problem with your request.' | ||
}, | ||
CLIENT_RATE_LIMITED: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'CLIENT_RATE_LIMITED', | ||
message: 'You are being rate-limited; please try again in a few minutes.' | ||
} | ||
}; | ||
},{"../lib/error":19}],3:[function(_dereq_,module,exports){ | ||
},{"../lib/error":18}],3:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -207,3 +239,3 @@ 'use strict'; | ||
} catch (err) { | ||
callback(new BraintreeError(errors.INVALID_AUTHORIZATION)); | ||
callback(new BraintreeError(errors.CLIENT_INVALID_AUTHORIZATION)); | ||
return; | ||
@@ -224,6 +256,8 @@ } | ||
callback(new BraintreeError({ | ||
type: errors.GATEWAY_NETWORK.type, | ||
code: errors.GATEWAY_NETWORK.code, | ||
message: errors.GATEWAY_NETWORK.message, | ||
details: err | ||
type: errors.CLIENT_GATEWAY_NETWORK.type, | ||
code: errors.CLIENT_GATEWAY_NETWORK.code, | ||
message: errors.CLIENT_GATEWAY_NETWORK.message, | ||
details: { | ||
originalError: err | ||
} | ||
})); | ||
@@ -248,3 +282,3 @@ return; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"../lib/constants":15,"../lib/create-authorization-data":16,"../lib/error":19,"../lib/uuid":25,"./errors":2,"./request":8}],4:[function(_dereq_,module,exports){ | ||
},{"../lib/constants":14,"../lib/create-authorization-data":15,"../lib/error":18,"../lib/uuid":24,"./errors":2,"./request":7}],4:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -255,3 +289,3 @@ | ||
var getConfiguration = _dereq_('./get-configuration').getConfiguration; | ||
var packageVersion = "3.0.0-beta.12"; | ||
var packageVersion = "3.0.0"; | ||
var deferred = _dereq_('../lib/deferred'); | ||
@@ -327,3 +361,3 @@ var sharedErrors = _dereq_('../errors'); | ||
},{"../errors":13,"../lib/deferred":17,"../lib/error":19,"./client":1,"./get-configuration":3}],5:[function(_dereq_,module,exports){ | ||
},{"../errors":12,"../lib/deferred":16,"../lib/error":18,"./client":1,"./get-configuration":3}],5:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -333,6 +367,4 @@ 'use strict'; | ||
var querystring = _dereq_('../../lib/querystring'); | ||
var once = _dereq_('../../lib/once'); | ||
var prepBody = _dereq_('./prep-body'); | ||
var parseBody = _dereq_('./parse-body'); | ||
var constants = _dereq_('./constants'); | ||
var isXHRAvailable = global.XMLHttpRequest && 'withCredentials' in new global.XMLHttpRequest(); | ||
@@ -346,8 +378,8 @@ | ||
var status, resBody; | ||
var method = (options.method || 'GET').toUpperCase(); | ||
var method = options.method; | ||
var url = options.url; | ||
var body = options.data || {}; | ||
var timeout = options.timeout == null ? 60000 : options.timeout; | ||
var body = options.data; | ||
var timeout = options.timeout; | ||
var req = getRequestObject(); | ||
var callback = once(cb || Function.prototype); | ||
var callback = cb; | ||
@@ -366,8 +398,4 @@ if (method === 'GET') { | ||
if (status === 429) { | ||
callback(constants.errors.RATE_LIMIT_ERROR, null, 429); | ||
} else if (status >= 400) { | ||
callback(resBody || constants.errors.UNKNOWN_ERROR, null, status); | ||
} else if (status <= 0) { | ||
callback(resBody || constants.errors.UNKNOWN_ERROR, null, 500); | ||
if (status >= 400 || status < 200) { | ||
callback(resBody || 'error', null, status || 500); | ||
} else { | ||
@@ -383,3 +411,3 @@ callback(null, resBody, status); | ||
req.onerror = function () { | ||
callback(constants.errors.UNKNOWN_ERROR, null, req.status); | ||
callback('error', null, req.status); | ||
}; | ||
@@ -391,3 +419,3 @@ | ||
req.ontimeout = function () { | ||
callback(constants.errors.TIMEOUT_ERROR, null, 500); | ||
callback('timeout', null, -1); | ||
}; | ||
@@ -413,15 +441,3 @@ } | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"../../lib/once":22,"../../lib/querystring":24,"./constants":6,"./parse-body":11,"./prep-body":12}],6:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
module.exports = { | ||
errors: { | ||
UNKNOWN_ERROR: 'Unknown error.', | ||
TIMEOUT_ERROR: 'Request timed out waiting for a reply.', | ||
INVALID_TIMEOUT: 'Timeout must be a number.', | ||
RATE_LIMIT_ERROR: 'You are being rate-limited; please try again in a few minutes.' | ||
} | ||
}; | ||
},{}],7:[function(_dereq_,module,exports){ | ||
},{"../../lib/querystring":23,"./parse-body":10,"./prep-body":11}],6:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -435,6 +451,7 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],8:[function(_dereq_,module,exports){ | ||
},{}],7:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var ajaxIsAvaliable; | ||
var once = _dereq_('../../lib/once'); | ||
var JSONPDriver = _dereq_('./jsonp-driver'); | ||
@@ -453,9 +470,16 @@ var AJAXDriver = _dereq_('./ajax-driver'); | ||
module.exports = function () { | ||
var request = isAjaxAvailable() ? AJAXDriver.request : JSONPDriver.request; | ||
module.exports = function (options, cb) { | ||
cb = once(cb || Function.prototype); | ||
options.method = (options.method || 'GET').toUpperCase(); | ||
options.timeout = options.timeout == null ? 60000 : options.timeout; | ||
options.data = options.data || {}; | ||
request.apply(null, arguments); | ||
if (isAjaxAvailable()) { | ||
AJAXDriver.request(options, cb); | ||
} else { | ||
JSONPDriver.request(options, cb); | ||
} | ||
}; | ||
},{"./ajax-driver":5,"./get-user-agent":7,"./is-http":9,"./jsonp-driver":10}],9:[function(_dereq_,module,exports){ | ||
},{"../../lib/once":21,"./ajax-driver":5,"./get-user-agent":6,"./is-http":8,"./jsonp-driver":9}],8:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -469,3 +493,3 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],10:[function(_dereq_,module,exports){ | ||
},{}],9:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -475,3 +499,2 @@ 'use strict'; | ||
var head; | ||
var constants = _dereq_('./constants'); | ||
var uuid = _dereq_('../../lib/uuid'); | ||
@@ -481,4 +504,2 @@ var querystring = _dereq_('../../lib/querystring'); | ||
function _noop() {} | ||
function _removeScript(script) { | ||
@@ -497,3 +518,3 @@ if (script && script.parentNode) { | ||
script.onerror = function () { | ||
global[callbackName]({message: constants.errors.UNKNOWN_ERROR, status: 500}); | ||
global[callbackName]({message: 'error', status: 500}); | ||
}; | ||
@@ -526,4 +547,4 @@ | ||
global[callbackName]({ | ||
error: constants.errors.TIMEOUT_ERROR, | ||
status: 500 | ||
error: 'timeout', | ||
status: -1 | ||
}); | ||
@@ -538,4 +559,2 @@ | ||
function _setupGlobalCallback(script, callback, callbackName) { | ||
callback = callback || _noop; | ||
global[callbackName] = function (response) { | ||
@@ -548,3 +567,3 @@ var status = response.status || 500; | ||
if (status >= 400) { | ||
if (status >= 400 || status < 200) { | ||
err = response; | ||
@@ -568,4 +587,4 @@ } else { | ||
var attrs = options.data; | ||
var method = (options.method || 'GET').toUpperCase(); | ||
var timeout = options.timeout == null ? 60000 : options.timeout; | ||
var method = options.method; | ||
var timeout = options.timeout; | ||
@@ -594,3 +613,3 @@ url = querystring.queryify(url, attrs); | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"../../lib/querystring":24,"../../lib/uuid":25,"./constants":6}],11:[function(_dereq_,module,exports){ | ||
},{"../../lib/querystring":23,"../../lib/uuid":24}],10:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -606,3 +625,3 @@ | ||
},{}],12:[function(_dereq_,module,exports){ | ||
},{}],11:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -622,3 +641,3 @@ | ||
},{}],13:[function(_dereq_,module,exports){ | ||
},{}],12:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -647,3 +666,3 @@ | ||
},{"./lib/error":19}],14:[function(_dereq_,module,exports){ | ||
},{"./lib/error":18}],13:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -682,6 +701,6 @@ | ||
},{"./constants":15,"./create-authorization-data":16,"./json-clone":21}],15:[function(_dereq_,module,exports){ | ||
},{"./constants":14,"./create-authorization-data":15,"./json-clone":20}],14:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
var PLATFORM = 'web'; | ||
@@ -699,3 +718,3 @@ | ||
},{}],16:[function(_dereq_,module,exports){ | ||
},{}],15:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -749,3 +768,3 @@ | ||
},{"../lib/polyfill":23}],17:[function(_dereq_,module,exports){ | ||
},{"../lib/polyfill":22}],16:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -764,3 +783,3 @@ | ||
},{}],18:[function(_dereq_,module,exports){ | ||
},{}],17:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -779,3 +798,3 @@ | ||
},{}],19:[function(_dereq_,module,exports){ | ||
},{}],18:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -857,3 +876,3 @@ | ||
},{"./enumerate":18}],20:[function(_dereq_,module,exports){ | ||
},{"./enumerate":17}],19:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -869,4 +888,10 @@ | ||
/* eslint-enable no-undef,block-scoped-var */ | ||
function stripSubdomains(domain) { | ||
return domain.split('.').slice(-2).join('.'); | ||
} | ||
function isWhitelistedDomain(url) { | ||
var pieces, topLevelDomain; | ||
var mainDomain; | ||
@@ -881,6 +906,5 @@ url = url.toLowerCase(); | ||
parser.href = url; | ||
pieces = parser.hostname.split('.'); | ||
topLevelDomain = pieces.slice(-2).join('.'); | ||
mainDomain = stripSubdomains(parser.hostname); | ||
return legalHosts.hasOwnProperty(topLevelDomain); | ||
return legalHosts.hasOwnProperty(mainDomain); | ||
} | ||
@@ -890,3 +914,3 @@ | ||
},{}],21:[function(_dereq_,module,exports){ | ||
},{}],20:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -898,3 +922,3 @@ | ||
},{}],22:[function(_dereq_,module,exports){ | ||
},{}],21:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -915,3 +939,3 @@ | ||
},{}],23:[function(_dereq_,module,exports){ | ||
},{}],22:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -955,3 +979,3 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],24:[function(_dereq_,module,exports){ | ||
},{}],23:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -1047,3 +1071,3 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],25:[function(_dereq_,module,exports){ | ||
},{}],24:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1050,0 +1074,0 @@ |
@@ -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={})).client=e()}}(function(){return function e(t,n,r){function o(a,s){if(!n[a]){if(!t[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:{}};t[a][0].call(f.exports,function(e){var n=t[a][1][e];return o(n?n:e)},f,f.exports,e,t,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(e,t,n){"use strict";function r(e){var t,n;if(e=e||{},t=JSON.stringify(e),n=e.gatewayConfiguration,!n)throw new a(c.MISSING_GATEWAY_CONFIGURATION);["assetsUrl","clientApiUrl","configUrl"].forEach(function(e){if(e in n&&!i(n[e]))throw new a({type:c.GATEWAY_CONFIGURATION_INVALID_DOMAIN.type,code:c.GATEWAY_CONFIGURATION_INVALID_DOMAIN.code,message:e+" property is on an invalid domain."})}),this.getConfiguration=function(){return JSON.parse(t)},this._request=o,this._baseUrl=e.gatewayConfiguration.clientApiUrl+"/v1/",this._configuration=this.getConfiguration(),this.toJSON=this.getConfiguration}var o=e("./request"),i=e("../lib/is-whitelisted-domain"),a=e("../lib/error"),s=e("../lib/add-metadata"),u=e("../lib/deferred"),c=e("./errors");r.prototype.request=function(e,t){var n;return e.method?e.endpoint||(n="options.endpoint"):n="options.method",n?(t=u(t),void t(new a({type:c.OPTION_REQUIRED.type,code:c.OPTION_REQUIRED.code,message:n+" is required when making a request."}))):void this._request({url:this._baseUrl+e.endpoint,method:e.method,data:s(this._configuration,e.data),timeout:e.timeout},t)},t.exports=r},{"../lib/add-metadata":14,"../lib/deferred":17,"../lib/error":19,"../lib/is-whitelisted-domain":20,"./errors":2,"./request":8}],2:[function(e,t,n){"use strict";var r=e("../lib/error");t.exports={GATEWAY_CONFIGURATION_INVALID_DOMAIN:{type:r.types.MERCHANT,code:"GATEWAY_CONFIGURATION_INVALID_DOMAIN"},OPTION_REQUIRED:{type:r.types.MERCHANT,code:"OPTION_REQUIRED"},MISSING_GATEWAY_CONFIGURATION:{type:r.types.INTERNAL,code:"MISSING_GATEWAY_CONFIGURATION",message:"Missing gatewayConfiguration."},INVALID_AUTHORIZATION:{type:r.types.MERCHANT,code:"INVALID_AUTHORIZATION",message:"Authorization is invalid. Make sure your client token or tokenization key is valid."},GATEWAY_NETWORK:{type:r.types.NETWORK,code:"GATEWAY_NETWORK",message:"Cannot contact the gateway at this time."}}},{"../lib/error":19}],3:[function(e,t,n){(function(n){"use strict";function r(e,t){var r,f,l,d,p=a(),y={merchantAppId:n.location.host,platform:s.PLATFORM,sdkVersion:s.VERSION,source:s.SOURCE,integration:s.INTEGRATION,integrationType:s.INTEGRATION,sessionId:p};try{f=u(e.authorization)}catch(R){return void t(new o(c.INVALID_AUTHORIZATION))}l=f.attrs,d=f.configUrl,l._meta=y,l.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION,i({url:d,method:"GET",data:l},function(n,i){return n?void t(new o({type:c.GATEWAY_NETWORK.type,code:c.GATEWAY_NETWORK.code,message:c.GATEWAY_NETWORK.message,details:n})):(r={authorization:e.authorization,analyticsMetadata:y,gatewayConfiguration:i},void t(null,r))})}var o=e("../lib/error"),i=e("./request"),a=e("../lib/uuid"),s=e("../lib/constants"),u=e("../lib/create-authorization-data"),c=e("./errors");t.exports={getConfiguration:r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../lib/constants":15,"../lib/create-authorization-data":16,"../lib/error":19,"../lib/uuid":25,"./errors":2,"./request":8}],4:[function(e,t,n){"use strict";function r(e,t){if("function"!=typeof t)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return t=u(t),e.authorization?void a(e,function(e,n){var r;if(e)return void t(e);try{r=new i(n)}catch(o){return void t(o)}t(null,r)}):void t(new o({type:c.INSTANTIATION_OPTION_REQUIRED.type,code:c.INSTANTIATION_OPTION_REQUIRED.code,message:"options.authorization is required when instantiating a client."}))}var o=e("../lib/error"),i=e("./client"),a=e("./get-configuration").getConfiguration,s="3.0.0-beta.12",u=e("../lib/deferred"),c=e("../errors");t.exports={create:r,VERSION:s}},{"../errors":13,"../lib/deferred":17,"../lib/error":19,"./client":1,"./get-configuration":3}],5:[function(e,t,n){(function(n){"use strict";function r(){return f?new XMLHttpRequest:new XDomainRequest}function o(e,t){var n,o,l=(e.method||"GET").toUpperCase(),d=e.url,p=e.data||{},y=null==e.timeout?6e4:e.timeout,R=r(),N=a(t||Function.prototype);"GET"===l&&(d=i.queryify(d,p),p=null),f?R.onreadystatechange=function(){4===R.readyState&&(n=R.status,o=u(R.responseText),429===n?N(c.errors.RATE_LIMIT_ERROR,null,429):n>=400?N(o||c.errors.UNKNOWN_ERROR,null,n):0>=n?N(o||c.errors.UNKNOWN_ERROR,null,500):N(null,o,n))}:(R.onload=function(){N(null,u(R.responseText),R.status)},R.onerror=function(){N(c.errors.UNKNOWN_ERROR,null,R.status)},R.onprogress=function(){},R.ontimeout=function(){N(c.errors.TIMEOUT_ERROR,null,500)}),R.open(l,d,!0),R.timeout=y,f&&"POST"===l&&R.setRequestHeader("Content-Type","application/json");try{R.send(s(l,p))}catch(I){}}var i=e("../../lib/querystring"),a=e("../../lib/once"),s=e("./prep-body"),u=e("./parse-body"),c=e("./constants"),f=n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest;t.exports={request:o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/once":22,"../../lib/querystring":24,"./constants":6,"./parse-body":11,"./prep-body":12}],6:[function(e,t,n){"use strict";t.exports={errors:{UNKNOWN_ERROR:"Unknown error.",TIMEOUT_ERROR:"Request timed out waiting for a reply.",INVALID_TIMEOUT:"Timeout must be a number.",RATE_LIMIT_ERROR:"You are being rate-limited; please try again in a few minutes."}}},{}],7:[function(e,t,n){(function(e){"use strict";t.exports=function(){return e.navigator.userAgent}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,t,n){"use strict";function r(){return null==o&&(o=!(u()&&/MSIE\s(8|9)/.test(s()))),o}var o,i=e("./jsonp-driver"),a=e("./ajax-driver"),s=e("./get-user-agent"),u=e("./is-http");t.exports=function(){var e=r()?a.request:i.request;e.apply(null,arguments)}},{"./ajax-driver":5,"./get-user-agent":7,"./is-http":9,"./jsonp-driver":10}],9:[function(e,t,n){(function(e){"use strict";t.exports=function(){return"http:"===e.location.protocol}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(e,t,n){(function(n){"use strict";function r(){}function o(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function i(e,t){var r=document.createElement("script"),o=!1;return r.src=e,r.async=!0,r.onerror=function(){n[t]({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(e){try{delete n[e]}catch(t){n[e]=null}}function s(e,t){y[t]=setTimeout(function(){y[t]=null,n[t]({error:l.errors.TIMEOUT_ERROR,status:500}),n[t]=function(){a(t)}},e)}function u(e,t,i){t=t||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(e),clearTimeout(y[i]),t(s,u,r)}}function c(e,t){var n,r="callback_json_"+d().replace(/-/g,""),o=e.url,a=e.data,c=(e.method||"GET").toUpperCase(),l=null==e.timeout?6e4:e.timeout;o=p.queryify(o,a),o=p.queryify(o,{_method:c,callback:r}),n=i(o,r),u(n,t,r),s(l,r),f||(f=document.getElementsByTagName("head")[0]),f.appendChild(n)}var f,l=e("./constants"),d=e("../../lib/uuid"),p=e("../../lib/querystring"),y={};t.exports={request:c}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/querystring":24,"../../lib/uuid":25,"./constants":6}],11:[function(e,t,n){"use strict";t.exports=function(e){try{e=JSON.parse(e)}catch(t){}return e}},{}],12:[function(e,t,n){"use strict";t.exports=function(e,t){if("string"!=typeof e)throw new Error("Method must be a string");return"get"!==e.toLowerCase()&&null!=t&&(t="string"==typeof t?t:JSON.stringify(t)),t}},{}],13:[function(e,t,n){"use strict";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":19}],14:[function(e,t,n){"use strict";function r(e,t){var n,r=t?i(t):{},s=o(e.authorization).attrs,u=i(e.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=e("./create-authorization-data"),i=e("./json-clone"),a=e("./constants");t.exports=r},{"./constants":15,"./create-authorization-data":16,"./json-clone":21}],15:[function(e,t,n){"use strict";var r="3.0.0-beta.12",o="web";t.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:o,BRAINTREE_LIBRARY_VERSION:"braintree/"+o+"/"+r}},{}],16:[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 o(e){var t=e.split("_"),n=t[0],r=t.slice(2).join("_");return{merchantId:r,environment:n}}function i(e){var t,n,i={attrs:{},configUrl:""};return r(e)?(n=o(e),i.attrs.tokenizationKey=e,i.configUrl=s[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(a(e)),i.attrs.authorizationFingerprint=t.authorizationFingerprint,i.configUrl=t.configUrl),i}var a=e("../lib/polyfill").atob,s={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=i},{"../lib/polyfill":23}],17:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],18:[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},{}],19:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":18}],20:[function(e,t,n){"use strict";function r(e){var t,n;return e=e.toLowerCase(),/^https:/.test(e)?(o=o||document.createElement("a"),o.href=e,t=o.hostname.split("."),n=t.slice(-2).join("."),i.hasOwnProperty(n)):!1}var o,i={"paypal.com":1,"braintreepayments.com":1,"braintreegateway.com":1,localhost:1};t.exports=r},{}],21:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],22:[function(e,t,n){"use strict";function r(e){var t=!1;return function(){t||(t=!0,e.apply(null,arguments))}}t.exports=r},{}],23:[function(e,t,n){(function(e){"use strict";function n(e){var t,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(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");u=0;do o=f.indexOf(e.charAt(u++)),i=f.indexOf(e.charAt(u++)),a=f.indexOf(e.charAt(u++)),s=f.indexOf(e.charAt(u++)),t=(63&o)<<2|i>>4&3,n=(15&i)<<4|a>>2&15,r=(3&a)<<6|63&s,l+=String.fromCharCode(t)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(u<e.length);return l}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:{})},{}],24:[function(e,t,n){(function(e){"use strict";function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function r(e){return e&&"object"==typeof e&&"number"==typeof e.length&&"[object Array]"===Object.prototype.toString.call(e)||!1}function o(t){var n,r;return t=t||e.location.href,/\?/.test(t)?(n=t.replace(/#.*$/,"").replace(/^.*\?/,"").split("&"),r=n.reduce(function(e,t){var n=t.split("="),r=decodeURIComponent(n[0]),o=decodeURIComponent(n[1]);return e[r]=o,e},{})):{}}function i(e,t){var n,o,a,s=[];for(a in e)e.hasOwnProperty(a)&&(o=e[a],n=t?r(e)?t+"[]":t+"["+a+"]":a,"object"==typeof o?s.push(i(o,n)):s.push(encodeURIComponent(n)+"="+encodeURIComponent(o)));return s.join("&")}function a(e,t){return e=e||"",null!=t&&"object"==typeof t&&n(t)&&(e+=-1===e.indexOf("?")?"?":"",e+=-1!==e.indexOf("=")?"&":"",e+=i(t)),e}t.exports={parse:o,stringify:i,queryify:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],25:[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},{}]},{},[4])(4)}); | ||
!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={})).client=e()}}(function(){return function e(t,n,r){function o(a,s){if(!n[a]){if(!t[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 l=n[a]={exports:{}};t[a][0].call(l.exports,function(e){var n=t[a][1][e];return o(n?n:e)},l,l.exports,e,t,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(e,t,n){"use strict";function r(e){var t,n;if(e=e||{},t=JSON.stringify(e),n=e.gatewayConfiguration,!n)throw new a(c.CLIENT_MISSING_GATEWAY_CONFIGURATION);["assetsUrl","clientApiUrl","configUrl"].forEach(function(e){if(e in n&&!i(n[e]))throw new a({type:c.CLIENT_GATEWAY_CONFIGURATION_INVALID_DOMAIN.type,code:c.CLIENT_GATEWAY_CONFIGURATION_INVALID_DOMAIN.code,message:e+" property is on an invalid domain."})}),this.getConfiguration=function(){return JSON.parse(t)},this._request=o,this._baseUrl=e.gatewayConfiguration.clientApiUrl+"/v1/",this._configuration=this.getConfiguration(),this.toJSON=this.getConfiguration}var o=e("./request"),i=e("../lib/is-whitelisted-domain"),a=e("../lib/error"),s=e("../lib/add-metadata"),u=e("../lib/deferred"),c=e("./errors");r.prototype.request=function(e,t){var n;return e.method?e.endpoint||(n="options.endpoint"):n="options.method",n?(t=u(t),void t(new a({type:c.CLIENT_OPTION_REQUIRED.type,code:c.CLIENT_OPTION_REQUIRED.code,message:n+" is required when making a request."}))):void this._request({url:this._baseUrl+e.endpoint,method:e.method,data:s(this._configuration,e.data),timeout:e.timeout},function(e,n,r){-1===r?t(new a(c.CLIENT_REQUEST_TIMEOUT),null,r):429===r?t(new a(c.CLIENT_RATE_LIMITED),null,r):r>=500?t(new a(c.CLIENT_GATEWAY_NETWORK),null,r):200>r||r>=400?t(new a({type:c.CLIENT_REQUEST_ERROR.type,code:c.CLIENT_REQUEST_ERROR.code,message:c.CLIENT_REQUEST_ERROR.message,details:{originalError:e}}),null,r):t(null,n,r)})},t.exports=r},{"../lib/add-metadata":13,"../lib/deferred":16,"../lib/error":18,"../lib/is-whitelisted-domain":19,"./errors":2,"./request":7}],2:[function(e,t,n){"use strict";var r=e("../lib/error");t.exports={CLIENT_GATEWAY_CONFIGURATION_INVALID_DOMAIN:{type:r.types.MERCHANT,code:"CLIENT_GATEWAY_CONFIGURATION_INVALID_DOMAIN"},CLIENT_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"CLIENT_OPTION_REQUIRED"},CLIENT_MISSING_GATEWAY_CONFIGURATION:{type:r.types.INTERNAL,code:"CLIENT_MISSING_GATEWAY_CONFIGURATION",message:"Missing gatewayConfiguration."},CLIENT_INVALID_AUTHORIZATION:{type:r.types.MERCHANT,code:"CLIENT_INVALID_AUTHORIZATION",message:"Authorization is invalid. Make sure your client token or tokenization key is valid."},CLIENT_GATEWAY_NETWORK:{type:r.types.NETWORK,code:"CLIENT_GATEWAY_NETWORK",message:"Cannot contact the gateway at this time."},CLIENT_REQUEST_TIMEOUT:{type:r.types.NETWORK,code:"CLIENT_REQUEST_TIMEOUT",message:"Request timed out waiting for a reply."},CLIENT_REQUEST_ERROR:{type:r.types.NETWORK,code:"CLIENT_REQUEST_ERROR",message:"There was a problem with your request."},CLIENT_RATE_LIMITED:{type:r.types.MERCHANT,code:"CLIENT_RATE_LIMITED",message:"You are being rate-limited; please try again in a few minutes."}}},{"../lib/error":18}],3:[function(e,t,n){(function(n){"use strict";function r(e,t){var r,l,f,d,p=a(),E={merchantAppId:n.location.host,platform:s.PLATFORM,sdkVersion:s.VERSION,source:s.SOURCE,integration:s.INTEGRATION,integrationType:s.INTEGRATION,sessionId:p};try{l=u(e.authorization)}catch(T){return void t(new o(c.CLIENT_INVALID_AUTHORIZATION))}f=l.attrs,d=l.configUrl,f._meta=E,f.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION,i({url:d,method:"GET",data:f},function(n,i){return n?void t(new o({type:c.CLIENT_GATEWAY_NETWORK.type,code:c.CLIENT_GATEWAY_NETWORK.code,message:c.CLIENT_GATEWAY_NETWORK.message,details:{originalError:n}})):(r={authorization:e.authorization,analyticsMetadata:E,gatewayConfiguration:i},void t(null,r))})}var o=e("../lib/error"),i=e("./request"),a=e("../lib/uuid"),s=e("../lib/constants"),u=e("../lib/create-authorization-data"),c=e("./errors");t.exports={getConfiguration:r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../lib/constants":14,"../lib/create-authorization-data":15,"../lib/error":18,"../lib/uuid":24,"./errors":2,"./request":7}],4:[function(e,t,n){"use strict";function r(e,t){if("function"!=typeof t)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return t=u(t),e.authorization?void a(e,function(e,n){var r;if(e)return void t(e);try{r=new i(n)}catch(o){return void t(o)}t(null,r)}):void t(new o({type:c.INSTANTIATION_OPTION_REQUIRED.type,code:c.INSTANTIATION_OPTION_REQUIRED.code,message:"options.authorization is required when instantiating a client."}))}var o=e("../lib/error"),i=e("./client"),a=e("./get-configuration").getConfiguration,s="3.0.0",u=e("../lib/deferred"),c=e("../errors");t.exports={create:r,VERSION:s}},{"../errors":12,"../lib/deferred":16,"../lib/error":18,"./client":1,"./get-configuration":3}],5:[function(e,t,n){(function(n){"use strict";function r(){return u?new XMLHttpRequest:new XDomainRequest}function o(e,t){var n,o,c=e.method,l=e.url,f=e.data,d=e.timeout,p=r(),E=t;"GET"===c&&(l=i.queryify(l,f),f=null),u?p.onreadystatechange=function(){4===p.readyState&&(n=p.status,o=s(p.responseText),n>=400||200>n?E(o||"error",null,n||500):E(null,o,n))}:(p.onload=function(){E(null,s(p.responseText),p.status)},p.onerror=function(){E("error",null,p.status)},p.onprogress=function(){},p.ontimeout=function(){E("timeout",null,-1)}),p.open(c,l,!0),p.timeout=d,u&&"POST"===c&&p.setRequestHeader("Content-Type","application/json");try{p.send(a(c,f))}catch(T){}}var i=e("../../lib/querystring"),a=e("./prep-body"),s=e("./parse-body"),u=n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest;t.exports={request:o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/querystring":23,"./parse-body":10,"./prep-body":11}],6:[function(e,t,n){(function(e){"use strict";t.exports=function(){return e.navigator.userAgent}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],7:[function(e,t,n){"use strict";function r(){return null==o&&(o=!(c()&&/MSIE\s(8|9)/.test(u()))),o}var o,i=e("../../lib/once"),a=e("./jsonp-driver"),s=e("./ajax-driver"),u=e("./get-user-agent"),c=e("./is-http");t.exports=function(e,t){t=i(t||Function.prototype),e.method=(e.method||"GET").toUpperCase(),e.timeout=null==e.timeout?6e4:e.timeout,e.data=e.data||{},r()?s.request(e,t):a.request(e,t)}},{"../../lib/once":21,"./ajax-driver":5,"./get-user-agent":6,"./is-http":8,"./jsonp-driver":9}],8:[function(e,t,n){(function(e){"use strict";t.exports=function(){return"http:"===e.location.protocol}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,t,n){(function(n){"use strict";function r(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function o(e,t){var r=document.createElement("script"),o=!1;return r.src=e,r.async=!0,r.onerror=function(){n[t]({message:"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 i(e){try{delete n[e]}catch(t){n[e]=null}}function a(e,t){d[t]=setTimeout(function(){d[t]=null,n[t]({error:"timeout",status:-1}),n[t]=function(){i(t)}},e)}function s(e,t,o){n[o]=function(n){var a=n.status||500,s=null,u=null;delete n.status,a>=400||200>a?s=n:u=n,i(o),r(e),clearTimeout(d[o]),t(s,u,a)}}function u(e,t){var n,r="callback_json_"+l().replace(/-/g,""),i=e.url,u=e.data,d=e.method,p=e.timeout;i=f.queryify(i,u),i=f.queryify(i,{_method:d,callback:r}),n=o(i,r),s(n,t,r),a(p,r),c||(c=document.getElementsByTagName("head")[0]),c.appendChild(n)}var c,l=e("../../lib/uuid"),f=e("../../lib/querystring"),d={};t.exports={request:u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/querystring":23,"../../lib/uuid":24}],10:[function(e,t,n){"use strict";t.exports=function(e){try{e=JSON.parse(e)}catch(t){}return e}},{}],11:[function(e,t,n){"use strict";t.exports=function(e,t){if("string"!=typeof e)throw new Error("Method must be a string");return"get"!==e.toLowerCase()&&null!=t&&(t="string"==typeof t?t:JSON.stringify(t)),t}},{}],12:[function(e,t,n){"use strict";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":18}],13:[function(e,t,n){"use strict";function r(e,t){var n,r=t?i(t):{},s=o(e.authorization).attrs,u=i(e.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=e("./create-authorization-data"),i=e("./json-clone"),a=e("./constants");t.exports=r},{"./constants":14,"./create-authorization-data":15,"./json-clone":20}],14:[function(e,t,n){"use strict";var r="3.0.0",o="web";t.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:r,INTEGRATION:"custom",SOURCE:"client",PLATFORM:o,BRAINTREE_LIBRARY_VERSION:"braintree/"+o+"/"+r}},{}],15:[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 o(e){var t=e.split("_"),n=t[0],r=t.slice(2).join("_");return{merchantId:r,environment:n}}function i(e){var t,n,i={attrs:{},configUrl:""};return r(e)?(n=o(e),i.attrs.tokenizationKey=e,i.configUrl=s[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(a(e)),i.attrs.authorizationFingerprint=t.authorizationFingerprint,i.configUrl=t.configUrl),i}var a=e("../lib/polyfill").atob,s={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=i},{"../lib/polyfill":22}],16:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],17:[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},{}],18:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":17}],19:[function(e,t,n){"use strict";function r(e){return e.split(".").slice(-2).join(".")}function o(e){var t;return e=e.toLowerCase(),/^https:/.test(e)?(i=i||document.createElement("a"),i.href=e,t=r(i.hostname),a.hasOwnProperty(t)):!1}var i,a={"paypal.com":1,"braintreepayments.com":1,"braintreegateway.com":1,localhost:1};t.exports=o},{}],20:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],21:[function(e,t,n){"use strict";function r(e){var t=!1;return function(){t||(t=!0,e.apply(null,arguments))}}t.exports=r},{}],22:[function(e,t,n){(function(e){"use strict";function n(e){var t,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})?$"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="";if(!c.test(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");u=0;do o=l.indexOf(e.charAt(u++)),i=l.indexOf(e.charAt(u++)),a=l.indexOf(e.charAt(u++)),s=l.indexOf(e.charAt(u++)),t=(63&o)<<2|i>>4&3,n=(15&i)<<4|a>>2&15,r=(3&a)<<6|63&s,f+=String.fromCharCode(t)+(n?String.fromCharCode(n):"")+(r?String.fromCharCode(r):"");while(u<e.length);return f}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:{})},{}],23:[function(e,t,n){(function(e){"use strict";function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function r(e){return e&&"object"==typeof e&&"number"==typeof e.length&&"[object Array]"===Object.prototype.toString.call(e)||!1}function o(t){var n,r;return t=t||e.location.href,/\?/.test(t)?(n=t.replace(/#.*$/,"").replace(/^.*\?/,"").split("&"),r=n.reduce(function(e,t){var n=t.split("="),r=decodeURIComponent(n[0]),o=decodeURIComponent(n[1]);return e[r]=o,e},{})):{}}function i(e,t){var n,o,a,s=[];for(a in e)e.hasOwnProperty(a)&&(o=e[a],n=t?r(e)?t+"[]":t+"["+a+"]":a,"object"==typeof o?s.push(i(o,n)):s.push(encodeURIComponent(n)+"="+encodeURIComponent(o)));return s.join("&")}function a(e,t){return e=e||"",null!=t&&"object"==typeof t&&n(t)&&(e+=-1===e.indexOf("?")?"?":"",e+=-1!==e.indexOf("=")?"&":"",e+=i(t)),e}t.exports={parse:o,stringify:i,queryify:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],24:[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},{}]},{},[4])(4)}); |
@@ -65,19 +65,19 @@ (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){ | ||
module.exports = { | ||
KOUNT_NOT_ENABLED: { | ||
DATA_COLLECTOR_KOUNT_NOT_ENABLED: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'KOUNT_NOT_ENABLED', | ||
code: 'DATA_COLLECTOR_KOUNT_NOT_ENABLED', | ||
message: 'Kount is not enabled for this merchant.' | ||
}, | ||
KOUNT_ERROR: { | ||
DATA_COLLECTOR_KOUNT_ERROR: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'KOUNT_ERROR' | ||
code: 'DATA_COLLECTOR_KOUNT_ERROR' | ||
}, | ||
PAYPAL_NOT_ENABLED: { | ||
DATA_COLLECTOR_PAYPAL_NOT_ENABLED: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'PAYPAL_NOT_ENABLED', | ||
code: 'DATA_COLLECTOR_PAYPAL_NOT_ENABLED', | ||
message: 'PayPal is not enabled for this merchant.' | ||
}, | ||
REQUIRES_CREATE_OPTIONS: { | ||
DATA_COLLECTOR_REQUIRES_CREATE_OPTIONS: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'REQUIRES_CREATE_OPTIONS', | ||
code: 'DATA_COLLECTOR_REQUIRES_CREATE_OPTIONS', | ||
message: 'Data Collector must be created with Kount and/or PayPal.' | ||
@@ -201,3 +201,3 @@ } | ||
var deferred = _dereq_('../lib/deferred'); | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
var sharedErrors = _dereq_('../errors'); | ||
@@ -294,3 +294,3 @@ var errors = _dereq_('./errors'); | ||
if (!config.gatewayConfiguration.kount) { | ||
callback(new BraintreeError(errors.KOUNT_NOT_ENABLED)); | ||
callback(new BraintreeError(errors.DATA_COLLECTOR_KOUNT_NOT_ENABLED)); | ||
return; | ||
@@ -306,4 +306,4 @@ } | ||
callback(new BraintreeError({ | ||
type: errors.KOUNT_ERROR.type, | ||
code: errors.KOUNT_ERROR.code, | ||
type: errors.DATA_COLLECTOR_KOUNT_ERROR.type, | ||
code: errors.DATA_COLLECTOR_KOUNT_ERROR.code, | ||
message: err.message | ||
@@ -322,3 +322,3 @@ })); | ||
if (config.gatewayConfiguration.paypalEnabled !== true) { | ||
callback(new BraintreeError(errors.PAYPAL_NOT_ENABLED)); | ||
callback(new BraintreeError(errors.DATA_COLLECTOR_PAYPAL_NOT_ENABLED)); | ||
return; | ||
@@ -333,3 +333,3 @@ } | ||
if (instances.length === 0) { | ||
callback(new BraintreeError(errors.REQUIRES_CREATE_OPTIONS)); | ||
callback(new BraintreeError(errors.DATA_COLLECTOR_REQUIRES_CREATE_OPTIONS)); | ||
return; | ||
@@ -336,0 +336,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 f.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,p=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[p],h=t[a>>>24]^y[s>>16&255]^g[e>>8&255]^v[255&o]^r[p+1],d=t[s>>>24]^y[e>>16&255]^g[o>>8&255]^v[255&a]^r[p+2],e=t[e>>>24]^y[o>>16&255]^g[a>>8&255]^v[255&s]^r[p+3],p+=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[p++],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],p=a[5],f=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)+(f^l&(p^f))+s[n],m=f,f=p,p=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]+p|0,a[6]=a[6]+f|0,a[7]=a[7]+m|0}function s(t,e){var n,r=f.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?f.random.addEntropy(window.performance.now(),t,"loadtime"):f.random.addEntropy((new Date).valueOf(),t,"loadtime")}function h(t){t.b=d(t).concat(d(t)),t.A=new f.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,p=!1,f={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=f),"function"==typeof t&&t([],function(){return f}),f.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 f.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]]},f.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)}},f.bitArray={bitSlice:function(t,e,n){return t=f.bitArray.P(t.slice(e/32),32-(31&e)).slice(1),n===l?t:f.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=f.bitArray.getPartial(n);return 32===r?t.concat(e):f.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)+f.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]=f.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(f.bitArray.bitLength(t)!==f.bitArray.bitLength(e))return p;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=f.bitArray.getPartial(i),r.push(f.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}},f.codec.utf8String={fromBits:function(t){var e,n,r="",i=f.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(f.bitArray.partial(8*(3&e),r)),n}},f.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,f.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 f.bitArray.clamp(r,4*n)}},f.codec.base64={J:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,n){var r="",i=0,o=f.codec.base64.J,a=0,s=f.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=f.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 f.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(f.bitArray.partial(56&a,c,1)),o}},f.codec.base64url={fromBits:function(t){return f.codec.base64.fromBits(t,1,1)},toBits:function(t){return f.codec.base64.toBits(t,1)}},f.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()},f.hash.sha256.hash=function(t){return(new f.hash.sha256).update(t).finalize()},f.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=f.codec.utf8String.toBits(t));var e,n=this.o=f.bitArray.concat(this.o,t);for(e=this.h,t=this.h=e+f.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=f.bitArray.concat(e,[f.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++}}},f.mode.ccm={name:"ccm",encrypt:function(t,e,n,r,o){var a,s=e.slice(0),c=f.bitArray,h=c.bitLength(n)/8,d=c.bitLength(s)/8;for(o=o||64,r=r||[],7>h&&i(new f.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=f.mode.ccm.L(t,e,n,r,o,a),s=f.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=f.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 f.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=f.mode.ccm.p(t,h,n,d,o,e),t=f.mode.ccm.L(t,h.data,n,r,o,e),a.equal(h.tag,t)||i(new f.exception.corrupt("ccm: tag doesn't match")),h.data},L:function(t,e,n,r,o,a){var s=[],c=f.bitArray,h=c.l;if(o/=8,(o%2||4>o||o>16)&&i(new f.exception.invalid("ccm: invalid tag length")),(4294967295<r.length||4294967295<e.length)&&i(new f.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=f.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)}}},f.mode.ocb2={name:"ocb2",encrypt:function(t,e,n,r,o,a){128!==f.bitArray.bitLength(n)&&i(new f.exception.invalid("ocb iv must be 128 bits"));var s,c=f.mode.ocb2.H,h=f.bitArray,d=h.l,u=[0,0,0,0];n=c(t.encrypt(n));var l,p=[];for(r=r||[],o=o||64,s=0;s+4<e.length;s+=4)l=e.slice(s,s+4),u=d(u,l),p=p.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:f.mode.ocb2.pmac(t,r))),p.concat(h.concat(l,h.clamp(u,o)))},decrypt:function(t,e,n,r,o,a){128!==f.bitArray.bitLength(n)&&i(new f.exception.invalid("ocb iv must be 128 bits")),o=o||64;var s,c,h=f.mode.ocb2.H,d=f.bitArray,u=d.l,l=[0,0,0,0],p=h(t.encrypt(n)),m=f.bitArray.bitLength(e)-o,y=[];for(r=r||[],n=0;m/32>n+4;n+=4)s=u(p,t.decrypt(u(p,e.slice(n,n+4)))),l=u(l,s),y=y.concat(s),p=h(p);return c=m-32*n,s=t.encrypt(u(p,[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(p,h(p)))),r.length&&(l=u(l,a?r:f.mode.ocb2.pmac(t,r))),d.equal(d.clamp(l,o),d.bitSlice(e,m))||i(new f.exception.corrupt("ocb: tag doesn't match")),y.concat(d.clamp(s,c))},pmac:function(t,e){var n,r=f.mode.ocb2.H,i=f.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)]}},f.mode.gcm={name:"gcm",encrypt:function(t,e,n,r,i){var o=e.slice(0);return e=f.bitArray,r=r||[],t=f.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=f.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=f.mode.gcm.p(p,t,a,r,n,o),s.equal(t.tag,e)||i(new f.exception.corrupt("gcm: tag doesn't match")),t.data},Z:function(t,e){var n,r,i,o,a,s=f.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=f.mode.gcm.Z(e,t);return e},p:function(t,e,n,r,i,o){var a,s,c,h,d,u,l,p,m=f.bitArray;for(u=n.length,l=m.bitLength(n),p=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=f.mode.gcm.g(a,[0,0,0,0],i),i=f.mode.gcm.g(a,i,[0,0,Math.floor(s/4294967296),4294967295&s])),s=f.mode.gcm.g(a,[0,0,0,0],r),d=i.slice(0),r=s.slice(0),t||(r=f.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=f.mode.gcm.g(a,s,n)),t=[Math.floor(p/4294967296),4294967295&p,Math.floor(l/4294967296),4294967295&l],r=f.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}}},f.misc.hmac=function(t,e){this.M=e=e||f.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])},f.misc.hmac.prototype.encrypt=f.misc.hmac.prototype.mac=function(t){return this.Q&&i(new f.exception.invalid("encrypt on already updated hmac called!")),this.update(t),this.digest(t)},f.misc.hmac.prototype.reset=function(){this.G=new this.M(this.n[0]),this.Q=p},f.misc.hmac.prototype.update=function(t){this.Q=!0,this.G.update(t)},f.misc.hmac.prototype.digest=function(){var t=this.G.finalize(),t=new this.M(this.n[1]).update(t).finalize();return this.reset(),t},f.misc.pbkdf2=function(t,e,n,r,o){n=n||1e3,(0>r||0>n)&&i(f.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=f.codec.utf8String.toBits(t)),"string"==typeof e&&(e=f.codec.utf8String.toBits(e)),o=o||f.misc.hmac,t=new o(t);var a,s,c,h,d=[],u=f.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},f.prng=function(t){this.c=[new f.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=p,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},f.prng.prototype={randomWords:function(t,e){var n,r=[];n=this.isReady(e);var o;if(n===this.m&&i(new f.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 f.hash.sha256),this.i.push(0)),this.d-=s,s>this.j&&(this.j=s),this.F++,this.b=f.hash.sha256.hash(this.b.concat(o)),this.A=new f.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 f.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,p),window.addEventListener("mousemove",this.a.mouseCollector,p),window.addEventListener("keypress",this.a.keyboardCollector,p),window.addEventListener("devicemotion",this.a.accelerometerCollector,p),window.addEventListener("touchmove",this.a.touchCollector,p)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):i(new f.exception.bug("can't attach event")),this.q=!0)},stopCollectors:function(){this.q&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,p),window.removeEventListener("mousemove",this.a.mouseCollector,p),window.removeEventListener("keypress",this.a.keyboardCollector,p),window.removeEventListener("devicemotion",this.a.accelerometerCollector,p),window.removeEventListener("touchmove",this.a.touchCollector,p)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.q=p)},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&&f.random.addEntropy([e,n],2,"mouse"),c(0)},da:function(t){t=t.touches[0]||t.changedTouches[0],f.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&&f.random.addEntropy(e,1,"accelerometer")}t&&f.random.addEntropy(t,2,"accelerometer"),c(0)}},f.random=new f.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),f.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)}f.random.addEntropy(g,1024,"crypto['getRandomValues']")}}catch(A){"undefined"!=typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(A))}f.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=f.json,s=a.e({iv:f.random.randomWords(4,0)},a.defaults);return a.e(s,n),n=s.adata,"string"==typeof s.salt&&(s.salt=f.codec.base64.toBits(s.salt)),"string"==typeof s.iv&&(s.iv=f.codec.base64.toBits(s.iv)),(!f.mode[s.mode]||!f.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 f.exception.invalid("json encrypt: invalid parameters")),"string"==typeof t?(o=f.misc.cachedPbkdf2(t,s),t=o.key.slice(0,s.ks/32),s.salt=o.salt):f.ecc&&t instanceof f.ecc.elGamal.publicKey&&(o=t.kem(),s.kemtag=o.tag,t=o.key.slice(0,s.ks/32)),"string"==typeof e&&(e=f.codec.utf8String.toBits(e)),"string"==typeof n&&(s.adata=n=f.codec.utf8String.toBits(n)),o=new f.cipher[s.cipher](t),a.e(r,s),r.key=t,s.ct=f.mode[s.mode].encrypt(o,e,s.iv,n,s.ts),s},encrypt:function(t,e,n,r){var i=f.json,o=i.Y.apply(i,arguments);return i.encode(o)},X:function(t,e,n,r){n=n||{},r=r||{};var o=f.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=f.codec.base64.toBits(e.salt)),"string"==typeof e.iv&&(e.iv=f.codec.base64.toBits(e.iv)),(!f.mode[e.mode]||!f.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 f.exception.invalid("json decrypt: invalid parameters")),"string"==typeof t?(s=f.misc.cachedPbkdf2(t,e),t=s.key.slice(0,e.ks/32),e.salt=s.salt):f.ecc&&t instanceof f.ecc.elGamal.secretKey&&(t=t.unkem(f.codec.base64.toBits(e.kemtag)).slice(0,e.ks/32)),"string"==typeof a&&(a=f.codec.utf8String.toBits(a)),s=new f.cipher[e.cipher](t),a=f.mode[e.mode].decrypt(s,e.ct,e.iv,a,e.ts),o.e(r,e),r.key=t,1===n.raw?a:f.codec.utf8String.fromBits(a)},decrypt:function(t,e,n,r){var i=f.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 f.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+='"'+f.codec.base64.fromBits(t[e],0)+'"';break;default:i(new f.exception.bug("json encode: unsupported type"))}return n+"}"},decode:function(t){t=t.replace(/\s/g,""),t.match(/^\{.*\}$/)||i(new f.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 f.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)$/)?f.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 f.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}},f.encrypt=f.json.encrypt,f.decrypt=f.json.decrypt,f.misc.ca={},f.misc.cachedPbkdf2=function(t,e){var n,r=f.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):f.random.randomWords(2,0)},r=e.salt===l?n.firstSalt:e.salt,n[r]=n[r]||f.misc.pbkdf2(t,r,e.iter),{key:n[r].slice(0),salt:r.slice(0)}}},{crypto:1}],3:[function(t,e,n){"use strict";var r=t("../lib/error");e.exports={KOUNT_NOT_ENABLED:{type:r.types.MERCHANT,code:"KOUNT_NOT_ENABLED",message:"Kount is not enabled for this merchant."},KOUNT_ERROR:{type:r.types.MERCHANT,code:"KOUNT_ERROR"},PAYPAL_NOT_ENABLED:{type:r.types.MERCHANT,code:"PAYPAL_NOT_ENABLED",message:"PayPal is not enabled for this merchant."},REQUIRES_CREATE_OPTIONS:{type:r.types.MERCHANT,code:"REQUIRES_CREATE_OPTIONS",message:"Data Collector must be created with Kount and/or PayPal."}}},{"../lib/error":11}],4:[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}},{}],5:[function(t,e,n){"use strict";function r(t,e){function n(t){var e;for(e=0;e<v.length;e++)v[e].teardown();c(m,s(m)),t&&(t=h(t))()}var r,p,f,m,y,g,v=[];if("function"!=typeof e)throw new a({type:u.CALLBACK_REQUIRED.type,code:u.CALLBACK_REQUIRED.code,message:"create must include a callback function."});if(e=h(e),null==t.client)return void e(new a({type:u.INSTANTIATION_OPTION_REQUIRED.type,code:u.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating Data Collector."}));if(y=t.client.getConfiguration(),g=y.analyticsMetadata.sdkVersion,g!==d)return void e(new a({type:u.INCOMPATIBLE_VERSIONS.type,code:u.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+g+") and Data Collector (version "+d+") components must be from the same SDK version."}));if(t.kount===!0){if(!y.gatewayConfiguration.kount)return void e(new a(l.KOUNT_NOT_ENABLED));try{p=i.setup({environment:y.gatewayConfiguration.environment,merchantId:y.gatewayConfiguration.kount.kountMerchantId})}catch(b){return void e(new a({type:l.KOUNT_ERROR.type,code:l.KOUNT_ERROR.code,message:b.message}))}r=p.deviceData,v.push(p)}else r={};if(t.paypal===!0){if(y.gatewayConfiguration.paypalEnabled!==!0)return void e(new a(l.PAYPAL_NOT_ENABLED));f=o.setup(),r.correlation_id=f.sessionId,v.push(f)}return 0===v.length?void e(new a(l.REQUIRES_CREATE_OPTIONS)):(m={deviceData:JSON.stringify(r),teardown:n},void e(null,m))}var i=t("./kount"),o=t("./fraudnet"),a=t("../lib/error"),s=t("../lib/methods"),c=t("../lib/convert-methods-to-error"),h=t("../lib/deferred"),d="3.0.0-beta.12",u=t("../errors"),l=t("./errors");e.exports={create:r,VERSION:d}},{"../errors":7,"../lib/convert-methods-to-error":8,"../lib/deferred":9,"../lib/error":11,"../lib/methods":12,"./errors":3,"./fraudnet":4,"./kount":6}],6:[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}],7:[function(t,e,n){"use strict";var r=t("./lib/error");e.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":11}],8:[function(t,e,n){"use strict";var r=t("./error"),i=t("../errors");e.exports=function(t,e){e.forEach(function(e){t[e]=function(){throw new r({type:i.METHOD_CALLED_AFTER_TEARDOWN.type,code:i.METHOD_CALLED_AFTER_TEARDOWN.code,message:e+" cannot be called after teardown."})}})}},{"../errors":7,"./error":11}],9:[function(t,e,n){"use strict";e.exports=function(t){return function(){var e=arguments;setTimeout(function(){t.apply(null,e)},1)}}},{}],10:[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},{}],11:[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.code)throw new Error("Error code required.");if(!t.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=t.code,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":10}],12:[function(t,e,n){"use strict";e.exports=function(t){return Object.keys(t).filter(function(e){return"function"==typeof t[e]})}},{}]},{},[5])(5)}); | ||
!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 f.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,p=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[p],h=t[a>>>24]^y[s>>16&255]^g[e>>8&255]^v[255&o]^r[p+1],d=t[s>>>24]^y[e>>16&255]^g[o>>8&255]^v[255&a]^r[p+2],e=t[e>>>24]^y[o>>16&255]^g[a>>8&255]^v[255&s]^r[p+3],p+=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[p++],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],p=a[5],f=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)+(f^l&(p^f))+s[n],m=f,f=p,p=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]+p|0,a[6]=a[6]+f|0,a[7]=a[7]+m|0}function s(t,e){var n,r=f.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?f.random.addEntropy(window.performance.now(),t,"loadtime"):f.random.addEntropy((new Date).valueOf(),t,"loadtime")}function h(t){t.b=d(t).concat(d(t)),t.A=new f.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,p=!1,f={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=f),"function"==typeof t&&t([],function(){return f}),f.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 f.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]]},f.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)}},f.bitArray={bitSlice:function(t,e,n){return t=f.bitArray.P(t.slice(e/32),32-(31&e)).slice(1),n===l?t:f.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=f.bitArray.getPartial(n);return 32===r?t.concat(e):f.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)+f.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]=f.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(f.bitArray.bitLength(t)!==f.bitArray.bitLength(e))return p;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=f.bitArray.getPartial(i),r.push(f.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}},f.codec.utf8String={fromBits:function(t){var e,n,r="",i=f.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(f.bitArray.partial(8*(3&e),r)),n}},f.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,f.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 f.bitArray.clamp(r,4*n)}},f.codec.base64={J:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,n){var r="",i=0,o=f.codec.base64.J,a=0,s=f.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=f.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 f.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(f.bitArray.partial(56&a,c,1)),o}},f.codec.base64url={fromBits:function(t){return f.codec.base64.fromBits(t,1,1)},toBits:function(t){return f.codec.base64.toBits(t,1)}},f.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()},f.hash.sha256.hash=function(t){return(new f.hash.sha256).update(t).finalize()},f.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=f.codec.utf8String.toBits(t));var e,n=this.o=f.bitArray.concat(this.o,t);for(e=this.h,t=this.h=e+f.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=f.bitArray.concat(e,[f.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++}}},f.mode.ccm={name:"ccm",encrypt:function(t,e,n,r,o){var a,s=e.slice(0),c=f.bitArray,h=c.bitLength(n)/8,d=c.bitLength(s)/8;for(o=o||64,r=r||[],7>h&&i(new f.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=f.mode.ccm.L(t,e,n,r,o,a),s=f.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=f.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 f.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=f.mode.ccm.p(t,h,n,d,o,e),t=f.mode.ccm.L(t,h.data,n,r,o,e),a.equal(h.tag,t)||i(new f.exception.corrupt("ccm: tag doesn't match")),h.data},L:function(t,e,n,r,o,a){var s=[],c=f.bitArray,h=c.l;if(o/=8,(o%2||4>o||o>16)&&i(new f.exception.invalid("ccm: invalid tag length")),(4294967295<r.length||4294967295<e.length)&&i(new f.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=f.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)}}},f.mode.ocb2={name:"ocb2",encrypt:function(t,e,n,r,o,a){128!==f.bitArray.bitLength(n)&&i(new f.exception.invalid("ocb iv must be 128 bits"));var s,c=f.mode.ocb2.H,h=f.bitArray,d=h.l,u=[0,0,0,0];n=c(t.encrypt(n));var l,p=[];for(r=r||[],o=o||64,s=0;s+4<e.length;s+=4)l=e.slice(s,s+4),u=d(u,l),p=p.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:f.mode.ocb2.pmac(t,r))),p.concat(h.concat(l,h.clamp(u,o)))},decrypt:function(t,e,n,r,o,a){128!==f.bitArray.bitLength(n)&&i(new f.exception.invalid("ocb iv must be 128 bits")),o=o||64;var s,c,h=f.mode.ocb2.H,d=f.bitArray,u=d.l,l=[0,0,0,0],p=h(t.encrypt(n)),m=f.bitArray.bitLength(e)-o,y=[];for(r=r||[],n=0;m/32>n+4;n+=4)s=u(p,t.decrypt(u(p,e.slice(n,n+4)))),l=u(l,s),y=y.concat(s),p=h(p);return c=m-32*n,s=t.encrypt(u(p,[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(p,h(p)))),r.length&&(l=u(l,a?r:f.mode.ocb2.pmac(t,r))),d.equal(d.clamp(l,o),d.bitSlice(e,m))||i(new f.exception.corrupt("ocb: tag doesn't match")),y.concat(d.clamp(s,c))},pmac:function(t,e){var n,r=f.mode.ocb2.H,i=f.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)]}},f.mode.gcm={name:"gcm",encrypt:function(t,e,n,r,i){var o=e.slice(0);return e=f.bitArray,r=r||[],t=f.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=f.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=f.mode.gcm.p(p,t,a,r,n,o),s.equal(t.tag,e)||i(new f.exception.corrupt("gcm: tag doesn't match")),t.data},Z:function(t,e){var n,r,i,o,a,s=f.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=f.mode.gcm.Z(e,t);return e},p:function(t,e,n,r,i,o){var a,s,c,h,d,u,l,p,m=f.bitArray;for(u=n.length,l=m.bitLength(n),p=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=f.mode.gcm.g(a,[0,0,0,0],i),i=f.mode.gcm.g(a,i,[0,0,Math.floor(s/4294967296),4294967295&s])),s=f.mode.gcm.g(a,[0,0,0,0],r),d=i.slice(0),r=s.slice(0),t||(r=f.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=f.mode.gcm.g(a,s,n)),t=[Math.floor(p/4294967296),4294967295&p,Math.floor(l/4294967296),4294967295&l],r=f.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}}},f.misc.hmac=function(t,e){this.M=e=e||f.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])},f.misc.hmac.prototype.encrypt=f.misc.hmac.prototype.mac=function(t){return this.Q&&i(new f.exception.invalid("encrypt on already updated hmac called!")),this.update(t),this.digest(t)},f.misc.hmac.prototype.reset=function(){this.G=new this.M(this.n[0]),this.Q=p},f.misc.hmac.prototype.update=function(t){this.Q=!0,this.G.update(t)},f.misc.hmac.prototype.digest=function(){var t=this.G.finalize(),t=new this.M(this.n[1]).update(t).finalize();return this.reset(),t},f.misc.pbkdf2=function(t,e,n,r,o){n=n||1e3,(0>r||0>n)&&i(f.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=f.codec.utf8String.toBits(t)),"string"==typeof e&&(e=f.codec.utf8String.toBits(e)),o=o||f.misc.hmac,t=new o(t);var a,s,c,h,d=[],u=f.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},f.prng=function(t){this.c=[new f.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=p,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},f.prng.prototype={randomWords:function(t,e){var n,r=[];n=this.isReady(e);var o;if(n===this.m&&i(new f.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 f.hash.sha256),this.i.push(0)),this.d-=s,s>this.j&&(this.j=s),this.F++,this.b=f.hash.sha256.hash(this.b.concat(o)),this.A=new f.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 f.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,p),window.addEventListener("mousemove",this.a.mouseCollector,p),window.addEventListener("keypress",this.a.keyboardCollector,p),window.addEventListener("devicemotion",this.a.accelerometerCollector,p),window.addEventListener("touchmove",this.a.touchCollector,p)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):i(new f.exception.bug("can't attach event")),this.q=!0)},stopCollectors:function(){this.q&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,p),window.removeEventListener("mousemove",this.a.mouseCollector,p),window.removeEventListener("keypress",this.a.keyboardCollector,p),window.removeEventListener("devicemotion",this.a.accelerometerCollector,p),window.removeEventListener("touchmove",this.a.touchCollector,p)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.q=p)},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&&f.random.addEntropy([e,n],2,"mouse"),c(0)},da:function(t){t=t.touches[0]||t.changedTouches[0],f.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&&f.random.addEntropy(e,1,"accelerometer")}t&&f.random.addEntropy(t,2,"accelerometer"),c(0)}},f.random=new f.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),f.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)}f.random.addEntropy(g,1024,"crypto['getRandomValues']")}}catch(A){"undefined"!=typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(A))}f.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=f.json,s=a.e({iv:f.random.randomWords(4,0)},a.defaults);return a.e(s,n),n=s.adata,"string"==typeof s.salt&&(s.salt=f.codec.base64.toBits(s.salt)),"string"==typeof s.iv&&(s.iv=f.codec.base64.toBits(s.iv)),(!f.mode[s.mode]||!f.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 f.exception.invalid("json encrypt: invalid parameters")),"string"==typeof t?(o=f.misc.cachedPbkdf2(t,s),t=o.key.slice(0,s.ks/32),s.salt=o.salt):f.ecc&&t instanceof f.ecc.elGamal.publicKey&&(o=t.kem(),s.kemtag=o.tag,t=o.key.slice(0,s.ks/32)),"string"==typeof e&&(e=f.codec.utf8String.toBits(e)),"string"==typeof n&&(s.adata=n=f.codec.utf8String.toBits(n)),o=new f.cipher[s.cipher](t),a.e(r,s),r.key=t,s.ct=f.mode[s.mode].encrypt(o,e,s.iv,n,s.ts),s},encrypt:function(t,e,n,r){var i=f.json,o=i.Y.apply(i,arguments);return i.encode(o)},X:function(t,e,n,r){n=n||{},r=r||{};var o=f.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=f.codec.base64.toBits(e.salt)),"string"==typeof e.iv&&(e.iv=f.codec.base64.toBits(e.iv)),(!f.mode[e.mode]||!f.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 f.exception.invalid("json decrypt: invalid parameters")),"string"==typeof t?(s=f.misc.cachedPbkdf2(t,e),t=s.key.slice(0,e.ks/32),e.salt=s.salt):f.ecc&&t instanceof f.ecc.elGamal.secretKey&&(t=t.unkem(f.codec.base64.toBits(e.kemtag)).slice(0,e.ks/32)),"string"==typeof a&&(a=f.codec.utf8String.toBits(a)),s=new f.cipher[e.cipher](t),a=f.mode[e.mode].decrypt(s,e.ct,e.iv,a,e.ts),o.e(r,e),r.key=t,1===n.raw?a:f.codec.utf8String.fromBits(a)},decrypt:function(t,e,n,r){var i=f.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 f.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+='"'+f.codec.base64.fromBits(t[e],0)+'"';break;default:i(new f.exception.bug("json encode: unsupported type"))}return n+"}"},decode:function(t){t=t.replace(/\s/g,""),t.match(/^\{.*\}$/)||i(new f.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 f.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)$/)?f.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 f.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}},f.encrypt=f.json.encrypt,f.decrypt=f.json.decrypt,f.misc.ca={},f.misc.cachedPbkdf2=function(t,e){var n,r=f.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):f.random.randomWords(2,0)},r=e.salt===l?n.firstSalt:e.salt,n[r]=n[r]||f.misc.pbkdf2(t,r,e.iter),{key:n[r].slice(0),salt:r.slice(0)}}},{crypto:1}],3:[function(t,e,n){"use strict";var r=t("../lib/error");e.exports={DATA_COLLECTOR_KOUNT_NOT_ENABLED:{type:r.types.MERCHANT,code:"DATA_COLLECTOR_KOUNT_NOT_ENABLED",message:"Kount is not enabled for this merchant."},DATA_COLLECTOR_KOUNT_ERROR:{type:r.types.MERCHANT,code:"DATA_COLLECTOR_KOUNT_ERROR"},DATA_COLLECTOR_PAYPAL_NOT_ENABLED:{type:r.types.MERCHANT,code:"DATA_COLLECTOR_PAYPAL_NOT_ENABLED",message:"PayPal is not enabled for this merchant."},DATA_COLLECTOR_REQUIRES_CREATE_OPTIONS:{type:r.types.MERCHANT,code:"DATA_COLLECTOR_REQUIRES_CREATE_OPTIONS",message:"Data Collector must be created with Kount and/or PayPal."}}},{"../lib/error":11}],4:[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}},{}],5:[function(t,e,n){"use strict";function r(t,e){function n(t){var e;for(e=0;e<v.length;e++)v[e].teardown();c(m,s(m)),t&&(t=h(t))()}var r,p,f,m,y,g,v=[];if("function"!=typeof e)throw new a({type:u.CALLBACK_REQUIRED.type,code:u.CALLBACK_REQUIRED.code,message:"create must include a callback function."});if(e=h(e),null==t.client)return void e(new a({type:u.INSTANTIATION_OPTION_REQUIRED.type,code:u.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating Data Collector."}));if(y=t.client.getConfiguration(),g=y.analyticsMetadata.sdkVersion,g!==d)return void e(new a({type:u.INCOMPATIBLE_VERSIONS.type,code:u.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+g+") and Data Collector (version "+d+") components must be from the same SDK version."}));if(t.kount===!0){if(!y.gatewayConfiguration.kount)return void e(new a(l.DATA_COLLECTOR_KOUNT_NOT_ENABLED));try{p=i.setup({environment:y.gatewayConfiguration.environment,merchantId:y.gatewayConfiguration.kount.kountMerchantId})}catch(b){return void e(new a({type:l.DATA_COLLECTOR_KOUNT_ERROR.type,code:l.DATA_COLLECTOR_KOUNT_ERROR.code,message:b.message}))}r=p.deviceData,v.push(p)}else r={};if(t.paypal===!0){if(y.gatewayConfiguration.paypalEnabled!==!0)return void e(new a(l.DATA_COLLECTOR_PAYPAL_NOT_ENABLED));f=o.setup(),r.correlation_id=f.sessionId,v.push(f)}return 0===v.length?void e(new a(l.DATA_COLLECTOR_REQUIRES_CREATE_OPTIONS)):(m={deviceData:JSON.stringify(r),teardown:n},void e(null,m))}var i=t("./kount"),o=t("./fraudnet"),a=t("../lib/error"),s=t("../lib/methods"),c=t("../lib/convert-methods-to-error"),h=t("../lib/deferred"),d="3.0.0",u=t("../errors"),l=t("./errors");e.exports={create:r,VERSION:d}},{"../errors":7,"../lib/convert-methods-to-error":8,"../lib/deferred":9,"../lib/error":11,"../lib/methods":12,"./errors":3,"./fraudnet":4,"./kount":6}],6:[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}],7:[function(t,e,n){"use strict";var r=t("./lib/error");e.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":11}],8:[function(t,e,n){"use strict";var r=t("./error"),i=t("../errors");e.exports=function(t,e){e.forEach(function(e){t[e]=function(){throw new r({type:i.METHOD_CALLED_AFTER_TEARDOWN.type,code:i.METHOD_CALLED_AFTER_TEARDOWN.code,message:e+" cannot be called after teardown."})}})}},{"../errors":7,"./error":11}],9:[function(t,e,n){"use strict";e.exports=function(t){return function(){var e=arguments;setTimeout(function(){t.apply(null,e)},1)}}},{}],10:[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},{}],11:[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.code)throw new Error("Error code required.");if(!t.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=t.code,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":10}],12:[function(t,e,n){"use strict";e.exports=function(t){return Object.keys(t).filter(function(e){return"function"==typeof t[e]})}},{}]},{},[5])(5)}); |
@@ -69,3 +69,3 @@ 'use strict'; | ||
*/ | ||
VERSION: '3.0.0-beta.12' | ||
VERSION: '3.0.0' | ||
}; |
@@ -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={})).hostedFields=e()}}(function(){var e;return function t(e,n,r){function i(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(u.exports,function(t){var n=e[s][1][t];return i(n?n:t)},u,u.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(e,t,n){"use strict";function r(e){return JSON.parse(JSON.stringify(e))}var i=[{niceType:"Visa",type:"visa",pattern:"^4\\d*$",gaps:[4,8,12],lengths:[16],code:{name:"CVV",size:3}},{niceType:"MasterCard",type:"master-card",pattern:"^(5|5[1-5]\\d*|2|22|222|222[1-9]\\d*|2[3-6]\\d*|27[0-1]\\d*|2720\\d*)$",gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},{niceType:"American Express",type:"american-express",pattern:"^3([47]\\d*)?$",isAmex:!0,gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},{niceType:"Diners Club",type:"diners-club",pattern:"^3((0([0-5]\\d*)?)|[689]\\d*)?$",gaps:[4,10],lengths:[14],code:{name:"CVV",size:3}},{niceType:"Discover",type:"discover",pattern:"^6(0|01|011\\d*|5\\d*|4|4[4-9]\\d*)?$",gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},{niceType:"JCB",type:"jcb",pattern:"^((2|21|213|2131\\d*)|(1|18|180|1800\\d*)|(3|35\\d*))$",gaps:[4,8,12],lengths:[16],code:{name:"CVV",size:3}},{niceType:"UnionPay",type:"unionpay",pattern:"^6(2\\d*)?$",gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVN",size:3}},{niceType:"Maestro",type:"maestro",pattern:"^((5((0|[6-9])\\d*)?)|(6|6[37]\\d*))$",gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}}];t.exports=function(e){var t,n,o=[];if(!("string"==typeof e||e instanceof String))return o;if(""===e)return r(i);for(t=0;t<i.length;t++)n=i[t],RegExp(n.pattern).test(e)&&o.push(r(n));return o}},{}],2:[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:(T.push(e),!0)}function n(e){var t,n={};for(t in g)g.hasOwnProperty(t)&&(n[t]=g[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=c(e,n,r),t===!1?!1:(y(I.top,t,r),!0))}function i(e,t){var n=s(this);return m(e,t,n)?!1:(N[n]=N[n]||{},N[n][e]=N[n][e]||[],N[n][e].push(t),!0)}function o(e,t){var n,r,i=s(this);if(m(e,t,i))return!1;if(r=N[i]&&N[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 c(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=b+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,b.length)!==b)return!1;try{t=JSON.parse(e.data.slice(b.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){I||(I=t||e,I.addEventListener?I.addEventListener("message",f,!1):I.attachEvent?I.attachEvent("onmessage",f):null===I.onmessage?I.onmessage=f:I=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 f(e){var t;a(e.data)||(t=l(e),t&&(p("*",t.event,t.args,e),p(e.origin,t.event,t.args,e),E(e.data,t.origin,e.source)))}function p(e,t,n,r){var i;if(N[e]&&N[e][t])for(i=0;i<N[e][t].length;i++)N[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=T.length-1;r>=0;r--)i=T[r],i.closed===!0?T=T.slice(r,1):n!==i&&y(i.top,e,t)}function _(e,t){function n(i,o){e(i,o),g.target(t).unsubscribe(r,n)}var r=d();return g.target(t).subscribe(r,n),r}function m(e,t,n){return a(e)?!0:"function"!=typeof t?!0:a(n)?!0:!1}var I,g,T=[],N={},b="/*framebus*/";return u(),g={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:{})},{}],3:[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":4,"./lib/default-attributes":5,"./lib/set-attributes":6}],4:[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}},{}],5:[function(e,t,n){t.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],6:[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))}},{}],7:[function(e,t,n){"use strict";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":28}],8:[function(e,t,n){"use strict";var r=e("../shared/constants");t.exports=function(e,t){return e+"/web/"+r.VERSION+"/html/hosted-fields-frame.min.html#"+t}},{"../shared/constants":12}],9:[function(e,t,n){"use strict";function r(e){return function(t){var n,r=t.merchantPayload,i=r.emittedBy,o=e[i].containerElement;Object.keys(r.fields).forEach(function(t){r.fields[t].container=e[t].containerElement}),n=r.fields[i],s.toggle(o,d.externalClasses.FOCUSED,n.isFocused),s.toggle(o,d.externalClasses.VALID,n.isValid),s.toggle(o,d.externalClasses.INVALID,!n.isPotentiallyValid),this._state={cards:r.cards,fields:r.fields},this._emit(t.type,r)}}function i(e){var t,n,y=this,E={},T=0,A=h();if(!e.client)throw new l({type:D.INSTANTIATION_OPTION_REQUIRED.type,code:D.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating Hosted Fields."});if(n=e.client.getConfiguration().analyticsMetadata.sdkVersion,n!==N)throw new l({type:D.INCOMPATIBLE_VERSIONS.type,code:D.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+n+") and Hosted Fields (version "+N+") components must be from the same SDK version."});if(!e.fields)throw new l({type:D.INSTANTIATION_OPTION_REQUIRED.type,code:D.INSTANTIATION_OPTION_REQUIRED.code,message:"options.fields is required when instantiating Hosted Fields."});m.call(this),this._injectedNodes=[],this._destructor=new o,this._fields=E,this._state={fields:{},cards:x("")},this._bus=new c({channel:A,merchantUrl:location.href}),this._destructor.registerFunctionForTeardown(function(){y._bus.teardown()}),this._client=e.client,g.sendEvent(this._client,"web.custom.hosted-fields.initialized"),Object.keys(e.fields).forEach(function(t){var n,r,i;if(!d.whitelistedFields.hasOwnProperty(t))throw new l({type:f.INVALID_FIELD_KEY.type,code:f.INVALID_FIELD_KEY.code,message:'"'+t+'" is not a valid field.'});if(n=e.fields[t],r=document.querySelector(n.selector),!r)throw new l({type:f.INVALID_FIELD_SELECTOR.type,code:f.INVALID_FIELD_SELECTOR.code,message:f.INVALID_FIELD_SELECTOR.message,details:{fieldSelector:n.selector,fieldKey:t}});if(r.querySelector('iframe[name^="braintree-"]'))throw new l({type:f.FIELD_DUPLICATE_IFRAME.type,code:f.FIELD_DUPLICATE_IFRAME.code,message:f.FIELD_DUPLICATE_IFRAME.message,details:{fieldSelector:n.selector,fieldKey:t}});i=a({type:t,name:"braintree-hosted-field-"+t,style:d.defaultIFrameStyle}),this._injectedNodes=this._injectedNodes.concat(I(i,r)),this._setupLabelFocus(t,r),E[t]={frameElement:i,containerElement:r},T++,this._state.fields[t]={isEmpty:!0,isValid:!1,isPotentiallyValid:!0,isFocused:!1,container:r},setTimeout(function(){i.src=u(y._client.getConfiguration().gatewayConfiguration.assetsUrl,A)},0)}.bind(this)),t=setTimeout(function(){g.sendEvent(y._client,"web.custom.hosted-fields.load.timed-out")},p),this._bus.on(_.FRAME_READY,function(n){T--,0===T&&(clearTimeout(t),n(e),y._emit("ready"))}),this._bus.on(_.INPUT_EVENT,r(E).bind(this)),this._destructor.registerFunctionForTeardown(function(){var e,t,n;for(e=0;e<y._injectedNodes.length;e++)t=y._injectedNodes[e],n=t.parentNode,n.removeChild(t),s.remove(n,d.externalClasses.FOCUSED,d.externalClasses.INVALID,d.externalClasses.VALID)}),this._destructor.registerFunctionForTeardown(function(){var e=b(i.prototype).concat(b(m.prototype));v(y,e)})}var o=e("../../lib/destructor"),s=e("../../lib/classlist"),a=e("iframer"),c=e("../../lib/bus"),l=e("../../lib/error"),u=e("./compose-url"),d=e("../shared/constants"),f=e("../shared/errors"),p=e("../../lib/constants").INTEGRATION_TIMEOUT_MS,h=e("../../lib/uuid"),y=e("../shared/find-parent-tags"),E=e("../../lib/is-ios"),_=d.events,m=e("../../lib/event-emitter"),I=e("./inject-frame"),g=e("../../lib/analytics"),T=d.whitelistedFields,N="3.0.0-beta.12",b=e("../../lib/methods"),v=e("../../lib/convert-methods-to-error"),A=e("../../lib/deferred"),D=e("../../errors"),x=e("credit-card-type");i.prototype=Object.create(m.prototype,{constructor:i}),i.prototype._setupLabelFocus=function(e,t){function n(){s.emit(_.TRIGGER_INPUT_FOCUS,e)}var r,i,o=E(),s=this._bus;if(!o&&null!=t.id){for(r=Array.prototype.slice.call(document.querySelectorAll('label[for="'+t.id+'"]')),r=r.concat(y(t,"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(e){var t=this._client;this._destructor.teardown(function(n){g.sendEvent(t,"web.custom.hosted-fields.teardown-completed"),"function"==typeof e&&(e=A(e))(n)})},i.prototype.tokenize=function(e,t){if(t||(t=e,e={}),"function"!=typeof t)throw new l({type:D.CALLBACK_REQUIRED.type,code:D.CALLBACK_REQUIRED.code,message:"tokenize must include a callback function."});this._bus.emit(_.TOKENIZATION_REQUEST,e,function(e){t.apply(null,e)})},i.prototype.addClass=function(e,t,n){var r;T.hasOwnProperty(e)?this._fields.hasOwnProperty(e)?this._bus.emit(_.ADD_CLASS,e,t):r=new l({type:f.FIELD_NOT_PRESENT.type,code:f.FIELD_NOT_PRESENT.code,message:'Cannot add class to "'+e+'" field because it is not part of the current Hosted Fields options.'}):r=new l({type:f.INVALID_FIELD.type,code:f.INVALID_FIELD.code,message:'"'+e+'" is not a valid field. You must use a valid field option when adding a class.'}),"function"==typeof n&&(n=A(n))(r)},i.prototype.removeClass=function(e,t,n){var r;T.hasOwnProperty(e)?this._fields.hasOwnProperty(e)?this._bus.emit(_.REMOVE_CLASS,e,t):r=new l({type:f.FIELD_NOT_PRESENT.type,code:f.FIELD_NOT_PRESENT.code,message:'Cannot remove class from "'+e+'" field because it is not part of the current Hosted Fields options.'}):r=new l({type:f.INVALID_FIELD.type,code:f.INVALID_FIELD.code,message:'"'+e+'" is not a valid field. You must use a valid field option when removing a class.'}),"function"==typeof n&&(n=A(n))(r)},i.prototype.setPlaceholder=function(e,t,n){var r;T.hasOwnProperty(e)?this._fields.hasOwnProperty(e)?this._bus.emit(_.SET_PLACEHOLDER,e,t):r=new l({type:f.FIELD_NOT_PRESENT.type,code:f.FIELD_NOT_PRESENT.code,message:'Cannot set placeholder for "'+e+'" field because it is not part of the current Hosted Fields options.'}):r=new l({type:f.INVALID_FIELD.type,code:f.INVALID_FIELD.code,message:'"'+e+'" is not a valid field. You must use a valid field option when setting a placeholder.'}),"function"==typeof n&&(n=A(n))(r)},i.prototype.clear=function(e,t){var n;T.hasOwnProperty(e)?this._fields.hasOwnProperty(e)?this._bus.emit(_.CLEAR_FIELD,e):n=new l({type:f.FIELD_NOT_PRESENT.type,code:f.FIELD_NOT_PRESENT.code,message:'Cannot clear "'+e+'" field because it is not part of the current Hosted Fields options.'}):n=new l({type:f.INVALID_FIELD.type,code:f.INVALID_FIELD.code,message:'"'+e+'" is not a valid field. You must use a valid field option when clearing a field.'}),"function"==typeof t&&(t=A(t))(n)},i.prototype.getState=function(){return this._state},t.exports=i},{"../../errors":7,"../../lib/analytics":16,"../../lib/bus":20,"../../lib/classlist":21,"../../lib/constants":22,"../../lib/convert-methods-to-error":23,"../../lib/deferred":25,"../../lib/destructor":26,"../../lib/error":28,"../../lib/event-emitter":29,"../../lib/is-ios":30,"../../lib/methods":32,"../../lib/uuid":35,"../shared/constants":12,"../shared/errors":13,"../shared/find-parent-tags":14,"./compose-url":8,"./inject-frame":10,"credit-card-type":1,iframer:3}],10:[function(e,t,n){"use strict";t.exports=function(e,t){var n=document.createElement("div"),r=document.createDocumentFragment();return n.style.clear="both",r.appendChild(e),r.appendChild(n),t.appendChild(r),[e,n]}},{}],11:[function(e,t,n){"use strict";function r(e,t){var n;if("function"!=typeof t)throw new s({type:a.CALLBACK_REQUIRED.type,code:a.CALLBACK_REQUIRED.code,message:"create must include a callback function."});try{n=new i(e)}catch(r){return t=o(t),void t(r)}n.on("ready",function(){t(null,n)})}var i=e("./external/hosted-fields"),o=e("../lib/deferred"),s=e("../lib/error"),a=e("../errors"),c="3.0.0-beta.12";t.exports={create:r,VERSION:c}},{"../errors":7,"../lib/deferred":25,"../lib/error":28,"./external/hosted-fields":9}],12:[function(e,t,n){"use strict";var r=e("../../lib/enumerate"),i="3.0.0-beta.12",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","ADD_CLASS","REMOVE_CLASS","SET_PLACEHOLDER","CLEAR_FIELD"],"hosted-fields:"),t.exports=o},{"../../lib/enumerate":27}],13:[function(e,t,n){"use strict";var r=e("../../lib/error");t.exports={INVALID_FIELD_KEY:{type:r.types.MERCHANT,code:"INVALID_FIELD_KEY"},INVALID_FIELD_SELECTOR:{type:r.types.MERCHANT,code:"INVALID_FIELD_SELECTOR",message:"Selector does not reference a valid DOM node."},FIELD_DUPLICATE_IFRAME:{type:r.types.MERCHANT,code:"FIELD_DUPLICATE_IFRAME",message:"Element already contains a Braintree iframe."},INVALID_FIELD:{type:r.types.MERCHANT,code:"INVALID_FIELD"},FIELD_NOT_PRESENT:{type:r.types.MERCHANT,code:"FIELD_NOT_PRESENT"},TOKENIZATION_NETWORK_ERROR:{type:r.types.NETWORK,code:"TOKENIZATION_NETWORK_ERROR",message:"A tokenization network error occurred."},FAILED_HOSTED_FIELDS_TOKENIZATION:{type:r.types.CUSTOMER,code:"FAILED_HOSTED_FIELDS_TOKENIZATION",message:"The supplied card data failed tokenization."},FIELDS_EMPTY:{type:r.types.CUSTOMER,code:"FIELDS_EMPTY",message:"All fields are empty. Cannot tokenize empty card fields."},FIELDS_INVALID:{type:r.types.CUSTOMER,code:"FIELDS_INVALID",message:"Some payment input fields are invalid. Cannot tokenize invalid card fields."}}},{"../../lib/error":28}],14:[function(e,t,n){"use strict";function r(e,t){for(var n=e.parentNode,r=[];null!=n;)null!=n.tagName&&n.tagName.toLowerCase()===t&&r.push(n),n=n.parentNode;return r}t.exports=r},{}],15:[function(e,t,n){"use strict";function r(e,t){var n,r=t?o(t):{},a=i(e.authorization).attrs,c=o(e.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=e("./create-authorization-data"),o=e("./json-clone"),s=e("./constants");t.exports=r},{"./constants":22,"./create-authorization-data":24,"./json-clone":31}],16:[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,c=r(Date.now()),l=i.gatewayConfiguration.analytics.url,u={analytics:[{kind:t,timestamp:c}]};a({url:l,method:"post",data:s(i,u),timeout:o.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var o=e("./constants"),s=e("./add-metadata");t.exports={sendEvent:i}},{"./add-metadata":15,"./constants":22}],17:[function(e,t,n){"use strict";function r(e,t){var n=0===e.length;n?(e(),t(null)):e(t)}var i=e("./once");t.exports=function(e,t){function n(e){return e?void c(e):(a-=1,void(0===a&&c(null)))}var o,s=e.length,a=s,c=i(t);if(0===s)return void c(null);for(o=0;s>o;o++)r(e[o],n)}},{"./once":33}],18:[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}},{}],19:[function(e,t,n){"use strict";var r=e("../enumerate");t.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":27}],20:[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,code:"MISSING_CHANNEL_ID",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":28,"./check-origin":18,"./events":19,framebus:2}],21:[function(e,t,n){"use strict";function r(e){return e.className.trim().split(/\s+/)}function i(e){var t=Array.prototype.slice.call(arguments,1),n=r(e).filter(function(e){return-1===t.indexOf(e)}).concat(t).join(" ");e.className=n}function o(e){var t=Array.prototype.slice.call(arguments,1),n=r(e).filter(function(e){return-1===t.indexOf(e)}).join(" ");e.className=n}function s(e,t,n){n?i(e,t):o(e,t)}t.exports={add:i,remove:o,toggle:s}},{}],22:[function(e,t,n){"use strict";var r="3.0.0-beta.12",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}},{}],23:[function(e,t,n){"use strict";var r=e("./error"),i=e("../errors");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new r({type:i.METHOD_CALLED_AFTER_TEARDOWN.type,code:i.METHOD_CALLED_AFTER_TEARDOWN.code,message:t+" cannot be called after teardown."})}})}},{"../errors":7,"./error":28}],24:[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":34}],25:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],26:[function(e,t,n){"use strict";function r(){this._teardownRegistry=[],this._isTearingDown=!1}var i=e("./batch-execute-functions");r.prototype.registerFunctionForTeardown=function(e){"function"==typeof e&&this._teardownRegistry.push(e)},r.prototype.teardown=function(e){return this._isTearingDown?void e(new Error("Destructor is already tearing down")):(this._isTearingDown=!0,void i(this._teardownRegistry,function(t){this._teardownRegistry=[],this._isTearingDown=!1,"function"==typeof e&&e(t)}.bind(this)))},t.exports=r},{"./batch-execute-functions":17}],27:[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},{}],28:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":27}],29:[function(e,t,n){"use strict";function r(){this._events={}}r.prototype.on=function(e,t){this._events[e]?this._events[e].push(t):this._events[e]=[t]},r.prototype._emit=function(e){var t,n,r=this._events[e];if(r)for(n=Array.prototype.slice.call(arguments,1),t=0;t<r.length;t++)r[t].apply(null,n)},t.exports=r},{}],30:[function(e,t,n){"use strict";t.exports=function(e){return e=e||navigator.userAgent,/(iPad|iPhone|iPod)/i.test(e)}},{}],31:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],32:[function(e,t,n){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],33:[function(e,t,n){"use strict";function r(e){var t=!1;return function(){t||(t=!0,e.apply(null,arguments))}}t.exports=r},{}],34:[function(e,t,n){(function(e){"use strict";function n(e){var t,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+/=",d="";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++)),s=u.indexOf(e.charAt(c++)),a=u.indexOf(e.charAt(c++)),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(c<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:{})},{}],35:[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},{}]},{},[11])(11)}); | ||
!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={})).hostedFields=e()}}(function(){var e;return function t(e,n,r){function i(s,a){if(!n[s]){if(!e[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:{}};e[s][0].call(u.exports,function(t){var n=e[s][1][t];return i(n?n:t)},u,u.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(e,t,n){"use strict";function r(e){return JSON.parse(JSON.stringify(e))}var i=[{niceType:"Visa",type:"visa",pattern:"^4\\d*$",gaps:[4,8,12],lengths:[16],code:{name:"CVV",size:3}},{niceType:"MasterCard",type:"master-card",pattern:"^(5|5[1-5]\\d*|2|22|222|222[1-9]\\d*|2[3-6]\\d*|27[0-1]\\d*|2720\\d*)$",gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},{niceType:"American Express",type:"american-express",pattern:"^3([47]\\d*)?$",isAmex:!0,gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},{niceType:"Diners Club",type:"diners-club",pattern:"^3((0([0-5]\\d*)?)|[689]\\d*)?$",gaps:[4,10],lengths:[14],code:{name:"CVV",size:3}},{niceType:"Discover",type:"discover",pattern:"^6(0|01|011\\d*|5\\d*|4|4[4-9]\\d*)?$",gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},{niceType:"JCB",type:"jcb",pattern:"^((2|21|213|2131\\d*)|(1|18|180|1800\\d*)|(3|35\\d*))$",gaps:[4,8,12],lengths:[16],code:{name:"CVV",size:3}},{niceType:"UnionPay",type:"unionpay",pattern:"^6(2\\d*)?$",gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVN",size:3}},{niceType:"Maestro",type:"maestro",pattern:"^((5((0|[6-9])\\d*)?)|(6|6[37]\\d*))$",gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}}];t.exports=function(e){var t,n,o=[];if(!("string"==typeof e||e instanceof String))return o;if(""===e)return r(i);for(t=0;t<i.length;t++)n=i[t],RegExp(n.pattern).test(e)&&o.push(r(n));return o}},{}],2:[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:(T.push(e),!0)}function n(e){var t,n={};for(t in D)D.hasOwnProperty(t)&&(n[t]=D[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=c(e,n,r),t===!1?!1:(_(m.top,t,r),!0))}function i(e,t){var n=s(this);return I(e,t,n)?!1:(g[n]=g[n]||{},g[n][e]=g[n][e]||[],g[n][e].push(t),!0)}function o(e,t){var n,r,i=s(this);if(I(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 s(e){return e&&e._origin||"*"}function a(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=y(o,n),t=t.slice(0,-1)),i.args=t;try{r=O+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,O.length)!==O)return!1;try{t=JSON.parse(e.data.slice(O.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){m||(m=t||e,m.addEventListener?m.addEventListener("message",f,!1):m.attachEvent?m.attachEvent("onmessage",f):null===m.onmessage?m.onmessage=f:m=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 f(e){var t;a(e.data)||(t=l(e),t&&(p("*",t.event,t.args,e),p(e.origin,t.event,t.args,e),h(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 E(e){return e.top!==e?!1:null==e.opener?!1:e.opener===e?!1:e.opener.closed===!0?!1:!0}function _(e,t,n){var r;try{for(e.postMessage(t,n),E(e)&&_(e.opener.top,t,n),r=0;r<e.frames.length;r++)_(e.frames[r],t,n)}catch(i){}}function h(e,t,n){var r,i;for(r=T.length-1;r>=0;r--)i=T[r],i.closed===!0?T=T.slice(r,1):n!==i&&_(i.top,e,t)}function y(e,t){function n(i,o){e(i,o),D.target(t).unsubscribe(r,n)}var r=d();return D.target(t).subscribe(r,n),r}function I(e,t,n){return a(e)?!0:"function"!=typeof t?!0:a(n)?!0:!1}var m,D,T=[],g={},O="/*framebus*/";return u(),D={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:{})},{}],3:[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":4,"./lib/default-attributes":5,"./lib/set-attributes":6}],4:[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}},{}],5:[function(e,t,n){t.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],6:[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))}},{}],7:[function(e,t,n){"use strict";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":28}],8:[function(e,t,n){"use strict";var r=e("../shared/constants");t.exports=function(e,t){return e+"/web/"+r.VERSION+"/html/hosted-fields-frame.min.html#"+t}},{"../shared/constants":12}],9:[function(e,t,n){"use strict";function r(e){return function(t){var n,r=t.merchantPayload,i=r.emittedBy,o=e[i].containerElement;Object.keys(r.fields).forEach(function(t){r.fields[t].container=e[t].containerElement}),n=r.fields[i],s.toggle(o,d.externalClasses.FOCUSED,n.isFocused),s.toggle(o,d.externalClasses.VALID,n.isValid),s.toggle(o,d.externalClasses.INVALID,!n.isPotentiallyValid),this._state={cards:r.cards,fields:r.fields},this._emit(t.type,r)}}function i(e){var t,n,_=this,h={},T=0,L=E();if(!e.client)throw new l({type:N.INSTANTIATION_OPTION_REQUIRED.type,code:N.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating Hosted Fields."});if(n=e.client.getConfiguration().analyticsMetadata.sdkVersion,n!==g)throw new l({type:N.INCOMPATIBLE_VERSIONS.type,code:N.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+n+") and Hosted Fields (version "+g+") components must be from the same SDK version."});if(!e.fields)throw new l({type:N.INSTANTIATION_OPTION_REQUIRED.type,code:N.INSTANTIATION_OPTION_REQUIRED.code,message:"options.fields is required when instantiating Hosted Fields."});I.call(this),this._injectedNodes=[],this._destructor=new o,this._fields=h,this._state={fields:{},cards:v("")},this._bus=new c({channel:L,merchantUrl:location.href}),this._destructor.registerFunctionForTeardown(function(){_._bus.teardown()}),this._client=e.client,D.sendEvent(this._client,"web.custom.hosted-fields.initialized"),Object.keys(e.fields).forEach(function(t){var n,r,i;if(!d.whitelistedFields.hasOwnProperty(t))throw new l({type:f.HOSTED_FIELDS_INVALID_FIELD_KEY.type,code:f.HOSTED_FIELDS_INVALID_FIELD_KEY.code,message:'"'+t+'" is not a valid field.'});if(n=e.fields[t],r=document.querySelector(n.selector),!r)throw new l({type:f.HOSTED_FIELDS_INVALID_FIELD_SELECTOR.type,code:f.HOSTED_FIELDS_INVALID_FIELD_SELECTOR.code,message:f.HOSTED_FIELDS_INVALID_FIELD_SELECTOR.message,details:{fieldSelector:n.selector,fieldKey:t}});if(r.querySelector('iframe[name^="braintree-"]'))throw new l({type:f.HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME.type,code:f.HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME.code,message:f.HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME.message,details:{fieldSelector:n.selector,fieldKey:t}});i=a({type:t,name:"braintree-hosted-field-"+t,style:d.defaultIFrameStyle}),this._injectedNodes=this._injectedNodes.concat(m(i,r)),this._setupLabelFocus(t,r),h[t]={frameElement:i,containerElement:r},T++,this._state.fields[t]={isEmpty:!0,isValid:!1,isPotentiallyValid:!0,isFocused:!1,container:r},setTimeout(function(){i.src=u(_._client.getConfiguration().gatewayConfiguration.assetsUrl,L)},0)}.bind(this)),t=setTimeout(function(){D.sendEvent(_._client,"web.custom.hosted-fields.load.timed-out")},p),this._bus.on(y.FRAME_READY,function(n){T--,0===T&&(clearTimeout(t),n(e),_._emit("ready"))}),this._bus.on(y.INPUT_EVENT,r(h).bind(this)),this._destructor.registerFunctionForTeardown(function(){var e,t,n;for(e=0;e<_._injectedNodes.length;e++)t=_._injectedNodes[e],n=t.parentNode,n.removeChild(t),s.remove(n,d.externalClasses.FOCUSED,d.externalClasses.INVALID,d.externalClasses.VALID)}),this._destructor.registerFunctionForTeardown(function(){var e=O(i.prototype).concat(O(I.prototype));S(_,e)})}var o=e("../../lib/destructor"),s=e("../../lib/classlist"),a=e("iframer"),c=e("../../lib/bus"),l=e("../../lib/error"),u=e("./compose-url"),d=e("../shared/constants"),f=e("../shared/errors"),p=e("../../lib/constants").INTEGRATION_TIMEOUT_MS,E=e("../../lib/uuid"),_=e("../shared/find-parent-tags"),h=e("../../lib/is-ios"),y=d.events,I=e("../../lib/event-emitter"),m=e("./inject-frame"),D=e("../../lib/analytics"),T=d.whitelistedFields,g="3.0.0",O=e("../../lib/methods"),S=e("../../lib/convert-methods-to-error"),L=e("../../lib/deferred"),N=e("../../errors"),v=e("credit-card-type");i.prototype=Object.create(I.prototype,{constructor:i}),i.prototype._setupLabelFocus=function(e,t){function n(){s.emit(y.TRIGGER_INPUT_FOCUS,e)}var r,i,o=h(),s=this._bus;if(!o&&null!=t.id){for(r=Array.prototype.slice.call(document.querySelectorAll('label[for="'+t.id+'"]')),r=r.concat(_(t,"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(e){var t=this._client;this._destructor.teardown(function(n){D.sendEvent(t,"web.custom.hosted-fields.teardown-completed"),"function"==typeof e&&(e=L(e))(n)})},i.prototype.tokenize=function(e,t){if(t||(t=e,e={}),"function"!=typeof t)throw new l({type:N.CALLBACK_REQUIRED.type,code:N.CALLBACK_REQUIRED.code,message:"tokenize must include a callback function."});this._bus.emit(y.TOKENIZATION_REQUEST,e,function(e){t.apply(null,e)})},i.prototype.addClass=function(e,t,n){var r;T.hasOwnProperty(e)?this._fields.hasOwnProperty(e)?this._bus.emit(y.ADD_CLASS,e,t):r=new l({type:f.HOSTED_FIELDS_FIELD_NOT_PRESENT.type,code:f.HOSTED_FIELDS_FIELD_NOT_PRESENT.code,message:'Cannot add class to "'+e+'" field because it is not part of the current Hosted Fields options.'}):r=new l({type:f.HOSTED_FIELDS_FIELD_INVALID.type,code:f.HOSTED_FIELDS_FIELD_INVALID.code,message:'"'+e+'" is not a valid field. You must use a valid field option when adding a class.'}),"function"==typeof n&&(n=L(n))(r)},i.prototype.removeClass=function(e,t,n){var r;T.hasOwnProperty(e)?this._fields.hasOwnProperty(e)?this._bus.emit(y.REMOVE_CLASS,e,t):r=new l({type:f.HOSTED_FIELDS_FIELD_NOT_PRESENT.type,code:f.HOSTED_FIELDS_FIELD_NOT_PRESENT.code,message:'Cannot remove class from "'+e+'" field because it is not part of the current Hosted Fields options.'}):r=new l({type:f.HOSTED_FIELDS_FIELD_INVALID.type,code:f.HOSTED_FIELDS_FIELD_INVALID.code,message:'"'+e+'" is not a valid field. You must use a valid field option when removing a class.'}),"function"==typeof n&&(n=L(n))(r)},i.prototype.setPlaceholder=function(e,t,n){var r;T.hasOwnProperty(e)?this._fields.hasOwnProperty(e)?this._bus.emit(y.SET_PLACEHOLDER,e,t):r=new l({type:f.HOSTED_FIELDS_FIELD_NOT_PRESENT.type,code:f.HOSTED_FIELDS_FIELD_NOT_PRESENT.code,message:'Cannot set placeholder for "'+e+'" field because it is not part of the current Hosted Fields options.'}):r=new l({type:f.HOSTED_FIELDS_FIELD_INVALID.type,code:f.HOSTED_FIELDS_FIELD_INVALID.code,message:'"'+e+'" is not a valid field. You must use a valid field option when setting a placeholder.'}),"function"==typeof n&&(n=L(n))(r)},i.prototype.clear=function(e,t){var n;T.hasOwnProperty(e)?this._fields.hasOwnProperty(e)?this._bus.emit(y.CLEAR_FIELD,e):n=new l({type:f.HOSTED_FIELDS_FIELD_NOT_PRESENT.type,code:f.HOSTED_FIELDS_FIELD_NOT_PRESENT.code,message:'Cannot clear "'+e+'" field because it is not part of the current Hosted Fields options.'}):n=new l({type:f.HOSTED_FIELDS_FIELD_INVALID.type,code:f.HOSTED_FIELDS_FIELD_INVALID.code,message:'"'+e+'" is not a valid field. You must use a valid field option when clearing a field.'}),"function"==typeof t&&(t=L(t))(n)},i.prototype.getState=function(){return this._state},t.exports=i},{"../../errors":7,"../../lib/analytics":16,"../../lib/bus":20,"../../lib/classlist":21,"../../lib/constants":22,"../../lib/convert-methods-to-error":23,"../../lib/deferred":25,"../../lib/destructor":26,"../../lib/error":28,"../../lib/event-emitter":29,"../../lib/is-ios":30,"../../lib/methods":33,"../../lib/uuid":36,"../shared/constants":12,"../shared/errors":13,"../shared/find-parent-tags":14,"./compose-url":8,"./inject-frame":10,"credit-card-type":1,iframer:3}],10:[function(e,t,n){"use strict";t.exports=function(e,t){var n=document.createElement("div"),r=document.createDocumentFragment();return n.style.clear="both",r.appendChild(e),r.appendChild(n),t.appendChild(r),[e,n]}},{}],11:[function(e,t,n){"use strict";function r(e,t){var n;if("function"!=typeof t)throw new s({type:a.CALLBACK_REQUIRED.type,code:a.CALLBACK_REQUIRED.code,message:"create must include a callback function."});try{n=new i(e)}catch(r){return t=o(t),void t(r)}n.on("ready",function(){t(null,n)})}var i=e("./external/hosted-fields"),o=e("../lib/deferred"),s=e("../lib/error"),a=e("../errors"),c="3.0.0";t.exports={create:r,VERSION:c}},{"../errors":7,"../lib/deferred":25,"../lib/error":28,"./external/hosted-fields":9}],12:[function(e,t,n){"use strict";var r=e("../../lib/enumerate"),i="3.0.0",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","ADD_CLASS","REMOVE_CLASS","SET_PLACEHOLDER","CLEAR_FIELD"],"hosted-fields:"),t.exports=o},{"../../lib/enumerate":27}],13:[function(e,t,n){"use strict";var r=e("../../lib/error");t.exports={HOSTED_FIELDS_INVALID_FIELD_KEY:{type:r.types.MERCHANT,code:"HOSTED_FIELDS_INVALID_FIELD_KEY"},HOSTED_FIELDS_INVALID_FIELD_SELECTOR:{type:r.types.MERCHANT,code:"HOSTED_FIELDS_INVALID_FIELD_SELECTOR",message:"Selector does not reference a valid DOM node."},HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME:{type:r.types.MERCHANT,code:"HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME",message:"Element already contains a Braintree iframe."},HOSTED_FIELDS_FIELD_INVALID:{type:r.types.MERCHANT,code:"HOSTED_FIELDS_FIELD_INVALID"},HOSTED_FIELDS_FIELD_NOT_PRESENT:{type:r.types.MERCHANT,code:"HOSTED_FIELDS_FIELD_NOT_PRESENT"},HOSTED_FIELDS_TOKENIZATION_NETWORK_ERROR:{type:r.types.NETWORK,code:"HOSTED_FIELDS_TOKENIZATION_NETWORK_ERROR",message:"A tokenization network error occurred."},HOSTED_FIELDS_FAILED_TOKENIZATION:{type:r.types.CUSTOMER,code:"HOSTED_FIELDS_FAILED_TOKENIZATION",message:"The supplied card data failed tokenization."},HOSTED_FIELDS_FIELDS_EMPTY:{type:r.types.CUSTOMER,code:"HOSTED_FIELDS_FIELDS_EMPTY",message:"All fields are empty. Cannot tokenize empty card fields."},HOSTED_FIELDS_FIELDS_INVALID:{type:r.types.CUSTOMER,code:"HOSTED_FIELDS_FIELDS_INVALID",message:"Some payment input fields are invalid. Cannot tokenize invalid card fields."}}},{"../../lib/error":28}],14:[function(e,t,n){"use strict";function r(e,t){for(var n=e.parentNode,r=[];null!=n;)null!=n.tagName&&n.tagName.toLowerCase()===t&&r.push(n),n=n.parentNode;return r}t.exports=r},{}],15:[function(e,t,n){"use strict";function r(e,t){var n,r=t?o(t):{},a=i(e.authorization).attrs,c=o(e.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=e("./create-authorization-data"),o=e("./json-clone"),s=e("./constants");t.exports=r},{"./constants":22,"./create-authorization-data":24,"./json-clone":32}],16:[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,c=r(Date.now()),l=i.gatewayConfiguration.analytics.url,u={analytics:[{kind:t,timestamp:c}]};a({url:l,method:"post",data:s(i,u),timeout:o.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var o=e("./constants"),s=e("./add-metadata");t.exports={sendEvent:i}},{"./add-metadata":15,"./constants":22}],17:[function(e,t,n){"use strict";function r(e,t){var n=0===e.length;n?(e(),t(null)):e(t)}var i=e("./once");t.exports=function(e,t){function n(e){return e?void c(e):(a-=1,void(0===a&&c(null)))}var o,s=e.length,a=s,c=i(t);if(0===s)return void c(null);for(o=0;s>o;o++)r(e[o],n)}},{"./once":34}],18:[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?!0:(o.href=e,i(e)&&"localhost"!==o.hostname)}var i=e("../is-whitelisted-domain");t.exports={checkOrigin:r}},{"../is-whitelisted-domain":31}],19:[function(e,t,n){"use strict";var r=e("../enumerate");t.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":27}],20:[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,code:"MISSING_CHANNEL_ID",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":28,"./check-origin":18,"./events":19,framebus:2}],21:[function(e,t,n){"use strict";function r(e){return e.className.trim().split(/\s+/)}function i(e){var t=Array.prototype.slice.call(arguments,1),n=r(e).filter(function(e){return-1===t.indexOf(e)}).concat(t).join(" ");e.className=n}function o(e){var t=Array.prototype.slice.call(arguments,1),n=r(e).filter(function(e){return-1===t.indexOf(e)}).join(" ");e.className=n}function s(e,t,n){n?i(e,t):o(e,t)}t.exports={add:i,remove:o,toggle:s}},{}],22:[function(e,t,n){"use strict";var r="3.0.0",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}},{}],23:[function(e,t,n){"use strict";var r=e("./error"),i=e("../errors");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new r({type:i.METHOD_CALLED_AFTER_TEARDOWN.type,code:i.METHOD_CALLED_AFTER_TEARDOWN.code,message:t+" cannot be called after teardown."})}})}},{"../errors":7,"./error":28}],24:[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":35}],25:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],26:[function(e,t,n){"use strict";function r(){this._teardownRegistry=[],this._isTearingDown=!1}var i=e("./batch-execute-functions");r.prototype.registerFunctionForTeardown=function(e){"function"==typeof e&&this._teardownRegistry.push(e)},r.prototype.teardown=function(e){return this._isTearingDown?void e(new Error("Destructor is already tearing down")):(this._isTearingDown=!0,void i(this._teardownRegistry,function(t){this._teardownRegistry=[],this._isTearingDown=!1,"function"==typeof e&&e(t)}.bind(this)))},t.exports=r},{"./batch-execute-functions":17}],27:[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},{}],28:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":27}],29:[function(e,t,n){"use strict";function r(){this._events={}}r.prototype.on=function(e,t){this._events[e]?this._events[e].push(t):this._events[e]=[t]},r.prototype._emit=function(e){var t,n,r=this._events[e];if(r)for(n=Array.prototype.slice.call(arguments,1),t=0;t<r.length;t++)r[t].apply(null,n)},t.exports=r},{}],30:[function(e,t,n){"use strict";t.exports=function(e){return e=e||navigator.userAgent,/(iPad|iPhone|iPod)/i.test(e)}},{}],31:[function(e,t,n){"use strict";function r(e){return e.split(".").slice(-2).join(".")}function i(e){var t;return e=e.toLowerCase(),/^https:/.test(e)?(o=o||document.createElement("a"),o.href=e,t=r(o.hostname),s.hasOwnProperty(t)):!1}var o,s={"paypal.com":1,"braintreepayments.com":1,"braintreegateway.com":1,localhost:1};t.exports=i},{}],32:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],33:[function(e,t,n){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],34:[function(e,t,n){"use strict";function r(e){var t=!1;return function(){t||(t=!0,e.apply(null,arguments))}}t.exports=r},{}],35:[function(e,t,n){(function(e){"use strict";function n(e){var t,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+/=",d="";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++)),s=u.indexOf(e.charAt(c++)),a=u.indexOf(e.charAt(c++)),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(c<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:{})},{}],36:[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},{}]},{},[11])(11)}); |
@@ -20,3 +20,3 @@ 'use strict'; | ||
applePay: applePay, | ||
VERSION: '3.0.0-beta.12' | ||
VERSION: '3.0.0' | ||
}; |
{ | ||
"name": "braintree-web", | ||
"description": "A suite of tools for integrating Braintree in the browser", | ||
"version": "3.0.0-beta.12", | ||
"version": "3.0.0", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -406,3 +406,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 = {})).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){ | ||
},{"./constants":13,"./create-authorization-data":15,"./json-clone":28}],8:[function(_dereq_,module,exports){ | ||
},{"./constants":13,"./create-authorization-data":15,"./json-clone":29}],8:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -449,3 +449,3 @@ | ||
ua = ua || global.navigator.userAgent; | ||
return ua.indexOf('Android') > -1 && ua.indexOf('Firefox') > -1; | ||
return isAndroid(ua) && ua.indexOf('Firefox') > -1; | ||
} | ||
@@ -467,6 +467,46 @@ | ||
protocol = protocol || global.location.protocol; | ||
return protocol === 'https:'; | ||
} | ||
function isIos(ua) { | ||
ua = ua || global.navigator.userAgent; | ||
return /iPhone|iPod|iPad/.test(ua); | ||
} | ||
function isAndroid(ua) { | ||
ua = ua || global.navigator.userAgent; | ||
return /Android/.test(ua); | ||
} | ||
function supportsPopups(ua) { | ||
ua = ua || global.navigator.userAgent; | ||
return !(isIosWebview(ua) || isAndroidWebview(ua) || isOperaMini(ua)); | ||
} | ||
// The Google Search iOS app is technically a webview and doesn't support popups. | ||
function isGoogleSearchApp(ua) { | ||
return /\bGSA\b/.test(ua); | ||
} | ||
function isIosWebview(ua) { | ||
ua = ua || global.navigator.userAgent; | ||
if (isIos(ua)) { | ||
if (isGoogleSearchApp(ua)) { | ||
return true; | ||
} | ||
return /.+AppleWebKit(?!.*Safari)/.test(ua); | ||
} | ||
return false; | ||
} | ||
function isAndroidWebview(ua) { | ||
var androidWebviewRegExp = /Version\/[\d\.]+/; | ||
ua = ua || global.navigator.userAgent; | ||
if (isAndroid(ua)) { | ||
return androidWebviewRegExp.test(ua) && !isOperaMini(ua); | ||
} | ||
return false; | ||
} | ||
module.exports = { | ||
@@ -476,3 +516,6 @@ isOperaMini: isOperaMini, | ||
getIEVersion: getIEVersion, | ||
isHTTPS: isHTTPS | ||
isHTTPS: isHTTPS, | ||
isIos: isIos, | ||
isAndroid: isAndroid, | ||
supportsPopups: supportsPopups | ||
}; | ||
@@ -484,3 +527,3 @@ | ||
var BT_ORIGIN_REGEX = /^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/; | ||
var isWhitelistedDomain = _dereq_('../is-whitelisted-domain'); | ||
@@ -503,3 +546,7 @@ function checkOrigin(postMessageOrigin, merchantUrl) { | ||
return merchantOrigin === postMessageOrigin || BT_ORIGIN_REGEX.test(postMessageOrigin); | ||
if (merchantOrigin === postMessageOrigin) { return true; } | ||
a.href = postMessageOrigin; | ||
return isWhitelistedDomain(postMessageOrigin) && a.hostname !== 'localhost'; | ||
} | ||
@@ -511,3 +558,3 @@ | ||
},{}],11:[function(_dereq_,module,exports){ | ||
},{"../is-whitelisted-domain":28}],11:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -655,3 +702,3 @@ | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
var PLATFORM = 'web'; | ||
@@ -736,3 +783,3 @@ | ||
},{"../lib/polyfill":31}],16:[function(_dereq_,module,exports){ | ||
},{"../lib/polyfill":32}],16:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -973,3 +1020,3 @@ | ||
if (this._onCompleteCallback) { | ||
this._onCompleteCallback(new BraintreeError(errors.FRAME_CLOSED)); | ||
this._onCompleteCallback(new BraintreeError(errors.FRAME_SERVICE_FRAME_CLOSED)); | ||
} | ||
@@ -984,3 +1031,3 @@ } | ||
},{"../../bus":12,"../../error":18,"../../uuid":33,"../shared/constants":25,"../shared/errors":26,"../shared/events":27,"./popup":22,"iframer":2}],20:[function(_dereq_,module,exports){ | ||
},{"../../bus":12,"../../error":18,"../../uuid":34,"../shared/constants":25,"../shared/errors":26,"../shared/events":27,"./popup":22,"iframer":2}],20:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1070,3 +1117,2 @@ | ||
// TODO: May be dependent on payment method in the future | ||
var POPUP_HEIGHT = 535; | ||
@@ -1090,5 +1136,5 @@ var POPUP_WIDTH = 450; | ||
module.exports = { | ||
FRAME_CLOSED: { | ||
type: BraintreeError.types.CUSTOMER, | ||
code: 'FRAME_CLOSED', | ||
FRAME_SERVICE_FRAME_CLOSED: { | ||
type: BraintreeError.types.INTERNAL, | ||
code: 'FRAME_SERVICE_FRAME_CLOSED', | ||
message: 'Frame closed before tokenization could occur.' | ||
@@ -1111,2 +1157,37 @@ } | ||
var parser; | ||
var legalHosts = { | ||
'paypal.com': 1, | ||
'braintreepayments.com': 1, | ||
'braintreegateway.com': 1, | ||
localhost: 1 | ||
}; | ||
/* eslint-enable no-undef,block-scoped-var */ | ||
function stripSubdomains(domain) { | ||
return domain.split('.').slice(-2).join('.'); | ||
} | ||
function isWhitelistedDomain(url) { | ||
var mainDomain; | ||
url = url.toLowerCase(); | ||
if (!/^https:/.test(url)) { | ||
return false; | ||
} | ||
parser = parser || document.createElement('a'); | ||
parser.href = url; | ||
mainDomain = stripSubdomains(parser.hostname); | ||
return legalHosts.hasOwnProperty(mainDomain); | ||
} | ||
module.exports = isWhitelistedDomain; | ||
},{}],29:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
module.exports = function (value) { | ||
@@ -1116,3 +1197,3 @@ return JSON.parse(JSON.stringify(value)); | ||
},{}],29:[function(_dereq_,module,exports){ | ||
},{}],30:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1126,3 +1207,3 @@ | ||
},{}],30:[function(_dereq_,module,exports){ | ||
},{}],31:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1143,3 +1224,3 @@ | ||
},{}],31:[function(_dereq_,module,exports){ | ||
},{}],32:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -1183,3 +1264,3 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],32:[function(_dereq_,module,exports){ | ||
},{}],33:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -1275,3 +1356,3 @@ 'use strict'; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],33:[function(_dereq_,module,exports){ | ||
},{}],34:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1290,10 +1371,9 @@ | ||
},{}],34:[function(_dereq_,module,exports){ | ||
},{}],35:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var frameService = _dereq_('../../lib/frame-service/external'); | ||
var frameServiceErrors = _dereq_('../../lib/frame-service/shared/errors'); | ||
var BraintreeError = _dereq_('../../lib/error'); | ||
var once = _dereq_('../../lib/once'); | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
var constants = _dereq_('../shared/constants'); | ||
@@ -1305,3 +1385,2 @@ var INTEGRATION_TIMEOUT_MS = _dereq_('../../lib/constants').INTEGRATION_TIMEOUT_MS; | ||
var errors = _dereq_('../shared/errors'); | ||
var getCountry = _dereq_('../shared/get-country'); | ||
var convertMethodsToError = _dereq_('../../lib/convert-methods-to-error'); | ||
@@ -1376,6 +1455,6 @@ var querystring = _dereq_('../../lib/querystring'); | ||
/** | ||
* Launches the PayPal login flow and returns a nonce payload. | ||
* Launches the PayPal login flow and returns a nonce payload. Only one PayPal login flow should be active at a time. One way to achieve this is to disable your PayPal button while the flow is open. | ||
* @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.flow Set to 'checkout' for one-time payment flow, or 'vault' for Vault flow. If 'vault' is used with a client token generated with a customer id, the PayPal account will be added to that customer as a saved payment method. | ||
* @param {string} [options.intent=authorize] | ||
@@ -1395,3 +1474,3 @@ * Checkout flows only. | ||
* @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 {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}. | ||
@@ -1412,2 +1491,5 @@ * @param {object} [options.shippingAddressOverride] Allows you to pass a shipping address you have already collected into the PayPal payment flow. | ||
* button.addEventListener('click', function () { | ||
* // Disable the button so that we don't attempt to open multiple popups. | ||
* button.setAttribute('disabled', 'disabled'); | ||
* | ||
* // Because PayPal tokenization opens a popup, this must be called | ||
@@ -1419,7 +1501,23 @@ * // as a result of a user action, such as a button click. | ||
* }, function (tokenizeErr, payload) { | ||
* button.removeAttribute('disabled'); | ||
* | ||
* if (tokenizeErr) { | ||
* // Handle tokenization errors or premature flow closure | ||
* return; | ||
* | ||
* switch (tokenizeErr.code) { | ||
* case 'PAYPAL_POPUP_CLOSED': | ||
* console.error('Customer closed PayPal popup.'); | ||
* break; | ||
* case 'PAYPAL_ACCOUNT_TOKENIZATION_FAILED': | ||
* console.error('PayPal tokenization failed. See details:', tokenizeErr.details); | ||
* break; | ||
* case 'PAYPAL_FLOW_FAILED': | ||
* console.error('Unable to initialize PayPal flow. Are your options correct?', tokenizeErr.details); | ||
* break; | ||
* default: | ||
* console.error('Error!', tokenizeErr); | ||
* } | ||
* } else { | ||
* // Submit payload.nonce to your server | ||
* } | ||
* // Submit payload.nonce to your server | ||
* }); | ||
@@ -1445,3 +1543,3 @@ * }); | ||
callback(new BraintreeError(errors.TOKENIZATION_REQUEST_ACTIVE)); | ||
callback(new BraintreeError(errors.PAYPAL_TOKENIZATION_REQUEST_ACTIVE)); | ||
} else { | ||
@@ -1471,7 +1569,7 @@ this._authorizationInProgress = true; | ||
if (err) { | ||
if (err.code === frameServiceErrors.FRAME_CLOSED.code) { | ||
if (err.code === 'FRAME_SERVICE_FRAME_CLOSED') { | ||
analytics.sendEvent(client, 'web.paypal.tokenization.closed.by-user'); | ||
} | ||
callback(new BraintreeError(err)); | ||
callback(new BraintreeError(errors.PAYPAL_POPUP_CLOSED)); | ||
} else { | ||
@@ -1494,6 +1592,8 @@ this._tokenizePayPal(options, params, callback); | ||
callback(err instanceof BraintreeError ? err : new BraintreeError({ | ||
type: errors.ACCOUNT_TOKENIZATION_FAILED.type, | ||
code: errors.ACCOUNT_TOKENIZATION_FAILED.code, | ||
message: errors.ACCOUNT_TOKENIZATION_FAILED.message, | ||
details: err | ||
type: errors.PAYPAL_ACCOUNT_TOKENIZATION_FAILED.type, | ||
code: errors.PAYPAL_ACCOUNT_TOKENIZATION_FAILED.code, | ||
message: errors.PAYPAL_ACCOUNT_TOKENIZATION_FAILED.message, | ||
details: { | ||
originalError: err | ||
} | ||
})); | ||
@@ -1531,3 +1631,8 @@ } else { | ||
var data = { | ||
paypalAccount: {correlationId: this._frameService._serviceId} | ||
paypalAccount: { | ||
correlationId: this._frameService._serviceId, | ||
options: { | ||
validate: options.flow === 'vault' | ||
} | ||
} | ||
}; | ||
@@ -1567,12 +1672,25 @@ | ||
data: this._formatPaymentResourceData(options) | ||
}, function (err, response) { | ||
}, function (err, response, status) { | ||
var redirectUrl; | ||
if (err) { | ||
callback(err instanceof BraintreeError ? err : new BraintreeError({ | ||
type: errors.PAYPAL_FLOW_FAILED.type, | ||
code: errors.PAYPAL_FLOW_FAILED.code, | ||
message: errors.PAYPAL_FLOW_FAILED.message, | ||
details: err | ||
})); | ||
if (status === 422) { | ||
callback(new BraintreeError({ | ||
type: errors.PAYPAL_INVALID_PAYMENT_OPTION.type, | ||
code: errors.PAYPAL_INVALID_PAYMENT_OPTION.code, | ||
message: errors.PAYPAL_INVALID_PAYMENT_OPTION.message, | ||
details: { | ||
originalError: err | ||
} | ||
})); | ||
} else { | ||
callback(err instanceof BraintreeError ? err : new BraintreeError({ | ||
type: errors.PAYPAL_FLOW_FAILED.type, | ||
code: errors.PAYPAL_FLOW_FAILED.code, | ||
message: errors.PAYPAL_FLOW_FAILED.message, | ||
details: { | ||
originalError: err | ||
} | ||
})); | ||
} | ||
this._frameService.close(); | ||
@@ -1605,3 +1723,3 @@ } else { | ||
brandName: options.displayName || gatewayConfiguration.paypal.displayName, | ||
localeCode: getCountry(options.locale), | ||
localeCode: options.locale, | ||
noShipping: (!options.enableShippingAddress).toString(), | ||
@@ -1613,3 +1731,3 @@ addressOverride: options.shippingAddressEditable === false | ||
if (options.flow === 'checkout') { | ||
paymentResource.amount = parseFloat(options.amount).toFixed(2); | ||
paymentResource.amount = options.amount; | ||
paymentResource.currencyIsoCode = options.currency; | ||
@@ -1659,3 +1777,3 @@ paymentResource.offerPaypalCredit = options.offerCredit === true; | ||
},{"../../errors":6,"../../lib/analytics":8,"../../lib/constants":13,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/frame-service/external":20,"../../lib/frame-service/shared/errors":26,"../../lib/methods":29,"../../lib/once":30,"../../lib/querystring":32,"../shared/constants":36,"../shared/errors":37,"../shared/get-country":38}],35:[function(_dereq_,module,exports){ | ||
},{"../../errors":6,"../../lib/analytics":8,"../../lib/constants":13,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/frame-service/external":20,"../../lib/methods":30,"../../lib/once":31,"../../lib/querystring":33,"../shared/constants":37,"../shared/errors":38}],36:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1671,3 +1789,3 @@ /** @module braintree-web/paypal */ | ||
var sharedErrors = _dereq_('../errors'); | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
@@ -1685,3 +1803,7 @@ /** | ||
* if (createErr) { | ||
* // Handle any creation errors here | ||
* if (createErr.code === 'PAYPAL_BROWSER_NOT_SUPPORTED') { | ||
* console.error('This browser is not supported.'); | ||
* } else { | ||
* console.error('Error!', createErr); | ||
* } | ||
* } | ||
@@ -1730,4 +1852,4 @@ * } | ||
if (!_isBrowserSupported()) { | ||
callback(new BraintreeError(errors.BROWSER_NOT_SUPPORTED)); | ||
if (!browserDetection.supportsPopups()) { | ||
callback(new BraintreeError(errors.PAYPAL_BROWSER_NOT_SUPPORTED)); | ||
return; | ||
@@ -1744,6 +1866,2 @@ } | ||
function _isBrowserSupported() { | ||
return !browserDetection.isOperaMini(); | ||
} | ||
module.exports = { | ||
@@ -1758,3 +1876,3 @@ create: create, | ||
},{"../errors":6,"../lib/analytics":8,"../lib/browser-detection":9,"../lib/deferred":16,"../lib/error":18,"./external/paypal":34,"./shared/errors":37}],36:[function(_dereq_,module,exports){ | ||
},{"../errors":6,"../lib/analytics":8,"../lib/browser-detection":9,"../lib/deferred":16,"../lib/error":18,"./external/paypal":35,"./shared/errors":38}],37:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1774,3 +1892,3 @@ | ||
},{}],37:[function(_dereq_,module,exports){ | ||
},{}],38:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1786,10 +1904,10 @@ | ||
}, | ||
TOKENIZATION_REQUEST_ACTIVE: { | ||
PAYPAL_TOKENIZATION_REQUEST_ACTIVE: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'TOKENIZATION_REQUEST_ACTIVE', | ||
code: 'PAYPAL_TOKENIZATION_REQUEST_ACTIVE', | ||
message: 'Another tokenization request is active.' | ||
}, | ||
ACCOUNT_TOKENIZATION_FAILED: { | ||
PAYPAL_ACCOUNT_TOKENIZATION_FAILED: { | ||
type: BraintreeError.types.NETWORK, | ||
code: 'ACCOUNT_TOKENIZATION_FAILED', | ||
code: 'PAYPAL_ACCOUNT_TOKENIZATION_FAILED', | ||
message: 'Could not tokenize user\'s PayPal account.' | ||
@@ -1807,60 +1925,20 @@ }, | ||
}, | ||
BROWSER_NOT_SUPPORTED: { | ||
PAYPAL_BROWSER_NOT_SUPPORTED: { | ||
type: BraintreeError.types.CUSTOMER, | ||
code: 'BROWSER_NOT_SUPPORTED', | ||
code: 'PAYPAL_BROWSER_NOT_SUPPORTED', | ||
message: 'Browser is not supported.' | ||
}, | ||
PAYPAL_POPUP_CLOSED: { | ||
type: BraintreeError.types.CUSTOMER, | ||
code: 'PAYPAL_POPUP_CLOSED', | ||
message: 'Customer closed PayPal popup before authorizing.' | ||
}, | ||
PAYPAL_INVALID_PAYMENT_OPTION: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'PAYPAL_INVALID_PAYMENT_OPTION', | ||
message: 'PayPal payment options are invalid.' | ||
} | ||
}; | ||
},{"../../lib/error":18}],38:[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; | ||
},{}]},{},[35])(35) | ||
},{"../../lib/error":18}]},{},[36])(36) | ||
}); |
@@ -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={})).paypal=e()}}(function(){var e;return function t(e,n,r){function o(a,s){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(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 o(n?n:t)},u,u.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,n,r){(function(t){"use strict";!function(o,i){"object"==typeof r&&"undefined"!=typeof n?n.exports=i("undefined"==typeof t?o:t):"function"==typeof e&&e.amd?e([],function(){return i(o)}):o.framebus=i(o)}(this,function(e){function t(e){return null==e?!1:null==e.Window?!1:e.constructor!==e.Window?!1:(b.push(e),!0)}function n(e){var t,n={};for(t in g)g.hasOwnProperty(t)&&(n[t]=g[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:(_(A.top,t,r),!0))}function o(e,t){var n=a(this);return E(e,t,n)?!1:(v[n]=v[n]||{},v[n][e]=v[n][e]||[],v[n][e].push(t),!0)}function i(e,t){var n,r,o=a(this);if(E(e,t,o))return!1;if(r=v[o]&&v[o][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,o={event:e,origin:n},i=t[t.length-1];"function"==typeof i&&(o.reply=m(i,n),t=t.slice(0,-1)),o.args=t;try{r=O+JSON.stringify(o)}catch(a){throw new Error("Could not stringify event: "+a.message)}return r}function l(e){var t,n,r,o;if(e.data.slice(0,O.length)!==O)return!1;try{t=JSON.parse(e.data.slice(O.length))}catch(i){return!1}return null!=t.reply&&(n=e.origin,r=e.source,o=t.reply,t.reply=function(e){var t=c(o,[e],n);return t===!1?!1:void r.postMessage(t,n)},t.args.push(t.reply)),t}function u(t){A||(A=t||e,A.addEventListener?A.addEventListener("message",f,!1):A.attachEvent?A.attachEvent("onmessage",f):null===A.onmessage?A.onmessage=f:A=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),y(e.data,t.origin,e.source)))}function d(e,t,n,r){var o;if(v[e]&&v[e][t])for(o=0;o<v[e][t].length;o++)v[e][t][o].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 _(e,t,n){var r;try{for(e.postMessage(t,n),h(e)&&_(e.opener.top,t,n),r=0;r<e.frames.length;r++)_(e.frames[r],t,n)}catch(o){}}function y(e,t,n){var r,o;for(r=b.length-1;r>=0;r--)o=b[r],o.closed===!0?b=b.slice(r,1):n!==o&&_(o.top,e,t)}function m(e,t){function n(o,i){e(o,i),g.target(t).unsubscribe(r,n)}var r=p();return g.target(t).subscribe(r,n),r}function E(e,t,n){return s(e)?!0:"function"!=typeof t?!0:s(n)?!0:!1}var A,g,b=[],v={},O="/*framebus*/";return u(),g={target:n,include:t,publish:r,pub:r,trigger:r,emit:r,subscribe:o,sub:o,on:o,unsubscribe:i,unsub:i,off:i}})}).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"),o=e("./lib/default-attributes"),i=e("./lib/assign");t.exports=function(e){var t=document.createElement("iframe"),n=i({},o,e);return n.style&&"string"!=typeof n.style&&(i(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";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":18}],7:[function(e,t,n){"use strict";function r(e,t){var n,r=t?i(t):{},s=o(e.authorization).attrs,c=i(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 o=e("./create-authorization-data"),i=e("./json-clone"),a=e("./constants");t.exports=r},{"./constants":13,"./create-authorization-data":15,"./json-clone":28}],8:[function(e,t,n){"use strict";function r(e){return Math.floor(e/1e3)}function o(e,t,n){var o=e.getConfiguration(),s=e._request,c=r(Date.now()),l=o.gatewayConfiguration.analytics.url,u={analytics:[{kind:t,timestamp:c}]};s({url:l,method:"post",data:a(o,u),timeout:i.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var i=e("./constants"),a=e("./add-metadata");t.exports={sendEvent:o}},{"./add-metadata":7,"./constants":13}],9:[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,t.indexOf("Android")>-1&&t.indexOf("Firefox")>-1}function o(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}function i(t){return t=t||e.location.protocol,"https:"===t}t.exports={isOperaMini:n,isAndroidFirefox:r,getIEVersion:o,isHTTPS:i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(e,t,n){"use strict";function r(e,t){var n,r,i=document.createElement("a");return i.href=t,r="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,n=i.protocol+"//"+r,n===e||o.test(e)}var o=/^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/;t.exports={checkOrigin:r}},{}],11:[function(e,t,n){"use strict";var r=e("../enumerate");t.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":17}],12:[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,code:"MISSING_CHANNEL_ID",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 o=e("framebus"),i=e("./events"),a=e("./check-origin").checkOrigin,s=e("../error");r.prototype.on=function(e,t){var n,r,i=t,s=this;this._isDestroyed||(this.merchantUrl&&(i=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]=i,this._log("on",r),o.on.apply(o,r),this._listeners.push({eventName:e,handler:i,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),o.emit.apply(o,t))},r.prototype._offDirect=function(e){var t=Array.prototype.slice.call(arguments);this._isDestroyed||(t[0]=this._namespaceEvent(e),this._log("off",t),o.off.apply(o,t))},r.prototype.off=function(e,t){var n,r,o=t;if(!this._isDestroyed){if(this.merchantUrl)for(n=0;n<this._listeners.length;n++)r=this._listeners[n],r.originalHandler===t&&(o=r.handler);this._offDirect(e,o)}},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=i,t.exports=r},{"../error":18,"./check-origin":10,"./events":11,framebus:1}],13:[function(e,t,n){"use strict";var r="3.0.0-beta.12",o="web";t.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(e,t,n){"use strict";var r=e("./error"),o=e("../errors");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new r({type:o.METHOD_CALLED_AFTER_TEARDOWN.type,code:o.METHOD_CALLED_AFTER_TEARDOWN.code,message:t+" cannot be called after teardown."})}})}},{"../errors":6,"./error":18}],15:[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 o(e){var t=e.split("_"),n=t[0],r=t.slice(2).join("_");return{merchantId:r,environment:n}}function i(e){var t,n,i={attrs:{},configUrl:""};return r(e)?(n=o(e),i.attrs.tokenizationKey=e,i.configUrl=s[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(a(e)),i.attrs.authorizationFingerprint=t.authorizationFingerprint,i.configUrl=t.configUrl),i}var a=e("../lib/polyfill").atob,s={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=i},{"../lib/polyfill":31}],16:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],17:[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},{}],18:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":17}],19:[function(e,t,n){"use strict";function r(e){if(!e)throw new Error("Valid configuration is required");if(d.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 o(e){r(e),this._serviceId=u().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 i=e("./popup"),a=e("../../bus"),s=e("../shared/events"),c=e("../shared/errors"),l=e("../shared/constants"),u=e("../../uuid"),p=e("iframer"),f=e("../../error"),d=["name","dispatchFrameUrl","openFrameUrl"];o.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()},o.prototype._writeDispatchFrame=function(){var e=l.DISPATCH_FRAME_NAME+"_"+this._serviceId,t=this._options.dispatchFrameUrl;this._dispatchFrame=p({name:e,src:t,height:0,width:0}),document.body.appendChild(this._dispatchFrame)},o.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))},o.prototype.open=function(e){this._onCompleteCallback=e,this._frame=i.open(this._options),this._pollForPopupClose()},o.prototype.redirect=function(e){this._frame&&!this.isFrameClosed()&&(this._frame.location.href=e)},o.prototype.close=function(){this.isFrameClosed()||this._frame.close()},o.prototype.teardown=function(){this.close(),this._dispatchFrame.parentNode.removeChild(this._dispatchFrame),this._dispatchFrame=null,this._cleanupFrame()},o.prototype.isFrameClosed=function(){return null==this._frame||this._frame.closed},o.prototype._cleanupFrame=function(){this._frame=null,clearInterval(this._popupInterval),this._popupInterval=null},o.prototype._pollForPopupClose=function(){return this._popupInterval=setInterval(function(){this.isFrameClosed()&&(this._cleanupFrame(),this._onCompleteCallback&&this._onCompleteCallback(new f(c.FRAME_CLOSED)))}.bind(this),l.POPUP_POLL_INTERVAL),this._popupInterval},t.exports=o},{"../../bus":12,"../../error":18,"../../uuid":33,"../shared/constants":25,"../shared/errors":26,"../shared/events":27,"./popup":22,iframer:2}],20:[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":19}],21:[function(e,t,n){"use strict";var r=e("../../shared/constants"),o=e("./position");t.exports=function(){return[r.POPUP_BASE_OPTIONS,"top="+o.top(),"left="+o.left()].join(",")}},{"../../shared/constants":25,"./position":24}],22:[function(e,t,n){"use strict";t.exports={open:e("./open")}},{"./open":23}],23:[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":21}],24:[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 i(e,a.POPUP_HEIGHT,t)}function o(){var e=n.outerWidth||document.documentElement.clientWidth,t=null==n.screenX?n.screenLeft:n.screenX;return i(e,a.POPUP_WIDTH,t)}function i(e,t,n){return(e-t)/2+n}var a=e("../../shared/constants");t.exports={top:r,left:o,center:i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../shared/constants":25}],25:[function(e,t,n){"use strict";var r=535,o=450;t.exports={DISPATCH_FRAME_NAME:"dispatch",POPUP_BASE_OPTIONS:"resizable,scrollbars,height="+r+",width="+o,POPUP_WIDTH:o,POPUP_HEIGHT:r,POPUP_POLL_INTERVAL:100,POPUP_CLOSE_TIMEOUT:100}},{}],26:[function(e,t,n){"use strict";var r=e("../../error");t.exports={FRAME_CLOSED:{type:r.types.CUSTOMER,code:"FRAME_CLOSED",message:"Frame closed before tokenization could occur."}}},{"../../error":18}],27:[function(e,t,n){"use strict";var r=e("../../enumerate");t.exports=r(["DISPATCH_FRAME_READY","DISPATCH_FRAME_REPORT"],"frameService:")},{"../../enumerate":17}],28:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],29:[function(e,t,n){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],30:[function(e,t,n){"use strict";function r(e){var t=!1;return function(){t||(t=!0,e.apply(null,arguments))}}t.exports=r},{}],31:[function(e,t,n){(function(e){"use strict";function n(e){var t,n,r,o,i,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 o=u.indexOf(e.charAt(c++)),i=u.indexOf(e.charAt(c++)),a=u.indexOf(e.charAt(c++)),s=u.indexOf(e.charAt(c++)),t=(63&o)<<2|i>>4&3,n=(15&i)<<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:{})},{}],32:[function(e,t,n){(function(e){"use strict";function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function r(e){return e&&"object"==typeof e&&"number"==typeof e.length&&"[object Array]"===Object.prototype.toString.call(e)||!1}function o(t){var n,r;return t=t||e.location.href,/\?/.test(t)?(n=t.replace(/#.*$/,"").replace(/^.*\?/,"").split("&"),r=n.reduce(function(e,t){var n=t.split("="),r=decodeURIComponent(n[0]),o=decodeURIComponent(n[1]);return e[r]=o,e},{})):{}}function i(e,t){var n,o,a,s=[];for(a in e)e.hasOwnProperty(a)&&(o=e[a],n=t?r(e)?t+"[]":t+"["+a+"]":a,"object"==typeof o?s.push(i(o,n)):s.push(encodeURIComponent(n)+"="+encodeURIComponent(o)));return s.join("&")}function a(e,t){return e=e||"",null!=t&&"object"==typeof t&&n(t)&&(e+=-1===e.indexOf("?")?"?":"",e+=-1!==e.indexOf("=")?"&":"",e+=i(t)),e}t.exports={parse:o,stringify:i,queryify:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],33:[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},{}],34:[function(e,t,n){"use strict";function r(e){this._client=e.client,this._assetsUrl=e.client.getConfiguration().gatewayConfiguration.paypal.assetsUrl+"/web/"+c,this._authorizationInProgress=!1}var o=e("../../lib/frame-service/external"),i=e("../../lib/frame-service/shared/errors"),a=e("../../lib/error"),s=e("../../lib/once"),c="3.0.0-beta.12",l=e("../shared/constants"),u=e("../../lib/constants").INTEGRATION_TIMEOUT_MS,p=e("../../lib/analytics"),f=e("../../lib/methods"),d=e("../../lib/deferred"),h=e("../shared/errors"),_=e("../shared/get-country"),y=e("../../lib/convert-methods-to-error"),m=e("../../lib/querystring"),E=e("../../errors");r.prototype._initialize=function(e){var t=this._client,n=setTimeout(function(){p.sendEvent(t,"web.paypal.load.timed-out")},u);o.create({name:l.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),p.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 a({type:E.CALLBACK_REQUIRED.type,code:E.CALLBACK_REQUIRED.code,message:"tokenize must include a callback function."});return t=s(d(t)),this._authorizationInProgress?(p.sendEvent(n,"web.paypal.tokenization.error.already-opened"),t(new a(h.TOKENIZATION_REQUEST_ACTIVE))):(this._authorizationInProgress=!0,p.sendEvent(n,"web.paypal.tokenization.opened"),this._navigateFrameToAuth(e,t),this._frameService.open(this._createFrameServiceCallback(e,t))),{close:function(){p.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,o){this._authorizationInProgress=!1,r?(r.code===i.FRAME_CLOSED.code&&p.sendEvent(n,"web.paypal.tokenization.closed.by-user"),t(new a(r))):this._tokenizePayPal(e,o,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?(p.sendEvent(r,"web.paypal.tokenization.failed"),n(e instanceof a?e:new a({type:h.ACCOUNT_TOKENIZATION_FAILED.type,code:h.ACCOUNT_TOKENIZATION_FAILED.code,message:h.ACCOUNT_TOKENIZATION_FAILED.message,details:e}))):(p.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:{},type:n.type},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 a(h.PAYPAL_FLOW_OPTION_REQUIRED));r+="setup_billing_agreement"}n.request({endpoint:r,method:"post",data:this._formatPaymentResourceData(e)},function(n,r){var o;n?(t(n instanceof a?n:new a({type:h.PAYPAL_FLOW_FAILED.type,code:h.PAYPAL_FLOW_FAILED.code,message:h.PAYPAL_FLOW_FAILED.message,details:n})),this._frameService.close()):(o="checkout"===e.flow?r.paymentResource.redirectUrl:r.agreementSetup.approvalUrl,"commit"===e.useraction&&(o=m.queryify(o,{useraction:"commit"})),this._frameService.redirect(o))}.bind(this))},r.prototype._formatPaymentResourceData=function(e){var t,n=this._client.getConfiguration().gatewayConfiguration,r=this._frameService._serviceId,o={returnUrl:n.paypal.assetsUrl+"/web/"+c+"/html/paypal-redirect-frame.min.html?channel="+r,cancelUrl:n.paypal.assetsUrl+"/web/"+c+"/html/paypal-cancel-frame.min.html?channel="+r,correlationId:r,experienceProfile:{brandName:e.displayName||n.paypal.displayName,localeCode:_(e.locale),noShipping:(!e.enableShippingAddress).toString(),addressOverride:e.shippingAddressEditable===!1}};if("checkout"===e.flow){o.amount=parseFloat(e.amount).toFixed(2),o.currencyIsoCode=e.currency,o.offerPaypalCredit=e.offerCredit===!0,e.hasOwnProperty("intent")&&(o.intent=e.intent);for(t in e.shippingAddressOverride)e.shippingAddressOverride.hasOwnProperty(t)&&(o[t]=e.shippingAddressOverride[t])}else o.shippingAddress=e.shippingAddressOverride,e.billingAgreementDescription&&(o.description=e.billingAgreementDescription);return o},r.prototype.teardown=function(e){this._frameService.teardown(),y(this,f(r.prototype)),p.sendEvent(this._client,"web.paypal.teardown-completed"),"function"==typeof e&&(e=d(e))()},t.exports=r},{"../../errors":6,"../../lib/analytics":8,"../../lib/constants":13,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/frame-service/external":20,"../../lib/frame-service/shared/errors":26,"../../lib/methods":29,"../../lib/once":30,"../../lib/querystring":32,"../shared/constants":36,"../shared/errors":37,"../shared/get-country":38}],35:[function(e,t,n){"use strict";function r(e,t){var n,r,s;if(!t)throw new a({type:p.CALLBACK_REQUIRED.type,code:p.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return t=c(t),null==e.client?void t(new a({type:p.INSTANTIATION_OPTION_REQUIRED.type,code:p.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating PayPal."})):(n=e.client.getConfiguration(),s=n.analyticsMetadata.sdkVersion,s!==f?void t(new a({type:p.INCOMPATIBLE_VERSIONS.type,code:p.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+s+") and PayPal (version "+f+") components must be from the same SDK version."})):n.gatewayConfiguration.paypalEnabled!==!0?void t(new a(l.PAYPAL_NOT_ENABLED)):o()?(i.sendEvent(e.client,"web.paypal.initialized"),r=new u(e),void r._initialize(function(){t(null,r)})):void t(new a(l.BROWSER_NOT_SUPPORTED)))}function o(){return!s.isOperaMini()}var i=e("../lib/analytics"),a=e("../lib/error"),s=e("../lib/browser-detection"),c=e("../lib/deferred"),l=e("./shared/errors"),u=e("./external/paypal"),p=e("../errors"),f="3.0.0-beta.12";t.exports={create:r,VERSION:f}},{"../errors":6,"../lib/analytics":8,"../lib/browser-detection":9,"../lib/deferred":16,"../lib/error":18,"./external/paypal":34,"./shared/errors":37}],36:[function(e,t,n){"use strict";var r=535,o=450;t.exports={AUTH_INIT_ERROR_MESSAGE:"Could not initialize PayPal flow.",LANDING_FRAME_NAME:"braintreepaypallanding",POPUP_BASE_OPTIONS:"resizable,scrollbars,height="+r+",width="+o,POPUP_WIDTH:o,POPUP_HEIGHT:r,POPUP_POLL_INTERVAL:100}},{}],37:[function(e,t,n){"use strict";var r=e("../../lib/error");t.exports={PAYPAL_NOT_ENABLED:{type:r.types.MERCHANT,code:"PAYPAL_NOT_ENABLED",message:"PayPal is not enabled for this merchant."},TOKENIZATION_REQUEST_ACTIVE:{type:r.types.MERCHANT,code:"TOKENIZATION_REQUEST_ACTIVE",message:"Another tokenization request is active."},ACCOUNT_TOKENIZATION_FAILED:{type:r.types.NETWORK,code:"ACCOUNT_TOKENIZATION_FAILED",message:"Could not tokenize user's PayPal account."},PAYPAL_FLOW_FAILED:{type:r.types.NETWORK,code:"PAYPAL_FLOW_FAILED",message:"Could not initialize PayPal flow."},PAYPAL_FLOW_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"PAYPAL_FLOW_OPTION_REQUIRED",message:"PayPal flow property is invalid or missing."},BROWSER_NOT_SUPPORTED:{type:r.types.CUSTOMER,code:"BROWSER_NOT_SUPPORTED",message:"Browser is not supported."}}},{"../../lib/error":18}],38:[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=o[t]?t:"us","uk"===t&&(t="gb"),t}var o={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},{}]},{},[35])(35)}); | ||
!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 o(a,s){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(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 o(n?n:t)},u,u.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,n,r){(function(t){"use strict";!function(o,i){"object"==typeof r&&"undefined"!=typeof n?n.exports=i("undefined"==typeof t?o:t):"function"==typeof e&&e.amd?e([],function(){return i(o)}):o.framebus=i(o)}(this,function(e){function t(e){return null==e?!1:null==e.Window?!1:e.constructor!==e.Window?!1:(P.push(e),!0)}function n(e){var t,n={};for(t in g)g.hasOwnProperty(t)&&(n[t]=g[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:(_(E.top,t,r),!0))}function o(e,t){var n=a(this);return A(e,t,n)?!1:(v[n]=v[n]||{},v[n][e]=v[n][e]||[],v[n][e].push(t),!0)}function i(e,t){var n,r,o=a(this);if(A(e,t,o))return!1;if(r=v[o]&&v[o][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,o={event:e,origin:n},i=t[t.length-1];"function"==typeof i&&(o.reply=m(i,n),t=t.slice(0,-1)),o.args=t;try{r=O+JSON.stringify(o)}catch(a){throw new Error("Could not stringify event: "+a.message)}return r}function l(e){var t,n,r,o;if(e.data.slice(0,O.length)!==O)return!1;try{t=JSON.parse(e.data.slice(O.length))}catch(i){return!1}return null!=t.reply&&(n=e.origin,r=e.source,o=t.reply,t.reply=function(e){var t=c(o,[e],n);return t===!1?!1:void r.postMessage(t,n)},t.args.push(t.reply)),t}function u(t){E||(E=t||e,E.addEventListener?E.addEventListener("message",f,!1):E.attachEvent?E.attachEvent("onmessage",f):null===E.onmessage?E.onmessage=f:E=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),y(e.data,t.origin,e.source)))}function d(e,t,n,r){var o;if(v[e]&&v[e][t])for(o=0;o<v[e][t].length;o++)v[e][t][o].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 _(e,t,n){var r;try{for(e.postMessage(t,n),h(e)&&_(e.opener.top,t,n),r=0;r<e.frames.length;r++)_(e.frames[r],t,n)}catch(o){}}function y(e,t,n){var r,o;for(r=P.length-1;r>=0;r--)o=P[r],o.closed===!0?P=P.slice(r,1):n!==o&&_(o.top,e,t)}function m(e,t){function n(o,i){e(o,i),g.target(t).unsubscribe(r,n)}var r=p();return g.target(t).subscribe(r,n),r}function A(e,t,n){return s(e)?!0:"function"!=typeof t?!0:s(n)?!0:!1}var E,g,P=[],v={},O="/*framebus*/";return u(),g={target:n,include:t,publish:r,pub:r,trigger:r,emit:r,subscribe:o,sub:o,on:o,unsubscribe:i,unsub:i,off:i}})}).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"),o=e("./lib/default-attributes"),i=e("./lib/assign");t.exports=function(e){var t=document.createElement("iframe"),n=i({},o,e);return n.style&&"string"!=typeof n.style&&(i(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";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":18}],7:[function(e,t,n){"use strict";function r(e,t){var n,r=t?i(t):{},s=o(e.authorization).attrs,c=i(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 o=e("./create-authorization-data"),i=e("./json-clone"),a=e("./constants");t.exports=r},{"./constants":13,"./create-authorization-data":15,"./json-clone":29}],8:[function(e,t,n){"use strict";function r(e){return Math.floor(e/1e3)}function o(e,t,n){var o=e.getConfiguration(),s=e._request,c=r(Date.now()),l=o.gatewayConfiguration.analytics.url,u={analytics:[{kind:t,timestamp:c}]};s({url:l,method:"post",data:a(o,u),timeout:i.ANALYTICS_REQUEST_TIMEOUT_MS},n)}var i=e("./constants"),a=e("./add-metadata");t.exports={sendEvent:o}},{"./add-metadata":7,"./constants":13}],9:[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,s(t)&&t.indexOf("Firefox")>-1}function o(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}function i(t){return t=t||e.location.protocol,"https:"===t}function a(t){return t=t||e.navigator.userAgent,/iPhone|iPod|iPad/.test(t)}function s(t){return t=t||e.navigator.userAgent,/Android/.test(t)}function c(t){return t=t||e.navigator.userAgent,!(u(t)||p(t)||n(t))}function l(e){return/\bGSA\b/.test(e)}function u(t){return t=t||e.navigator.userAgent,a(t)?l(t)?!0:/.+AppleWebKit(?!.*Safari)/.test(t):!1}function p(t){var r=/Version\/[\d\.]+/;return t=t||e.navigator.userAgent,s(t)?r.test(t)&&!n(t):!1}t.exports={isOperaMini:n,isAndroidFirefox:r,getIEVersion:o,isHTTPS:i,isIos:a,isAndroid:s,supportsPopups:c}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(e,t,n){"use strict";function r(e,t){var n,r,i=document.createElement("a");return i.href=t,r="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,n=i.protocol+"//"+r,n===e?!0:(i.href=e,o(e)&&"localhost"!==i.hostname)}var o=e("../is-whitelisted-domain");t.exports={checkOrigin:r}},{"../is-whitelisted-domain":28}],11:[function(e,t,n){"use strict";var r=e("../enumerate");t.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":17}],12:[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,code:"MISSING_CHANNEL_ID",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 o=e("framebus"),i=e("./events"),a=e("./check-origin").checkOrigin,s=e("../error");r.prototype.on=function(e,t){var n,r,i=t,s=this;this._isDestroyed||(this.merchantUrl&&(i=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]=i,this._log("on",r),o.on.apply(o,r),this._listeners.push({eventName:e,handler:i,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),o.emit.apply(o,t))},r.prototype._offDirect=function(e){var t=Array.prototype.slice.call(arguments);this._isDestroyed||(t[0]=this._namespaceEvent(e),this._log("off",t),o.off.apply(o,t))},r.prototype.off=function(e,t){var n,r,o=t;if(!this._isDestroyed){if(this.merchantUrl)for(n=0;n<this._listeners.length;n++)r=this._listeners[n],r.originalHandler===t&&(o=r.handler);this._offDirect(e,o)}},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=i,t.exports=r},{"../error":18,"./check-origin":10,"./events":11,framebus:1}],13:[function(e,t,n){"use strict";var r="3.0.0",o="web";t.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(e,t,n){"use strict";var r=e("./error"),o=e("../errors");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new r({type:o.METHOD_CALLED_AFTER_TEARDOWN.type,code:o.METHOD_CALLED_AFTER_TEARDOWN.code,message:t+" cannot be called after teardown."})}})}},{"../errors":6,"./error":18}],15:[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 o(e){var t=e.split("_"),n=t[0],r=t.slice(2).join("_");return{merchantId:r,environment:n}}function i(e){var t,n,i={attrs:{},configUrl:""};return r(e)?(n=o(e),i.attrs.tokenizationKey=e,i.configUrl=s[n.environment]+"/merchants/"+n.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(a(e)),i.attrs.authorizationFingerprint=t.authorizationFingerprint,i.configUrl=t.configUrl),i}var a=e("../lib/polyfill").atob,s={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=i},{"../lib/polyfill":32}],16:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],17:[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},{}],18:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":17}],19:[function(e,t,n){"use strict";function r(e){if(!e)throw new Error("Valid configuration is required");if(d.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 o(e){r(e),this._serviceId=u().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 i=e("./popup"),a=e("../../bus"),s=e("../shared/events"),c=e("../shared/errors"),l=e("../shared/constants"),u=e("../../uuid"),p=e("iframer"),f=e("../../error"),d=["name","dispatchFrameUrl","openFrameUrl"];o.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()},o.prototype._writeDispatchFrame=function(){var e=l.DISPATCH_FRAME_NAME+"_"+this._serviceId,t=this._options.dispatchFrameUrl;this._dispatchFrame=p({name:e,src:t,height:0,width:0}),document.body.appendChild(this._dispatchFrame)},o.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))},o.prototype.open=function(e){this._onCompleteCallback=e,this._frame=i.open(this._options),this._pollForPopupClose()},o.prototype.redirect=function(e){this._frame&&!this.isFrameClosed()&&(this._frame.location.href=e)},o.prototype.close=function(){this.isFrameClosed()||this._frame.close()},o.prototype.teardown=function(){this.close(),this._dispatchFrame.parentNode.removeChild(this._dispatchFrame),this._dispatchFrame=null,this._cleanupFrame()},o.prototype.isFrameClosed=function(){return null==this._frame||this._frame.closed},o.prototype._cleanupFrame=function(){this._frame=null,clearInterval(this._popupInterval),this._popupInterval=null},o.prototype._pollForPopupClose=function(){return this._popupInterval=setInterval(function(){this.isFrameClosed()&&(this._cleanupFrame(),this._onCompleteCallback&&this._onCompleteCallback(new f(c.FRAME_SERVICE_FRAME_CLOSED)))}.bind(this),l.POPUP_POLL_INTERVAL),this._popupInterval},t.exports=o},{"../../bus":12,"../../error":18,"../../uuid":34,"../shared/constants":25,"../shared/errors":26,"../shared/events":27,"./popup":22,iframer:2}],20:[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":19}],21:[function(e,t,n){"use strict";var r=e("../../shared/constants"),o=e("./position");t.exports=function(){return[r.POPUP_BASE_OPTIONS,"top="+o.top(),"left="+o.left()].join(",")}},{"../../shared/constants":25,"./position":24}],22:[function(e,t,n){"use strict";t.exports={open:e("./open")}},{"./open":23}],23:[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":21}],24:[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 i(e,a.POPUP_HEIGHT,t)}function o(){var e=n.outerWidth||document.documentElement.clientWidth,t=null==n.screenX?n.screenLeft:n.screenX;return i(e,a.POPUP_WIDTH,t)}function i(e,t,n){return(e-t)/2+n}var a=e("../../shared/constants");t.exports={top:r,left:o,center:i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../shared/constants":25}],25:[function(e,t,n){"use strict";var r=535,o=450;t.exports={DISPATCH_FRAME_NAME:"dispatch",POPUP_BASE_OPTIONS:"resizable,scrollbars,height="+r+",width="+o,POPUP_WIDTH:o,POPUP_HEIGHT:r,POPUP_POLL_INTERVAL:100,POPUP_CLOSE_TIMEOUT:100}},{}],26:[function(e,t,n){"use strict";var r=e("../../error");t.exports={FRAME_SERVICE_FRAME_CLOSED:{type:r.types.INTERNAL,code:"FRAME_SERVICE_FRAME_CLOSED",message:"Frame closed before tokenization could occur."}}},{"../../error":18}],27:[function(e,t,n){"use strict";var r=e("../../enumerate");t.exports=r(["DISPATCH_FRAME_READY","DISPATCH_FRAME_REPORT"],"frameService:")},{"../../enumerate":17}],28:[function(e,t,n){"use strict";function r(e){return e.split(".").slice(-2).join(".")}function o(e){var t;return e=e.toLowerCase(),/^https:/.test(e)?(i=i||document.createElement("a"),i.href=e,t=r(i.hostname),a.hasOwnProperty(t)):!1}var i,a={"paypal.com":1,"braintreepayments.com":1,"braintreegateway.com":1,localhost:1};t.exports=o},{}],29:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],30:[function(e,t,n){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],31:[function(e,t,n){"use strict";function r(e){var t=!1;return function(){t||(t=!0,e.apply(null,arguments))}}t.exports=r},{}],32:[function(e,t,n){(function(e){"use strict";function n(e){var t,n,r,o,i,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 o=u.indexOf(e.charAt(c++)),i=u.indexOf(e.charAt(c++)),a=u.indexOf(e.charAt(c++)),s=u.indexOf(e.charAt(c++)),t=(63&o)<<2|i>>4&3,n=(15&i)<<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:{})},{}],33:[function(e,t,n){(function(e){"use strict";function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function r(e){return e&&"object"==typeof e&&"number"==typeof e.length&&"[object Array]"===Object.prototype.toString.call(e)||!1}function o(t){var n,r;return t=t||e.location.href,/\?/.test(t)?(n=t.replace(/#.*$/,"").replace(/^.*\?/,"").split("&"),r=n.reduce(function(e,t){var n=t.split("="),r=decodeURIComponent(n[0]),o=decodeURIComponent(n[1]);return e[r]=o,e},{})):{}}function i(e,t){var n,o,a,s=[];for(a in e)e.hasOwnProperty(a)&&(o=e[a],n=t?r(e)?t+"[]":t+"["+a+"]":a,"object"==typeof o?s.push(i(o,n)):s.push(encodeURIComponent(n)+"="+encodeURIComponent(o)));return s.join("&")}function a(e,t){return e=e||"",null!=t&&"object"==typeof t&&n(t)&&(e+=-1===e.indexOf("?")?"?":"",e+=-1!==e.indexOf("=")?"&":"",e+=i(t)),e}t.exports={parse:o,stringify:i,queryify:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],34:[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},{}],35:[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 o=e("../../lib/frame-service/external"),i=e("../../lib/error"),a=e("../../lib/once"),s="3.0.0",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/errors"),h=e("../../lib/convert-methods-to-error"),_=e("../../lib/querystring"),y=e("../../errors");r.prototype._initialize=function(e){var t=this._client,n=setTimeout(function(){u.sendEvent(t,"web.paypal.load.timed-out")},l);o.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 i({type:y.CALLBACK_REQUIRED.type,code:y.CALLBACK_REQUIRED.code,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 i(d.PAYPAL_TOKENIZATION_REQUEST_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,o){this._authorizationInProgress=!1,r?("FRAME_SERVICE_FRAME_CLOSED"===r.code&&u.sendEvent(n,"web.paypal.tokenization.closed.by-user"),t(new i(d.PAYPAL_POPUP_CLOSED))):this._tokenizePayPal(e,o,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 i?e:new i({type:d.PAYPAL_ACCOUNT_TOKENIZATION_FAILED.type,code:d.PAYPAL_ACCOUNT_TOKENIZATION_FAILED.code,message:d.PAYPAL_ACCOUNT_TOKENIZATION_FAILED.message,details:{originalError: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:{},type:n.type},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,options:{validate:"vault"===e.flow}}};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 i(d.PAYPAL_FLOW_OPTION_REQUIRED));r+="setup_billing_agreement"}n.request({endpoint:r,method:"post",data:this._formatPaymentResourceData(e)},function(n,r,o){var a;n?(t(422===o?new i({type:d.PAYPAL_INVALID_PAYMENT_OPTION.type,code:d.PAYPAL_INVALID_PAYMENT_OPTION.code,message:d.PAYPAL_INVALID_PAYMENT_OPTION.message,details:{originalError:n}}):n instanceof i?n:new i({type:d.PAYPAL_FLOW_FAILED.type,code:d.PAYPAL_FLOW_FAILED.code,message:d.PAYPAL_FLOW_FAILED.message,details:{originalError:n}})),this._frameService.close()):(a="checkout"===e.flow?r.paymentResource.redirectUrl:r.agreementSetup.approvalUrl,"commit"===e.useraction&&(a=_.queryify(a,{useraction:"commit"})),this._frameService.redirect(a))}.bind(this))},r.prototype._formatPaymentResourceData=function(e){var t,n=this._client.getConfiguration().gatewayConfiguration,r=this._frameService._serviceId,o={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:e.locale,noShipping:(!e.enableShippingAddress).toString(),addressOverride:e.shippingAddressEditable===!1}};if("checkout"===e.flow){o.amount=e.amount,o.currencyIsoCode=e.currency,o.offerPaypalCredit=e.offerCredit===!0,e.hasOwnProperty("intent")&&(o.intent=e.intent);for(t in e.shippingAddressOverride)e.shippingAddressOverride.hasOwnProperty(t)&&(o[t]=e.shippingAddressOverride[t])}else o.shippingAddress=e.shippingAddressOverride,e.billingAgreementDescription&&(o.description=e.billingAgreementDescription);return o},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},{"../../errors":6,"../../lib/analytics":8,"../../lib/constants":13,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/frame-service/external":20,"../../lib/methods":30,"../../lib/once":31,"../../lib/querystring":33,"../shared/constants":37,"../shared/errors":38}],36:[function(e,t,n){"use strict";function r(e,t){var n,r,f;if(!t)throw new i({type:u.CALLBACK_REQUIRED.type,code:u.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return t=s(t),null==e.client?void t(new i({type:u.INSTANTIATION_OPTION_REQUIRED.type,code:u.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating PayPal."})):(n=e.client.getConfiguration(),f=n.analyticsMetadata.sdkVersion,f!==p?void t(new i({type:u.INCOMPATIBLE_VERSIONS.type,code:u.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+f+") and PayPal (version "+p+") components must be from the same SDK version."})):n.gatewayConfiguration.paypalEnabled!==!0?void t(new i(c.PAYPAL_NOT_ENABLED)):a.supportsPopups()?(o.sendEvent(e.client,"web.paypal.initialized"),r=new l(e),void r._initialize(function(){t(null,r)})):void t(new i(c.PAYPAL_BROWSER_NOT_SUPPORTED)))}var o=e("../lib/analytics"),i=e("../lib/error"),a=e("../lib/browser-detection"),s=e("../lib/deferred"),c=e("./shared/errors"),l=e("./external/paypal"),u=e("../errors"),p="3.0.0";t.exports={create:r,VERSION:p}},{"../errors":6,"../lib/analytics":8,"../lib/browser-detection":9,"../lib/deferred":16,"../lib/error":18,"./external/paypal":35,"./shared/errors":38}],37:[function(e,t,n){"use strict";var r=535,o=450;t.exports={AUTH_INIT_ERROR_MESSAGE:"Could not initialize PayPal flow.",LANDING_FRAME_NAME:"braintreepaypallanding",POPUP_BASE_OPTIONS:"resizable,scrollbars,height="+r+",width="+o,POPUP_WIDTH:o,POPUP_HEIGHT:r,POPUP_POLL_INTERVAL:100}},{}],38:[function(e,t,n){"use strict";var r=e("../../lib/error");t.exports={PAYPAL_NOT_ENABLED:{type:r.types.MERCHANT,code:"PAYPAL_NOT_ENABLED",message:"PayPal is not enabled for this merchant."},PAYPAL_TOKENIZATION_REQUEST_ACTIVE:{type:r.types.MERCHANT,code:"PAYPAL_TOKENIZATION_REQUEST_ACTIVE",message:"Another tokenization request is active."},PAYPAL_ACCOUNT_TOKENIZATION_FAILED:{type:r.types.NETWORK,code:"PAYPAL_ACCOUNT_TOKENIZATION_FAILED",message:"Could not tokenize user's PayPal account."},PAYPAL_FLOW_FAILED:{type:r.types.NETWORK,code:"PAYPAL_FLOW_FAILED",message:"Could not initialize PayPal flow."},PAYPAL_FLOW_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"PAYPAL_FLOW_OPTION_REQUIRED",message:"PayPal flow property is invalid or missing."},PAYPAL_BROWSER_NOT_SUPPORTED:{type:r.types.CUSTOMER,code:"PAYPAL_BROWSER_NOT_SUPPORTED",message:"Browser is not supported."},PAYPAL_POPUP_CLOSED:{type:r.types.CUSTOMER,code:"PAYPAL_POPUP_CLOSED",message:"Customer closed PayPal popup before authorizing."},PAYPAL_INVALID_PAYMENT_OPTION:{type:r.types.MERCHANT,code:"PAYPAL_INVALID_PAYMENT_OPTION",message:"PayPal payment options are invalid."}}},{"../../lib/error":18}]},{},[36])(36)}); |
braintree-web | ||
============= | ||
__NOTE: v3 of our JavaScript SDK is currently in beta. If you are interested in using this new major version [join our Google Group](https://groups.google.com/forum/#!forum/braintree-sdk-announce) for updates.__ | ||
A suite of tools for integrating Braintree in the browser. | ||
@@ -14,7 +12,7 @@ | ||
``` | ||
npm install braintree-web@beta | ||
npm install braintree-web | ||
``` | ||
``` | ||
bower install braintree-web#3.x-beta | ||
bower install braintree-web | ||
``` | ||
@@ -21,0 +19,0 @@ |
@@ -406,3 +406,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 = {})).threeDSecure = 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){ | ||
},{"./constants":13,"./create-authorization-data":15,"./json-clone":19}],8:[function(_dereq_,module,exports){ | ||
},{"./constants":13,"./create-authorization-data":15,"./json-clone":20}],8:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -449,3 +449,3 @@ | ||
ua = ua || global.navigator.userAgent; | ||
return ua.indexOf('Android') > -1 && ua.indexOf('Firefox') > -1; | ||
return isAndroid(ua) && ua.indexOf('Firefox') > -1; | ||
} | ||
@@ -467,6 +467,46 @@ | ||
protocol = protocol || global.location.protocol; | ||
return protocol === 'https:'; | ||
} | ||
function isIos(ua) { | ||
ua = ua || global.navigator.userAgent; | ||
return /iPhone|iPod|iPad/.test(ua); | ||
} | ||
function isAndroid(ua) { | ||
ua = ua || global.navigator.userAgent; | ||
return /Android/.test(ua); | ||
} | ||
function supportsPopups(ua) { | ||
ua = ua || global.navigator.userAgent; | ||
return !(isIosWebview(ua) || isAndroidWebview(ua) || isOperaMini(ua)); | ||
} | ||
// The Google Search iOS app is technically a webview and doesn't support popups. | ||
function isGoogleSearchApp(ua) { | ||
return /\bGSA\b/.test(ua); | ||
} | ||
function isIosWebview(ua) { | ||
ua = ua || global.navigator.userAgent; | ||
if (isIos(ua)) { | ||
if (isGoogleSearchApp(ua)) { | ||
return true; | ||
} | ||
return /.+AppleWebKit(?!.*Safari)/.test(ua); | ||
} | ||
return false; | ||
} | ||
function isAndroidWebview(ua) { | ||
var androidWebviewRegExp = /Version\/[\d\.]+/; | ||
ua = ua || global.navigator.userAgent; | ||
if (isAndroid(ua)) { | ||
return androidWebviewRegExp.test(ua) && !isOperaMini(ua); | ||
} | ||
return false; | ||
} | ||
module.exports = { | ||
@@ -476,3 +516,6 @@ isOperaMini: isOperaMini, | ||
getIEVersion: getIEVersion, | ||
isHTTPS: isHTTPS | ||
isHTTPS: isHTTPS, | ||
isIos: isIos, | ||
isAndroid: isAndroid, | ||
supportsPopups: supportsPopups | ||
}; | ||
@@ -484,3 +527,3 @@ | ||
var BT_ORIGIN_REGEX = /^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/; | ||
var isWhitelistedDomain = _dereq_('../is-whitelisted-domain'); | ||
@@ -503,3 +546,7 @@ function checkOrigin(postMessageOrigin, merchantUrl) { | ||
return merchantOrigin === postMessageOrigin || BT_ORIGIN_REGEX.test(postMessageOrigin); | ||
if (merchantOrigin === postMessageOrigin) { return true; } | ||
a.href = postMessageOrigin; | ||
return isWhitelistedDomain(postMessageOrigin) && a.hostname !== 'localhost'; | ||
} | ||
@@ -511,3 +558,3 @@ | ||
},{}],11:[function(_dereq_,module,exports){ | ||
},{"../is-whitelisted-domain":19}],11:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -655,3 +702,3 @@ | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
var PLATFORM = 'web'; | ||
@@ -736,3 +783,3 @@ | ||
},{"../lib/polyfill":21}],16:[function(_dereq_,module,exports){ | ||
},{"../lib/polyfill":22}],16:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -845,2 +892,37 @@ | ||
var parser; | ||
var legalHosts = { | ||
'paypal.com': 1, | ||
'braintreepayments.com': 1, | ||
'braintreegateway.com': 1, | ||
localhost: 1 | ||
}; | ||
/* eslint-enable no-undef,block-scoped-var */ | ||
function stripSubdomains(domain) { | ||
return domain.split('.').slice(-2).join('.'); | ||
} | ||
function isWhitelistedDomain(url) { | ||
var mainDomain; | ||
url = url.toLowerCase(); | ||
if (!/^https:/.test(url)) { | ||
return false; | ||
} | ||
parser = parser || document.createElement('a'); | ||
parser.href = url; | ||
mainDomain = stripSubdomains(parser.hostname); | ||
return legalHosts.hasOwnProperty(mainDomain); | ||
} | ||
module.exports = isWhitelistedDomain; | ||
},{}],20:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
module.exports = function (value) { | ||
@@ -850,3 +932,3 @@ return JSON.parse(JSON.stringify(value)); | ||
},{}],20:[function(_dereq_,module,exports){ | ||
},{}],21:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -860,3 +942,3 @@ | ||
},{}],21:[function(_dereq_,module,exports){ | ||
},{}],22:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -900,3 +982,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'; | ||
@@ -915,3 +997,3 @@ | ||
},{}],23:[function(_dereq_,module,exports){ | ||
},{}],24:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -929,3 +1011,3 @@ | ||
var events = _dereq_('../shared/events'); | ||
var version = "3.0.0-beta.12"; | ||
var version = "3.0.0"; | ||
var iFramer = _dereq_('iframer'); | ||
@@ -1034,3 +1116,3 @@ var sharedErrors = _dereq_('../../errors'); | ||
if (this._verifyCardInProgress === true) { | ||
error = errors.AUTHENTICATION_IN_PROGRESS; | ||
error = errors.THREEDS_AUTHENTICATION_IN_PROGRESS; | ||
} else if (!options.nonce) { | ||
@@ -1048,4 +1130,4 @@ errorOption = 'a nonce'; | ||
error = { | ||
type: errors.MISSING_VERIFY_CARD_OPTION.type, | ||
code: errors.MISSING_VERIFY_CARD_OPTION.code, | ||
type: errors.THREEDS_MISSING_VERIFY_CARD_OPTION.type, | ||
code: errors.THREEDS_MISSING_VERIFY_CARD_OPTION.code, | ||
message: 'verifyCard options must include ' + errorOption + '.' | ||
@@ -1117,3 +1199,3 @@ }; | ||
if (!this._lookupPaymentMethod) { | ||
error = new BraintreeError(errors.NO_VERIFICATION_PAYLOAD); | ||
error = new BraintreeError(errors.THREEDS_NO_VERIFICATION_PAYLOAD); | ||
} | ||
@@ -1249,3 +1331,3 @@ | ||
},{"../../errors":6,"../../lib/analytics":8,"../../lib/bus":12,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/methods":20,"../../lib/uuid":22,"../shared/constants.json":25,"../shared/errors":26,"../shared/events":27,"iframer":2}],24:[function(_dereq_,module,exports){ | ||
},{"../../errors":6,"../../lib/analytics":8,"../../lib/bus":12,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/methods":21,"../../lib/uuid":23,"../shared/constants.json":26,"../shared/errors":27,"../shared/events":28,"iframer":2}],25:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1261,3 +1343,3 @@ /** @module braintree-web/three-d-secure */ | ||
var sharedErrors = _dereq_('../errors'); | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
@@ -1339,3 +1421,3 @@ /** | ||
},{"../errors":6,"../lib/analytics":8,"../lib/browser-detection":9,"../lib/deferred":16,"../lib/error":18,"./external/three-d-secure":23,"./shared/errors":26}],25:[function(_dereq_,module,exports){ | ||
},{"../errors":6,"../lib/analytics":8,"../lib/browser-detection":9,"../lib/deferred":16,"../lib/error":18,"./external/three-d-secure":24,"./shared/errors":27}],26:[function(_dereq_,module,exports){ | ||
module.exports={ | ||
@@ -1345,3 +1427,3 @@ "LANDING_FRAME_NAME": "braintreethreedsecurelanding" | ||
},{}],26:[function(_dereq_,module,exports){ | ||
},{}],27:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1352,14 +1434,14 @@ | ||
module.exports = { | ||
AUTHENTICATION_IN_PROGRESS: { | ||
THREEDS_AUTHENTICATION_IN_PROGRESS: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'AUTHENTICATION_IN_PROGRESS', | ||
code: 'THREEDS_AUTHENTICATION_IN_PROGRESS', | ||
message: 'Cannot call verifyCard while existing authentication is in progress.' | ||
}, | ||
MISSING_VERIFY_CARD_OPTION: { | ||
THREEDS_MISSING_VERIFY_CARD_OPTION: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'MISSING_VERIFY_CARD_OPTION' | ||
code: 'THREEDS_MISSING_VERIFY_CARD_OPTION' | ||
}, | ||
NO_VERIFICATION_PAYLOAD: { | ||
THREEDS_NO_VERIFICATION_PAYLOAD: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'NO_VERIFICATION_PAYLOAD', | ||
code: 'THREEDS_NO_VERIFICATION_PAYLOAD', | ||
message: 'No verification payload available.' | ||
@@ -1377,5 +1459,5 @@ }, | ||
}, | ||
TERM_URL_REQUIRES_BRAINTREE_DOMAIN: { | ||
THREEDS_TERM_URL_REQUIRES_BRAINTREE_DOMAIN: { | ||
type: BraintreeError.types.INTERNAL, | ||
code: 'TERM_URL_REQUIRES_BRAINTREE_DOMAIN', | ||
code: 'THREEDS_TERM_URL_REQUIRES_BRAINTREE_DOMAIN', | ||
message: 'Term Url must be on a Braintree domain.' | ||
@@ -1385,3 +1467,3 @@ } | ||
},{"../../lib/error":18}],27:[function(_dereq_,module,exports){ | ||
},{"../../lib/error":18}],28:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1395,3 +1477,3 @@ | ||
},{"../../lib/enumerate":17}]},{},[24])(24) | ||
},{"../../lib/enumerate":17}]},{},[25])(25) | ||
}); |
@@ -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={})).threeDSecure=e()}}(function(){var e;return function t(e,r,n){function o(s,a){if(!r[s]){if(!e[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 l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return o(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(t,r,n){(function(t){"use strict";!function(o,i){"object"==typeof n&&"undefined"!=typeof r?r.exports=i("undefined"==typeof t?o:t):"function"==typeof e&&e.amd?e([],function(){return i(o)}):o.framebus=i(o)}(this,function(e){function t(e){return null==e?!1:null==e.Window?!1:e.constructor!==e.Window?!1:(g.push(e),!0)}function r(e){var t,r={};for(t in I)I.hasOwnProperty(t)&&(r[t]=I[t]);return r._origin=e||"*",r}function n(e){var t,r,n=s(this);return a(e)?!1:a(n)?!1:(r=Array.prototype.slice.call(arguments,1),t=c(e,r,n),t===!1?!1:(y(b.top,t,n),!0))}function o(e,t){var r=s(this);return E(e,t,r)?!1:(v[r]=v[r]||{},v[r][e]=v[r][e]||[],v[r][e].push(t),!0)}function i(e,t){var r,n,o=s(this);if(E(e,t,o))return!1;if(n=v[o]&&v[o][e],!n)return!1;for(r=0;r<n.length;r++)if(n[r]===t)return n.splice(r,1),!0;return!1}function s(e){return e&&e._origin||"*"}function a(e){return"string"!=typeof e}function c(e,t,r){var n=!1,o={event:e,origin:r},i=t[t.length-1];"function"==typeof i&&(o.reply=m(i,r),t=t.slice(0,-1)),o.args=t;try{n=N+JSON.stringify(o)}catch(s){throw new Error("Could not stringify event: "+s.message)}return n}function u(e){var t,r,n,o;if(e.data.slice(0,N.length)!==N)return!1;try{t=JSON.parse(e.data.slice(N.length))}catch(i){return!1}return null!=t.reply&&(r=e.origin,n=e.source,o=t.reply,t.reply=function(e){var t=c(o,[e],r);return t===!1?!1:void n.postMessage(t,r)},t.args.push(t.reply)),t}function l(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 f(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,r="x"===e?t:3&t|8;return r.toString(16)})}function p(e){var t;a(e.data)||(t=u(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,r,n){var o;if(v[e]&&v[e][t])for(o=0;o<v[e][t].length;o++)v[e][t][o].apply(n,r)}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,r){var n;try{for(e.postMessage(t,r),h(e)&&y(e.opener.top,t,r),n=0;n<e.frames.length;n++)y(e.frames[n],t,r)}catch(o){}}function _(e,t,r){var n,o;for(n=g.length-1;n>=0;n--)o=g[n],o.closed===!0?g=g.slice(n,1):r!==o&&y(o.top,e,t)}function m(e,t){function r(o,i){e(o,i),I.target(t).unsubscribe(n,r)}var n=f();return I.target(t).subscribe(n,r),n}function E(e,t,r){return a(e)?!0:"function"!=typeof t?!0:a(r)?!0:!1}var b,I,g=[],v={},N="/*framebus*/";return l(),I={target:r,include:t,publish:n,pub:n,trigger:n,emit:n,subscribe:o,sub:o,on:o,unsubscribe:i,unsub:i,off:i}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,r){"use strict";var n=e("./lib/set-attributes"),o=e("./lib/default-attributes"),i=e("./lib/assign");t.exports=function(e){var t=document.createElement("iframe"),r=i({},o,e);return r.style&&"string"!=typeof r.style&&(i(t.style,r.style),delete r.style),n(t,r),t.getAttribute("id")||(t.id=t.name),t}},{"./lib/assign":3,"./lib/default-attributes":4,"./lib/set-attributes":5}],3:[function(e,t,r){"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(r){e[r]=t[r]})}),e}},{}],4:[function(e,t,r){t.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],5:[function(e,t,r){"use strict";t.exports=function(e,t){var r;for(var n in t)t.hasOwnProperty(n)&&(r=t[n],null==r?e.removeAttribute(n):e.setAttribute(n,r))}},{}],6:[function(e,t,r){"use strict";var n=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:n.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:n.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:n.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:n.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":18}],7:[function(e,t,r){"use strict";function n(e,t){var r,n=t?i(t):{},a=o(e.authorization).attrs,c=i(e.analyticsMetadata);n.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION;for(r in n._meta)n._meta.hasOwnProperty(r)&&(c[r]=n._meta[r]);return n._meta=c,a.tokenizationKey?n.tokenizationKey=a.tokenizationKey:n.authorizationFingerprint=a.authorizationFingerprint,n}var o=e("./create-authorization-data"),i=e("./json-clone"),s=e("./constants");t.exports=n},{"./constants":13,"./create-authorization-data":15,"./json-clone":19}],8:[function(e,t,r){"use strict";function n(e){return Math.floor(e/1e3)}function o(e,t,r){var o=e.getConfiguration(),a=e._request,c=n(Date.now()),u=o.gatewayConfiguration.analytics.url,l={analytics:[{kind:t,timestamp:c}]};a({url:u,method:"post",data:s(o,l),timeout:i.ANALYTICS_REQUEST_TIMEOUT_MS},r)}var i=e("./constants"),s=e("./add-metadata");t.exports={sendEvent:o}},{"./add-metadata":7,"./constants":13}],9:[function(e,t,r){(function(e){"use strict";function r(t){return t=t||e.navigator.userAgent,t.indexOf("Opera Mini")>-1}function n(t){return t=t||e.navigator.userAgent,t.indexOf("Android")>-1&&t.indexOf("Firefox")>-1}function o(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}function i(t){return t=t||e.location.protocol,"https:"===t}t.exports={isOperaMini:r,isAndroidFirefox:n,getIEVersion:o,isHTTPS:i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(e,t,r){"use strict";function n(e,t){var r,n,i=document.createElement("a");return i.href=t,n="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,r=i.protocol+"//"+n,r===e||o.test(e)}var o=/^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/;t.exports={checkOrigin:n}},{}],11:[function(e,t,r){"use strict";var n=e("../enumerate");t.exports=n(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":17}],12:[function(e,t,r){"use strict";function n(e){if(e=e||{},this.channel=e.channel,!this.channel)throw new a({type:a.types.INTERNAL,code:"MISSING_CHANNEL_ID",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 o=e("framebus"),i=e("./events"),s=e("./check-origin").checkOrigin,a=e("../error");n.prototype.on=function(e,t){var r,n,i=t,a=this;this._isDestroyed||(this.merchantUrl&&(i=function(){s(this.origin,a.merchantUrl)&&t.apply(this,arguments)}),r=this._namespaceEvent(e),n=Array.prototype.slice.call(arguments),n[0]=r,n[1]=i,this._log("on",n),o.on.apply(o,n),this._listeners.push({eventName:e,handler:i,originalHandler:t}))},n.prototype.emit=function(e){var t;this._isDestroyed||(t=Array.prototype.slice.call(arguments),t[0]=this._namespaceEvent(e),this._log("emit",t),o.emit.apply(o,t))},n.prototype._offDirect=function(e){var t=Array.prototype.slice.call(arguments);this._isDestroyed||(t[0]=this._namespaceEvent(e),this._log("off",t),o.off.apply(o,t))},n.prototype.off=function(e,t){var r,n,o=t;if(!this._isDestroyed){if(this.merchantUrl)for(r=0;r<this._listeners.length;r++)n=this._listeners[r],n.originalHandler===t&&(o=n.handler);this._offDirect(e,o)}},n.prototype._namespaceEvent=function(e){return["braintree",this.channel,e].join(":")},n.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},n.prototype._log=function(e,t){this._isVerbose&&console.log(e,t)},n.events=i,t.exports=n},{"../error":18,"./check-origin":10,"./events":11,framebus:1}],13:[function(e,t,r){"use strict";var n="3.0.0-beta.12",o="web";t.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:n,INTEGRATION:"custom",SOURCE:"client",PLATFORM:o,BRAINTREE_LIBRARY_VERSION:"braintree/"+o+"/"+n}},{}],14:[function(e,t,r){"use strict";var n=e("./error"),o=e("../errors");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new n({type:o.METHOD_CALLED_AFTER_TEARDOWN.type,code:o.METHOD_CALLED_AFTER_TEARDOWN.code,message:t+" cannot be called after teardown."})}})}},{"../errors":6,"./error":18}],15:[function(e,t,r){"use strict";function n(e){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(e)}function o(e){var t=e.split("_"),r=t[0],n=t.slice(2).join("_");return{merchantId:n,environment:r}}function i(e){var t,r,i={attrs:{},configUrl:""};return n(e)?(r=o(e),i.attrs.tokenizationKey=e,i.configUrl=a[r.environment]+"/merchants/"+r.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(s(e)),i.attrs.authorizationFingerprint=t.authorizationFingerprint,i.configUrl=t.configUrl),i}var s=e("../lib/polyfill").atob,a={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=i},{"../lib/polyfill":21}],16:[function(e,t,r){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],17:[function(e,t,r){"use strict";function n(e,t){return t=null==t?"":t,e.reduce(function(e,r){return e[r]=t+r,e},{})}t.exports=n},{}],18:[function(e,t,r){"use strict";function n(e){if(!n.types.hasOwnProperty(e.type))throw new Error(e.type+" is not a valid type.");if(!e.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,this.message=e.message,this.type=e.type,this.details=e.details}var o=e("./enumerate");n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n.types=o(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),t.exports=n},{"./enumerate":17}],19:[function(e,t,r){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],20:[function(e,t,r){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],21:[function(e,t,r){(function(e){"use strict";function r(e){var t,r,n,o,i,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+/=",f="";if(!u.test(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");c=0;do o=l.indexOf(e.charAt(c++)),i=l.indexOf(e.charAt(c++)),s=l.indexOf(e.charAt(c++)),a=l.indexOf(e.charAt(c++)),t=(63&o)<<2|i>>4&3,r=(15&i)<<4|s>>2&15,n=(3&s)<<6|63&a,f+=String.fromCharCode(t)+(r?String.fromCharCode(r):"")+(n?String.fromCharCode(n):"");while(c<e.length);return f}var n="function"==typeof e.atob?e.atob:r;t.exports={atob:n,_atob:r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],22:[function(e,t,r){"use strict";function n(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,r="x"===e?t:3&t|8;return r.toString(16)})}t.exports=n},{}],23:[function(e,t,r){"use strict";function n(e){this._options=e,this._assetsUrl=e.client.getConfiguration().gatewayConfiguration.assetsUrl,this._client=e.client}var o=e("../../lib/error"),i=e("../../lib/analytics"),s=e("../../lib/methods"),a=e("../../lib/convert-methods-to-error"),c=e("../shared/constants.json"),u=e("../../lib/bus"),l=e("../../lib/uuid"),f=e("../../lib/deferred"),p=e("../shared/errors"),d=e("../shared/events"),h="3.0.0-beta.12",y=e("iframer"),_=e("../../errors"),m=400,E=400;n.prototype.verifyCard=function(e,t){var r,n,i,s,a;if("function"!=typeof t)throw new o({type:_.CALLBACK_REQUIRED.type,code:_.CALLBACK_REQUIRED.code,message:"verifyCard must include a callback function."});return e=e||{},t=f(t),this._verifyCardInProgress===!0?s=p.AUTHENTICATION_IN_PROGRESS:e.nonce?e.amount?"function"!=typeof e.addFrame?a="an addFrame function":"function"!=typeof e.removeFrame&&(a="a removeFrame function"):a="an amount":a="a nonce",a&&(s={type:p.MISSING_VERIFY_CARD_OPTION.type,code:p.MISSING_VERIFY_CARD_OPTION.code,message:"verifyCard options must include "+a+"."}),s?void t(new o(s)):(this._verifyCardInProgress=!0,n=f(e.addFrame),i=f(e.removeFrame),r="payment_methods/"+e.nonce+"/three_d_secure/lookup",void this._client.request({endpoint:r,method:"post",data:{amount:e.amount}},function(e,r){return e?void t(e):(this._lookupPaymentMethod=r.paymentMethod,this._verifyCardCallback=function(){this._verifyCardInProgress=!1,t.apply(null,arguments)}.bind(this),void this._handleLookupResponse({lookupResponse:r,addFrame:n,removeFrame:i}))}.bind(this)))},n.prototype.cancelVerifyCard=function(e){var t;this._verifyCardInProgress=!1,"function"==typeof e&&(this._lookupPaymentMethod||(t=new o(p.NO_VERIFICATION_PAYLOAD)),e(t,this._lookupPaymentMethod))},n.prototype._handleLookupResponse=function(e){var t=e.lookupResponse;t.lookup&&t.lookup.acsUrl&&t.lookup.acsUrl.length>0?e.addFrame(null,this._createIframe({response:t.lookup,removeFrame:e.removeFrame})):this._verifyCardCallback(null,{nonce:t.paymentMethod.nonce,verificationDetails:t.threeDSecureInfo})},n.prototype._createIframe=function(e){var t,r,n=window.location.href,o=e.response;return this._bus=new u({channel:l(),merchantUrl:location.href}),r=this._assetsUrl+"/web/"+h+"/html/three-d-secure-authentication-complete-frame.html?channel="+encodeURIComponent(this._bus.channel)+"&",n.indexOf("#")>-1&&(n=n.split("#")[0]),this._bus.on(u.events.CONFIGURATION_REQUEST,function(e){e({acsUrl:o.acsUrl,pareq:o.pareq,termUrl:o.termUrl+"&three_d_secure_version="+h+"&authentication_complete_base_url="+encodeURIComponent(r),md:o.md,parentUrl:n})}),this._bus.on(d.AUTHENTICATION_COMPLETE,function(t){this._handleAuthResponse(t,e)}.bind(this)),t=this._assetsUrl+"/web/"+h+"/html/three-d-secure-bank-frame.min.html",this._bankIframe=y({src:t,height:m,width:E,name:c.LANDING_FRAME_NAME+"_"+this._bus.channel}),this._bankIframe},n.prototype._handleAuthResponse=function(e,t){var r=JSON.parse(e.auth_response);this._bus.teardown(),t.removeFrame(),f(function(){r.success?this._verifyCardCallback(null,this._formatAuthResponse(r.paymentMethod,r.threeDSecureInfo)):r.threeDSecureInfo&&r.threeDSecureInfo.liabilityShiftPossible?this._verifyCardCallback(null,this._formatAuthResponse(this._lookupPaymentMethod,r.threeDSecureInfo)):this._verifyCardCallback(new o({type:o.types.UNKNOWN,code:"UNKNOWN_AUTH_RESPONSE",message:r.error.message}))}.bind(this))()},n.prototype._formatAuthResponse=function(e,t){return{nonce:e.nonce,details:e.details,description:e.description,liabilityShifted:t.liabilityShifted,liabilityShiftPossible:t.liabilityShiftPossible}},n.prototype.teardown=function(e){var t;a(this,s(n.prototype)),i.sendEvent(this._options.client,"web.threedsecure.teardown-completed"),this._bus&&this._bus.teardown(),this._bankIframe&&(t=this._bankIframe.parentNode,t&&t.removeChild(this._bankIframe)),"function"==typeof e&&(e=f(e))()},t.exports=n},{"../../errors":6,"../../lib/analytics":8,"../../lib/bus":12,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/methods":20,"../../lib/uuid":22,"../shared/constants.json":25,"../shared/errors":26,"../shared/events":27,iframer:2}],24:[function(e,t,r){"use strict";function n(e,t){var r,n,p,d;if("function"!=typeof t)throw new s({type:l.CALLBACK_REQUIRED.type,code:l.CALLBACK_REQUIRED.code,message:"create must include a callback function."});if(t=c(t),null==e.client)return void t(new s({type:l.INSTANTIATION_OPTION_REQUIRED.type,code:l.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating 3D Secure."}));if(r=e.client.getConfiguration(),d=r.analyticsMetadata.sdkVersion,r.gatewayConfiguration.threeDSecureEnabled?r.analyticsMetadata.sdkVersion!==f?p={type:l.INCOMPATIBLE_VERSIONS.type,code:l.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+d+") and 3D Secure (version "+f+") components must be from the same SDK version."}:i.isHTTPS()||(p=u.THREEDS_HTTPS_REQUIRED):p=u.THREEDS_NOT_ENABLED,p)return void t(new s(p));a.sendEvent(e.client,"web.threedsecure.initialized");try{n=new o(e)}catch(h){return void t(h)}t(null,n)}var o=e("./external/three-d-secure"),i=e("../lib/browser-detection"),s=e("../lib/error"),a=e("../lib/analytics"),c=e("../lib/deferred"),u=e("./shared/errors"),l=e("../errors"),f="3.0.0-beta.12";t.exports={create:n,VERSION:f}},{"../errors":6,"../lib/analytics":8,"../lib/browser-detection":9,"../lib/deferred":16,"../lib/error":18,"./external/three-d-secure":23,"./shared/errors":26}],25:[function(e,t,r){t.exports={LANDING_FRAME_NAME:"braintreethreedsecurelanding"}},{}],26:[function(e,t,r){"use strict";var n=e("../../lib/error");t.exports={AUTHENTICATION_IN_PROGRESS:{type:n.types.MERCHANT,code:"AUTHENTICATION_IN_PROGRESS",message:"Cannot call verifyCard while existing authentication is in progress."},MISSING_VERIFY_CARD_OPTION:{type:n.types.MERCHANT,code:"MISSING_VERIFY_CARD_OPTION"},NO_VERIFICATION_PAYLOAD:{type:n.types.MERCHANT,code:"NO_VERIFICATION_PAYLOAD",message:"No verification payload available."},THREEDS_NOT_ENABLED:{type:n.types.MERCHANT,code:"THREEDS_NOT_ENABLED",message:"3D Secure is not enabled for this merchant."},THREEDS_HTTPS_REQUIRED:{type:n.types.MERCHANT,code:"THREEDS_HTTPS_REQUIRED",message:"3D Secure requires HTTPS."},TERM_URL_REQUIRES_BRAINTREE_DOMAIN:{type:n.types.INTERNAL,code:"TERM_URL_REQUIRES_BRAINTREE_DOMAIN",message:"Term Url must be on a Braintree domain."}}},{"../../lib/error":18}],27:[function(e,t,r){"use strict";var n=e("../../lib/enumerate");t.exports=n(["AUTHENTICATION_COMPLETE"],"threedsecure:")},{"../../lib/enumerate":17}]},{},[24])(24)}); | ||
!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={})).threeDSecure=e()}}(function(){var e;return function t(e,r,n){function o(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return o(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(t,r,n){(function(t){"use strict";!function(o,i){"object"==typeof n&&"undefined"!=typeof r?r.exports=i("undefined"==typeof t?o:t):"function"==typeof e&&e.amd?e([],function(){return i(o)}):o.framebus=i(o)}(this,function(e){function t(e){return null==e?!1:null==e.Window?!1:e.constructor!==e.Window?!1:(I.push(e),!0)}function r(e){var t,r={};for(t in g)g.hasOwnProperty(t)&&(r[t]=g[t]);return r._origin=e||"*",r}function n(e){var t,r,n=s(this);return a(e)?!1:a(n)?!1:(r=Array.prototype.slice.call(arguments,1),t=u(e,r,n),t===!1?!1:(_(b.top,t,n),!0))}function o(e,t){var r=s(this);return m(e,t,r)?!1:(v[r]=v[r]||{},v[r][e]=v[r][e]||[],v[r][e].push(t),!0)}function i(e,t){var r,n,o=s(this);if(m(e,t,o))return!1;if(n=v[o]&&v[o][e],!n)return!1;for(r=0;r<n.length;r++)if(n[r]===t)return n.splice(r,1),!0;return!1}function s(e){return e&&e._origin||"*"}function a(e){return"string"!=typeof e}function u(e,t,r){var n=!1,o={event:e,origin:r},i=t[t.length-1];"function"==typeof i&&(o.reply=E(i,r),t=t.slice(0,-1)),o.args=t;try{n=A+JSON.stringify(o)}catch(s){throw new Error("Could not stringify event: "+s.message)}return n}function c(e){var t,r,n,o;if(e.data.slice(0,A.length)!==A)return!1;try{t=JSON.parse(e.data.slice(A.length))}catch(i){return!1}return null!=t.reply&&(r=e.origin,n=e.source,o=t.reply,t.reply=function(e){var t=u(o,[e],r);return t===!1?!1:void n.postMessage(t,r)},t.args.push(t.reply)),t}function l(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 f(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,r="x"===e?t:3&t|8;return r.toString(16)})}function p(e){var t;a(e.data)||(t=c(e),t&&(d("*",t.event,t.args,e),d(e.origin,t.event,t.args,e),y(e.data,t.origin,e.source)))}function d(e,t,r,n){var o;if(v[e]&&v[e][t])for(o=0;o<v[e][t].length;o++)v[e][t][o].apply(n,r)}function h(e){return e.top!==e?!1:null==e.opener?!1:e.opener===e?!1:e.opener.closed===!0?!1:!0}function _(e,t,r){var n;try{for(e.postMessage(t,r),h(e)&&_(e.opener.top,t,r),n=0;n<e.frames.length;n++)_(e.frames[n],t,r)}catch(o){}}function y(e,t,r){var n,o;for(n=I.length-1;n>=0;n--)o=I[n],o.closed===!0?I=I.slice(n,1):r!==o&&_(o.top,e,t)}function E(e,t){function r(o,i){e(o,i),g.target(t).unsubscribe(n,r)}var n=f();return g.target(t).subscribe(n,r),n}function m(e,t,r){return a(e)?!0:"function"!=typeof t?!0:a(r)?!0:!1}var b,g,I=[],v={},A="/*framebus*/";return l(),g={target:r,include:t,publish:n,pub:n,trigger:n,emit:n,subscribe:o,sub:o,on:o,unsubscribe:i,unsub:i,off:i}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,r){"use strict";var n=e("./lib/set-attributes"),o=e("./lib/default-attributes"),i=e("./lib/assign");t.exports=function(e){var t=document.createElement("iframe"),r=i({},o,e);return r.style&&"string"!=typeof r.style&&(i(t.style,r.style),delete r.style),n(t,r),t.getAttribute("id")||(t.id=t.name),t}},{"./lib/assign":3,"./lib/default-attributes":4,"./lib/set-attributes":5}],3:[function(e,t,r){"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(r){e[r]=t[r]})}),e}},{}],4:[function(e,t,r){t.exports={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no"}},{}],5:[function(e,t,r){"use strict";t.exports=function(e,t){var r;for(var n in t)t.hasOwnProperty(n)&&(r=t[n],null==r?e.removeAttribute(n):e.setAttribute(n,r))}},{}],6:[function(e,t,r){"use strict";var n=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:n.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:n.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:n.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:n.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":18}],7:[function(e,t,r){"use strict";function n(e,t){var r,n=t?i(t):{},a=o(e.authorization).attrs,u=i(e.analyticsMetadata);n.braintreeLibraryVersion=s.BRAINTREE_LIBRARY_VERSION;for(r in n._meta)n._meta.hasOwnProperty(r)&&(u[r]=n._meta[r]);return n._meta=u,a.tokenizationKey?n.tokenizationKey=a.tokenizationKey:n.authorizationFingerprint=a.authorizationFingerprint,n}var o=e("./create-authorization-data"),i=e("./json-clone"),s=e("./constants");t.exports=n},{"./constants":13,"./create-authorization-data":15,"./json-clone":20}],8:[function(e,t,r){"use strict";function n(e){return Math.floor(e/1e3)}function o(e,t,r){var o=e.getConfiguration(),a=e._request,u=n(Date.now()),c=o.gatewayConfiguration.analytics.url,l={analytics:[{kind:t,timestamp:u}]};a({url:c,method:"post",data:s(o,l),timeout:i.ANALYTICS_REQUEST_TIMEOUT_MS},r)}var i=e("./constants"),s=e("./add-metadata");t.exports={sendEvent:o}},{"./add-metadata":7,"./constants":13}],9:[function(e,t,r){(function(e){"use strict";function r(t){return t=t||e.navigator.userAgent,t.indexOf("Opera Mini")>-1}function n(t){return t=t||e.navigator.userAgent,a(t)&&t.indexOf("Firefox")>-1}function o(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}function i(t){return t=t||e.location.protocol,"https:"===t}function s(t){return t=t||e.navigator.userAgent,/iPhone|iPod|iPad/.test(t)}function a(t){return t=t||e.navigator.userAgent,/Android/.test(t)}function u(t){return t=t||e.navigator.userAgent,!(l(t)||f(t)||r(t))}function c(e){return/\bGSA\b/.test(e)}function l(t){return t=t||e.navigator.userAgent,s(t)?c(t)?!0:/.+AppleWebKit(?!.*Safari)/.test(t):!1}function f(t){var n=/Version\/[\d\.]+/;return t=t||e.navigator.userAgent,a(t)?n.test(t)&&!r(t):!1}t.exports={isOperaMini:r,isAndroidFirefox:n,getIEVersion:o,isHTTPS:i,isIos:s,isAndroid:a,supportsPopups:u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(e,t,r){"use strict";function n(e,t){var r,n,i=document.createElement("a");return i.href=t,n="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,r=i.protocol+"//"+n,r===e?!0:(i.href=e,o(e)&&"localhost"!==i.hostname)}var o=e("../is-whitelisted-domain");t.exports={checkOrigin:n}},{"../is-whitelisted-domain":19}],11:[function(e,t,r){"use strict";var n=e("../enumerate");t.exports=n(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":17}],12:[function(e,t,r){"use strict";function n(e){if(e=e||{},this.channel=e.channel,!this.channel)throw new a({type:a.types.INTERNAL,code:"MISSING_CHANNEL_ID",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 o=e("framebus"),i=e("./events"),s=e("./check-origin").checkOrigin,a=e("../error");n.prototype.on=function(e,t){var r,n,i=t,a=this;this._isDestroyed||(this.merchantUrl&&(i=function(){s(this.origin,a.merchantUrl)&&t.apply(this,arguments)}),r=this._namespaceEvent(e),n=Array.prototype.slice.call(arguments),n[0]=r,n[1]=i,this._log("on",n),o.on.apply(o,n),this._listeners.push({eventName:e,handler:i,originalHandler:t}))},n.prototype.emit=function(e){var t;this._isDestroyed||(t=Array.prototype.slice.call(arguments),t[0]=this._namespaceEvent(e),this._log("emit",t),o.emit.apply(o,t))},n.prototype._offDirect=function(e){var t=Array.prototype.slice.call(arguments);this._isDestroyed||(t[0]=this._namespaceEvent(e),this._log("off",t),o.off.apply(o,t))},n.prototype.off=function(e,t){var r,n,o=t;if(!this._isDestroyed){if(this.merchantUrl)for(r=0;r<this._listeners.length;r++)n=this._listeners[r],n.originalHandler===t&&(o=n.handler);this._offDirect(e,o)}},n.prototype._namespaceEvent=function(e){return["braintree",this.channel,e].join(":")},n.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},n.prototype._log=function(e,t){this._isVerbose&&console.log(e,t)},n.events=i,t.exports=n},{"../error":18,"./check-origin":10,"./events":11,framebus:1}],13:[function(e,t,r){"use strict";var n="3.0.0",o="web";t.exports={ANALYTICS_REQUEST_TIMEOUT_MS:2e3,INTEGRATION_TIMEOUT_MS:6e4,VERSION:n,INTEGRATION:"custom",SOURCE:"client",PLATFORM:o,BRAINTREE_LIBRARY_VERSION:"braintree/"+o+"/"+n}},{}],14:[function(e,t,r){"use strict";var n=e("./error"),o=e("../errors");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new n({type:o.METHOD_CALLED_AFTER_TEARDOWN.type,code:o.METHOD_CALLED_AFTER_TEARDOWN.code,message:t+" cannot be called after teardown."})}})}},{"../errors":6,"./error":18}],15:[function(e,t,r){"use strict";function n(e){return/^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+$/.test(e)}function o(e){var t=e.split("_"),r=t[0],n=t.slice(2).join("_");return{merchantId:n,environment:r}}function i(e){var t,r,i={attrs:{},configUrl:""};return n(e)?(r=o(e),i.attrs.tokenizationKey=e,i.configUrl=a[r.environment]+"/merchants/"+r.merchantId+"/client_api/v1/configuration"):(t=JSON.parse(s(e)),i.attrs.authorizationFingerprint=t.authorizationFingerprint,i.configUrl=t.configUrl),i}var s=e("../lib/polyfill").atob,a={production:"https://api.braintreegateway.com:443",sandbox:"https://api.sandbox.braintreegateway.com:443"};t.exports=i},{"../lib/polyfill":22}],16:[function(e,t,r){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],17:[function(e,t,r){"use strict";function n(e,t){return t=null==t?"":t,e.reduce(function(e,r){return e[r]=t+r,e},{})}t.exports=n},{}],18:[function(e,t,r){"use strict";function n(e){if(!n.types.hasOwnProperty(e.type))throw new Error(e.type+" is not a valid type.");if(!e.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,this.message=e.message,this.type=e.type,this.details=e.details}var o=e("./enumerate");n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n.types=o(["CUSTOMER","MERCHANT","NETWORK","INTERNAL","UNKNOWN"]),t.exports=n},{"./enumerate":17}],19:[function(e,t,r){"use strict";function n(e){return e.split(".").slice(-2).join(".")}function o(e){var t;return e=e.toLowerCase(),/^https:/.test(e)?(i=i||document.createElement("a"),i.href=e,t=n(i.hostname),s.hasOwnProperty(t)):!1}var i,s={"paypal.com":1,"braintreepayments.com":1,"braintreegateway.com":1,localhost:1};t.exports=o},{}],20:[function(e,t,r){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],21:[function(e,t,r){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],22:[function(e,t,r){(function(e){"use strict";function r(e){var t,r,n,o,i,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+/=",f="";if(!c.test(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");u=0;do o=l.indexOf(e.charAt(u++)),i=l.indexOf(e.charAt(u++)),s=l.indexOf(e.charAt(u++)),a=l.indexOf(e.charAt(u++)),t=(63&o)<<2|i>>4&3,r=(15&i)<<4|s>>2&15,n=(3&s)<<6|63&a,f+=String.fromCharCode(t)+(r?String.fromCharCode(r):"")+(n?String.fromCharCode(n):"");while(u<e.length);return f}var n="function"==typeof e.atob?e.atob:r;t.exports={atob:n,_atob:r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],23:[function(e,t,r){"use strict";function n(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,r="x"===e?t:3&t|8;return r.toString(16)})}t.exports=n},{}],24:[function(e,t,r){"use strict";function n(e){this._options=e,this._assetsUrl=e.client.getConfiguration().gatewayConfiguration.assetsUrl,this._client=e.client}var o=e("../../lib/error"),i=e("../../lib/analytics"),s=e("../../lib/methods"),a=e("../../lib/convert-methods-to-error"),u=e("../shared/constants.json"),c=e("../../lib/bus"),l=e("../../lib/uuid"),f=e("../../lib/deferred"),p=e("../shared/errors"),d=e("../shared/events"),h="3.0.0",_=e("iframer"),y=e("../../errors"),E=400,m=400;n.prototype.verifyCard=function(e,t){var r,n,i,s,a;if("function"!=typeof t)throw new o({type:y.CALLBACK_REQUIRED.type,code:y.CALLBACK_REQUIRED.code,message:"verifyCard must include a callback function."});return e=e||{},t=f(t),this._verifyCardInProgress===!0?s=p.THREEDS_AUTHENTICATION_IN_PROGRESS:e.nonce?e.amount?"function"!=typeof e.addFrame?a="an addFrame function":"function"!=typeof e.removeFrame&&(a="a removeFrame function"):a="an amount":a="a nonce",a&&(s={type:p.THREEDS_MISSING_VERIFY_CARD_OPTION.type,code:p.THREEDS_MISSING_VERIFY_CARD_OPTION.code,message:"verifyCard options must include "+a+"."}),s?void t(new o(s)):(this._verifyCardInProgress=!0,n=f(e.addFrame),i=f(e.removeFrame),r="payment_methods/"+e.nonce+"/three_d_secure/lookup",void this._client.request({endpoint:r,method:"post",data:{amount:e.amount}},function(e,r){return e?void t(e):(this._lookupPaymentMethod=r.paymentMethod,this._verifyCardCallback=function(){this._verifyCardInProgress=!1,t.apply(null,arguments)}.bind(this),void this._handleLookupResponse({lookupResponse:r,addFrame:n,removeFrame:i}))}.bind(this)))},n.prototype.cancelVerifyCard=function(e){var t;this._verifyCardInProgress=!1,"function"==typeof e&&(this._lookupPaymentMethod||(t=new o(p.THREEDS_NO_VERIFICATION_PAYLOAD)),e(t,this._lookupPaymentMethod))},n.prototype._handleLookupResponse=function(e){var t=e.lookupResponse;t.lookup&&t.lookup.acsUrl&&t.lookup.acsUrl.length>0?e.addFrame(null,this._createIframe({response:t.lookup,removeFrame:e.removeFrame})):this._verifyCardCallback(null,{nonce:t.paymentMethod.nonce,verificationDetails:t.threeDSecureInfo})},n.prototype._createIframe=function(e){var t,r,n=window.location.href,o=e.response;return this._bus=new c({channel:l(),merchantUrl:location.href}),r=this._assetsUrl+"/web/"+h+"/html/three-d-secure-authentication-complete-frame.html?channel="+encodeURIComponent(this._bus.channel)+"&",n.indexOf("#")>-1&&(n=n.split("#")[0]),this._bus.on(c.events.CONFIGURATION_REQUEST,function(e){e({acsUrl:o.acsUrl,pareq:o.pareq,termUrl:o.termUrl+"&three_d_secure_version="+h+"&authentication_complete_base_url="+encodeURIComponent(r),md:o.md,parentUrl:n})}),this._bus.on(d.AUTHENTICATION_COMPLETE,function(t){this._handleAuthResponse(t,e)}.bind(this)),t=this._assetsUrl+"/web/"+h+"/html/three-d-secure-bank-frame.min.html",this._bankIframe=_({src:t,height:E,width:m,name:u.LANDING_FRAME_NAME+"_"+this._bus.channel}),this._bankIframe},n.prototype._handleAuthResponse=function(e,t){var r=JSON.parse(e.auth_response);this._bus.teardown(),t.removeFrame(),f(function(){r.success?this._verifyCardCallback(null,this._formatAuthResponse(r.paymentMethod,r.threeDSecureInfo)):r.threeDSecureInfo&&r.threeDSecureInfo.liabilityShiftPossible?this._verifyCardCallback(null,this._formatAuthResponse(this._lookupPaymentMethod,r.threeDSecureInfo)):this._verifyCardCallback(new o({type:o.types.UNKNOWN,code:"UNKNOWN_AUTH_RESPONSE",message:r.error.message}))}.bind(this))()},n.prototype._formatAuthResponse=function(e,t){return{nonce:e.nonce,details:e.details,description:e.description,liabilityShifted:t.liabilityShifted,liabilityShiftPossible:t.liabilityShiftPossible}},n.prototype.teardown=function(e){var t;a(this,s(n.prototype)),i.sendEvent(this._options.client,"web.threedsecure.teardown-completed"),this._bus&&this._bus.teardown(),this._bankIframe&&(t=this._bankIframe.parentNode,t&&t.removeChild(this._bankIframe)),"function"==typeof e&&(e=f(e))()},t.exports=n},{"../../errors":6,"../../lib/analytics":8,"../../lib/bus":12,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/methods":21,"../../lib/uuid":23,"../shared/constants.json":26,"../shared/errors":27,"../shared/events":28,iframer:2}],25:[function(e,t,r){"use strict";function n(e,t){var r,n,p,d;if("function"!=typeof t)throw new s({type:l.CALLBACK_REQUIRED.type,code:l.CALLBACK_REQUIRED.code,message:"create must include a callback function."});if(t=u(t),null==e.client)return void t(new s({type:l.INSTANTIATION_OPTION_REQUIRED.type,code:l.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating 3D Secure."}));if(r=e.client.getConfiguration(),d=r.analyticsMetadata.sdkVersion,r.gatewayConfiguration.threeDSecureEnabled?r.analyticsMetadata.sdkVersion!==f?p={type:l.INCOMPATIBLE_VERSIONS.type,code:l.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+d+") and 3D Secure (version "+f+") components must be from the same SDK version."}:i.isHTTPS()||(p=c.THREEDS_HTTPS_REQUIRED):p=c.THREEDS_NOT_ENABLED,p)return void t(new s(p));a.sendEvent(e.client,"web.threedsecure.initialized");try{n=new o(e)}catch(h){return void t(h)}t(null,n)}var o=e("./external/three-d-secure"),i=e("../lib/browser-detection"),s=e("../lib/error"),a=e("../lib/analytics"),u=e("../lib/deferred"),c=e("./shared/errors"),l=e("../errors"),f="3.0.0";t.exports={create:n,VERSION:f}},{"../errors":6,"../lib/analytics":8,"../lib/browser-detection":9,"../lib/deferred":16,"../lib/error":18,"./external/three-d-secure":24,"./shared/errors":27}],26:[function(e,t,r){t.exports={LANDING_FRAME_NAME:"braintreethreedsecurelanding"}},{}],27:[function(e,t,r){"use strict";var n=e("../../lib/error");t.exports={THREEDS_AUTHENTICATION_IN_PROGRESS:{type:n.types.MERCHANT,code:"THREEDS_AUTHENTICATION_IN_PROGRESS",message:"Cannot call verifyCard while existing authentication is in progress."},THREEDS_MISSING_VERIFY_CARD_OPTION:{type:n.types.MERCHANT,code:"THREEDS_MISSING_VERIFY_CARD_OPTION"},THREEDS_NO_VERIFICATION_PAYLOAD:{type:n.types.MERCHANT,code:"THREEDS_NO_VERIFICATION_PAYLOAD",message:"No verification payload available."},THREEDS_NOT_ENABLED:{type:n.types.MERCHANT,code:"THREEDS_NOT_ENABLED",message:"3D Secure is not enabled for this merchant."},THREEDS_HTTPS_REQUIRED:{type:n.types.MERCHANT,code:"THREEDS_HTTPS_REQUIRED",message:"3D Secure requires HTTPS."},THREEDS_TERM_URL_REQUIRES_BRAINTREE_DOMAIN:{type:n.types.INTERNAL,code:"THREEDS_TERM_URL_REQUIRES_BRAINTREE_DOMAIN",message:"Term Url must be on a Braintree domain."}}},{"../../lib/error":18}],28:[function(e,t,r){"use strict";var n=e("../../lib/enumerate");t.exports=n(["AUTHENTICATION_COMPLETE"],"threedsecure:")},{"../../lib/enumerate":17}]},{},[25])(25)}); |
@@ -406,3 +406,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 = {})).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){ | ||
},{"./constants":13,"./create-authorization-data":15,"./json-clone":19}],8:[function(_dereq_,module,exports){ | ||
},{"./constants":13,"./create-authorization-data":15,"./json-clone":20}],8:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -466,3 +466,3 @@ | ||
var BT_ORIGIN_REGEX = /^https:\/\/([a-zA-Z0-9-]+\.)*(braintreepayments|braintreegateway|paypal)\.com(:\d{1,5})?$/; | ||
var isWhitelistedDomain = _dereq_('../is-whitelisted-domain'); | ||
@@ -485,3 +485,7 @@ function checkOrigin(postMessageOrigin, merchantUrl) { | ||
return merchantOrigin === postMessageOrigin || BT_ORIGIN_REGEX.test(postMessageOrigin); | ||
if (merchantOrigin === postMessageOrigin) { return true; } | ||
a.href = postMessageOrigin; | ||
return isWhitelistedDomain(postMessageOrigin) && a.hostname !== 'localhost'; | ||
} | ||
@@ -493,3 +497,3 @@ | ||
},{}],11:[function(_dereq_,module,exports){ | ||
},{"../is-whitelisted-domain":19}],11:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -637,3 +641,3 @@ | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
var PLATFORM = 'web'; | ||
@@ -718,3 +722,3 @@ | ||
},{"../lib/polyfill":21}],16:[function(_dereq_,module,exports){ | ||
},{"../lib/polyfill":22}],16:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -827,2 +831,37 @@ | ||
var parser; | ||
var legalHosts = { | ||
'paypal.com': 1, | ||
'braintreepayments.com': 1, | ||
'braintreegateway.com': 1, | ||
localhost: 1 | ||
}; | ||
/* eslint-enable no-undef,block-scoped-var */ | ||
function stripSubdomains(domain) { | ||
return domain.split('.').slice(-2).join('.'); | ||
} | ||
function isWhitelistedDomain(url) { | ||
var mainDomain; | ||
url = url.toLowerCase(); | ||
if (!/^https:/.test(url)) { | ||
return false; | ||
} | ||
parser = parser || document.createElement('a'); | ||
parser.href = url; | ||
mainDomain = stripSubdomains(parser.hostname); | ||
return legalHosts.hasOwnProperty(mainDomain); | ||
} | ||
module.exports = isWhitelistedDomain; | ||
},{}],20:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
module.exports = function (value) { | ||
@@ -832,3 +871,3 @@ return JSON.parse(JSON.stringify(value)); | ||
},{}],20:[function(_dereq_,module,exports){ | ||
},{}],21:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -842,3 +881,3 @@ | ||
},{}],21:[function(_dereq_,module,exports){ | ||
},{}],22:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
@@ -882,3 +921,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'; | ||
@@ -897,3 +936,3 @@ | ||
},{}],23:[function(_dereq_,module,exports){ | ||
},{}],24:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -911,3 +950,3 @@ /** | ||
var sharedErrors = _dereq_('../errors'); | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
@@ -983,3 +1022,3 @@ /** | ||
},{"../errors":6,"../lib/analytics":8,"../lib/deferred":16,"../lib/error":18,"./shared/errors":25,"./shared/unionpay":26}],24:[function(_dereq_,module,exports){ | ||
},{"../errors":6,"../lib/analytics":8,"../lib/deferred":16,"../lib/error":18,"./shared/errors":26,"./shared/unionpay":27}],25:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -998,3 +1037,3 @@ | ||
},{"../../lib/enumerate":17}],25:[function(_dereq_,module,exports){ | ||
},{"../../lib/enumerate":17}],26:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1010,40 +1049,40 @@ | ||
}, | ||
HOSTED_FIELDS_INSTANCE_INVALID: { | ||
UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'HOSTED_FIELDS_INSTANCE_INVALID', | ||
code: 'UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID', | ||
message: 'Found an invalid Hosted Fields instance. Please use a valid Hosted Fields instance.' | ||
}, | ||
HOSTED_FIELDS_INSTANCE_REQUIRED: { | ||
UNIONPAY_HOSTED_FIELDS_INSTANCE_REQUIRED: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'HOSTED_FIELDS_INSTANCE_REQUIRED', | ||
code: 'UNIONPAY_HOSTED_FIELDS_INSTANCE_REQUIRED', | ||
message: 'Could not find the Hosted Fields instance.' | ||
}, | ||
CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED: { | ||
UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED', | ||
code: 'UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED', | ||
message: 'A card or a Hosted Fields instance is required. Please supply a card or a Hosted Fields instance.' | ||
}, | ||
CARD_AND_HOSTED_FIELDS_INSTANCES: { | ||
UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'CARD_AND_HOSTED_FIELDS_INSTANCES', | ||
code: 'UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES', | ||
message: 'Please supply either a card or a Hosted Fields instance, not both.' | ||
}, | ||
EXPIRATION_DATE_INCOMPLETE: { | ||
UNIONPAY_EXPIRATION_DATE_INCOMPLETE: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'EXPIRATION_DATE_INCOMPLETE', | ||
code: 'UNIONPAY_EXPIRATION_DATE_INCOMPLETE', | ||
message: 'You must supply expiration month and year or neither.' | ||
}, | ||
ENROLLMENT_CUSTOMER_INPUT_INVALID: { | ||
UNIONPAY_ENROLLMENT_CUSTOMER_INPUT_INVALID: { | ||
type: BraintreeError.types.CUSTOMER, | ||
code: 'ENROLLMENT_CUSTOMER_INPUT_INVALID', | ||
code: 'UNIONPAY_ENROLLMENT_CUSTOMER_INPUT_INVALID', | ||
message: 'Enrollment failed due to user input error.' | ||
}, | ||
ENROLLMENT_NETWORK_ERROR: { | ||
UNIONPAY_ENROLLMENT_NETWORK_ERROR: { | ||
type: BraintreeError.types.NETWORK, | ||
code: 'ENROLLMENT_NETWORK_ERROR', | ||
code: 'UNIONPAY_ENROLLMENT_NETWORK_ERROR', | ||
message: 'Could not enroll UnionPay card.' | ||
}, | ||
FETCH_CAPABILITIES_NETWORK_ERROR: { | ||
UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR: { | ||
type: BraintreeError.types.NETWORK, | ||
code: 'FETCH_CAPABILITIES_NETWORK_ERROR', | ||
code: 'UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR', | ||
message: 'Could not fetch card capabilities.' | ||
@@ -1056,5 +1095,5 @@ }, | ||
}, | ||
MISSING_MOBILE_PHONE_DATA: { | ||
UNIONPAY_MISSING_MOBILE_PHONE_DATA: { | ||
type: BraintreeError.types.MERCHANT, | ||
code: 'MISSING_MOBILE_PHONE_DATA', | ||
code: 'UNIONPAY_MISSING_MOBILE_PHONE_DATA', | ||
message: 'A `mobile` with `countryCode` and `number` is required.' | ||
@@ -1069,3 +1108,3 @@ }, | ||
},{"../../lib/error":18}],26:[function(_dereq_,module,exports){ | ||
},{"../../lib/error":18}],27:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -1084,3 +1123,3 @@ | ||
var methods = _dereq_('../../lib/methods'); | ||
var VERSION = "3.0.0-beta.12"; | ||
var VERSION = "3.0.0"; | ||
var uuid = _dereq_('../../lib/uuid'); | ||
@@ -1186,3 +1225,3 @@ | ||
if (cardNumber && hostedFields) { | ||
callback(new BraintreeError(errors.CARD_AND_HOSTED_FIELDS_INSTANCES)); | ||
callback(new BraintreeError(errors.UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES)); | ||
return; | ||
@@ -1202,5 +1241,5 @@ } else if (cardNumber) { | ||
callback(new BraintreeError({ | ||
type: errors.FETCH_CAPABILITIES_NETWORK_ERROR.type, | ||
code: errors.FETCH_CAPABILITIES_NETWORK_ERROR.code, | ||
message: errors.FETCH_CAPABILITIES_NETWORK_ERROR.message, | ||
type: errors.UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR.type, | ||
code: errors.UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR.code, | ||
message: errors.UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR.message, | ||
details: { | ||
@@ -1219,3 +1258,3 @@ originalError: err | ||
if (!hostedFields._bus) { | ||
callback(new BraintreeError(errors.HOSTED_FIELDS_INSTANCE_INVALID)); | ||
callback(new BraintreeError(errors.UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID)); | ||
return; | ||
@@ -1234,3 +1273,3 @@ } | ||
} else { | ||
callback(new BraintreeError(errors.CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED)); | ||
callback(new BraintreeError(errors.UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED)); | ||
return; | ||
@@ -1319,3 +1358,3 @@ } | ||
if (!mobile) { | ||
callback(new BraintreeError(errors.MISSING_MOBILE_PHONE_DATA)); | ||
callback(new BraintreeError(errors.UNIONPAY_MISSING_MOBILE_PHONE_DATA)); | ||
return; | ||
@@ -1326,6 +1365,6 @@ } | ||
if (!hostedFields._bus) { | ||
callback(new BraintreeError(errors.HOSTED_FIELDS_INSTANCE_INVALID)); | ||
callback(new BraintreeError(errors.UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID)); | ||
return; | ||
} else if (card) { | ||
callback(new BraintreeError(errors.CARD_AND_HOSTED_FIELDS_INSTANCES)); | ||
callback(new BraintreeError(errors.UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES)); | ||
return; | ||
@@ -1361,3 +1400,3 @@ } | ||
} else { | ||
callback(new BraintreeError(errors.EXPIRATION_DATE_INCOMPLETE)); | ||
callback(new BraintreeError(errors.UNIONPAY_EXPIRATION_DATE_INCOMPLETE)); | ||
return; | ||
@@ -1376,5 +1415,5 @@ } | ||
if (status < 500) { | ||
error = errors.ENROLLMENT_CUSTOMER_INPUT_INVALID; | ||
error = errors.UNIONPAY_ENROLLMENT_CUSTOMER_INPUT_INVALID; | ||
} else { | ||
error = errors.ENROLLMENT_NETWORK_ERROR; | ||
error = errors.UNIONPAY_ENROLLMENT_NETWORK_ERROR; | ||
} | ||
@@ -1397,3 +1436,3 @@ error = assign({}, error, { | ||
} else { | ||
callback(new BraintreeError(errors.CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED)); | ||
callback(new BraintreeError(errors.UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED)); | ||
return; | ||
@@ -1425,2 +1464,3 @@ } | ||
* @param {string} options.enrollmentId The enrollment ID from {@link UnionPay#enroll}. | ||
* @param {boolean} [options.vault=false] When true, will vault the tokenized card. Cards will only be vaulted when using a client created with a client token that includes a customer ID. | ||
* @param {string} [options.smsCode] The SMS code received from the user if {@link UnionPay#enroll} payload have `smsCodeRequired`. if `smsCodeRequired` is false, smsCode should not be passed. | ||
@@ -1470,3 +1510,3 @@ * @param {callback} callback The second argument, <code>data</code>, is a {@link UnionPay~tokenizePayload|tokenizePayload}. | ||
if (card && hostedFields) { | ||
callback(new BraintreeError(errors.CARD_AND_HOSTED_FIELDS_INSTANCES)); | ||
callback(new BraintreeError(errors.UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES)); | ||
return; | ||
@@ -1501,2 +1541,4 @@ } else if (card) { | ||
data.creditCard.options.validate = options.vault === true; | ||
client.request({ | ||
@@ -1531,3 +1573,3 @@ method: 'post', | ||
if (!hostedFields._bus) { | ||
callback(new BraintreeError(errors.HOSTED_FIELDS_INSTANCE_INVALID)); | ||
callback(new BraintreeError(errors.UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID)); | ||
return; | ||
@@ -1547,3 +1589,3 @@ } | ||
} else { | ||
callback(new BraintreeError(errors.CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED)); | ||
callback(new BraintreeError(errors.UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED)); | ||
return; | ||
@@ -1611,3 +1653,3 @@ } | ||
},{"../../lib/analytics":8,"../../lib/assign":9,"../../lib/bus":12,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/methods":20,"../../lib/uuid":22,"./constants":24,"./errors":25,"iframer":2}]},{},[23])(23) | ||
},{"../../lib/analytics":8,"../../lib/assign":9,"../../lib/bus":12,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/methods":21,"../../lib/uuid":23,"./constants":25,"./errors":26,"iframer":2}]},{},[24])(24) | ||
}); |
@@ -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){(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:(m.push(e),!0)}function n(e){var t,n={};for(t in T)T.hasOwnProperty(t)&&(n[t]=T[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:(_(I.top,t,r),!0))}function i(e,t){var n=s(this);return N(e,t,n)?!1:(O[n]=O[n]||{},O[n][e]=O[n][e]||[],O[n][e].push(t),!0)}function o(e,t){var n,r,i=s(this);if(N(e,t,i))return!1;if(r=O[i]&&O[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=y(o,n),t=t.slice(0,-1)),i.args=t;try{r=A+JSON.stringify(i)}catch(s){throw new Error("Could not stringify event: "+s.message)}return r}function c(e){var t,n,r,i;if(e.data.slice(0,A.length)!==A)return!1;try{t=JSON.parse(e.data.slice(A.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 l(t){I||(I=t||e,I.addEventListener?I.addEventListener("message",p,!1):I.attachEvent?I.attachEvent("onmessage",p):null===I.onmessage?I.onmessage=p:I=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=c(e),t&&(E("*",t.event,t.args,e),E(e.origin,t.event,t.args,e),h(e.data,t.origin,e.source)))}function E(e,t,n,r){var i;if(O[e]&&O[e][t])for(i=0;i<O[e][t].length;i++)O[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 _(e,t,n){var r;try{for(e.postMessage(t,n),f(e)&&_(e.opener.top,t,n),r=0;r<e.frames.length;r++)_(e.frames[r],t,n)}catch(i){}}function h(e,t,n){var r,i;for(r=m.length-1;r>=0;r--)i=m[r],i.closed===!0?m=m.slice(r,1):n!==i&&_(i.top,e,t)}function y(e,t){function n(i,o){e(i,o),T.target(t).unsubscribe(r,n)}var r=d();return T.target(t).subscribe(r,n),r}function N(e,t,n){return a(e)?!0:"function"!=typeof t?!0:a(n)?!0:!1}var I,T,m=[],O={},A="/*framebus*/";return l(),T={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";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":18}],7:[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":13,"./create-authorization-data":15,"./json-clone":19}],8:[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":7,"./constants":13}],9:[function(e,t,n){"use strict";function r(e){var t,n,r;for(t=1;t<arguments.length;t++){n=arguments[t];for(r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}var i="function"==typeof Object.assign?Object.assign:r;t.exports={assign:i,_assign:r}},{}],10:[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}},{}],11:[function(e,t,n){"use strict";var r=e("../enumerate");t.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":17}],12:[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,code:"MISSING_CHANNEL_ID",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":18,"./check-origin":10,"./events":11,framebus:1}],13:[function(e,t,n){"use strict";var r="3.0.0-beta.12",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}},{}],14:[function(e,t,n){"use strict";var r=e("./error"),i=e("../errors");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new r({type:i.METHOD_CALLED_AFTER_TEARDOWN.type,code:i.METHOD_CALLED_AFTER_TEARDOWN.code,message:t+" cannot be called after teardown."})}})}},{"../errors":6,"./error":18}],15:[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":21}],16:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],17:[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},{}],18:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":17}],19:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],20:[function(e,t,n){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],21:[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:{})},{}],22:[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},{}],23:[function(e,t,n){"use strict";function r(e,t){var n,r;if("function"!=typeof t)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return t=a(t),null==e.client?void t(new o({type:c.INSTANTIATION_OPTION_REQUIRED.type,code:c.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating UnionPay."})):(n=e.client.getConfiguration(),r=n.analyticsMetadata.sdkVersion,r!==l?void t(new o({type:c.INCOMPATIBLE_VERSIONS.type,code:c.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+r+") and UnionPay (version "+l+") components must be from the same SDK version."})):n.gatewayConfiguration.unionPay&&n.gatewayConfiguration.unionPay.enabled===!0?(s.sendEvent(e.client,"web.unionpay.initialized"),void t(null,new i(e))):void t(new o(u.UNIONPAY_NOT_ENABLED)))}var i=e("./shared/unionpay"),o=e("../lib/error"),s=e("../lib/analytics"),a=e("../lib/deferred"),u=e("./shared/errors"),c=e("../errors"),l="3.0.0-beta.12";t.exports={create:r,VERSION:l}},{"../errors":6,"../lib/analytics":8,"../lib/deferred":16,"../lib/error":18,"./shared/errors":25,"./shared/unionpay":26}],24:[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"}},{"../../lib/enumerate":17}],25:[function(e,t,n){"use strict";var r=e("../../lib/error");t.exports={UNIONPAY_NOT_ENABLED:{type:r.types.MERCHANT,code:"UNIONPAY_NOT_ENABLED",message:"UnionPay is not enabled for this merchant."},HOSTED_FIELDS_INSTANCE_INVALID:{type:r.types.MERCHANT,code:"HOSTED_FIELDS_INSTANCE_INVALID",message:"Found an invalid Hosted Fields instance. Please use a valid Hosted Fields instance."},HOSTED_FIELDS_INSTANCE_REQUIRED:{type:r.types.MERCHANT,code:"HOSTED_FIELDS_INSTANCE_REQUIRED",message:"Could not find the Hosted Fields instance."},CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED:{type:r.types.MERCHANT,code:"CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED",message:"A card or a Hosted Fields instance is required. Please supply a card or a Hosted Fields instance."},CARD_AND_HOSTED_FIELDS_INSTANCES:{type:r.types.MERCHANT,code:"CARD_AND_HOSTED_FIELDS_INSTANCES",message:"Please supply either a card or a Hosted Fields instance, not both."},EXPIRATION_DATE_INCOMPLETE:{type:r.types.MERCHANT,code:"EXPIRATION_DATE_INCOMPLETE",message:"You must supply expiration month and year or neither."},ENROLLMENT_CUSTOMER_INPUT_INVALID:{type:r.types.CUSTOMER,code:"ENROLLMENT_CUSTOMER_INPUT_INVALID",message:"Enrollment failed due to user input error."},ENROLLMENT_NETWORK_ERROR:{type:r.types.NETWORK,code:"ENROLLMENT_NETWORK_ERROR",message:"Could not enroll UnionPay card."},FETCH_CAPABILITIES_NETWORK_ERROR:{type:r.types.NETWORK,code:"FETCH_CAPABILITIES_NETWORK_ERROR",message:"Could not fetch card capabilities."},UNIONPAY_TOKENIZATION_NETWORK_ERROR:{type:r.types.NETWORK,code:"UNIONPAY_TOKENIZATION_NETWORK_ERROR",message:"A tokenization network error occurred."},MISSING_MOBILE_PHONE_DATA:{type:r.types.MERCHANT,code:"MISSING_MOBILE_PHONE_DATA",message:"A `mobile` with `countryCode` and `number` is required."},UNIONPAY_FAILED_TOKENIZATION:{type:r.types.CUSTOMER,code:"UNIONPAY_FAILED_TOKENIZATION",message:"The supplied card data failed tokenization."}}},{"../../lib/error":18}],26:[function(e,t,n){"use strict";function r(e){this._options=e}var i=e("../../lib/analytics"),o=e("../../lib/assign").assign,s=e("../../lib/error"),a=e("../../lib/bus"),u=e("./constants"),c=e("../../lib/convert-methods-to-error"),l=e("../../lib/deferred"),d=e("./errors"),p=u.events,E=e("iframer"),f=e("../../lib/methods"),_="3.0.0-beta.12",h=e("../../lib/uuid");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 s(d.CARD_AND_HOSTED_FIELDS_INSTANCES));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 s({type:d.FETCH_CAPABILITIES_NETWORK_ERROR.type,code:d.FETCH_CAPABILITIES_NETWORK_ERROR.code,message:d.FETCH_CAPABILITIES_NETWORK_ERROR.message,details:{originalError:e}})),void i.sendEvent(n,"web.unionpay.capabilities-failed")):(i.sendEvent(n,"web.unionpay.capabilities-received"),void t(null,r))});else{if(!o)return void t(new s(d.CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED));if(!o._bus)return void t(new s(d.HOSTED_FIELDS_INSTANCE_INVALID));this._initializeHostedFields(function(){this._bus.emit(p.HOSTED_FIELDS_FETCH_CAPABILITIES,{hostedFields:o},function(e){return e.err?void t(new s(e.err)):void t(null,e.payload)})}.bind(this))}},r.prototype.enroll=function(e,t){var n,r=this._options.client,a=e.card,u=e.mobile,c=e.hostedFields;if(t=l(t),!u)return void t(new s(d.MISSING_MOBILE_PHONE_DATA));if(c){if(!c._bus)return void t(new s(d.HOSTED_FIELDS_INSTANCE_INVALID));if(a)return void t(new s(d.CARD_AND_HOSTED_FIELDS_INSTANCES));this._initializeHostedFields(function(){this._bus.emit(p.HOSTED_FIELDS_ENROLL,{hostedFields:c,mobile:u},function(e){return e.err?void t(new s(e.err)):void t(null,e.payload)})}.bind(this))}else{if(!a||!a.number)return void t(new s(d.CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED));if(n={_meta:{source:"unionpay"},unionPayEnrollment:{number:a.number,mobileCountryCode:u.countryCode,mobileNumber:u.number}},a.expirationDate)n.unionPayEnrollment.expirationDate=a.expirationDate;else if(a.expirationMonth||a.expirationYear){if(!a.expirationMonth||!a.expirationYear)return void t(new s(d.EXPIRATION_DATE_INCOMPLETE));n.unionPayEnrollment.expirationYear=a.expirationYear,n.unionPayEnrollment.expirationMonth=a.expirationMonth}r.request({method:"post",endpoint:"union_pay_enrollments",data:n},function(e,n,a){var u;return e?(u=500>a?d.ENROLLMENT_CUSTOMER_INPUT_INVALID:d.ENROLLMENT_NETWORK_ERROR,u=o({},u,{details:{originalError:e}}),i.sendEvent(r,"web.unionpay.enrollment-failed"),void t(new s(u))):(i.sendEvent(r,"web.unionpay.enrollment-succeeded"),void t(null,{enrollmentId:n.unionPayEnrollmentId,smsCodeRequired:n.smsCodeRequired}))})}},r.prototype.tokenize=function(e,t){var n,r,a,u=this._options.client,c=e.card,E=e.hostedFields;if(t=l(t),c&&E)return void t(new s(d.CARD_AND_HOSTED_FIELDS_INSTANCES));if(c)n={_meta:{source:"unionpay"},creditCard:{number:e.card.number,options:{unionPayEnrollment:{id:e.enrollmentId}}}},e.smsCode&&(n.creditCard.options.unionPayEnrollment.smsCode=e.smsCode),c.expirationDate?n.creditCard.expirationDate=c.expirationDate:c.expirationMonth&&c.expirationYear&&(n.creditCard.expirationYear=c.expirationYear,n.creditCard.expirationMonth=c.expirationMonth),e.card.cvv&&(n.creditCard.cvv=e.card.cvv),u.request({method:"post",endpoint:"payment_methods/credit_cards",data:n},function(e,n,c){return e?(i.sendEvent(u,"web.unionpay.nonce-failed"),a=500>c?d.UNIONPAY_FAILED_TOKENIZATION:d.UNIONPAY_TOKENIZATION_NETWORK_ERROR,a=o({},a,{details:{originalError:e}}),void t(new s(a))):(r=n.creditCards[0],delete r.consumed,delete r.threeDSecureInfo,i.sendEvent(u,"web.unionpay.nonce-received"),void t(null,r))});else{if(!E)return void t(new s(d.CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED));if(!E._bus)return void t(new s(d.HOSTED_FIELDS_INSTANCE_INVALID));this._initializeHostedFields(function(){this._bus.emit(p.HOSTED_FIELDS_TOKENIZE,e,function(e){return e.err?void t(new s(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()),c(this,f(r.prototype)),"function"==typeof e&&(e=l(e))()},r.prototype._initializeHostedFields=function(e){var t=h();return this._bus?void e():(this._bus=new a({channel:t,merchantUrl:location.href}),this._hostedFieldsFrame=E({name:u.HOSTED_FIELDS_FRAME_NAME+"_"+t,src:this._options.client.getConfiguration().gatewayConfiguration.assetsUrl+"/web/"+_+"/html/unionpay-hosted-fields-frame.min.html",height:0,width:0}),this._bus.on(a.events.CONFIGURATION_REQUEST,function(t){t(this._options.client),e()}.bind(this)),void document.body.appendChild(this._hostedFieldsFrame))},t.exports=r},{"../../lib/analytics":8,"../../lib/assign":9,"../../lib/bus":12,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/methods":20,"../../lib/uuid":22,"./constants":24,"./errors":25,iframer:2}]},{},[23])(23)}); | ||
!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){(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:(A.push(e),!0)}function n(e){var t,n={};for(t in O)O.hasOwnProperty(t)&&(n[t]=O[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:(E(y.top,t,r),!0))}function i(e,t){var n=s(this);return h(e,t,n)?!1:(T[n]=T[n]||{},T[n][e]=T[n][e]||[],T[n][e].push(t),!0)}function o(e,t){var n,r,i=s(this);if(h(e,t,i))return!1;if(r=T[i]&&T[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=I(o,n),t=t.slice(0,-1)),i.args=t;try{r=m+JSON.stringify(i)}catch(s){throw new Error("Could not stringify event: "+s.message)}return r}function c(e){var t,n,r,i;if(e.data.slice(0,m.length)!==m)return!1;try{t=JSON.parse(e.data.slice(m.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 l(t){y||(y=t||e,y.addEventListener?y.addEventListener("message",p,!1):y.attachEvent?y.attachEvent("onmessage",p):null===y.onmessage?y.onmessage=p:y=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=c(e),t&&(_("*",t.event,t.args,e),_(e.origin,t.event,t.args,e),N(e.data,t.origin,e.source)))}function _(e,t,n,r){var i;if(T[e]&&T[e][t])for(i=0;i<T[e][t].length;i++)T[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 E(e,t,n){var r;try{for(e.postMessage(t,n),f(e)&&E(e.opener.top,t,n),r=0;r<e.frames.length;r++)E(e.frames[r],t,n)}catch(i){}}function N(e,t,n){var r,i;for(r=A.length-1;r>=0;r--)i=A[r],i.closed===!0?A=A.slice(r,1):n!==i&&E(i.top,e,t)}function I(e,t){function n(i,o){e(i,o),O.target(t).unsubscribe(r,n)}var r=d();return O.target(t).subscribe(r,n),r}function h(e,t,n){return a(e)?!0:"function"!=typeof t?!0:a(n)?!0:!1}var y,O,A=[],T={},m="/*framebus*/";return l(),O={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";var r=e("./lib/error");t.exports={CALLBACK_REQUIRED:{type:r.types.MERCHANT,code:"CALLBACK_REQUIRED"},INSTANTIATION_OPTION_REQUIRED:{type:r.types.MERCHANT,code:"INSTANTIATION_OPTION_REQUIRED"},INCOMPATIBLE_VERSIONS:{type:r.types.MERCHANT,code:"INCOMPATIBLE_VERSIONS"},METHOD_CALLED_AFTER_TEARDOWN:{type:r.types.MERCHANT,code:"METHOD_CALLED_AFTER_TEARDOWN"}}},{"./lib/error":18}],7:[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":13,"./create-authorization-data":15,"./json-clone":20}],8:[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":7,"./constants":13}],9:[function(e,t,n){"use strict";function r(e){var t,n,r;for(t=1;t<arguments.length;t++){n=arguments[t];for(r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}var i="function"==typeof Object.assign?Object.assign:r;t.exports={assign:i,_assign:r}},{}],10:[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?!0:(o.href=e,i(e)&&"localhost"!==o.hostname)}var i=e("../is-whitelisted-domain");t.exports={checkOrigin:r}},{"../is-whitelisted-domain":19}],11:[function(e,t,n){"use strict";var r=e("../enumerate");t.exports=r(["CONFIGURATION_REQUEST"],"bus:")},{"../enumerate":17}],12:[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,code:"MISSING_CHANNEL_ID",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":18,"./check-origin":10,"./events":11,framebus:1}],13:[function(e,t,n){"use strict";var r="3.0.0",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}},{}],14:[function(e,t,n){"use strict";var r=e("./error"),i=e("../errors");t.exports=function(e,t){t.forEach(function(t){e[t]=function(){throw new r({type:i.METHOD_CALLED_AFTER_TEARDOWN.type,code:i.METHOD_CALLED_AFTER_TEARDOWN.code,message:t+" cannot be called after teardown."})}})}},{"../errors":6,"./error":18}],15:[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":22}],16:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments;setTimeout(function(){e.apply(null,t)},1)}}},{}],17:[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},{}],18:[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.code)throw new Error("Error code required.");if(!e.message)throw new Error("Error message required.");this.name="BraintreeError",this.code=e.code,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":17}],19:[function(e,t,n){"use strict";function r(e){return e.split(".").slice(-2).join(".")}function i(e){var t;return e=e.toLowerCase(),/^https:/.test(e)?(o=o||document.createElement("a"),o.href=e,t=r(o.hostname),s.hasOwnProperty(t)):!1}var o,s={"paypal.com":1,"braintreepayments.com":1,"braintreegateway.com":1,localhost:1};t.exports=i},{}],20:[function(e,t,n){"use strict";t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],21:[function(e,t,n){"use strict";t.exports=function(e){return Object.keys(e).filter(function(t){return"function"==typeof e[t]})}},{}],22:[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:{})},{}],23:[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},{}],24:[function(e,t,n){"use strict";function r(e,t){var n,r;if("function"!=typeof t)throw new o({type:c.CALLBACK_REQUIRED.type,code:c.CALLBACK_REQUIRED.code,message:"create must include a callback function."});return t=a(t),null==e.client?void t(new o({type:c.INSTANTIATION_OPTION_REQUIRED.type,code:c.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating UnionPay."})):(n=e.client.getConfiguration(),r=n.analyticsMetadata.sdkVersion,r!==l?void t(new o({type:c.INCOMPATIBLE_VERSIONS.type,code:c.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+r+") and UnionPay (version "+l+") components must be from the same SDK version."})):n.gatewayConfiguration.unionPay&&n.gatewayConfiguration.unionPay.enabled===!0?(s.sendEvent(e.client,"web.unionpay.initialized"),void t(null,new i(e))):void t(new o(u.UNIONPAY_NOT_ENABLED)))}var i=e("./shared/unionpay"),o=e("../lib/error"),s=e("../lib/analytics"),a=e("../lib/deferred"),u=e("./shared/errors"),c=e("../errors"),l="3.0.0";t.exports={create:r,VERSION:l}},{"../errors":6,"../lib/analytics":8,"../lib/deferred":16,"../lib/error":18,"./shared/errors":26,"./shared/unionpay":27}],25:[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"}},{"../../lib/enumerate":17}],26:[function(e,t,n){"use strict";var r=e("../../lib/error");t.exports={UNIONPAY_NOT_ENABLED:{type:r.types.MERCHANT,code:"UNIONPAY_NOT_ENABLED",message:"UnionPay is not enabled for this merchant."},UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID:{type:r.types.MERCHANT,code:"UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID",message:"Found an invalid Hosted Fields instance. Please use a valid Hosted Fields instance."},UNIONPAY_HOSTED_FIELDS_INSTANCE_REQUIRED:{type:r.types.MERCHANT,code:"UNIONPAY_HOSTED_FIELDS_INSTANCE_REQUIRED",message:"Could not find the Hosted Fields instance."},UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED:{type:r.types.MERCHANT,code:"UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED",message:"A card or a Hosted Fields instance is required. Please supply a card or a Hosted Fields instance."},UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES:{type:r.types.MERCHANT,code:"UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES",message:"Please supply either a card or a Hosted Fields instance, not both."},UNIONPAY_EXPIRATION_DATE_INCOMPLETE:{type:r.types.MERCHANT,code:"UNIONPAY_EXPIRATION_DATE_INCOMPLETE",message:"You must supply expiration month and year or neither."},UNIONPAY_ENROLLMENT_CUSTOMER_INPUT_INVALID:{type:r.types.CUSTOMER,code:"UNIONPAY_ENROLLMENT_CUSTOMER_INPUT_INVALID",message:"Enrollment failed due to user input error."},UNIONPAY_ENROLLMENT_NETWORK_ERROR:{type:r.types.NETWORK,code:"UNIONPAY_ENROLLMENT_NETWORK_ERROR",message:"Could not enroll UnionPay card."},UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR:{type:r.types.NETWORK,code:"UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR",message:"Could not fetch card capabilities."},UNIONPAY_TOKENIZATION_NETWORK_ERROR:{type:r.types.NETWORK,code:"UNIONPAY_TOKENIZATION_NETWORK_ERROR",message:"A tokenization network error occurred."},UNIONPAY_MISSING_MOBILE_PHONE_DATA:{type:r.types.MERCHANT,code:"UNIONPAY_MISSING_MOBILE_PHONE_DATA",message:"A `mobile` with `countryCode` and `number` is required."},UNIONPAY_FAILED_TOKENIZATION:{type:r.types.CUSTOMER,code:"UNIONPAY_FAILED_TOKENIZATION",message:"The supplied card data failed tokenization."}}},{"../../lib/error":18}],27:[function(e,t,n){"use strict";function r(e){this._options=e}var i=e("../../lib/analytics"),o=e("../../lib/assign").assign,s=e("../../lib/error"),a=e("../../lib/bus"),u=e("./constants"),c=e("../../lib/convert-methods-to-error"),l=e("../../lib/deferred"),d=e("./errors"),p=u.events,_=e("iframer"),f=e("../../lib/methods"),E="3.0.0",N=e("../../lib/uuid");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 s(d.UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES));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 s({type:d.UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR.type,code:d.UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR.code,message:d.UNIONPAY_FETCH_CAPABILITIES_NETWORK_ERROR.message,details:{originalError:e}})),void i.sendEvent(n,"web.unionpay.capabilities-failed")):(i.sendEvent(n,"web.unionpay.capabilities-received"),void t(null,r))});else{if(!o)return void t(new s(d.UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED));if(!o._bus)return void t(new s(d.UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID));this._initializeHostedFields(function(){this._bus.emit(p.HOSTED_FIELDS_FETCH_CAPABILITIES,{hostedFields:o},function(e){return e.err?void t(new s(e.err)):void t(null,e.payload)})}.bind(this))}},r.prototype.enroll=function(e,t){var n,r=this._options.client,a=e.card,u=e.mobile,c=e.hostedFields;if(t=l(t),!u)return void t(new s(d.UNIONPAY_MISSING_MOBILE_PHONE_DATA));if(c){if(!c._bus)return void t(new s(d.UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID));if(a)return void t(new s(d.UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES));this._initializeHostedFields(function(){this._bus.emit(p.HOSTED_FIELDS_ENROLL,{hostedFields:c,mobile:u},function(e){return e.err?void t(new s(e.err)):void t(null,e.payload)})}.bind(this))}else{if(!a||!a.number)return void t(new s(d.UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED));if(n={_meta:{source:"unionpay"},unionPayEnrollment:{number:a.number,mobileCountryCode:u.countryCode,mobileNumber:u.number}},a.expirationDate)n.unionPayEnrollment.expirationDate=a.expirationDate;else if(a.expirationMonth||a.expirationYear){if(!a.expirationMonth||!a.expirationYear)return void t(new s(d.UNIONPAY_EXPIRATION_DATE_INCOMPLETE));n.unionPayEnrollment.expirationYear=a.expirationYear,n.unionPayEnrollment.expirationMonth=a.expirationMonth}r.request({method:"post",endpoint:"union_pay_enrollments",data:n},function(e,n,a){var u;return e?(u=500>a?d.UNIONPAY_ENROLLMENT_CUSTOMER_INPUT_INVALID:d.UNIONPAY_ENROLLMENT_NETWORK_ERROR,u=o({},u,{details:{originalError:e}}),i.sendEvent(r,"web.unionpay.enrollment-failed"),void t(new s(u))):(i.sendEvent(r,"web.unionpay.enrollment-succeeded"),void t(null,{enrollmentId:n.unionPayEnrollmentId,smsCodeRequired:n.smsCodeRequired}))})}},r.prototype.tokenize=function(e,t){var n,r,a,u=this._options.client,c=e.card,_=e.hostedFields;if(t=l(t),c&&_)return void t(new s(d.UNIONPAY_CARD_AND_HOSTED_FIELDS_INSTANCES));if(c)n={_meta:{source:"unionpay"},creditCard:{number:e.card.number,options:{unionPayEnrollment:{id:e.enrollmentId}}}},e.smsCode&&(n.creditCard.options.unionPayEnrollment.smsCode=e.smsCode),c.expirationDate?n.creditCard.expirationDate=c.expirationDate:c.expirationMonth&&c.expirationYear&&(n.creditCard.expirationYear=c.expirationYear,n.creditCard.expirationMonth=c.expirationMonth),e.card.cvv&&(n.creditCard.cvv=e.card.cvv),n.creditCard.options.validate=e.vault===!0,u.request({method:"post",endpoint:"payment_methods/credit_cards",data:n},function(e,n,c){return e?(i.sendEvent(u,"web.unionpay.nonce-failed"),a=500>c?d.UNIONPAY_FAILED_TOKENIZATION:d.UNIONPAY_TOKENIZATION_NETWORK_ERROR,a=o({},a,{details:{originalError:e}}),void t(new s(a))):(r=n.creditCards[0],delete r.consumed,delete r.threeDSecureInfo,i.sendEvent(u,"web.unionpay.nonce-received"),void t(null,r))});else{if(!_)return void t(new s(d.UNIONPAY_CARD_OR_HOSTED_FIELDS_INSTANCE_REQUIRED));if(!_._bus)return void t(new s(d.UNIONPAY_HOSTED_FIELDS_INSTANCE_INVALID));this._initializeHostedFields(function(){this._bus.emit(p.HOSTED_FIELDS_TOKENIZE,e,function(e){return e.err?void t(new s(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()),c(this,f(r.prototype)),"function"==typeof e&&(e=l(e))()},r.prototype._initializeHostedFields=function(e){var t=N();return this._bus?void e():(this._bus=new a({channel:t,merchantUrl:location.href}),this._hostedFieldsFrame=_({name:u.HOSTED_FIELDS_FRAME_NAME+"_"+t,src:this._options.client.getConfiguration().gatewayConfiguration.assetsUrl+"/web/"+E+"/html/unionpay-hosted-fields-frame.min.html",height:0,width:0}),this._bus.on(a.events.CONFIGURATION_REQUEST,function(t){t(this._options.client),e()}.bind(this)),void document.body.appendChild(this._hostedFieldsFrame))},t.exports=r},{"../../lib/analytics":8,"../../lib/assign":9,"../../lib/bus":12,"../../lib/convert-methods-to-error":14,"../../lib/deferred":16,"../../lib/error":18,"../../lib/methods":21,"../../lib/uuid":23,"./constants":25,"./errors":26,iframer:2}]},{},[24])(24)}); |
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
485297
8877
8
126