diff --git a/package.json b/package.json index 465773d..86370fe 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "git+https://github.com/mozilla/payments-example.git" }, "author": "Mozilla Payments Team", - "license": "MPL 2.0", + "license": "MPL-2.0", "bugs": { "url": "https://github.com/mozilla/payments-example/issues" }, @@ -25,7 +25,7 @@ }, "dependencies": { "jquery": "^2.1.4", - "mozilla-payments-client": "0.0.10", + "mozilla-payments-client": "0.0.11", "mozilla-payments-config": "0.0.7" } } diff --git a/public/lib/js/payments-client.js b/public/lib/js/payments-client.js index d12930e..139a1f9 100644 --- a/public/lib/js/payments-client.js +++ b/public/lib/js/payments-client.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):"object"==typeof exports?exports.PaymentsClient=e():t.PaymentsClient=e()}(this,function(){return function(t){function e(i){if(o[i])return o[i].exports;var r=o[i]={exports:{},id:i,loaded:!1};return t[i].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){"use strict";function i(t){t=t||{},t.product=t.product||{},this.modalParent=t.modalParent||document.body,this.id="_"+Math.random().toString(36).substr(2,9),this.modalWidth=t.modalWidth||318,this.modalHeight=t.modalHeight||468,this.closeDelayMs="number"==typeof t.closeDelayMs?t.closeDelayMs:300,this.accessToken=t.accessToken||null,this.paymentHost=t.paymentHost||"http://pay.dev:8000/",this.httpsOnly="undefined"==typeof t.httpsOnly?!0:t.httpsOnly;var e=r.getProtocol(this.paymentHost),o=t._window||window;if(this.httpsOnly===!0&&"https:"!==o.location.protocol)throw new Error("Host site should run under SSL");if(this.httpsOnly===!0&&"https:"!==e)throw new Error("paymentHost is not https");if("http:"!==e&&"https:"!==e)throw new Error("paymentHost must be http or https");if("object"!=typeof t.product||!t.product.id)throw new Error("A product id must be provided in a product object");var i=t.product.image;if(i){var n=r.getProtocol(i);if(this.httpsOnly&&"https:"!==n)throw new Error("product.image must be served over https");if("http:"!==n&&"https:"!==n)throw new Error("product.image is served over an invalid protocol")}else console.warn("A product image URL was not supplied as a property of config.product.");this.httpsOnly===!1&&console.warn("httpsOnly is set to false. Only use for dev");var s=this;return window.addEventListener("message",function(t){s.receiveMessage.call(s,t)},!1),this.product=t.product,this.amount=t.product.amount||null,this}var r=o(1);i.prototype={validIframeOrigins:["http://pay.dev:8000","http://pay.dev.mozaws.net:8000","http://pay.webpack:8080"],classPrefix:"fxa-pay",prefix:function(t){return this.classPrefix+"-"+t},receiveMessage:function(t){if(-1===this.validIframeOrigins.indexOf(t.origin))return void console.warn("Ignored message from invalid origin",t.origin);try{var e=JSON.parse(t.data)||{};"purchase-completed"===e.event?this.close():console.warn("Unhandled postMessage data received")}catch(o){throw console.error("postMessage data should be stringified JSON",t.data),o}},getStyle:function(t,e){return"undefined"!=typeof getComputedStyle?getComputedStyle(t,null).getPropertyValue(e):t.currentStyle[e]},iframeStyle:{border:"none",height:"100%",width:"100%"},closeButtonStyle:{color:"#666",fontSize:"20px",padding:"10px",position:"absolute",right:"5px",textDecoration:"none",zIndex:2020},outerStyle:{backgroundColor:"rgba(0, 0, 0, 0.5)",bottom:0,left:0,opacity:0,position:"fixed",right:0,top:0,transition:"opacity 0.3s",zIndex:2e3},getProductImageStyle:function(){var t=this;return{left:0,background:"url("+t.product.image+") no-repeat 50% 0",backgroundSize:"55px",position:"absolute",right:0,top:"-27.5px",zIndex:2015,height:"55px"}},getInnerStyle:function(){var t=this;return{backgroundColor:"#fff",border:"1px solid #C3CFD8",borderRadius:"3px",boxShadow:"0 3px 7px rgba(0, 0, 0, 0.5)",height:t.modalHeight+"px",left:"50%",marginLeft:"-"+t.modalWidth/2+"px",marginTop:"-"+t.modalHeight/2+"px",opacity:0,padding:"0",position:"absolute",top:"50%",transition:"opacity 0.3s",width:t.modalWidth+"px",zIndex:2010}},applyStyles:function(t,e){Object.keys(e).forEach(function(o){t.style[o]=e[o]})},buildModal:function(){var t=this,e=document,o=e.createElement("div");o.setAttribute("id",this.id),o.className=this.prefix("container"),o.addEventListener("click",function(e){e.preventDefault(),t.close()},!1);var i=e.createElement("div");if(i.className=this.prefix("modal"),i.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation()},!1),o.appendChild(i),this.applyStyles(o,this.outerStyle),this.product.image){var n=e.createElement("div");this.applyStyles(n,this.getProductImageStyle()),i.appendChild(n)}var s=e.createElement("a");s.href="#";var a=e.createTextNode("×");s.appendChild(a),this.applyStyles(s,this.closeButtonStyle),s.addEventListener("click",function(e){e.preventDefault(),t.close()},!1),i.appendChild(s);var l=e.createElement("iframe"),d=r.buildIframeSrc(this.paymentHost,{access_token:this.accessToken,amount:this.amount,product:this.product.id});return l.setAttribute("src",d),i.appendChild(l),this.applyStyles(l,this.iframeStyle),this.applyStyles(i,this.getInnerStyle()),o._inner=i,o},show:function(){this.modal=this.buildModal(),this.parentOverflow=this.getStyle(this.modalParent,"overflowY"),this.modalParent.style.overflowY="hidden",this.modalParent.appendChild(this.modal),this.modal.style.opacity=1,this.modal._inner.style.opacity=1},close:function(){this.modalParent.style.overflow=this.parentOverflow,this.modal.style.opacity=0,this.modal._inner.style.opacity=0;var t=this;window.setTimeout(function(){t.modal&&t.modal.parentNode&&t.modal.parentNode.removeChild(t.modal)},this.closeDelayMs)}},t.exports=i},function(t,e){"use strict";t.exports={getProtocol:function(t){var e=document.createElement("a");return e.href=t,e.protocol},serialize:function(t){var e=[];for(var o in t)t[o]&&t.hasOwnProperty(o)&&e.push(encodeURIComponent(o)+"="+encodeURIComponent(t[o]));return e.join("&")},buildIframeSrc:function(t,e){return t=/\/$/.test(t)?t:t+"/",t+"#/?"+this.serialize(e)}}}])}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):"object"==typeof exports?exports.PaymentsClient=e():t.PaymentsClient=e()}(this,function(){return function(t){function e(i){if(o[i])return o[i].exports;var r=o[i]={exports:{},id:i,loaded:!1};return t[i].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){"use strict";function i(t){t=t||{},t.product=t.product||{},this.modalParent=t.modalParent||document.body,this.id="_"+Math.random().toString(36).substr(2,9),this.modalWidth=t.modalWidth||318,this.modalHeight=t.modalHeight||468,this.closeDelayMs="number"==typeof t.closeDelayMs?t.closeDelayMs:300,this.accessToken=t.accessToken||null,this.paymentHost=t.paymentHost||"http://pay.dev:8000/",this.httpsOnly="undefined"==typeof t.httpsOnly?!0:t.httpsOnly;var e=r.getProtocol(this.paymentHost),o=t._window||window;if(this.httpsOnly===!0&&"https:"!==o.location.protocol)throw new Error("Host site should run under SSL");if(this.httpsOnly===!0&&"https:"!==e)throw new Error("paymentHost is not https");if("http:"!==e&&"https:"!==e)throw new Error("paymentHost must be http or https");if("object"!=typeof t.product||!t.product.id)throw new Error("A product id must be provided in a product object");var i=t.product.image;if(i){var n=r.getProtocol(i);if(this.httpsOnly&&"https:"!==n)throw new Error("product.image must be served over https");if("http:"!==n&&"https:"!==n)throw new Error("product.image is served over an invalid protocol")}else console.warn("A product image URL was not supplied as a property of config.product.");this.httpsOnly===!1&&console.warn("httpsOnly is set to false. Only use for dev");var s=this;return window.addEventListener("message",function(t){s.receiveMessage.call(s,t)},!1),this.product=t.product,this.amount=t.product.amount||null,this}var r=o(1);i.prototype={validIframeOrigins:["http://pay.dev:8000","http://pay.dev.mozaws.net:8000","http://pay.webpack:8080"],classPrefix:"fxa-pay",prefix:function(t){return this.classPrefix+"-"+t},receiveMessage:function(t){if(-1===this.validIframeOrigins.indexOf(t.origin))return void console.warn("Ignored message from invalid origin",t.origin);try{var e=JSON.parse(t.data)||{};"purchase-completed"===e.event?this.close():console.warn("Unhandled postMessage data received")}catch(o){throw console.error("postMessage data should be stringified JSON",t.data),o}},getStyle:function(t,e){return"undefined"!=typeof getComputedStyle?getComputedStyle(t,null).getPropertyValue(e):t.currentStyle[e]},iframeStyle:{border:"none",height:"100%",width:"100%"},closeButtonStyle:{color:"#666",fontSize:"20px",padding:"10px",position:"absolute",right:"5px",textDecoration:"none",zIndex:2020},outerStyle:{backgroundColor:"rgba(0, 0, 0, 0.5)",bottom:0,left:0,opacity:0,position:"fixed",right:0,top:0,transition:"opacity 0.3s",zIndex:2e3},getProductImageStyle:function(){var t=this;return{left:0,background:"url("+t.product.image+") no-repeat 50% 0",backgroundSize:"55px",position:"absolute",right:0,top:"-27.5px",zIndex:2015,height:"55px"}},getInnerStyle:function(){var t=this;return{backgroundColor:"#fff",border:"1px solid #C3CFD8",borderRadius:"3px",boxShadow:"0 3px 7px rgba(0, 0, 0, 0.5)",height:t.modalHeight+"px",left:"50%",marginLeft:"-"+t.modalWidth/2+"px",marginTop:"-"+t.modalHeight/2+"px",opacity:0,padding:"0",position:"absolute",top:"50%",transition:"opacity 0.3s",width:t.modalWidth+"px",zIndex:2010}},applyStyles:function(t,e){Object.keys(e).forEach(function(o){t.style[o]=e[o]})},buildModal:function(){var t=this,e=document,o=e.createElement("div");o.setAttribute("id",this.id),o.className=this.prefix("container");var i=e.createElement("div");if(i.className=this.prefix("modal"),i.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation()},!1),o.appendChild(i),this.applyStyles(o,this.outerStyle),this.product.image){var n=e.createElement("div");this.applyStyles(n,this.getProductImageStyle()),i.appendChild(n)}var s=e.createElement("a");s.href="#";var a=e.createTextNode("×");s.appendChild(a),this.applyStyles(s,this.closeButtonStyle),s.addEventListener("click",function(e){e.preventDefault(),t.close()},!1),i.appendChild(s);var l=e.createElement("iframe"),d=r.buildIframeSrc(this.paymentHost,{access_token:this.accessToken,amount:this.amount,product:this.product.id});return l.setAttribute("src",d),i.appendChild(l),this.applyStyles(l,this.iframeStyle),this.applyStyles(i,this.getInnerStyle()),o._inner=i,o},show:function(){this.modal=this.buildModal(),this.parentOverflow=this.getStyle(this.modalParent,"overflowY"),this.modalParent.style.overflowY="hidden",this.modalParent.appendChild(this.modal),this.modal.style.opacity=1,this.modal._inner.style.opacity=1},close:function(){this.modalParent.style.overflow=this.parentOverflow,this.modal.style.opacity=0,this.modal._inner.style.opacity=0;var t=this;window.setTimeout(function(){t.modal&&t.modal.parentNode&&t.modal.parentNode.removeChild(t.modal)},this.closeDelayMs)}},t.exports=i},function(t,e){"use strict";t.exports={getProtocol:function(t){var e=document.createElement("a");return e.href=t,e.protocol},serialize:function(t){var e=[];for(var o in t)t[o]&&t.hasOwnProperty(o)&&e.push(encodeURIComponent(o)+"="+encodeURIComponent(t[o]));return e.join("&")},buildIframeSrc:function(t,e){return t=/\/$/.test(t)?t:t+"/",t+"#/?"+this.serialize(e)}}}])}); //# sourceMappingURL=payments-client.js.map \ No newline at end of file