From ee3ffc383e604d7863625328d78ad0c654f5eb18 Mon Sep 17 00:00:00 2001
From: Chad Whitacre
Date: Thu, 7 Sep 2017 20:24:23 -0400
Subject: [PATCH 1/4] Redirect auth to /browse/projects(!)
---
tests/py/test_support_gratipay.py | 4 ++--
tests/ttw/test_homepage.py | 4 ++--
www/index.spt | 3 +++
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/tests/py/test_support_gratipay.py b/tests/py/test_support_gratipay.py
index 55e5907b30..faf8f942cc 100644
--- a/tests/py/test_support_gratipay.py
+++ b/tests/py/test_support_gratipay.py
@@ -7,7 +7,7 @@
class TestSupportGratipay(Harness):
def shown(self, to=None):
- return 'of active users also' in self.client.GET('/', auth_as=to).body
+ return 'of active users also' in self.client.GET('/about/', auth_as=to).body
def test_not_shown_to_anon(self):
assert not self.shown()
@@ -37,7 +37,7 @@ def test_not_shown_to_giver_to_Gratipay(self):
def check_button(self, lang, decimal, currency):
self.test_shown_when_on_the_fence()
- body = self.client.GET( '/'
+ body = self.client.GET( '/about/'
, auth_as='alice'
, HTTP_ACCEPT_LANGUAGE=str(lang)
).body.decode('utf8')
diff --git a/tests/ttw/test_homepage.py b/tests/ttw/test_homepage.py
index 2e1f50bbd0..bcfb1dbe7b 100644
--- a/tests/ttw/test_homepage.py
+++ b/tests/ttw/test_homepage.py
@@ -9,9 +9,9 @@ def test_loads_for_anon(self):
assert self.css('#banner h1').html == 'Pay for open source.'
assert self.css('#header .sign-in button').html.strip()[:17] == 'Sign in / Sign up'
- def test_loads_for_authed(self):
+ def test_redirects_for_authed_exclamation_point(self):
self.make_participant('alice', claimed_time='now')
self.sign_in('alice')
self.reload()
- assert self.css('#banner h1').html == 'Pay for open source.'
+ assert self.css('#banner h1').html == 'Browse'
assert self.css('.you-are a').html.strip()[:6] == '~alice'
diff --git a/www/index.spt b/www/index.spt
index f784f182d0..8f9761dab7 100644
--- a/www/index.spt
+++ b/www/index.spt
@@ -3,6 +3,9 @@
suppress_sidebar = True
page_id = "homepage"
banner = "Pay for Open Source"
+
+if not user.ANON:
+ website.redirect('/browse/projects')
[---] text/html
{% from "templates/nav-tabs.html" import nav_tabs with context %}
{% extends "templates/base.html" %}
From d59d0145bb5a762a79c2aced0820ba38fcc7c2eb Mon Sep 17 00:00:00 2001
From: Chad Whitacre
Date: Thu, 7 Sep 2017 20:34:26 -0400
Subject: [PATCH 2/4] Vendor in the braintree js sdk
- It's huge. o.O
- It contains non-ASCII. UTF8 seems to work? O.o
---
gratipay/utils/http_caching.py | 2 +-
gratipay/wireup.py | 2 +-
js/vendor/braintree.min.js | 6 ++++++
www/assets/vendors.js.spt | 1 +
www/index.spt | 1 -
5 files changed, 9 insertions(+), 3 deletions(-)
create mode 100644 js/vendor/braintree.min.js
diff --git a/gratipay/utils/http_caching.py b/gratipay/utils/http_caching.py
index f2eb7284e9..2ce3c0e9c5 100644
--- a/gratipay/utils/http_caching.py
+++ b/gratipay/utils/http_caching.py
@@ -38,7 +38,7 @@ def concat_files(files, root):
catted.append('/*' + filepath.center(68) + '*/\n')
catted.append('/' + ('*'*70) + '/' + '\n\n')
content = open(os.path.join(root, filepath)).read()
- content = content.decode('ascii')
+ content = content.decode('utf8')
catted.append(content + '\n')
return "".join(catted)
diff --git a/gratipay/wireup.py b/gratipay/wireup.py
index cb48f778f5..87e5a932cb 100644
--- a/gratipay/wireup.py
+++ b/gratipay/wireup.py
@@ -256,7 +256,7 @@ def compile_assets(website):
headers[b'HTTP_HOST'] = str(url.netloc)
content = client.GET(urlpath, **headers).body
tmpfd, tmpfpath = mkstemp(dir='.')
- os.write(tmpfd, content)
+ os.write(tmpfd, content.encode('utf8'))
os.close(tmpfd)
os.rename(tmpfpath, filepath)
atexit.register(lambda: clean_assets(website.www_root))
diff --git a/js/vendor/braintree.min.js b/js/vendor/braintree.min.js
new file mode 100644
index 0000000000..02f57db3f7
--- /dev/null
+++ b/js/vendor/braintree.min.js
@@ -0,0 +1,6 @@
+!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={})).dropin=e()}}(function(){var e;return function e(t,i,r){function n(o,s){if(!i[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var c=i[o]={exports:{}};t[o][0].call(c.exports,function(e){var i=t[o][1][e];return n(i?i:e)},c,c.exports,e,t,i,r)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o=500?i=new s(m.CLIENT_GATEWAY_NETWORK):(e<200||e>=400)&&(i=l(t,{type:m.CLIENT_REQUEST_ERROR.type,code:m.CLIENT_REQUEST_ERROR.code,message:m.CLIENT_REQUEST_ERROR.message})),i)return i.details=i.details||{},i.details.httpStatus=e,i}var a=e("./request"),o=e("../lib/is-whitelisted-domain"),s=e("../lib/braintree-error"),l=e("../lib/convert-to-braintree-error"),d=e("../lib/add-metadata"),c=e("../lib/promise"),p=e("../lib/once"),h=e("../lib/deferred"),u=e("../lib/assign").assign,y=e("./constants"),m=e("./errors"),f=e("../lib/errors"),v=e("../lib/constants").VERSION;r.prototype.request=function(e,t){var i=this,r=new c(function(t,r){var a,o,l,c;if(e.method?e.endpoint||(a="options.endpoint"):a="options.method",a)throw new s({type:m.CLIENT_OPTION_REQUIRED.type,code:m.CLIENT_OPTION_REQUIRED.code,message:a+" is required when making a request."});if(o="api"in e?e.api:"clientApi",c={method:e.method,timeout:e.timeout},"clientApi"===o)l=i._clientApiBaseUrl,c.data=d(i._configuration,e.data);else{if("braintreeApi"!==o)throw new s({type:m.CLIENT_OPTION_INVALID.type,code:m.CLIENT_OPTION_INVALID.code,message:"options.api is invalid."});if(!i._braintreeApi)throw new s(f.BRAINTREE_API_ACCESS_RESTRICTED);l=i._braintreeApi.baseUrl,c.data=e.data,c.headers={"Braintree-Version":y.BRAINTREE_API_VERSION_HEADER,Authorization:"Bearer "+i._braintreeApi.accessToken}}c.url=l+e.endpoint,i._request(c,function(e,i,a){var o,s;return(s=n(a,e))?void r(s):(o=u({_httpStatus:a},i),void t(o))})});return"function"==typeof t?(t=p(h(t)),void r.then(function(e){t(null,e,e._httpStatus)}).catch(function(e){var i=e&&e.details&&e.details.httpStatus;t(e,null,i)})):r},r.prototype.toJSON=function(){return this.getConfiguration()},r.prototype.getVersion=function(){return v},t.exports=r},{"../lib/add-metadata":40,"../lib/assign":42,"../lib/braintree-error":44,"../lib/constants":49,"../lib/convert-to-braintree-error":51,"../lib/deferred":53,"../lib/errors":56,"../lib/is-whitelisted-domain":58,"../lib/once":61,"../lib/promise":63,"./constants":20,"./errors":21,"./request":26}],20:[function(e,t,i){"use strict";t.exports={BRAINTREE_API_VERSION_HEADER:"2017-04-03"}},{}],21:[function(e,t,i){"use strict";var r=e("../lib/braintree-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_OPTION_INVALID:{type:r.types.MERCHANT,code:"CLIENT_OPTION_INVALID"},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."},CLIENT_AUTHORIZATION_INSUFFICIENT:{type:r.types.MERCHANT,code:"CLIENT_AUTHORIZATION_INSUFFICIENT",message:"The authorization used has insufficient privileges."}}},{"../lib/braintree-error":44}],22:[function(e,t,i){(function(i){"use strict";function r(e){return new a(function(t,r){var a,o,h,u,y=l(),m={merchantAppId:i.location.host,platform:d.PLATFORM,sdkVersion:d.VERSION,source:d.SOURCE,integration:d.INTEGRATION,integrationType:d.INTEGRATION,sessionId:y};try{o=c(e.authorization)}catch(e){return void r(new n(p.CLIENT_INVALID_AUTHORIZATION))}h=o.attrs,u=o.configUrl,h._meta=m,h.braintreeLibraryVersion=d.BRAINTREE_LIBRARY_VERSION,h.configVersion="3",s({url:u,method:"GET",data:h},function(i,o,s){var l;return i?(l=403===s?p.CLIENT_AUTHORIZATION_INSUFFICIENT:p.CLIENT_GATEWAY_NETWORK,void r(new n({type:l.type,code:l.code,message:l.message,details:{originalError:i}}))):(a={authorization:e.authorization,authorizationType:h.tokenizationKey?"TOKENIZATION_KEY":"CLIENT_TOKEN",analyticsMetadata:m,gatewayConfiguration:o},void t(a))})})}var n=e("../lib/braintree-error"),a=e("../lib/promise"),o=e("@braintree/wrap-promise"),s=e("./request"),l=e("../lib/uuid"),d=e("../lib/constants"),c=e("../lib/create-authorization-data"),p=e("./errors");t.exports={getConfiguration:o(r)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../lib/braintree-error":44,"../lib/constants":49,"../lib/create-authorization-data":52,"../lib/promise":63,"../lib/uuid":66,"./errors":21,"./request":26,"@braintree/wrap-promise":17}],23:[function(e,t,i){"use strict";function r(e){return e.authorization?h[e.authorization]?d.resolve(h[e.authorization]):s(e).then(function(t){var i;return e.debug&&(t.isDebug=!0),i=new o(t),h[e.authorization]=i,i}):d.reject(new a({type:p.INSTANTIATION_OPTION_REQUIRED.type,code:p.INSTANTIATION_OPTION_REQUIRED.code,message:"options.authorization is required when instantiating a client."}))}function n(){h={}}var a=e("../lib/braintree-error"),o=e("./client"),s=e("./get-configuration").getConfiguration,l="3.22.2",d=e("../lib/promise"),c=e("@braintree/wrap-promise"),p=e("../lib/errors"),h={};t.exports={create:c(r),VERSION:l,_clearCache:n}},{"../lib/braintree-error":44,"../lib/errors":56,"../lib/promise":63,"./client":19,"./get-configuration":22,"@braintree/wrap-promise":17}],24:[function(e,t,i){(function(i){"use strict";function r(){return h?new XMLHttpRequest:new XDomainRequest}function n(e){return(!e||e===y)&&l.isIe()}function a(e,t,i){var o,l,y=e.method,m=e.url,f=e.data,v=e.timeout,b=d({"Content-Type":"application/json"},e.headers),g=r(),E=i;"GET"===y&&(m=s.queryify(m,f),f=null),h?g.onreadystatechange=function(){if(4===g.readyState)if(o=g.status,l=p(g.responseText),o>=400||o<200){if(t=400||o<200?s=i:l=i,a(n),r(e),clearTimeout(h[n]),t(s,l,o)}}function l(e,t){var i,r="callback_json_"+c().replace(/-/g,""),a=e.url,l=e.data,h=e.method,u=e.timeout;a=p.queryify(a,l),a=p.queryify(a,{_method:h,callback:r}),i=n(a,r),s(i,t,r),o(u,r),d||(d=document.getElementsByTagName("head")[0]),d.appendChild(i)}var d,c=e("../../lib/uuid"),p=e("../../lib/querystring"),h={};t.exports={request:l}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/querystring":64,"../../lib/uuid":66}],29:[function(e,t,i){"use strict";t.exports=function(e){try{e=JSON.parse(e)}catch(e){}return e}},{}],30:[function(e,t,i){"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}},{}],31:[function(e,t,i){"use strict";function r(e,t){var i;return s.hasOwnProperty(e)?null==t||n(e,t)||(i=new a({type:o.HOSTED_FIELDS_ATTRIBUTE_VALUE_NOT_ALLOWED.type,code:o.HOSTED_FIELDS_ATTRIBUTE_VALUE_NOT_ALLOWED.code,message:'Value "'+t+'" is not allowed for "'+e+'" attribute.'})):i=new a({type:o.HOSTED_FIELDS_ATTRIBUTE_NOT_SUPPORTED.type,code:o.HOSTED_FIELDS_ATTRIBUTE_NOT_SUPPORTED.code,message:'The "'+e+'" attribute is not supported in Hosted Fields.'}),i}function n(e,t){return"string"===s[e]?"string"==typeof t||"number"==typeof t:"boolean"===s[e]&&("true"===String(t)||"false"===String(t))}var a=e("../../lib/braintree-error"),o=e("../shared/errors"),s=e("../shared/constants").whitelistedAttributes;t.exports=r},{"../../lib/braintree-error":44,"../shared/constants":37,"../shared/errors":38}],32:[function(e,t,i){"use strict";var r=e("../shared/constants"),n=e("../../lib/use-min");t.exports=function(e,t,i){return e+"/web/"+r.VERSION+"/html/hosted-fields-frame"+n(i)+".html#"+t}},{"../../lib/use-min":65,"../shared/constants":37}],33:[function(e,t,i){(function(i){"use strict";function r(e){return function(t){var i,r=t.merchantPayload,a=r.emittedBy,o=e[a].containerElement;Object.keys(r.fields).forEach(function(t){r.fields[t].container=e[t].containerElement}),i=r.fields[a],"blur"===t.type&&n(o),s.toggle(o,h.externalClasses.FOCUSED,i.isFocused),s.toggle(o,h.externalClasses.VALID,i.isValid),s.toggle(o,h.externalClasses.INVALID,!i.isPotentiallyValid),this._state={cards:r.cards,fields:r.fields},this._emit(t.type,r)}}function n(e){var t;v.isIos()&&document.activeElement===document.body&&(t=e.querySelector("input"),t||(t=document.createElement("input"),t.type="button",t.style.height="0px",t.style.width="0px",t.style.opacity="0",t.style.padding="0",t.style.position="absolute",t.style.left="-200%",t.style.top="0px",e.insertBefore(t,e.firstChild)),t.focus(),t.blur())}function a(e){var t,n,f,v=this,P={},F=0,N=m();if(!e.client)throw new c({type:D.INSTANTIATION_OPTION_REQUIRED.type,code:D.INSTANTIATION_OPTION_REQUIRED.code,message:"options.client is required when instantiating Hosted Fields."});if(f=e.client.getConfiguration(),n=e.client.getVersion(),n!==C)throw new c({type:D.INCOMPATIBLE_VERSIONS.type,code:D.INCOMPATIBLE_VERSIONS.code,message:"Client (version "+n+") and Hosted Fields (version "+C+") components must be from the same SDK version."});if(!e.fields)throw new c({type:D.INSTANTIATION_OPTION_REQUIRED.type,code:D.INSTANTIATION_OPTION_REQUIRED.code,message:"options.fields is required when instantiating Hosted Fields."});g.call(this),this._injectedNodes=[],this._destructor=new o,this._fields=P,this._state={fields:{},cards:A("")},this._bus=new d({channel:N,merchantUrl:location.href}),this._destructor.registerFunctionForTeardown(function(){v._bus.teardown()}),this._client=e.client,_.sendEvent(this._client,"custom.hosted-fields.initialized"),Object.keys(e.fields).forEach(function(t){var r,n,a;if(!h.whitelistedFields.hasOwnProperty(t))throw new c({type:u.HOSTED_FIELDS_INVALID_FIELD_KEY.type,code:u.HOSTED_FIELDS_INVALID_FIELD_KEY.code,message:'"'+t+'" is not a valid field.'});if(r=e.fields[t],n=document.querySelector(r.selector),!n)throw new c({type:u.HOSTED_FIELDS_INVALID_FIELD_SELECTOR.type,code:u.HOSTED_FIELDS_INVALID_FIELD_SELECTOR.code,message:u.HOSTED_FIELDS_INVALID_FIELD_SELECTOR.message,details:{fieldSelector:r.selector,fieldKey:t}});if(n.querySelector('iframe[name^="braintree-"]'))throw new c({type:u.HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME.type,code:u.HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME.code,message:u.HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME.message,details:{fieldSelector:r.selector,fieldKey:t}});if(r.maxlength&&"number"!=typeof r.maxlength)throw new c({type:u.HOSTED_FIELDS_FIELD_PROPERTY_INVALID.type,code:u.HOSTED_FIELDS_FIELD_PROPERTY_INVALID.code,message:"The value for maxlength must be a number.",details:{fieldKey:t}});if(r.minlength&&"number"!=typeof r.minlength)throw new c({type:u.HOSTED_FIELDS_FIELD_PROPERTY_INVALID.type,code:u.HOSTED_FIELDS_FIELD_PROPERTY_INVALID.code,message:"The value for minlength must be a number.",details:{fieldKey:t}});a=l({type:t,name:"braintree-hosted-field-"+t,style:h.defaultIFrameStyle}),this._injectedNodes=this._injectedNodes.concat(E(a,n)),this._setupLabelFocus(t,n),P[t]={frameElement:a,containerElement:n},F++,this._state.fields[t]={isEmpty:!0,isValid:!1,isPotentiallyValid:!0,isFocused:!1,container:n},setTimeout(function(){i.navigator&&i.navigator.vendor&&i.navigator.vendor.indexOf("Apple")===-1&&(a.src="about:blank"),setTimeout(function(){a.src=p(f.gatewayConfiguration.assetsUrl,N,f.isDebug)},0)},0)}.bind(this)),t=setTimeout(function(){_.sendEvent(v._client,"custom.hosted-fields.load.timed-out")},y),this._bus.on(b.FRAME_READY,function(i){F--,0===F&&(clearTimeout(t),i(e),v._emit("ready"))}),this._bus.on(b.INPUT_EVENT,r(P).bind(this)),this._destructor.registerFunctionForTeardown(function(){var e,t,i;for(e=0;e>4&3,i=(15&a)<<4|o>>2&15,r=(3&o)<<6|63&s,p+=String.fromCharCode(t)+(i?String.fromCharCode(i):"")+(r?String.fromCharCode(r):"");while(l=0;r--)n=_[r],n.closed===!0?_=_.slice(r,1):i!==n&&m(n.top,e,t)}function v(e,t){function i(n,a){e(n,a),E.target(t).unsubscribe(r,i)}var r=p();return E.target(t).subscribe(r,i),r}function b(e,t,i){return!!s(e)||("function"!=typeof t||!!s(i))}var g,E,_=[],P={},C="/*framebus*/";return c(),E={target:i,include:t,publish:r,pub:r,trigger:r,emit:r,subscribe:n,sub:n,on:n,unsubscribe:a,unsub:a,off:a}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],73:[function(e,t,i){!function(e){function i(){}function r(e,t){return function(){e.apply(t,arguments)}}function n(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(e,this)}function a(e,t){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(t):(e._handled=!0,void n._immediateFn(function(){var i=1===e._state?t.onFulfilled:t.onRejected;if(null===i)return void(1===e._state?o:s)(t.promise,e._value);var r;try{r=i(e._value)}catch(e){return void s(t.promise,e)}o(t.promise,r)}))}function o(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var i=t.then;if(t instanceof n)return e._state=3,e._value=t,void l(e);if("function"==typeof i)return void c(r(i,t),e)}e._state=1,e._value=t,l(e)}catch(t){s(e,t)}}function s(e,t){e._state=2,e._value=t,l(e)}function l(e){2===e._state&&0===e._deferreds.length&&n._immediateFn(function(){e._handled||n._unhandledRejectionFn(e._value)});for(var t=0,i=e._deferreds.length;t-1}function n(e){var t=e||s;return l(t)&&h.test(t)}function a(e){var t=e||s;return l(t)&&d(t)}function o(e){return e=e||s,/SamsungBrowser/.test(e)||r(e)}var s=i.navigator&&i.navigator.userAgent,l=e("@braintree/browser-detection/is-android"),d=e("@braintree/browser-detection/is-chrome"),c=e("@braintree/browser-detection/is-ios"),p=e("@braintree/browser-detection/is-ie9"),h=/Version\/\d\.\d* Chrome\/\d*\.0\.0\.0/;t.exports={isIE9:p,isAndroidChrome:a,isIos:c,isKitKatWebview:n,isSamsungBrowser:o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"@braintree/browser-detection/is-android":1,"@braintree/browser-detection/is-chrome":2,"@braintree/browser-detection/is-ie9":6,"@braintree/browser-detection/is-ios":8}],75:[function(e,t,i){"use strict";var r=e("./lib/device");t.exports=function(){return!r.isSamsungBrowser()}},{"./lib/device":74}],76:[function(e,t,i){"use strict";t.exports={paymentOptionIDs:{card:"card",paypal:"paypal",paypalCredit:"paypalCredit"},paymentMethodTypes:{card:"CreditCard",paypal:"PayPalAccount",paypalCredit:"PayPalAccount"},analyticsKinds:{CreditCard:"card",PayPalAccount:"paypal"},paymentMethodCardTypes:{Visa:"visa",MasterCard:"master-card","American Express":"american-express","Diners Club":"diners-club",Discover:"discover",JCB:"jcb",UnionPay:"unionpay",Maestro:"maestro"},configurationCardTypes:{visa:"Visa","master-card":"MasterCard","american-express":"American Express","diners-club":"Discover",discover:"Discover",jcb:"JCB",unionpay:"UnionPay",maestro:"Maestro"},errors:{NO_PAYMENT_METHOD_ERROR:"No payment method is available.",PAYPAL_NON_LINKED_SANDBOX:'A linked sandbox account is required to use PayPal Checkout in sandbox.'},ANALYTICS_REQUEST_TIMEOUT_MS:2e3,ANALYTICS_PREFIX:"web.dropin.",CHANGE_ACTIVE_PAYMENT_METHOD_TIMEOUT:200,CHECKOUT_JS_SOURCE:"https://www.paypalobjects.com/api/checkout.4.0.110.min.js",INTEGRATION:"dropin2",PAYPAL_CHECKOUT_SCRIPT_ID:"braintree-dropin-paypal-checkout-script",DATA_COLLECTOR_SCRIPT_ID:"braintree-dropin-data-collector-script",STYLESHEET_ID:"braintree-dropin-stylesheet"}},{}],77:[function(e,t,i){"use strict";function r(e){this.componentID=e.componentID,this.merchantConfiguration=e.merchantConfiguration,this.isGuestCheckout=p(e.client),this.dependenciesInitializing=0,this.dependencySuccessCount=0,this.failedDependencies={},this.supportedPaymentOptions=n(e),this._paymentMethods=this._getSupportedPaymentMethods(e.paymentMethods),this._paymentMethodIsRequestable=this._paymentMethods.length>0,s.call(this)}function n(e){var t=[],i=e.merchantConfiguration.paymentOptionPriority||["card","paypal","paypalCredit"];if(!(i instanceof Array))throw new o("paymentOptionPriority must be an array.");if(i=i.filter(function(e,t){return i.indexOf(e)===t}),i.forEach(function(i){a(i,e)&&t.push(c[i])}),0===t.length)throw new o("No valid payment options available.");return t}function a(e,t){var i=t.client.getConfiguration().gatewayConfiguration;if("card"===e)return i.creditCards.supportedCardTypes.length>0;if("paypal"===e)return i.paypalEnabled&&Boolean(t.merchantConfiguration.paypal);if("paypalCredit"===e)return i.paypalEnabled&&Boolean(t.merchantConfiguration.paypalCredit);throw new o("paymentOptionPriority: Invalid payment option specified.")}var o=e("./lib/dropin-error"),s=e("./lib/event-emitter"),l=e("./constants"),d=l.paymentMethodTypes,c=l.paymentOptionIDs,p=e("./lib/is-guest-checkout");r.prototype=Object.create(s.prototype,{constructor:r}),r.prototype.isPaymentMethodRequestable=function(){return Boolean(this._paymentMethodIsRequestable)},r.prototype.addPaymentMethod=function(e){this._paymentMethods.push(e),this._emit("addPaymentMethod",e),this.changeActivePaymentMethod(e)},r.prototype.removePaymentMethod=function(e){var t=this._paymentMethods.indexOf(e);t!==-1&&(this._paymentMethods.splice(t,1),this._emit("removePaymentMethod",e))},r.prototype.changeActivePaymentMethod=function(e){this._activePaymentMethod=e,this._emit("changeActivePaymentMethod",e)},r.prototype.changeActivePaymentView=function(e){this._activePaymentView=e,this._emit("changeActivePaymentView",e)},r.prototype.removeActivePaymentMethod=function(){this._activePaymentMethod=null,this._emit("removeActivePaymentMethod"),this.setPaymentMethodRequestable({isRequestable:!1})},r.prototype.selectPaymentOption=function(e){this._emit("paymentOptionSelected",{paymentOption:e})},r.prototype._shouldEmitRequestableEvent=function(e){var t=this.isPaymentMethodRequestable()===e.isRequestable,i=e.type===this._paymentMethodRequestableType;return!(t&&(!e.isRequestable||i))},r.prototype.setPaymentMethodRequestable=function(e){var t=this._shouldEmitRequestableEvent(e),i={paymentMethodIsSelected:Boolean(e.selectedPaymentMethod),type:e.type};this._paymentMethodIsRequestable=e.isRequestable,e.isRequestable?this._paymentMethodRequestableType=e.type:delete this._paymentMethodRequestableType,t&&(e.isRequestable?this._emit("paymentMethodRequestable",i):this._emit("noPaymentMethodRequestable"))},r.prototype.getPaymentMethods=function(){return this._paymentMethods.slice()},r.prototype.getActivePaymentMethod=function(){return this._activePaymentMethod},r.prototype.getActivePaymentView=function(){return this._activePaymentView},r.prototype.asyncDependencyStarting=function(){this.dependenciesInitializing++},r.prototype.asyncDependencyReady=function(){this.dependencySuccessCount++,this.dependenciesInitializing--,this._checkAsyncDependencyFinished()},r.prototype.asyncDependencyFailed=function(e){this.failedDependencies.hasOwnProperty(e.view)||(this.failedDependencies[e.view]=e.error,this.dependenciesInitializing--,this._checkAsyncDependencyFinished())},r.prototype._checkAsyncDependencyFinished=function(){0===this.dependenciesInitializing&&this._emit("asyncDependenciesReady")},r.prototype.cancelInitialization=function(e){this._emit("cancelInitialization",e)},r.prototype.reportError=function(e){this._emit("errorOccurred",e)},r.prototype.clearError=function(){this._emit("errorCleared")},r.prototype._getSupportedPaymentMethods=function(e){var t=this.supportedPaymentOptions.reduce(function(e,t){var i=d[t];return i&&e.push(i),e},[]);return e.filter(function(e){return t.indexOf(e.type)>-1})},t.exports=r},{"./constants":76,"./lib/dropin-error":86,"./lib/event-emitter":87,"./lib/is-guest-checkout":89}],78:[function(e,t,i){(function(i){"use strict";function r(e){this._client=e.client,this._componentID=v(),this._dropinWrapper=document.createElement("div"),this._dropinWrapper.id="braintree--dropin__"+this._componentID,this._dropinWrapper.setAttribute("data-braintree-id","wrapper"),this._dropinWrapper.style.display="none",this._dropinWrapper.className="braintree-loading",
+this._merchantConfiguration=e.merchantConfiguration,c.call(this)}function n(e){var t={nonce:e.nonce,details:e.details,type:e.type,vaulted:!0};return e.type===s.paymentMethodTypes.card&&(t.description=e.description),e.deviceData&&(t.deviceData=e.deviceData),e.binData&&(t.binData=e.binData),t}var a=e("./lib/assign").assign,o=e("./lib/analytics"),s=e("./constants"),l=e("./lib/dropin-error"),d=e("./dropin-model"),c=e("./lib/event-emitter"),p=e("./lib/is-guest-checkout"),h=e("./views/main-view"),u=e("./views/payment-methods-view").ID,y=e("./views/payment-options-view").ID,m=s.paymentOptionIDs,f=e("./translations"),v=e("./lib/uuid"),b=e("./lib/promise"),g=e("@braintree/wrap-promise").wrapPrototype,E='\n
\n
{{chooseAWayToPay}}
\n
\n\n
\n\n
\n\n
\n {{chooseAnotherWayToPay}}\n
\n
\n',_='\n',P=[m.paypal,m.paypalCredit],C=[m.paypal,m.paypalCredit],T="warn",I="1.7.0";
+r.prototype=Object.create(c.prototype,{constructor:r}),r.prototype._initialize=function(e){var t,i,r,n=this,c=this._merchantConfiguration.container||this._merchantConfiguration.selector;return this._injectStylesheet(),c?this._merchantConfiguration.container&&this._merchantConfiguration.selector?(o.sendEvent(this._client,"configuration-error"),void e(new l("Must only have one options.selector or options.container."))):("string"==typeof c&&(c=document.querySelector(c)),c&&1===c.nodeType?c.innerHTML.trim()?(o.sendEvent(this._client,"configuration-error"),void e(new l("options.selector or options.container must reference an empty DOM node."))):(this._strings=a({},f.en),this._merchantConfiguration.locale&&(t=f[this._merchantConfiguration.locale]||f[this._merchantConfiguration.locale.split("_")[0]],this._strings=a(this._strings,t)),this._merchantConfiguration.translations&&(this._strings=a(this._strings,this._merchantConfiguration.translations)),i=Object.keys(this._strings).reduce(function(e,t){var i=this._strings[t];return e.replace(RegExp("{{"+t+"}}","g"),i)}.bind(this),E),this._dropinWrapper.innerHTML=_+i,c.appendChild(this._dropinWrapper),void this._getVaultedPaymentMethods(function(t){var i;try{this._model=new d({client:this._client,componentID:this._componentID,merchantConfiguration:this._merchantConfiguration,paymentMethods:t})}catch(t){return void n.teardown().then(function(){e(t)})}this._model.on("cancelInitialization",function(t){o.sendEvent(this._client,"load-error"),this._dropinWrapper.innerHTML="",e(t)}.bind(this)),this._model.on("asyncDependenciesReady",function(){this._model.dependencySuccessCount>=1?(o.sendEvent(this._client,"appeared"),this._disableErroredPaymentMethods(),e(null,n)):this._model.cancelInitialization(new l("All payment options failed to load."))}.bind(this)),this._model.on("paymentMethodRequestable",function(e){this._emit("paymentMethodRequestable",e)}.bind(this)),this._model.on("noPaymentMethodRequestable",function(){this._emit("noPaymentMethodRequestable")}.bind(this)),this._model.on("paymentOptionSelected",function(e){this._emit("paymentOptionSelected",e)}.bind(this)),i=this._supportsPaymentOption(m.paypal)||this._supportsPaymentOption(m.paypalCredit),i&&!document.querySelector("#"+s.PAYPAL_CHECKOUT_SCRIPT_ID)?(r={src:s.CHECKOUT_JS_SOURCE,id:s.PAYPAL_CHECKOUT_SCRIPT_ID,logLevel:this._merchantConfiguration.paypal&&this._merchantConfiguration.paypal.logLevel||T},this._loadScript(r,function(){this._setUpDependenciesAndViews()}.bind(this))):this._setUpDependenciesAndViews()}.bind(this))):(o.sendEvent(this._client,"configuration-error"),void e(new l("options.selector or options.container must reference a valid DOM node.")))):(o.sendEvent(this._client,"configuration-error"),void e(new l("options.container is required.")))},r.prototype.updateConfiguration=function(e,t,i){P.indexOf(e)!==-1&&(this._mainView.getView(e).updateConfiguration(t,i),C.indexOf(e)!==-1&&(this._removeUnvaultedPaymentMethods(function(t){return t.type===s.paymentMethodTypes[e]}),this._navigateToInitialView()))},r.prototype.clearSelectedPaymentMethod=function(){this._removeUnvaultedPaymentMethods(),this._navigateToInitialView(),this._model.removeActivePaymentMethod()},r.prototype._setUpDataCollector=function(){var e=this,t=a({},e._merchantConfiguration.dataCollector,{client:e._client});this._model.asyncDependencyStarting(),i.braintree.dataCollector.create(t).then(function(t){e._dataCollectorInstance=t,e._model.asyncDependencyReady()}).catch(function(t){e._model.cancelInitialization(new l({message:"Data Collector failed to set up.",braintreeWebError:t}))})},r.prototype._setUpDependenciesAndViews=function(){var e,t;this._merchantConfiguration.dataCollector&&!document.querySelector("#"+s.DATA_COLLECTOR_SCRIPT_ID)&&(e=this._client.getVersion(),t={src:"https://js.braintreegateway.com/web/"+e+"/js/data-collector.min.js",id:s.DATA_COLLECTOR_SCRIPT_ID},this._loadScript(t,this._setUpDataCollector.bind(this))),this._mainView=new h({client:this._client,element:this._dropinWrapper,model:this._model,strings:this._strings})},r.prototype._removeUnvaultedPaymentMethods=function(e){e=e||function(){return!0},this._model.getPaymentMethods().forEach(function(t){e(t)&&!t.vaulted&&this._model.removePaymentMethod(t)}.bind(this))},r.prototype._navigateToInitialView=function(){var e,t,i=this._mainView.primaryView.ID===u;i&&(e=0===this._model.getPaymentMethods().length,e&&(t=1===this._model.supportedPaymentOptions.length,t?this._mainView.setPrimaryView(this._model.supportedPaymentOptions[0]):this._mainView.setPrimaryView(y)))},r.prototype._supportsPaymentOption=function(e){return this._model.supportedPaymentOptions.indexOf(e)!==-1},r.prototype._loadScript=function(e,t){var i=document.createElement("script");i.src=e.src,i.id=e.id,i.async=!0,e.logLevel&&i.setAttribute("data-log-level",e.logLevel),i.addEventListener("load",t),this._dropinWrapper.appendChild(i)},r.prototype._disableErroredPaymentMethods=function(){var e,t=Object.keys(this._model.failedDependencies);0!==t.length&&(e=this._mainView.getOptionsElements(),t.forEach(function(t){var i=e[t],r=i.div,n=i.clickHandler,a=this._model.failedDependencies[t],o=r.querySelector(".braintree-option__disabled-message");r.classList.add("braintree-disabled"),r.removeEventListener("click",n),"PAYPAL_SANDBOX_ACCOUNT_NOT_LINKED"===a.code?o.innerHTML=s.errors.PAYPAL_NON_LINKED_SANDBOX:o.textContent=a.message}.bind(this)))},r.prototype.requestPaymentMethod=function(){return this._mainView.requestPaymentMethod().then(function(e){return this._dataCollectorInstance&&(e.deviceData=this._dataCollectorInstance.deviceData),n(e)}.bind(this))},r.prototype._removeStylesheet=function(){var e=document.getElementById(s.STYLESHEET_ID);e&&e.parentNode.removeChild(e)},r.prototype._injectStylesheet=function(){var e,t,i,r;document.getElementById(s.STYLESHEET_ID)||(r=this._client.getConfiguration().gatewayConfiguration.assetsUrl,t=r+"/web/dropin/"+I+"/css/dropin.min.css",e=document.createElement("link"),i=document.head,e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",t),e.setAttribute("id",s.STYLESHEET_ID),i.firstChild?i.insertBefore(e,i.firstChild):i.appendChild(e))},r.prototype._getVaultedPaymentMethods=function(e){p(this._client)?e([]):this._client.request({endpoint:"payment_methods",method:"get",data:{defaultFirst:1}},function(t,i){var r;r=t?[]:i.paymentMethods.map(n),e(r)})},r.prototype.teardown=function(){var e,t,i=b.resolve(),r=this;return this._removeStylesheet(),this._mainView&&i.then(function(){return r._mainView.teardown().catch(function(t){e=t})}),this._dataCollectorInstance&&i.then(function(){return this._dataCollectorInstance.teardown().catch(function(e){t=new l({message:"Drop-in errored tearing down Data Collector.",braintreeWebError:e})})}.bind(this)),i.then(function(){return r._removeDropinWrapper()}).then(function(){return e?b.reject(e):t?b.reject(t):b.resolve()})},r.prototype.isPaymentMethodRequestable=function(){return this._model.isPaymentMethodRequestable()},r.prototype._removeDropinWrapper=function(){return this._dropinWrapper.parentNode.removeChild(this._dropinWrapper),b.resolve()},t.exports=g(r)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./constants":76,"./dropin-model":77,"./lib/analytics":81,"./lib/assign":82,"./lib/dropin-error":86,"./lib/event-emitter":87,"./lib/is-guest-checkout":89,"./lib/promise":92,"./lib/uuid":95,"./translations":105,"./views/main-view":121,"./views/payment-methods-view":123,"./views/payment-options-view":124,"@braintree/wrap-promise":17}],79:[function(e,t,i){"use strict";function r(e){return e.authorization?o.create({authorization:e.authorization}).catch(function(e){return p.reject(new c({message:"There was an error creating Drop-in.",braintreeWebError:e}))}).then(function(t){return t=n(t),"TOKENIZATION_KEY"===t.getConfiguration().authorizationType?d.sendEvent(t,"started.tokenization-key"):d.sendEvent(t,"started.client-token"),new p(function(i,r){new a({merchantConfiguration:e,client:t})._initialize(function(e,t){return e?void r(e):void i(t)})})}):p.reject(new c("options.authorization is required."))}function n(e){var t=e.getConfiguration();return t.analyticsMetadata.integration=l.INTEGRATION,t.analyticsMetadata.integrationType=l.INTEGRATION,t.analyticsMetadata.dropinVersion=u,e.getConfiguration=function(){return t},e}var a=e("./dropin"),o=e("braintree-web/client"),s=e("./lib/create-from-script-tag"),l=e("./constants"),d=e("./lib/analytics"),c=e("./lib/dropin-error"),p=e("./lib/promise"),h=e("@braintree/wrap-promise"),u="1.7.0";s(r,"undefined"!=typeof document&&document.querySelector("script[data-braintree-dropin-authorization]")),t.exports={create:h(r),VERSION:u}},{"./constants":76,"./dropin":78,"./lib/analytics":81,"./lib/create-from-script-tag":85,"./lib/dropin-error":86,"./lib/promise":92,"@braintree/wrap-promise":17,"braintree-web/client":23}],80:[function(e,t,i){"use strict";function r(e,t){e.addEventListener("click",t),e.addEventListener("keyup",function(e){13===e.keyCode&&t()})}t.exports=r},{}],81:[function(e,t,i){"use strict";function r(e){return Math.floor(e/1e3)}function n(e,t,i){var n=e.getConfiguration(),l=e._request,d=r(Date.now()),c=n.gatewayConfiguration.analytics.url,p={analytics:[{kind:o.ANALYTICS_PREFIX+t,timestamp:d}],_meta:n.analyticsMetadata,braintreeLibraryVersion:s};"TOKENIZATION_KEY"===n.authorizationType?p.tokenizationKey=n.authorization:p.authorizationFingerprint=JSON.parse(a(n.authorization)).authorizationFingerprint,l({url:c,method:"post",data:p,timeout:o.ANALYTICS_REQUEST_TIMEOUT_MS},i)}var a=e("./polyfill").atob,o=e("../constants"),s=e("braintree-web/client").VERSION;t.exports={sendEvent:n}},{"../constants":76,"./polyfill":91,"braintree-web/client":23}],82:[function(e,t,i){arguments[4][42][0].apply(i,arguments)},{dup:42}],83:[function(e,t,i){"use strict";var r=e("@braintree/browser-detection/is-ie9");t.exports={isIe9:r}},{"@braintree/browser-detection/is-ie9":6}],84:[function(e,t,i){"use strict";function r(e){return e.className.trim().split(/\s+/)}function n(e,t){return new RegExp("\\b"+t+"\\b").test(e.className)}function a(e){var t=Array.prototype.slice.call(arguments,1),i=r(e).filter(function(e){return t.indexOf(e)===-1}).concat(t).join(" ");e.className=i}function o(e){var t=Array.prototype.slice.call(arguments,1),i=r(e).filter(function(e){return t.indexOf(e)===-1}).join(" ");e.className=i}function s(e,t,i){arguments.length<3?n(e,t)?o(e,t):a(e,t):i?a(e,t):o(e,t)}t.exports={add:a,remove:o,toggle:s}},{}],85:[function(e,t,i){"use strict";function r(e,t,i){var r=i.querySelector('[name="'+e+'"]');r||(r=document.createElement("input"),r.type="hidden",r.name=e,i.appendChild(r)),r.value=t}function n(e,t,i){var r=t.split("."),o=p(r[0]);1===r.length?e[o]=a(i):(e[o]=e[o]||{},n(e[o],r.slice(1).join("."),i))}function a(e){try{return JSON.parse(e)}catch(t){return e}}function o(e,t){var i,a,o,p;if(t){if(i=t.getAttribute("data-braintree-dropin-authorization"),!i)throw new c("Authorization not found in data-braintree-dropin-authorization attribute");if(a=document.createElement("div"),a.id="braintree-dropin-"+d(),p=l.findParentForm(t),!p)throw new c("No form found for script tag integration.");p.addEventListener("submit",function(e){e.preventDefault()}),p.insertBefore(a,t),o={authorization:i,container:a},h.forEach(function(e){var i=t.getAttribute("data-"+e);null!=i&&n(o,e,i)}),e(o).then(function(e){s.sendEvent(e._client,"integration-type.script-tag"),p.addEventListener("submit",function(){e.requestPaymentMethod(function(e,t){e||(r("payment_method_nonce",t.nonce,p),t.deviceData&&r("device_data",t.deviceData,p),p.submit())})})})}}var s=e("./analytics"),l=e("./find-parent-form"),d=e("./uuid"),c=e("./dropin-error"),p=e("./kebab-case-to-camel-case"),h=["locale","payment-option-priority","data-collector.kount","data-collector.paypal","card.cardholderName","card.cardholderName.required","paypal.amount","paypal.currency","paypal.flow","paypal-credit.amount","paypal-credit.currency","paypal-credit.flow"];t.exports=o},{"./analytics":81,"./dropin-error":86,"./find-parent-form":88,"./kebab-case-to-camel-case":90,"./uuid":95}],86:[function(e,t,i){"use strict";function r(e){return"BraintreeError"===e.name}function n(e){this.name="DropinError","string"==typeof e?this.message=e:this.message=e.message,r(e)?this._braintreeWebError=e:this._braintreeWebError=e.braintreeWebError}n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,t.exports=n},{}],87:[function(e,t,i){arguments[4][57][0].apply(i,arguments)},{dup:57}],88:[function(e,t,i){"use strict";function r(e){var t=e.parentNode;return t&&"FORM"!==t.nodeName?r(t):t}t.exports={findParentForm:r}},{}],89:[function(e,t,i){"use strict";var r=e("./polyfill").atob;t.exports=function(e){var t,i=e.getConfiguration();return"TOKENIZATION_KEY"===i.authorizationType||(t=JSON.parse(r(i.authorization)).authorizationFingerprint,!t||t.indexOf("customer_id=")===-1)}},{"./polyfill":91}],90:[function(e,t,i){"use strict";function r(e){var t=e.split("-"),i=t.shift(),r=t.map(function(e){return e.charAt(0).toUpperCase()+e.substring(1)});return[i].concat(r).join("")}t.exports=r},{}],91:[function(e,t,i){(function(e){"use strict";function i(e){var t,i,r,n,a,o,s,l,d=new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p="";if(!d.test(e))throw new Error("Non base64 encoded input passed to window.atob polyfill");l=0;do n=c.indexOf(e.charAt(l++)),a=c.indexOf(e.charAt(l++)),o=c.indexOf(e.charAt(l++)),s=c.indexOf(e.charAt(l++)),t=(63&n)<<2|a>>4&3,i=(15&a)<<4|o>>2&15,r=(3&o)<<6|63&s,p+=String.fromCharCode(t)+(i?String.fromCharCode(i):"")+(r?String.fromCharCode(r):"");while(l1,i=this.model.getPaymentMethods();this._views={},this.sheetContainer=this.getElementById("sheet-container"),this.sheetErrorText=this.getElementById("sheet-error-text"),this.toggle=this.getElementById("toggle"),this.lowerContainer=this.getElementById("lower-container"),this.loadingContainer=this.getElementById("loading-container"),this.loadingIndicator=this.getElementById("loading-indicator"),this.dropinContainer=this.element.querySelector(".braintree-dropin"),this.supportsFlexbox=m(),this.model.on("asyncDependenciesReady",this.hideLoadingIndicator.bind(this)),this.model.on("errorOccurred",this.showSheetError.bind(this)),this.model.on("errorCleared",this.hideSheetError.bind(this)),this.paymentSheetViewIDs=Object.keys(c).reduce(function(e,t){var i,r;return this.model.supportedPaymentOptions.indexOf(t)!==-1&&(i=c[t],r=new i({element:this.getElementById(i.ID),mainView:this,model:this.model,client:this.client,strings:this.strings}),r.initialize(),this.addView(r),e.push(r.ID)),e}.bind(this),[]),this.paymentMethodsViews=new p({element:this.element,model:this.model,strings:this.strings}),this.addView(this.paymentMethodsViews),u(this.toggle,this.toggleAdditionalOptions.bind(this)),this.model.on("changeActivePaymentMethod",function(){setTimeout(function(){this.setPrimaryView(p.ID)}.bind(this),v)}.bind(this)),this.model.on("changeActivePaymentView",function(e){var t=this.getView(e);e===p.ID?(d.add(this.paymentMethodsViews.container,"braintree-methods--active"),d.remove(this.sheetContainer,"braintree-sheet--active")):(setTimeout(function(){d.add(this.sheetContainer,"braintree-sheet--active")}.bind(this),0),d.remove(this.paymentMethodsViews.container,"braintree-methods--active"),this.getView(e).getPaymentMethod()||this.model.setPaymentMethodRequestable({isRequestable:!1})),t.onSelection()}.bind(this)),this.model.on("removeActivePaymentMethod",function(){var e=this.getView(this.model.getActivePaymentView());e&&"function"==typeof e.removeActivePaymentMethod&&e.removeActivePaymentMethod()}.bind(this)),t&&(e=new h({client:this.client,element:this.getElementById(h.ID),mainView:this,model:this.model,strings:this.strings}),this.addView(e)),i.length>0?this.model.changeActivePaymentMethod(i[0]):t?this.setPrimaryView(e.ID):this.setPrimaryView(this.paymentSheetViewIDs[0])},r.prototype.addView=function(e){this._views[e.ID]=e},r.prototype.getView=function(e){return this._views[e]},r.prototype.setPrimaryView=function(e,t){var i;setTimeout(function(){this.element.className=a(e),t&&d.add(this.element,a(t))}.bind(this),0),this.primaryView=this.getView(e),this.model.changeActivePaymentView(e),this.paymentSheetViewIDs.indexOf(e)!==-1?this.model.getPaymentMethods().length>0||this.getView(h.ID)?this.showToggle():this.hideToggle():e===p.ID?(this.showToggle(),this.getElementById("lower-container").appendChild(this.getElementById("options"))):e===h.ID&&this.hideToggle(),this.supportsFlexbox||this.element.setAttribute("data-braintree-no-flexbox",!0),i=this.primaryView.getPaymentMethod(),this.model.setPaymentMethodRequestable({isRequestable:Boolean(i),type:i&&i.type,selectedPaymentMethod:i}),this.model.clearError()},r.prototype.requestPaymentMethod=function(){var e=this.getView(this.model.getActivePaymentView());return e.requestPaymentMethod().then(function(e){return o.sendEvent(this.client,"request-payment-method."+s[e.type]),e}.bind(this)).catch(function(e){return o.sendEvent(this.client,"request-payment-method.error"),y.reject(e)}.bind(this))},r.prototype.hideLoadingIndicator=function(){d.add(this.dropinContainer,"braintree-loaded"),f.onTransitionEnd(this.loadingIndicator,"transform",function(){this.loadingContainer.parentNode.removeChild(this.loadingContainer)}.bind(this))},r.prototype.toggleAdditionalOptions=function(){var e,t=this.model.supportedPaymentOptions.length>1,i=this.paymentSheetViewIDs.indexOf(this.primaryView.ID)!==-1;this.hideToggle(),t?i?0===this.model.getPaymentMethods().length?this.setPrimaryView(h.ID):(this.setPrimaryView(p.ID,h.ID),this.hideToggle()):d.add(this.element,a(h.ID)):(e=this.paymentSheetViewIDs[0],d.add(this.element,a(e)),this.model.changeActivePaymentView(e))},r.prototype.showToggle=function(){d.remove(this.toggle,"braintree-hidden"),d.add(this.lowerContainer,"braintree-hidden")},r.prototype.hideToggle=function(){d.add(this.toggle,"braintree-hidden"),d.remove(this.lowerContainer,"braintree-hidden")},r.prototype.showSheetError=function(e){var t,i=this.strings.genericError;this.strings.hasOwnProperty(e)?t=this.strings[e]:e&&e.code&&(t=this.strings[n(e.code)+"Error"]),t&&(i=t),d.add(this.sheetContainer,"braintree-sheet--has-error"),this.sheetErrorText.textContent=i},r.prototype.hideSheetError=function(){d.remove(this.sheetContainer,"braintree-sheet--has-error")},r.prototype.getOptionsElements=function(){return this._views.options.elements},r.prototype.teardown=function(){var e,t=Object.keys(this._views),i=t.map(function(t){return this._views[t].teardown().catch(function(t){e=t})}.bind(this));return y.all(i).then(function(){return e?y.reject(e):y.resolve()})},t.exports=r},{"../constants":76,"../lib/add-selection-event-handler":80,"../lib/analytics":81,"../lib/classlist":84,"../lib/promise":92,"../lib/supports-flexbox":93,"../lib/transition-helper":94,"./base-view":120,"./payment-methods-view":123,"./payment-options-view":124,"./payment-sheet-views":127}],122:[function(e,t,i){"use strict";function r(){n.apply(this,arguments),this._initialize()}var n=e("./base-view"),a=e("../lib/classlist"),o=e("../constants"),s=e("../lib/add-selection-event-handler"),l='\n \n
\n\n\n\n\n';r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.prototype._initialize=function(){var e,t=l,i=o.paymentMethodCardTypes,r=o.paymentMethodTypes;switch(this.element=document.createElement("div"),this.element.className="braintree-method",this.element.setAttribute("tabindex","0"),s(this.element,function(){this.model.changeActivePaymentMethod(this.paymentMethod)}.bind(this)),this.paymentMethod.type){case r.card:e=this.strings.endingIn.replace("{{lastTwoCardDigits}}",this.paymentMethod.details.lastTwo),t=t.replace(/@ICON/g,"icon-"+i[this.paymentMethod.details.cardType]).replace(/@CLASSNAME/g," braintree-icon--bordered").replace(/@TITLE/g,e).replace(/@SUBTITLE/g,this.strings[this.paymentMethod.details.cardType]);break;case r.paypal:t=t.replace(/@ICON/g,"logoPayPal").replace(/@CLASSNAME/g,"").replace(/@TITLE/g,this.paymentMethod.details.email).replace(/@SUBTITLE/g,this.strings.PayPal)}this.element.innerHTML=t},r.prototype.setActive=function(e){setTimeout(function(){a.toggle(this.element,"braintree-method--active",e)}.bind(this),0)},t.exports=r},{"../constants":76,"../lib/add-selection-event-handler":80,"../lib/classlist":84,"./base-view":120}],123:[function(e,t,i){"use strict";function r(){n.apply(this,arguments),this._initialize()}var n=e("./base-view"),a=e("./payment-method-view"),o=e("../lib/dropin-error"),s=e("../lib/classlist"),l=e("../constants").errors,d=e("../lib/promise"),c={CreditCard:"Card",PayPalAccount:"PayPal"};r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.ID=r.prototype.ID="methods",r.prototype._initialize=function(){var e,t=this.model.getPaymentMethods();for(this.views=[],this.container=this.getElementById("methods-container"),this._headingLabel=this.getElementById("methods-label"),this.model.on("addPaymentMethod",this._addPaymentMethod.bind(this)),this.model.on("removePaymentMethod",this._removePaymentMethod.bind(this)),this.model.on("changeActivePaymentMethod",this._changeActivePaymentMethodView.bind(this)),e=t.length-1;e>=0;e--)this._addPaymentMethod(t[e])},r.prototype.removeActivePaymentMethod=function(){this.activeMethodView&&(this.activeMethodView.setActive(!1),this.activeMethodView=null,s.add(this._headingLabel,"braintree-no-payment-method-selected"))},r.prototype._getPaymentMethodString=function(){var e=c[this.activeMethodView.paymentMethod.type],t=this.strings[e];return this.strings.payingWith.replace("{{paymentSource}}",t)},r.prototype._addPaymentMethod=function(e){var t=new a({model:this.model,paymentMethod:e,strings:this.strings});this.model.isGuestCheckout&&this.container.firstChild&&(this.container.removeChild(this.container.firstChild),this.views.pop()),this.container.firstChild?this.container.insertBefore(t.element,this.container.firstChild):this.container.appendChild(t.element),this.views.push(t)},r.prototype._removePaymentMethod=function(e){var t;for(t=0;t\n \n\n\n\n';r.prototype=Object.create(o.prototype),r.prototype.constructor=r,r.ID=r.prototype.ID="options",r.prototype._initialize=function(){this.container=this.getElementById("payment-options-container"),this.elements={},this.model.supportedPaymentOptions.forEach(function(e){this._addPaymentOption(e)}.bind(this))},r.prototype._addPaymentOption=function(e){var t,i=document.createElement("div"),r=l,o=function(){this.mainView.setPrimaryView(e),this.model.selectPaymentOption(e),n.sendEvent(this.client,"selected."+s[e])}.bind(this);switch(i.className="braintree-option braintree-option__"+e,i.setAttribute("tabindex","0"),e){case s.card:t=this.strings.Card,r=r.replace(/@ICON/g,"iconCardFront"),r=r.replace(/@OPTION_LABEL/g,this._generateOptionLabel(t)),r=r.replace(/@OPTION_TITLE/g,t),r=r.replace(/@CLASSNAME/g,"braintree-icon--bordered");break;case s.paypal:t=this.strings.PayPal,r=r.replace(/@ICON/g,"logoPayPal"),r=r.replace(/@OPTION_LABEL/g,this._generateOptionLabel(this.strings.PayPal)),r=r.replace(/@OPTION_TITLE/g,this.strings.PayPal),r=r.replace(/@CLASSNAME/g,"");break;case s.paypalCredit:t=this.strings["PayPal Credit"],r=r.replace(/@ICON/g,"logoPayPalCredit"),r=r.replace(/@OPTION_LABEL/g,this._generateOptionLabel(t)),r=r.replace(/@OPTION_TITLE/g,t),r=r.replace(/@CLASSNAME/g,"")}i.innerHTML=r,a(i,o),this.container.appendChild(i),this.elements[e]={div:i,clickHandler:o}},r.prototype._generateOptionLabel=function(e){return this.strings.payingWith.replace("{{paymentSource}}",e)},t.exports=r},{"../constants":76,"../lib/add-selection-event-handler":80,"../lib/analytics":81,"./base-view":120}],125:[function(e,t,i){(function(i){"use strict";function r(){a.apply(this,arguments)}var n=e("../../lib/assign").assign,a=e("../base-view"),o=e("braintree-web/paypal-checkout"),s=e("../../lib/dropin-error"),l=3e4,d=["offerCredit","locale"];r.prototype=Object.create(a.prototype),r.prototype.initialize=function(){function e(e){a?d.model.reportError(e):(d.model.asyncDependencyFailed({view:d.ID,error:e}),clearTimeout(t))}var t,r=Boolean(this._isPayPalCredit),a=!1,d=this,c=r?"paypalCredit":"paypal",p=this.model.merchantConfiguration[c];return this.paypalConfiguration=n({},p),this.model.asyncDependencyStarting(),t=setTimeout(function(){d.model.asyncDependencyFailed({view:d.ID,error:new s("There was an error connecting to PayPal.")})},l),o.create({client:this.client}).then(function(n){var o,s='[data-braintree-id="paypal-button"]',l="production"===d.client.getConfiguration().gatewayConfiguration.environment?"production":"sandbox",c=d.model.merchantConfiguration.locale;return d.paypalInstance=n,d.paypalConfiguration.offerCredit=Boolean(r),o={env:l,style:d.paypalConfiguration.buttonStyle||{},locale:c,payment:function(){return n.createPayment(d.paypalConfiguration).catch(e)},onAuthorize:function(t){return n.tokenizePayment(t).then(function(e){"vault"!==d.paypalConfiguration.flow||d.model.isGuestCheckout||(e.vaulted=!0),d.model.addPaymentMethod(e)}).catch(e)},onError:e},c&&(d.paypalConfiguration.locale=c),r&&(s='[data-braintree-id="paypal-credit-button"]',o.style.label="credit"),i.paypal.Button.render(o,s).then(function(){d.model.asyncDependencyReady(),a=!0,clearTimeout(t)})}).catch(e)},r.prototype.updateConfiguration=function(e,t){d.indexOf(e)===-1&&(this.paypalConfiguration[e]=t)},t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../lib/assign":82,"../../lib/dropin-error":86,"../base-view":120,"braintree-web/paypal-checkout":68}],126:[function(e,t,i){"use strict";function r(){d.apply(this,arguments)}function n(){var e=document.activeElement&&document.activeElement.id,t=document.activeElement instanceof HTMLIFrameElement&&e.indexOf("braintree-hosted-field")!==-1,i=e.indexOf("braintree__card-view-input")!==-1;return t||i}function a(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function o(e){return e[0].toUpperCase()+e.substr(1)}function s(e){Object.keys(e).forEach(function(t){var i=a(t);e[i]=e[t]})}var l=e("../../lib/assign").assign,d=e("../base-view"),c=e("../../lib/classlist"),p=e("../../constants"),h=e("../../lib/dropin-error"),u=e("braintree-web/hosted-fields"),y=e("../../lib/transition-helper"),m=e("../../lib/promise"),f='\n \n
\n\n \n
\n\n \n
\n\n \n
\n\n \n
\n\n\n \n
\n\n \n
\n\n \n
\n';r.prototype=Object.create(d.prototype),r.prototype.constructor=r,r.ID=r.prototype.ID=p.paymentOptionIDs.card,r.prototype.initialize=function(){var e,t,i=this.getElementById("cardholder-name-field-group"),r=this.getElementById("card-view-icons"),n=this._generateHostedFieldsOptions();return r.innerHTML=f,this._hideUnsupportedCardIcons(),this.hasCVV=n.fields.cvv,this.hasCardholderName=Boolean(this.model.merchantConfiguration.card&&this.model.merchantConfiguration.card.cardholderName),this.cardholderNameInput=i.querySelector("input"),this.cardNumberIcon=this.getElementById("card-number-icon"),this.cardNumberIconSvg=this.getElementById("card-number-icon-svg"),this.cvvIcon=this.getElementById("cvv-icon"),this.cvvIconSvg=this.getElementById("cvv-icon-svg"),this.cvvLabelDescriptor=this.getElementById("cvv-label-descriptor"),this.fieldErrors={},this.hasCVV||(e=this.getElementById("cvv-field-group"),e.parentNode.removeChild(e)),n.fields.postalCode||(t=this.getElementById("postal-code-field-group"),t.parentNode.removeChild(t)),this.hasCardholderName?this._setupCardholderName(i):i.parentNode.removeChild(i),this.model.asyncDependencyStarting(),u.create(n).then(function(e){this.hostedFieldsInstance=e,this.hostedFieldsInstance.on("blur",this._onBlurEvent.bind(this)),this.hostedFieldsInstance.on("cardTypeChange",this._onCardTypeChangeEvent.bind(this)),this.hostedFieldsInstance.on("focus",this._onFocusEvent.bind(this)),this.hostedFieldsInstance.on("notEmpty",this._onNotEmptyEvent.bind(this)),this.hostedFieldsInstance.on("validityChange",this._onValidityChangeEvent.bind(this)),this.model.asyncDependencyReady()}.bind(this)).catch(function(e){this.model.asyncDependencyFailed({view:this.ID,error:e})}.bind(this))},r.prototype._setupCardholderName=function(e){var t=this.model.merchantConfiguration.card&&this.model.merchantConfiguration.card.cardholderName,i=e.querySelector(".braintree-form__hosted-field");this.cardholderNameInput.addEventListener("keyup",function(){var r=this.cardholderNameInput.value.length>0;c.toggle(i,"braintree-form__field--valid",r),t.required&&(r&&c.remove(e,"braintree-form__field-group--has-error"),this._sendRequestableEvent())}.bind(this),!1),t.required&&this.cardholderNameInput.addEventListener("blur",function(){setTimeout(function(){n()&&0===this.cardholderNameInput.value.length&&c.add(e,"braintree-form__field-group--has-error")}.bind(this),0)}.bind(this),!1)},r.prototype._sendRequestableEvent=function(){this._isTokenizing||this.model.setPaymentMethodRequestable({isRequestable:this._validateForm(),type:p.paymentMethodTypes.card})},r.prototype._generateHostedFieldsOptions=function(){var e=this.client.getConfiguration().gatewayConfiguration.challenges,t=e.indexOf("cvv")!==-1,i=e.indexOf("postal_code")!==-1,r=this.model.merchantConfiguration.card&&this.model.merchantConfiguration.card.overrides,n={client:this.client,fields:{number:{selector:this._generateFieldSelector("number"),placeholder:"•••• •••• •••• ••••"},expirationDate:{selector:this._generateFieldSelector("expiration"),placeholder:this.strings.expirationDatePlaceholder},cvv:{selector:this._generateFieldSelector("cvv"),placeholder:"•••"},postalCode:{selector:this._generateFieldSelector("postal-code")}},styles:{input:{"font-size":"16px","font-family":'-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',color:"#000"},":focus":{color:"black"},"::-webkit-input-placeholder":{color:"#6a6a6a"},":-moz-placeholder":{color:"#6a6a6a"},"::-moz-placeholder":{color:"#6a6a6a"},":-ms-input-placeholder ":{color:"#6a6a6a"},"input::-ms-clear":{color:"transparent"}}};return t||delete n.fields.cvv,i||delete n.fields.postalCode,r?(r.fields&&(r.fields.cvv&&r.fields.cvv.placeholder&&(this._hasCustomCVVPlaceholder=!0),Object.keys(r.fields).forEach(function(e){return"cvv"!==e&&"postalCode"!==e||null!==r.fields[e]?void(n.fields[e]&&l(n.fields[e],r.fields[e],{selector:n.fields[e].selector})):void delete n.fields[e]})),r.styles&&Object.keys(r.styles).forEach(function(e){return null===r.styles[e]?void delete n.styles[e]:(s(r.styles[e]),void l(n.styles[e],r.styles[e]))}),n):n},r.prototype._validateForm=function(e){var t,i,r,n=!0,a=this.client.getConfiguration().gatewayConfiguration.creditCards.supportedCardTypes;return!!this.hostedFieldsInstance&&(r=this.hostedFieldsInstance.getState(),Object.keys(r.fields).forEach(function(t){var i=r.fields[t];(e||n)&&(i.isEmpty?(n=!1,e&&this.showFieldError(t,this.strings["fieldEmptyFor"+o(t)])):i.isValid||(n=!1,e&&this.showFieldError(t,this.strings["fieldInvalidFor"+o(t)])))}.bind(this)),r.fields.number.isValid&&(t=p.configurationCardTypes[r.cards[0].type],i=a.indexOf(t)!==-1,i||(n=!1,e&&this.showFieldError("number",this.strings.unsupportedCardTypeError))),this._validateCardholderName()||(n=!1),n)},r.prototype.getPaymentMethod=function(){var e=this._validateForm();if(e)return{type:p.paymentMethodTypes.card}},r.prototype.tokenize=function(){var e,t=this,i=t.hostedFieldsInstance.getState(),r={vault:!t.model.isGuestCheckout};return this.model.clearError(),this._validateForm(!0)?(this.hasCardholderName&&(r.cardholderName=this.cardholderNameInput.value),t._isTokenizing=!0,t.hostedFieldsInstance.tokenize(r).then(function(r){return Object.keys(i.fields).forEach(function(e){t.hostedFieldsInstance.clear(e)}),t.model.isGuestCheckout||(r.vaulted=!0),new m(function(i){e=function(){setTimeout(function(){t.model.addPaymentMethod(r),i(r),c.remove(t.element,"braintree-sheet--tokenized")},0),t._isTokenizing=!1},y.onTransitionEnd(t.element,"max-height",e),setTimeout(function(){c.remove(t.element,"braintree-sheet--loading")},p.CHANGE_ACTIVE_PAYMENT_METHOD_TIMEOUT),c.add(t.element,"braintree-sheet--tokenized")})}).catch(function(e){return t._isTokenizing=!1,t.model.reportError(e),c.remove(t.element,"braintree-sheet--loading"),m.reject(new h({message:p.errors.NO_PAYMENT_METHOD_ERROR,braintreeWebError:e}))})):(t.model.reportError("hostedFieldsFieldsInvalidError"),c.remove(t.element,"braintree-sheet--loading"),m.reject(new h(p.errors.NO_PAYMENT_METHOD_ERROR)))},r.prototype.showFieldError=function(e,t){var i,r=this.getElementById(a(e)+"-field-group");this.fieldErrors.hasOwnProperty(e)||(this.fieldErrors[e]=this.getElementById(a(e)+"-field-error")),c.add(r,"braintree-form__field-group--has-error"),i=this.fieldErrors[e],i.textContent=t,this.hostedFieldsInstance.setAttribute({field:e,attribute:"aria-invalid",value:!0})},r.prototype.hideFieldError=function(e){var t=this.getElementById(a(e)+"-field-group");this.fieldErrors.hasOwnProperty(e)||(this.fieldErrors[e]=this.getElementById(a(e)+"-field-error")),c.remove(t,"braintree-form__field-group--has-error"),this.hostedFieldsInstance.removeAttribute({field:e,attribute:"aria-invalid"})},r.prototype.teardown=function(){return this.hostedFieldsInstance.teardown()},r.prototype._generateFieldSelector=function(e){return"#braintree--dropin__"+this.model.componentID+" .braintree-form-"+e},r.prototype._validateCardholderName=function(){return!this.hasCardholderName||!this.model.merchantConfiguration.card.cardholderName.required||this.cardholderNameInput.value.length>0},r.prototype._onBlurEvent=function(e){var t=e.fields[e.emittedBy],i=this.getElementById(a(e.emittedBy)+"-field-group");c.remove(i,"braintree-form__field-group--is-focused"),n()&&t.isEmpty?this.showFieldError(e.emittedBy,this.strings["fieldEmptyFor"+o(e.emittedBy)]):t.isEmpty||t.isValid?"number"!==e.emittedBy||this._isCardTypeSupported(e.cards[0].type)||this.showFieldError("number",this.strings.unsupportedCardTypeError):this.showFieldError(e.emittedBy,this.strings["fieldInvalidFor"+o(e.emittedBy)])},r.prototype._onCardTypeChangeEvent=function(e){var t,i="#iconCardFront",r="#iconCVVBack",n=this.strings.cvvThreeDigitLabelSubheading,a="•••",o=this.getElementById("number-field-group");1===e.cards.length?(t=e.cards[0].type,i="#icon-"+t,"american-express"===t&&(r="#iconCVVFront",n=this.strings.cvvFourDigitLabelSubheading,a="••••"),c.add(o,"braintree-form__field-group--card-type-known")):c.remove(o,"braintree-form__field-group--card-type-known"),this.cardNumberIconSvg.setAttribute("xlink:href",i),this.hasCVV&&(this.cvvIconSvg.setAttribute("xlink:href",r),this.cvvLabelDescriptor.textContent=n,this._hasCustomCVVPlaceholder||this.hostedFieldsInstance.setAttribute({field:"cvv",attribute:"placeholder",value:a}))},r.prototype._onFocusEvent=function(e){var t=this.getElementById(a(e.emittedBy)+"-field-group");c.add(t,"braintree-form__field-group--is-focused")},r.prototype._onNotEmptyEvent=function(e){this.hideFieldError(e.emittedBy)},r.prototype._onValidityChangeEvent=function(e){var t,i=e.fields[e.emittedBy];t="number"===e.emittedBy&&e.cards[0]?i.isValid&&this._isCardTypeSupported(e.cards[0].type):i.isValid,c.toggle(i.container,"braintree-form__field--valid",t),i.isPotentiallyValid&&this.hideFieldError(e.emittedBy),this._sendRequestableEvent()},r.prototype.requestPaymentMethod=function(){return c.add(this.element,"braintree-sheet--loading"),this.tokenize()},r.prototype.onSelection=function(){this.hostedFieldsInstance&&(this.hasCardholderName?setTimeout(function(){this.cardholderNameInput.focus()}.bind(this),1):this.hostedFieldsInstance.focus("number"))},r.prototype._hideUnsupportedCardIcons=function(){var e=this.client.getConfiguration().gatewayConfiguration.creditCards.supportedCardTypes;Object.keys(p.configurationCardTypes).forEach(function(t){var i,r=p.configurationCardTypes[t];e.indexOf(r)===-1&&(i=this.getElementById(t+"-card-icon"),c.add(i,"braintree-hidden"))}.bind(this))},r.prototype._isCardTypeSupported=function(e){var t=p.configurationCardTypes[e],i=this.client.getConfiguration().gatewayConfiguration.creditCards.supportedCardTypes;return i.indexOf(t)!==-1},t.exports=r},{"../../constants":76,"../../lib/assign":82,"../../lib/classlist":84,"../../lib/dropin-error":86,"../../lib/promise":92,"../../lib/transition-helper":94,"../base-view":120,"braintree-web/hosted-fields":35}],127:[function(e,t,i){"use strict";var r=e("../../constants").paymentOptionIDs,n={};n[r.card]=e("./card-view"),n[r.paypal]=e("./paypal-view"),n[r.paypalCredit]=e("./paypal-credit-view"),t.exports=n},{"../../constants":76,"./card-view":126,"./paypal-credit-view":128,"./paypal-view":129}],128:[function(e,t,i){"use strict";function r(){a.apply(this,arguments),this._isPayPalCredit=!0}var n=e("../../constants").paymentOptionIDs,a=e("./base-paypal-view");r.prototype=Object.create(a.prototype),r.prototype.constructor=r,r.ID=r.prototype.ID=n.paypalCredit,t.exports=r},{"../../constants":76,"./base-paypal-view":125}],129:[function(e,t,i){"use strict";function r(){a.apply(this,arguments)}var n=e("../../constants").paymentOptionIDs,a=e("./base-paypal-view");r.prototype=Object.create(a.prototype),r.prototype.constructor=r,r.ID=r.prototype.ID=n.paypal,t.exports=r},{"../../constants":76,"./base-paypal-view":125}]},{},[79])(79)});
\ No newline at end of file
diff --git a/www/assets/vendors.js.spt b/www/assets/vendors.js.spt
index fd3721f15a..4aba78ab04 100644
--- a/www/assets/vendors.js.spt
+++ b/www/assets/vendors.js.spt
@@ -10,6 +10,7 @@ files = [
'tipr.min.js',
'bootstrap-dropdown.js',
'jquery.mousewheel.min.js',
+ 'braintree.min.js',
]
js = http_caching.concat_files(files, vendor_root)
diff --git a/www/index.spt b/www/index.spt
index 8f9761dab7..f015ac773a 100644
--- a/www/index.spt
+++ b/www/index.spt
@@ -25,7 +25,6 @@ if not user.ANON:
{% endblock %}
{% block scripts %}
-
{{ super() }}
{% endblock %}
From ccbf83080b3775ce5a98b99aa33251d974154184 Mon Sep 17 00:00:00 2001
From: Chad Whitacre
Date: Thu, 7 Sep 2017 20:41:40 -0400
Subject: [PATCH 3/4] Expose client authorization to envvar config
---
defaults.env | 1 +
gratipay/wireup.py | 1 +
js/gratipay/homepage.js | 4 ++--
www/index.spt | 6 +++++-
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/defaults.env b/defaults.env
index 1a5c35a887..d90408ccb1 100644
--- a/defaults.env
+++ b/defaults.env
@@ -31,6 +31,7 @@ BRAINTREE_SANDBOX_MODE=true
BRAINTREE_MERCHANT_ID=bk8h97tqzyqjhtfn
BRAINTREE_PUBLIC_KEY=xbty5dc9bgxpv5nb
BRAINTREE_PRIVATE_KEY=9d8646957c982bb0fb1aac764b582f7a
+BRAINTREE_CLIENT_AUTHORIZATION=sandbox_cr9dyy9c_bk8h97tqzyqjhtfn
COINBASE_API_KEY=uETKVUrnPuXzVaVj
COINBASE_API_SECRET=32zAkQCcHHYkGGn29VkvEZvn21PM1lgO
diff --git a/gratipay/wireup.py b/gratipay/wireup.py
index 87e5a932cb..f902aa0514 100644
--- a/gratipay/wireup.py
+++ b/gratipay/wireup.py
@@ -351,6 +351,7 @@ def env():
BRAINTREE_MERCHANT_ID = unicode,
BRAINTREE_PUBLIC_KEY = unicode,
BRAINTREE_PRIVATE_KEY = unicode,
+ BRAINTREE_CLIENT_AUTHORIZATION = unicode,
GITHUB_CLIENT_ID = unicode,
GITHUB_CLIENT_SECRET = unicode,
GITHUB_CALLBACK = unicode,
diff --git a/js/gratipay/homepage.js b/js/gratipay/homepage.js
index 32e86199c5..9212bcdd31 100644
--- a/js/gratipay/homepage.js
+++ b/js/gratipay/homepage.js
@@ -1,6 +1,6 @@
Gratipay.homepage = {}
-Gratipay.homepage.initForm = function () {
+Gratipay.homepage.initForm = function(clientAuthorization) {
$form = $('#homepage #content form');
$submit= $form.find('button[type=submit]');
$submit.click(Gratipay.homepage.submitForm);
@@ -9,7 +9,7 @@ Gratipay.homepage.initForm = function () {
$promote.click(Gratipay.homepage.openPromote);
braintree.dropin.create({
- authorization: 'sandbox_cr9dyy9c_bk8h97tqzyqjhtfn',
+ authorization: clientAuthorization,
container: '#braintree-container'
}, function (createErr, instance) {
$submit.click(function () {
diff --git a/www/index.spt b/www/index.spt
index f015ac773a..40a2a2281a 100644
--- a/www/index.spt
+++ b/www/index.spt
@@ -25,7 +25,11 @@ if not user.ANON:
{% endblock %}
{% block scripts %}
-
+
{{ super() }}
{% endblock %}
From f11aa13cc300dc3182afbddcc465cdf8c2a522b9 Mon Sep 17 00:00:00 2001
From: Chad Whitacre
Date: Thu, 7 Sep 2017 13:38:33 -0400
Subject: [PATCH 4/4] Stub out the ecosystem chooser
---
js/gratipay/homepage.js | 7 +++++++
www/index.spt | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/js/gratipay/homepage.js b/js/gratipay/homepage.js
index 9212bcdd31..d07ca9be7e 100644
--- a/js/gratipay/homepage.js
+++ b/js/gratipay/homepage.js
@@ -2,9 +2,16 @@ Gratipay.homepage = {}
Gratipay.homepage.initForm = function(clientAuthorization) {
$form = $('#homepage #content form');
+
$submit= $form.find('button[type=submit]');
$submit.click(Gratipay.homepage.submitForm);
+ $chooseEcosystem = $form.find('.ecosystem-chooser button');
+ $chooseEcosystem.click(function(e) {
+ e.preventDefault();
+ Gratipay.notification('Not implemented.', 'error');
+ });
+
$promote = $form.find('.promotion-gate button');
$promote.click(Gratipay.homepage.openPromote);
diff --git a/www/index.spt b/www/index.spt
index 40a2a2281a..0892c7d616 100644
--- a/www/index.spt
+++ b/www/index.spt
@@ -115,10 +115,10 @@ $(document).ready(function() {
{{ _('Which do you value most?{br}(JavaScript, Python, etc.)', br='
'|safe) }}
-