diff --git a/.gitignore b/.gitignore index 2ccbe46..7bec9be 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /node_modules/ +yarn.lock +package-lock.json diff --git a/Gruntfile.js b/Gruntfile.js index a00c27b..13ac5e5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,7 +9,7 @@ module.exports = function(grunt) { banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>' + '\n * <%= pkg.description %>' + '<%= pkg.homepage ? "\\n * " + pkg.homepage : "" %>' + - '\n * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>' + + '\n * Licensed <%= _.map(pkg.licenses, "type").join(", ") %>' + '\n */\n', // Task configuration. concat: { @@ -60,7 +60,7 @@ module.exports = function(grunt) { } }, jasmine : { - src : 'lib/*.js', + src : 'lib/*.js', options: { specs: 'specs/*spec.js', helpers: 'specs/*helper.js' diff --git a/dist/rxp-js.js b/dist/rxp-js.js index 93bd803..f45d2ac 100644 --- a/dist/rxp-js.js +++ b/dist/rxp-js.js @@ -1,4 +1,4 @@ -/*! rxp-js - v1.2.1 +/*! rxp-js - v1.2.1 - 2017-10-03 * The official Realex Payments JS SDK * https://github.com/realexpayments/rxp-js * Licensed MIT @@ -6,38 +6,46 @@ var RealexHpp = (function() { 'use strict'; - + var hppUrl = "https://pay.realexpayments.com/pay"; - + var randomId = randomId || Math.random().toString(16).substr(2,8); var setHppUrl = function(url) { hppUrl = url; }; - + var isWindowsMobileOs = /Windows Phone|IEMobile/.test(navigator.userAgent); var isAndroidOrIOs = /Android|iPad|iPhone|iPod/.test(navigator.userAgent); var isMobileXS = ( (((window.innerWidth > 0) ? window.innerWidth : screen.width) <= 360 ? true : false) || (((window.innerHeight > 0) ? window.innerHeight : screen.Height) <= 360 ? true : false)) ; - - // Display IFrame on WIndows Phone OS mobile devices + + // Display IFrame on WIndows Phone OS mobile devices var isMobileIFrame = isWindowsMobileOs; - + // For IOs/Android and small screen devices always open in new tab/window var isMobileNewTab = !isWindowsMobileOs && (isAndroidOrIOs || isMobileXS); var tabWindow; - + + function createFormHiddenInput(name, value) { + var el = document.createElement("input"); + el.setAttribute("type", "hidden"); + el.setAttribute("name", name); + el.setAttribute("value", value); + return el; + } + // Initialising some variables used throughout this file. var RxpLightbox = (function() { var instance; - + function init() { var overlayElement; var spinner; var iFrame; var closeButton; var token; - + function checkDevicesOrientation(){ if(window.orientation === 90 || window.orientation === -90){ return true; @@ -45,9 +53,9 @@ var RealexHpp = (function() { return false; } } - + var isLandscape = checkDevicesOrientation(); - + if(isMobileIFrame){ if(window.addEventListener){ window.addEventListener("orientationchange", function() { @@ -55,7 +63,7 @@ var RealexHpp = (function() { }, false); } } - + // Initialising some variables used throughout this function. function createOverlay() { var overlay = document.createElement("div"); @@ -66,15 +74,15 @@ var RealexHpp = (function() { overlay.style.top="0"; overlay.style.left="0"; overlay.style.transition="all 0.3s ease-in-out"; - overlay.style.zIndex="100"; - + overlay.style.zIndex="100"; + if(isMobileIFrame){ overlay.style.position="absolute !important"; overlay.style.WebkitOverflowScrolling = "touch"; overlay.style.overflowX = "hidden"; overlay.style.overflowY = "scroll"; } - + document.body.appendChild(overlay); setTimeout(function() { @@ -84,18 +92,40 @@ var RealexHpp = (function() { overlayElement = overlay; } - + function closeModal() { + + if (closeButton.parentNode) { + closeButton.parentNode.removeChild(closeButton); + } + + if (iFrame.parentNode) { + iFrame.parentNode.removeChild(iFrame); + } + + if (spinner.parentNode) { + spinner.parentNode.removeChild(spinner); + } + + overlayElement.className = ""; + setTimeout(function() { + if (overlayElement.parentNode) { + overlayElement.parentNode.removeChild(overlayElement); + } + }, 300); + } + + function createCloseButton(){ if(document.getElementById("rxp-frame-close-" + randomId) === null) { closeButton = document.createElement("img"); closeButton.setAttribute("id","rxp-frame-close-" + randomId); closeButton.setAttribute("src", "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQB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6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PlHco5QAAAHpSURBVHjafFRdTsJAEF42JaTKn4glGIg++qgX4AAchHAJkiZcwnAQD8AF4NFHCaC2VgWkIQQsfl/jNJUik8Duzs/XmW9mN7Xb7VRc5vP5zWKxaK5Wq8Zmu72FqobfJG0YQ9M0+/l8/qFQKDzGY1JxENd1288vLy1s786KRZXJZCLber1Wn7MZt4PLarVnWdZ9AmQ8Hncc17UvymVdBMB/MgPQm+cFFcuy6/V6lzqDf57ntWGwYdBIVx0TfkBD6I9M35iRJgfIoAVjBLDZbA4CiJ5+9AdQi/EahibqDTkQx6fRSIHcPwA8Uy9A9Gcc47Xv+w2wzhRDYzqdVihLIbsIiCvP1NNOoX/29FQx3vgOgtt4FyRdCgPRarX4+goB9vkyAMh443cOEsIAAcjncuoI4TXWMAmCIGFhCQLAdZ8jym/cRJ+Y5nC5XCYAhINKpZLgSISZgoqh5iiLQrojAFICVwGS7tCfe5DbZzkP56XS4NVxwvTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="); closeButton.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 173px; z-index: 99999999; top: 30px;"); - + setTimeout(function(){ closeButton.style.opacity = "1"; },500); - + if(isMobileIFrame){ closeButton.style.position = "absolute"; closeButton.style.float = "right"; @@ -104,7 +134,7 @@ var RealexHpp = (function() { closeButton.style.marginLeft = "0px"; closeButton.style.right = "20px"; } - + closeButton.addEventListener("click", closeModal, true); overlayElement.appendChild(closeButton); } @@ -116,35 +146,20 @@ var RealexHpp = (function() { form.setAttribute("action", hppUrl); for ( var key in token) { - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("type", "hidden"); - hiddenField.setAttribute("name", key); - hiddenField.setAttribute("value", token[key]); - - form.appendChild(hiddenField); + form.appendChild(createFormHiddenInput(key, token[key])); } - var hppTemplateType = document.createElement("input"); - hppTemplateType.setAttribute("type", "hidden"); - hppTemplateType.setAttribute("name", "HPP_TEMPLATE_TYPE"); - hppTemplateType.setAttribute("value", "LIGHTBOX"); - - form.appendChild(hppTemplateType); + form.appendChild(createFormHiddenInput("HPP_VERSION", "2")); var parser = document.createElement('a'); parser.href = window.location.href; var hppOriginParam = parser.protocol + '//' + parser.host; - var hppOrigin = document.createElement("input"); - hppOrigin.setAttribute("type", "hidden"); - hppOrigin.setAttribute("name", "HPP_ORIGIN"); - hppOrigin.setAttribute("value", hppOriginParam); - - form.appendChild(hppOrigin); + form.appendChild(createFormHiddenInput("HPP_POST_RESPONSE", hppOriginParam)); + form.appendChild(createFormHiddenInput("HPP_POST_DIMENSIONS", hppOriginParam)); return form; } - + function createIFrame() { //Create the spinner @@ -160,7 +175,7 @@ var RealexHpp = (function() { spinner.style.zIndex="200"; spinner.style.marginLeft="-15px"; spinner.style.top="120px"; - + document.body.appendChild(spinner); //Create the iframe @@ -171,15 +186,19 @@ var RealexHpp = (function() { iFrame.setAttribute("frameBorder", "0"); iFrame.setAttribute("width", "360px"); iFrame.setAttribute("seamless", "seamless"); - + + if (!isMobileIFrame) { + iFrame.setAttribute("scrolling", "no"); + } + iFrame.style.zIndex="10001"; iFrame.style.position="absolute"; iFrame.style.transition="transform 0.5s ease-in-out"; iFrame.style.transform="scale(0.7)"; iFrame.style.opacity="0"; - + overlayElement.appendChild(iFrame); - + if(isMobileIFrame){ iFrame.style.top = "0px"; iFrame.style.bottom = "0px"; @@ -199,11 +218,12 @@ var RealexHpp = (function() { iFrame.style.left="50%"; iFrame.style.marginLeft="-180px"; } - + iFrame.onload = function() { iFrame.style.opacity="1"; iFrame.style.transform="scale(1)"; - + iFrame.style.backgroundColor = "#ffffff"; + if (spinner.parentNode) { spinner.parentNode.removeChild(spinner); } @@ -216,16 +236,16 @@ var RealexHpp = (function() { } else { iFrame.contentWindow.document.appendChild(form); } - + form.submit(); } - + function openWindow() { //open new window tabWindow = window.open(); var doc = tabWindow.document; - + //add meta tag to new window (needed for iOS 8 bug) var meta = doc.createElement("meta"); var name = doc.createAttribute("name"); @@ -235,38 +255,16 @@ var RealexHpp = (function() { content.value="width=device-width"; meta.setAttributeNode(content); doc.head.appendChild(meta); - + //create form, append to new window and submit var form = createForm(doc); doc.body.appendChild(form); form.submit(); } - function closeModal() { - - if (closeButton.parentNode) { - closeButton.parentNode.removeChild(closeButton); - } - - if (iFrame.parentNode) { - iFrame.parentNode.removeChild(iFrame); - } - - if (spinner.parentNode) { - spinner.parentNode.removeChild(spinner); - } - - overlayElement.className = ""; - setTimeout(function() { - if (overlayElement.parentNode) { - overlayElement.parentNode.removeChild(overlayElement); - } - }, 300); - } - return { lightbox : function() { - + if(isMobileNewTab){ openWindow(); } else { @@ -282,27 +280,27 @@ var RealexHpp = (function() { } }; } - + return { // Get the Singleton instance if one exists // or create one if it doesn't getInstance: function (hppToken) { - + if ( !instance ) { instance = init(); } - + //Set the hpp token instance.setToken(hppToken); - + return instance; } }; - + })(); - - var init = function(idOfLightboxButton, merchantUrl, serverSdkJson) { + + var lightboxInit = function(idOfLightboxButton, merchantUrl, serverSdkJson) { //Get the lightbox instance (it's a singleton) and set the sdk json var lightboxInstance = RxpLightbox.getInstance(serverSdkJson); @@ -313,18 +311,24 @@ var RealexHpp = (function() { } else { document.getElementById(idOfLightboxButton).attachEvent('onclick', lightboxInstance.lightbox); } - + + function getHostnameFromUrl(url) { + var parser = document.createElement('a'); + parser.href = url; + return parser.hostname; + } + function receiveMessage(event) { - + //Check the origin of the response comes from HPP if (getHostnameFromUrl(event.origin) === getHostnameFromUrl(hppUrl)) { - - // check for iframe resize values + + // check for iframe resize values if (event.data && JSON.parse(event.data).iframe) { if(!isMobileNewTab){ var iframeWidth = JSON.parse(event.data).iframe.width; var iframeHeight = JSON.parse(event.data).iframe.height; - + var iFrame = document.getElementById("rxp-frame-" + randomId); iFrame.setAttribute("width", iframeWidth); iFrame.setAttribute("height", iframeHeight); @@ -338,7 +342,7 @@ var RealexHpp = (function() { iFrame.style.overflowY = "scroll"; overlay.style.overflowX = "scroll"; overlay.style.overflowY = "scroll"; - + }else{ iFrame.style.marginLeft = (parseInt(iframeWidth.replace("px", ""), 10)/2 * -1 ) + "px"; } @@ -346,60 +350,53 @@ var RealexHpp = (function() { var closeButton = document.getElementById("rxp-frame-close-" + randomId); closeButton.style.marginLeft = ((parseInt(iframeWidth.replace("px", ""), 10)/2) -7) + "px"; } - + } else { - + if(isMobileNewTab){ //Close the new window if(tabWindow){ - tabWindow.close(); + tabWindow.close(); } } else { //Close the lightbox lightboxInstance.close(); } - + var response = event.data; - + //Create a form and submit the hpp response to the merchant's response url var form = document.createElement("form"); form.setAttribute("method", "POST"); form.setAttribute("action", merchantUrl); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("type", "hidden"); - hiddenField.setAttribute("name", "hppResponse"); - hiddenField.setAttribute("value", response); - - form.appendChild(hiddenField); - + + form.appendChild(createFormHiddenInput("hppResponse", response)); + document.body.appendChild(form); - + form.submit(); } } } - + if (window.addEventListener) { window.addEventListener("message", receiveMessage, false); } else { window.attachEvent('message', receiveMessage); } - + }; - - function getHostnameFromUrl(url) { - var parser = document.createElement('a'); - parser.href = url; - return parser.hostname; - } return { - init : init, + init : lightboxInit, + lightbox: { + init: lightboxInit + }, setHppUrl : setHppUrl }; }()); + var RealexRemote = (function() { 'use strict'; diff --git a/dist/rxp-js.min.js b/dist/rxp-js.min.js index daef223..368e9b2 100644 --- a/dist/rxp-js.min.js +++ b/dist/rxp-js.min.js @@ -1,6 +1,7 @@ -/*! rxp-js - v1.2.1 +/*! rxp-js - v1.2.1 - 2017-10-03 * The official Realex Payments JS SDK * https://github.com/realexpayments/rxp-js * Licensed MIT */ -var RealexHpp=function(){"use strict";function a(a){var b=document.createElement("a");return b.href=a,b.hostname}var b,c="https://pay.realexpayments.com/pay",d=d||Math.random().toString(16).substr(2,8),e=function(a){c=a},f=/Windows Phone|IEMobile/.test(navigator.userAgent),g=/Android|iPad|iPhone|iPod/.test(navigator.userAgent),h=!(((window.innerWidth>0?window.innerWidth:screen.width)<=360?0:1)&&((window.innerHeight>0?window.innerHeight:screen.Height)<=360?0:1)),i=f,j=!f&&(g||h),k=function(){function a(){function a(){return 90===window.orientation||-90===window.orientation?!0:!1}function e(){var a=document.createElement("div");a.setAttribute("id","rxp-overlay-"+d),a.style.position="fixed",a.style.width="100%",a.style.height="100%",a.style.top="0",a.style.left="0",a.style.transition="all 0.3s ease-in-out",a.style.zIndex="100",i&&(a.style.position="absolute !important",a.style.WebkitOverflowScrolling="touch",a.style.overflowX="hidden",a.style.overflowY="scroll"),document.body.appendChild(a),setTimeout(function(){a.style.background="rgba(0, 0, 0, 0.7)"},1),m=a}function f(){null===document.getElementById("rxp-frame-close-"+d)&&(p=document.createElement("img"),p.setAttribute("id","rxp-frame-close-"+d),p.setAttribute("src","data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJv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OoX/29FQx3vgOgtt4FyRdCgPRarX4+goB9vkyAMh443cOEsIAAcjncuoI4TXWMAmCIGFhCQLAdZ8jym/cRJ+Y5nC5XCYAhINKpZLgSISZgoqh5iiLQrojAFICVwGS7tCfe5DbZzkP56XS4NVxwvTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="),p.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 173px; z-index: 99999999; top: 30px;"),setTimeout(function(){p.style.opacity="1"},500),i&&(p.style.position="absolute",p.style["float"]="right",p.style.top="20px",p.style.left="initial",p.style.marginLeft="0px",p.style.right="20px"),p.addEventListener("click",l,!0),m.appendChild(p))}function g(a){var b=document.createElement("form");b.setAttribute("method","POST"),b.setAttribute("action",c);for(var d in q){var e=document.createElement("input");e.setAttribute("type","hidden"),e.setAttribute("name",d),e.setAttribute("value",q[d]),b.appendChild(e)}var f=document.createElement("input");f.setAttribute("type","hidden"),f.setAttribute("name","HPP_TEMPLATE_TYPE"),f.setAttribute("value","LIGHTBOX"),b.appendChild(f);var g=document.createElement("a");g.href=window.location.href;var h=g.protocol+"//"+g.host,i=document.createElement("input");return i.setAttribute("type","hidden"),i.setAttribute("name","HPP_ORIGIN"),i.setAttribute("value",h),b.appendChild(i),b}function h(){if(n=document.createElement("img"),n.setAttribute("src","data:image/gif;base64,R0lGODlhHAAcAPYAAP////OQHv338fzw4frfwPjIkPzx4/nVq/jKlfe7dv337/vo0fvn0Pzy5/WrVv38+vjDhva2bfzq1fe/f/vkyve8d/WoT/nRpP327ve9e/zs2vrWrPWqVPWtWfvmzve5cvazZvrdvPjKlPfAgPnOnPvp0/zx5fawYfe+ff317PnTp/nMmfvgwvfBgv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QS6oEPgxpOGMXPQOPdjCMFESCgcZHdFiYUROQ0dChCgRkRCFOg4cRMCCiIcGAjhCUDgq6AiHDhWyxShAhJACKFweJJHAAgoFQ1dfrAwQlKRMhAwpfnCZMkXEihqCHmAwUIXRkAgRoLiQgsIHABsrVDRl1OPMDQAPZIzAAcAEjRVzOT2gI+XTjREMBF0RUZMThhyyAGyYYGCQhtaoCJVQMjk3ISQafAtHFAgAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iGD4mMh1UCjYkNXlWDSQKVgo+Rgkl3HZkCSEmdMwqcgnNOWoI8SDwAD0VFSKgAP05ONgACPLApKUUujAsesABIek46CkmuAjNFp4IPPIuEQ3p2dDgAJBEmhdAuLikDGljDhTY6OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+EaVUmSJJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"),n.setAttribute("id","rxp-loader-"+d),n.style.left="50%",n.style.position="fixed",n.style.background="#FFFFFF",n.style.borderRadius="50%",n.style.width="30px",n.style.marginLeft="-15px",n.style.zIndex="200",n.style.marginLeft="-15px",n.style.top="120px",document.body.appendChild(n),o=document.createElement("iframe"),o.setAttribute("name","rxp-frame-"+d),o.setAttribute("id","rxp-frame-"+d),o.setAttribute("height","85%"),o.setAttribute("frameBorder","0"),o.setAttribute("width","360px"),o.setAttribute("seamless","seamless"),o.style.zIndex="10001",o.style.position="absolute",o.style.transition="transform 0.5s ease-in-out",o.style.transform="scale(0.7)",o.style.opacity="0",m.appendChild(o),i){o.style.top="0px",o.style.bottom="0px",o.style.left="0px",o.style.marginLeft="0px;",o.style.width="100%",o.style.height="100%",o.style.minHeight="100%",o.style.WebkitTransform="translate3d(0,0,0)",o.style.transform="translate3d(0, 0, 0)";var a=document.createElement("meta");a.name="viewport",a.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0",document.getElementsByTagName("head")[0].appendChild(a)}else o.style.top="40px",o.style.left="50%",o.style.marginLeft="-180px";o.onload=function(){o.style.opacity="1",o.style.transform="scale(1)",n.parentNode&&n.parentNode.removeChild(n),f()};var b=g(document);o.contentWindow.document.body?o.contentWindow.document.body.appendChild(b):o.contentWindow.document.appendChild(b),b.submit()}function k(){b=window.open();var a=b.document,c=a.createElement("meta"),d=a.createAttribute("name");d.value="viewport",c.setAttributeNode(d);var e=a.createAttribute("content");e.value="width=device-width",c.setAttributeNode(e),a.head.appendChild(c);var f=g(a);a.body.appendChild(f),f.submit()}function l(){p.parentNode&&p.parentNode.removeChild(p),o.parentNode&&o.parentNode.removeChild(o),n.parentNode&&n.parentNode.removeChild(n),m.className="",setTimeout(function(){m.parentNode&&m.parentNode.removeChild(m)},300)}var m,n,o,p,q,r=a();return i&&window.addEventListener&&window.addEventListener("orientationchange",function(){r=a()},!1),{lightbox:function(){j?k():(e(),h())},close:function(){l()},setToken:function(a){q=a}}}var e;return{getInstance:function(b){return e||(e=a()),e.setToken(b),e}}}(),l=function(e,f,g){function h(e){if(a(e.origin)===a(c))if(e.data&&JSON.parse(e.data).iframe){if(!j){var g=JSON.parse(e.data).iframe.width,h=JSON.parse(e.data).iframe.height,k=document.getElementById("rxp-frame-"+d);if(k.setAttribute("width",g),k.setAttribute("height",h),k.style.backgroundColor="#ffffff",i){var m=document.getElementById("rxp-overlay-"+d);k.style.marginLeft="0px",k.style.WebkitOverflowScrolling="touch",k.style.overflowX="scroll",k.style.overflowY="scroll",m.style.overflowX="scroll",m.style.overflowY="scroll"}else k.style.marginLeft=parseInt(g.replace("px",""),10)/2*-1+"px";var n=document.getElementById("rxp-frame-close-"+d);n.style.marginLeft=parseInt(g.replace("px",""),10)/2-7+"px"}}else{j?b&&b.close():l.close();var o=e.data,p=document.createElement("form");p.setAttribute("method","POST"),p.setAttribute("action",f);var q=document.createElement("input");q.setAttribute("type","hidden"),q.setAttribute("name","hppResponse"),q.setAttribute("value",o),p.appendChild(q),document.body.appendChild(p),p.submit()}}var l=k.getInstance(g);document.getElementById(e).addEventListener?document.getElementById(e).addEventListener("click",l.lightbox,!0):document.getElementById(e).attachEvent("onclick",l.lightbox),window.addEventListener?window.addEventListener("message",h,!1):window.attachEvent("message",h)};return{init:l,setHppUrl:e}}(),RealexRemote=function(){"use strict";var a=function(a){if(!/^\d{12,19}$/.test(a))return!1;for(var b=0,c=0,d=0,e=!1,f=a.length-1;f>=0;f--)c=parseInt(a.substring(f,f+1),10),e?(d=2*c,d>9&&(d-=9)):d=c,b+=d,e=!e;var g=b%10;return 0!==g?!1:!0},b=function(a){return a&&a.trim()&&/^[\u0020-\u007E\u00A0-\u00FF]{1,100}$/.test(a)?!0:!1},c=function(a){return/^\d{3}$/.test(a)?!0:!1},d=function(a){return/^\d{4}$/.test(a)?!0:!1},e=function(a){if(!/^\d{4}$/.test(a))return!1;var b=parseInt(a.substring(0,2),10);parseInt(a.substring(2,4),10);return 1>b||b>12?!1:!0},f=function(a){if(!e(a))return!1;var b=parseInt(a.substring(0,2),10),c=parseInt(a.substring(2,4),10),d=new Date,f=d.getMonth()+1,g=d.getFullYear();return g%100>c?!1:c===g%100&&f>b?!1:!0};return{validateCardNumber:a,validateCardHolderName:b,validateCvn:c,validateAmexCvn:d,validateExpiryDateFormat:e,validateExpiryDateNotInPast:f}}(); \ No newline at end of file + +var RealexHpp=function(){"use strict";function A(A,e){var t=document.createElement("input");return t.setAttribute("type","hidden"),t.setAttribute("name",A),t.setAttribute("value",e),t}var e,t="https://pay.realexpayments.com/pay",i=i||Math.random().toString(16).substr(2,8),o=/Windows Phone|IEMobile/.test(navigator.userAgent),n=/Android|iPad|iPhone|iPod/.test(navigator.userAgent),a=(window.innerWidth>0?window.innerWidth:screen.width)<=360||(window.innerHeight>0?window.innerHeight:screen.Height)<=360,r=o,g=!o&&(n||a),l=function(){function o(){function o(){return 90===window.orientation||-90===window.orientation}function n(){var A=document.createElement("div");A.setAttribute("id","rxp-overlay-"+i),A.style.position="fixed",A.style.width="100%",A.style.height="100%",A.style.top="0",A.style.left="0",A.style.transition="all 0.3s ease-in-out",A.style.zIndex="100",r&&(A.style.position="absolute !important",A.style.WebkitOverflowScrolling="touch",A.style.overflowX="hidden",A.style.overflowY="scroll"),document.body.appendChild(A),setTimeout(function(){A.style.background="rgba(0, 0, 0, 0.7)"},1),C=A}function a(){h.parentNode&&h.parentNode.removeChild(h),c.parentNode&&c.parentNode.removeChild(c),E.parentNode&&E.parentNode.removeChild(E),C.className="",setTimeout(function(){C.parentNode&&C.parentNode.removeChild(C)},300)}function l(){null===document.getElementById("rxp-frame-close-"+i)&&((h=document.createElement("img")).setAttribute("id","rxp-frame-close-"+i),h.setAttribute("src","data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY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vP1NNOoX/29FQx3vgOgtt4FyRdCgPRarX4+goB9vkyAMh443cOEsIAAcjncuoI4TXWMAmCIGFhCQLAdZ8jym/cRJ+Y5nC5XCYAhINKpZLgSISZgoqh5iiLQrojAFICVwGS7tCfe5DbZzkP56XS4NVxwvTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="),h.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 173px; z-index: 99999999; top: 30px;"),setTimeout(function(){h.style.opacity="1"},500),r&&(h.style.position="absolute",h.style.float="right",h.style.top="20px",h.style.left="initial",h.style.marginLeft="0px",h.style.right="20px"),h.addEventListener("click",a,!0),C.appendChild(h))}function s(e){var i=document.createElement("form");i.setAttribute("method","POST"),i.setAttribute("action",t);for(var o in Q)i.appendChild(A(o,Q[o]));i.appendChild(A("HPP_VERSION","2"));var n=document.createElement("a");n.href=window.location.href;var a=n.protocol+"//"+n.host;return i.appendChild(A("HPP_POST_RESPONSE",a)),i.appendChild(A("HPP_POST_DIMENSIONS",a)),i}function d(){if((E=document.createElement("img")).setAttribute("src","data:image/gif;base64,R0lGODlhHAAcAPYAAP////OQHv338fzw4frfwPjIkPzx4/nVq/jKlfe7dv337/vo0fvn0Pzy5/WrVv38+vjDhva2bfzq1fe/f/vkyve8d/WoT/nRpP327ve9e/zs2vrWrPWqVPWtWfvmzve5cvazZvrdvPjKlPfAgPnOnPvp0/zx5fawYfe+ff317PnTp/nMmfvgwvfBgv39/PrXsPSeO/vjx/jJkvzz6PnNm/vkyfnUqfjLl/revvnQoPSfPfSgP/348/nPnvratfrYsvWlSvSbNPrZs/vhw/zv4P306vrXrvzq1/359f369vjHjvSjRvOXLfORIfOQHvjD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mAwUIXRkAgRoLiQgsIHABsrVDRl1OPMDQAPZIzAAcAEjRVzOT2gI+XTjREMBF0RUZMThhyyAGyYYGCQhtaoCJVQMjk3ISQafAtHFAgAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iGD4mMh1UCjYkNXlWDSQKVgo+Rgkl3HZkCSEmdMwqcgnNOWoI8SDwAD0VFSKgAP05ONgACPLApKUUujAsesABIek46CkmuAjNFp4IPPIuEQ3p2dDgAJBEmhdAuLikDGljDhTY6OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+EaVUmSJJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"),E.setAttribute("id","rxp-loader-"+i),E.style.left="50%",E.style.position="fixed",E.style.background="#FFFFFF",E.style.borderRadius="50%",E.style.width="30px",E.style.marginLeft="-15px",E.style.zIndex="200",E.style.marginLeft="-15px",E.style.top="120px",document.body.appendChild(E),(c=document.createElement("iframe")).setAttribute("name","rxp-frame-"+i),c.setAttribute("id","rxp-frame-"+i),c.setAttribute("height","85%"),c.setAttribute("frameBorder","0"),c.setAttribute("width","360px"),c.setAttribute("seamless","seamless"),r||c.setAttribute("scrolling","no"),c.style.zIndex="10001",c.style.position="absolute",c.style.transition="transform 0.5s ease-in-out",c.style.transform="scale(0.7)",c.style.opacity="0",C.appendChild(c),r){c.style.top="0px",c.style.bottom="0px",c.style.left="0px",c.style.marginLeft="0px;",c.style.width="100%",c.style.height="100%",c.style.minHeight="100%",c.style.WebkitTransform="translate3d(0,0,0)",c.style.transform="translate3d(0, 0, 0)";var A=document.createElement("meta");A.name="viewport",A.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0",document.getElementsByTagName("head")[0].appendChild(A)}else c.style.top="40px",c.style.left="50%",c.style.marginLeft="-180px";c.onload=function(){c.style.opacity="1",c.style.transform="scale(1)",c.style.backgroundColor="#ffffff",E.parentNode&&E.parentNode.removeChild(E),l()};var e=s(document);c.contentWindow.document.body?c.contentWindow.document.body.appendChild(e):c.contentWindow.document.appendChild(e),e.submit()}function I(){var A=(e=window.open()).document,t=A.createElement("meta"),i=A.createAttribute("name");i.value="viewport",t.setAttributeNode(i);var o=A.createAttribute("content");o.value="width=device-width",t.setAttributeNode(o),A.head.appendChild(t);var n=s(A);A.body.appendChild(n),n.submit()}var C,E,c,h,Q,w=o();return r&&window.addEventListener&&window.addEventListener("orientationchange",function(){w=o()},!1),{lightbox:function(){g?I():(n(),d())},close:function(){a()},setToken:function(A){Q=A}}}var n;return{getInstance:function(A){return n||(n=o()),n.setToken(A),n}}}(),s=function(o,n,a){function s(A){var e=document.createElement("a");return e.href=A,e.hostname}function d(o){if(s(o.origin)===s(t))if(o.data&&JSON.parse(o.data).iframe){if(!g){var a=JSON.parse(o.data).iframe.width,l=JSON.parse(o.data).iframe.height,d=document.getElementById("rxp-frame-"+i);if(d.setAttribute("width",a),d.setAttribute("height",l),d.style.backgroundColor="#ffffff",r){var C=document.getElementById("rxp-overlay-"+i);d.style.marginLeft="0px",d.style.WebkitOverflowScrolling="touch",d.style.overflowX="scroll",d.style.overflowY="scroll",C.style.overflowX="scroll",C.style.overflowY="scroll"}else d.style.marginLeft=parseInt(a.replace("px",""),10)/2*-1+"px";document.getElementById("rxp-frame-close-"+i).style.marginLeft=parseInt(a.replace("px",""),10)/2-7+"px"}}else{g?e&&e.close():I.close();var E=o.data,c=document.createElement("form");c.setAttribute("method","POST"),c.setAttribute("action",n),c.appendChild(A("hppResponse",E)),document.body.appendChild(c),c.submit()}}var I=l.getInstance(a);document.getElementById(o).addEventListener?document.getElementById(o).addEventListener("click",I.lightbox,!0):document.getElementById(o).attachEvent("onclick",I.lightbox),window.addEventListener?window.addEventListener("message",d,!1):window.attachEvent("message",d)};return{init:s,lightbox:{init:s},setHppUrl:function(A){t=A}}}(),RealexRemote=function(){"use strict";var A=function(A){if(!/^\d{4}$/.test(A))return!1;var e=parseInt(A.substring(0,2),10);parseInt(A.substring(2,4),10);return!(e<1||e>12)};return{validateCardNumber:function(A){if(!/^\d{12,19}$/.test(A))return!1;for(var e=0,t=0,i=0,o=!1,n=A.length-1;n>=0;n--)t=parseInt(A.substring(n,n+1),10),o?(i=2*t)>9&&(i-=9):i=t,e+=i,o=!o;return 0==e%10},validateCardHolderName:function(A){return!!A&&!!A.trim()&&!!/^[\u0020-\u007E\u00A0-\u00FF]{1,100}$/.test(A)},validateCvn:function(A){return!!/^\d{3}$/.test(A)},validateAmexCvn:function(A){return!!/^\d{4}$/.test(A)},validateExpiryDateFormat:A,validateExpiryDateNotInPast:function(e){if(!A(e))return!1;var t=parseInt(e.substring(0,2),10),i=parseInt(e.substring(2,4),10),o=new Date,n=o.getMonth()+1,a=o.getFullYear();return!(i + + + HPP Lightbox Demo + + + + + + + + + \ No newline at end of file diff --git a/examples/hpp/proxy-request.php b/examples/hpp/proxy-request.php new file mode 100644 index 0000000..aaa4b35 --- /dev/null +++ b/examples/hpp/proxy-request.php @@ -0,0 +1,11 @@ + $value) { + $response[$key] = base64_decode($value); +} + +echo json_encode($response); diff --git a/lib/rxp-hpp.js b/lib/rxp-hpp.js index e8dd7b6..afac58f 100644 --- a/lib/rxp-hpp.js +++ b/lib/rxp-hpp.js @@ -2,38 +2,46 @@ var RealexHpp = (function() { 'use strict'; - + var hppUrl = "https://pay.realexpayments.com/pay"; - + var randomId = randomId || Math.random().toString(16).substr(2,8); var setHppUrl = function(url) { hppUrl = url; }; - + var isWindowsMobileOs = /Windows Phone|IEMobile/.test(navigator.userAgent); var isAndroidOrIOs = /Android|iPad|iPhone|iPod/.test(navigator.userAgent); var isMobileXS = ( (((window.innerWidth > 0) ? window.innerWidth : screen.width) <= 360 ? true : false) || (((window.innerHeight > 0) ? window.innerHeight : screen.Height) <= 360 ? true : false)) ; - - // Display IFrame on WIndows Phone OS mobile devices + + // Display IFrame on WIndows Phone OS mobile devices var isMobileIFrame = isWindowsMobileOs; - + // For IOs/Android and small screen devices always open in new tab/window var isMobileNewTab = !isWindowsMobileOs && (isAndroidOrIOs || isMobileXS); var tabWindow; - + + function createFormHiddenInput(name, value) { + var el = document.createElement("input"); + el.setAttribute("type", "hidden"); + el.setAttribute("name", name); + el.setAttribute("value", value); + return el; + } + // Initialising some variables used throughout this file. var RxpLightbox = (function() { var instance; - + function init() { var overlayElement; var spinner; var iFrame; var closeButton; var token; - + function checkDevicesOrientation(){ if(window.orientation === 90 || window.orientation === -90){ return true; @@ -41,9 +49,9 @@ var RealexHpp = (function() { return false; } } - + var isLandscape = checkDevicesOrientation(); - + if(isMobileIFrame){ if(window.addEventListener){ window.addEventListener("orientationchange", function() { @@ -51,7 +59,7 @@ var RealexHpp = (function() { }, false); } } - + // Initialising some variables used throughout this function. function createOverlay() { var overlay = document.createElement("div"); @@ -62,15 +70,15 @@ var RealexHpp = (function() { overlay.style.top="0"; overlay.style.left="0"; overlay.style.transition="all 0.3s ease-in-out"; - overlay.style.zIndex="100"; - + overlay.style.zIndex="100"; + if(isMobileIFrame){ overlay.style.position="absolute !important"; overlay.style.WebkitOverflowScrolling = "touch"; overlay.style.overflowX = "hidden"; overlay.style.overflowY = "scroll"; } - + document.body.appendChild(overlay); setTimeout(function() { @@ -80,18 +88,40 @@ var RealexHpp = (function() { overlayElement = overlay; } - + function closeModal() { + + if (closeButton.parentNode) { + closeButton.parentNode.removeChild(closeButton); + } + + if (iFrame.parentNode) { + iFrame.parentNode.removeChild(iFrame); + } + + if (spinner.parentNode) { + spinner.parentNode.removeChild(spinner); + } + + overlayElement.className = ""; + setTimeout(function() { + if (overlayElement.parentNode) { + overlayElement.parentNode.removeChild(overlayElement); + } + }, 300); + } + + function createCloseButton(){ if(document.getElementById("rxp-frame-close-" + randomId) === null) { closeButton = document.createElement("img"); closeButton.setAttribute("id","rxp-frame-close-" + randomId); closeButton.setAttribute("src", "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QUJFRjU1MEIzMUQ3MTFFNThGQjNERjg2NEZCRjFDOTUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QUJFRjU1MEMzMUQ3MTFFNThGQjNERjg2NEZCRjFDOTUiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBQkVGNTUwOTMxRDcxMUU1OEZCM0RGODY0RkJGMUM5NSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBQkVGNTUwQTMxRDcxMUU1OEZCM0RGODY0RkJGMUM5NSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PlHco5QAAAHpSURBVHjafFRdTsJAEF42JaTKn4glGIg++qgX4AAchHAJkiZcwnAQD8AF4NFHCaC2VgWkIQQsfl/jNJUik8Duzs/XmW9mN7Xb7VRc5vP5zWKxaK5Wq8Zmu72FqobfJG0YQ9M0+/l8/qFQKDzGY1JxENd1288vLy1s786KRZXJZCLber1Wn7MZt4PLarVnWdZ9AmQ8Hncc17UvymVdBMB/MgPQm+cFFcuy6/V6lzqDf57ntWGwYdBIVx0TfkBD6I9M35iRJgfIoAVjBLDZbA4CiJ5+9AdQi/EahibqDTkQx6fRSIHcPwA8Uy9A9Gcc47Xv+w2wzhRDYzqdVihLIbsIiCvP1NNOoX/29FQx3vgOgtt4FyRdCgPRarX4+goB9vkyAMh443cOEsIAAcjncuoI4TXWMAmCIGFhCQLAdZ8jym/cRJ+Y5nC5XCYAhINKpZLgSISZgoqh5iiLQrojAFICVwGS7tCfe5DbZzkP56XS4NVxwvTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="); closeButton.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 173px; z-index: 99999999; top: 30px;"); - + setTimeout(function(){ closeButton.style.opacity = "1"; },500); - + if(isMobileIFrame){ closeButton.style.position = "absolute"; closeButton.style.float = "right"; @@ -100,7 +130,7 @@ var RealexHpp = (function() { closeButton.style.marginLeft = "0px"; closeButton.style.right = "20px"; } - + closeButton.addEventListener("click", closeModal, true); overlayElement.appendChild(closeButton); } @@ -112,35 +142,20 @@ var RealexHpp = (function() { form.setAttribute("action", hppUrl); for ( var key in token) { - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("type", "hidden"); - hiddenField.setAttribute("name", key); - hiddenField.setAttribute("value", token[key]); - - form.appendChild(hiddenField); + form.appendChild(createFormHiddenInput(key, token[key])); } - var hppTemplateType = document.createElement("input"); - hppTemplateType.setAttribute("type", "hidden"); - hppTemplateType.setAttribute("name", "HPP_TEMPLATE_TYPE"); - hppTemplateType.setAttribute("value", "LIGHTBOX"); - - form.appendChild(hppTemplateType); + form.appendChild(createFormHiddenInput("HPP_VERSION", "2")); var parser = document.createElement('a'); parser.href = window.location.href; var hppOriginParam = parser.protocol + '//' + parser.host; - var hppOrigin = document.createElement("input"); - hppOrigin.setAttribute("type", "hidden"); - hppOrigin.setAttribute("name", "HPP_ORIGIN"); - hppOrigin.setAttribute("value", hppOriginParam); - - form.appendChild(hppOrigin); + form.appendChild(createFormHiddenInput("HPP_POST_RESPONSE", hppOriginParam)); + form.appendChild(createFormHiddenInput("HPP_POST_DIMENSIONS", hppOriginParam)); return form; } - + function createIFrame() { //Create the spinner @@ -156,7 +171,7 @@ var RealexHpp = (function() { spinner.style.zIndex="200"; spinner.style.marginLeft="-15px"; spinner.style.top="120px"; - + document.body.appendChild(spinner); //Create the iframe @@ -167,15 +182,19 @@ var RealexHpp = (function() { iFrame.setAttribute("frameBorder", "0"); iFrame.setAttribute("width", "360px"); iFrame.setAttribute("seamless", "seamless"); - + + if (!isMobileIFrame) { + iFrame.setAttribute("scrolling", "no"); + } + iFrame.style.zIndex="10001"; iFrame.style.position="absolute"; iFrame.style.transition="transform 0.5s ease-in-out"; iFrame.style.transform="scale(0.7)"; iFrame.style.opacity="0"; - + overlayElement.appendChild(iFrame); - + if(isMobileIFrame){ iFrame.style.top = "0px"; iFrame.style.bottom = "0px"; @@ -195,11 +214,12 @@ var RealexHpp = (function() { iFrame.style.left="50%"; iFrame.style.marginLeft="-180px"; } - + iFrame.onload = function() { iFrame.style.opacity="1"; iFrame.style.transform="scale(1)"; - + iFrame.style.backgroundColor = "#ffffff"; + if (spinner.parentNode) { spinner.parentNode.removeChild(spinner); } @@ -212,16 +232,16 @@ var RealexHpp = (function() { } else { iFrame.contentWindow.document.appendChild(form); } - + form.submit(); } - + function openWindow() { //open new window tabWindow = window.open(); var doc = tabWindow.document; - + //add meta tag to new window (needed for iOS 8 bug) var meta = doc.createElement("meta"); var name = doc.createAttribute("name"); @@ -231,38 +251,16 @@ var RealexHpp = (function() { content.value="width=device-width"; meta.setAttributeNode(content); doc.head.appendChild(meta); - + //create form, append to new window and submit var form = createForm(doc); doc.body.appendChild(form); form.submit(); } - function closeModal() { - - if (closeButton.parentNode) { - closeButton.parentNode.removeChild(closeButton); - } - - if (iFrame.parentNode) { - iFrame.parentNode.removeChild(iFrame); - } - - if (spinner.parentNode) { - spinner.parentNode.removeChild(spinner); - } - - overlayElement.className = ""; - setTimeout(function() { - if (overlayElement.parentNode) { - overlayElement.parentNode.removeChild(overlayElement); - } - }, 300); - } - return { lightbox : function() { - + if(isMobileNewTab){ openWindow(); } else { @@ -278,27 +276,27 @@ var RealexHpp = (function() { } }; } - + return { // Get the Singleton instance if one exists // or create one if it doesn't getInstance: function (hppToken) { - + if ( !instance ) { instance = init(); } - + //Set the hpp token instance.setToken(hppToken); - + return instance; } }; - + })(); - - var init = function(idOfLightboxButton, merchantUrl, serverSdkJson) { + + var lightboxInit = function(idOfLightboxButton, merchantUrl, serverSdkJson) { //Get the lightbox instance (it's a singleton) and set the sdk json var lightboxInstance = RxpLightbox.getInstance(serverSdkJson); @@ -309,18 +307,24 @@ var RealexHpp = (function() { } else { document.getElementById(idOfLightboxButton).attachEvent('onclick', lightboxInstance.lightbox); } - + + function getHostnameFromUrl(url) { + var parser = document.createElement('a'); + parser.href = url; + return parser.hostname; + } + function receiveMessage(event) { - + //Check the origin of the response comes from HPP if (getHostnameFromUrl(event.origin) === getHostnameFromUrl(hppUrl)) { - - // check for iframe resize values + + // check for iframe resize values if (event.data && JSON.parse(event.data).iframe) { if(!isMobileNewTab){ var iframeWidth = JSON.parse(event.data).iframe.width; var iframeHeight = JSON.parse(event.data).iframe.height; - + var iFrame = document.getElementById("rxp-frame-" + randomId); iFrame.setAttribute("width", iframeWidth); iFrame.setAttribute("height", iframeHeight); @@ -334,7 +338,7 @@ var RealexHpp = (function() { iFrame.style.overflowY = "scroll"; overlay.style.overflowX = "scroll"; overlay.style.overflowY = "scroll"; - + }else{ iFrame.style.marginLeft = (parseInt(iframeWidth.replace("px", ""), 10)/2 * -1 ) + "px"; } @@ -342,57 +346,49 @@ var RealexHpp = (function() { var closeButton = document.getElementById("rxp-frame-close-" + randomId); closeButton.style.marginLeft = ((parseInt(iframeWidth.replace("px", ""), 10)/2) -7) + "px"; } - + } else { - + if(isMobileNewTab){ //Close the new window if(tabWindow){ - tabWindow.close(); + tabWindow.close(); } } else { //Close the lightbox lightboxInstance.close(); } - + var response = event.data; - + //Create a form and submit the hpp response to the merchant's response url var form = document.createElement("form"); form.setAttribute("method", "POST"); form.setAttribute("action", merchantUrl); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("type", "hidden"); - hiddenField.setAttribute("name", "hppResponse"); - hiddenField.setAttribute("value", response); - - form.appendChild(hiddenField); - + + form.appendChild(createFormHiddenInput("hppResponse", response)); + document.body.appendChild(form); - + form.submit(); } } } - + if (window.addEventListener) { window.addEventListener("message", receiveMessage, false); } else { window.attachEvent('message', receiveMessage); } - + }; - - function getHostnameFromUrl(url) { - var parser = document.createElement('a'); - parser.href = url; - return parser.hostname; - } return { - init : init, + init : lightboxInit, + lightbox: { + init: lightboxInit + }, setHppUrl : setHppUrl }; -}()); \ No newline at end of file +}()); diff --git a/package.json b/package.json index 27ffac3..8eaaa4b 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,15 @@ "node": ">= 0.10.0" }, "devDependencies": { - "grunt": "~0.4.5", - "grunt-contrib-concat": "~0.3.0", - "grunt-contrib-jasmine": "^0.9.0", - "grunt-contrib-jshint": "~0.6.0", - "grunt-contrib-uglify": "~0.2.0", - "grunt-contrib-watch": "~0.4.0" + "grunt": "^1.0.1", + "grunt-contrib-concat": "^1.0.1", + "grunt-contrib-jasmine": "^1.1.0", + "grunt-contrib-jshint": "^1.1.0", + "grunt-contrib-uglify": "^3.0.1", + "grunt-contrib-watch": "^1.0.0" }, - "keywords": [] + "keywords": [], + "scripts": { + "grunt": "grunt" + } }