diff --git a/Gruntfile.js b/Gruntfile.js index 13ac5e5..21d679e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -55,15 +55,37 @@ module.exports = function(grunt) { tasks: ['jshint:lib', 'jasmine'] }, specs: { - files: 'specs/*.js', + files: 'specs/unit/*.js', tasks: ['jasmine'] } }, jasmine : { src : 'lib/*.js', options: { - specs: 'specs/*spec.js', - helpers: 'specs/*helper.js' + specs: 'specs/unit/*spec.js', + helpers: 'specs/unit/*helper.js' + } + }, + intern: { + client: { + options: { + config: 'specs/intern.config' + } + }, + runner: { + options: { + config: 'specs/intern.config', + runType: 'runner', + // leaveRemoteOpen: true + } + } + }, + php: { + test: { + options: { + port: '8989', + silent: true, + } } } }); @@ -74,6 +96,12 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-jasmine'); + grunt.loadNpmTasks('intern'); + grunt.loadNpmTasks('grunt-php'); + + grunt.registerTask('test:functional', ['php', 'intern:runner']); + grunt.registerTask('test:unit', ['jasmine']); + grunt.registerTask('test', ['test:unit', 'test:functional']); // Default task. grunt.registerTask('default', ['jshint', 'jasmine', 'concat', 'uglify']); diff --git a/dist/rxp-js.js b/dist/rxp-js.js index f45d2ac..802251a 100644 --- a/dist/rxp-js.js +++ b/dist/rxp-js.js @@ -1,9 +1,9 @@ -/*! rxp-js - v1.2.1 - 2017-10-03 +/*! rxp-js - v1.2.1 - 2017-12-05 * The official Realex Payments JS SDK * https://github.com/realexpayments/rxp-js * Licensed MIT */ -var RealexHpp = (function() { +var RealexHpp = (function () { 'use strict'; @@ -26,338 +26,320 @@ var RealexHpp = (function() { 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; - } + var redirectUrl; - // Initialising some variables used throughout this file. - var RxpLightbox = (function() { - - var instance; - - function init() { - var overlayElement; - var spinner; - var iFrame; - var closeButton; - var token; + var internal = { + createFormHiddenInput: function (name, value) { + var el = document.createElement("input"); + el.setAttribute("type", "hidden"); + el.setAttribute("name", name); + el.setAttribute("value", value); + return el; + }, - function checkDevicesOrientation(){ - if(window.orientation === 90 || window.orientation === -90){ - return true; - }else{ - return false; - } + checkDevicesOrientation: function () { + if (window.orientation === 90 || window.orientation === -90) { + return true; + } else { + return false; } + }, - var isLandscape = checkDevicesOrientation(); - - if(isMobileIFrame){ - if(window.addEventListener){ - window.addEventListener("orientationchange", function() { - isLandscape = checkDevicesOrientation(); - }, false); - } + createOverlay: function () { + var overlay = document.createElement("div"); + overlay.setAttribute("id", "rxp-overlay-" + randomId); + overlay.style.position = "fixed"; + overlay.style.width = "100%"; + overlay.style.height = "100%"; + overlay.style.top = "0"; + overlay.style.left = "0"; + overlay.style.transition = "all 0.3s ease-in-out"; + overlay.style.zIndex = "100"; + + if (isMobileIFrame) { + overlay.style.position = "absolute !important"; + overlay.style.WebkitOverflowScrolling = "touch"; + overlay.style.overflowX = "hidden"; + overlay.style.overflowY = "scroll"; } - // Initialising some variables used throughout this function. - function createOverlay() { - var overlay = document.createElement("div"); - overlay.setAttribute("id", "rxp-overlay-" + randomId); - overlay.style.position="fixed"; - overlay.style.width="100%"; - overlay.style.height="100%"; - overlay.style.top="0"; - overlay.style.left="0"; - overlay.style.transition="all 0.3s ease-in-out"; - 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); - document.body.appendChild(overlay); + setTimeout(function () { + overlay.style.background = "rgba(0, 0, 0, 0.7)"; + }, 1); - setTimeout(function() { - overlay.style.background="rgba(0, 0, 0, 0.7)"; - }, 1); + return overlay; + }, - overlayElement = overlay; + closeModal: function (closeButton, iFrame, spinner, overlayElement) { + if (closeButton && closeButton.parentNode) { + closeButton.parentNode.removeChild(closeButton); } - function closeModal() { + if (iFrame && iFrame.parentNode) { + iFrame.parentNode.removeChild(iFrame); + } - if (closeButton.parentNode) { - closeButton.parentNode.removeChild(closeButton); - } + if (spinner && spinner.parentNode) { + spinner.parentNode.removeChild(spinner); + } - if (iFrame.parentNode) { - iFrame.parentNode.removeChild(iFrame); - } + if (!overlayElement) { + return; + } - if (spinner.parentNode) { - spinner.parentNode.removeChild(spinner); + overlayElement.className = ""; + setTimeout(function () { + if (overlayElement.parentNode) { + overlayElement.parentNode.removeChild(overlayElement); } + }, 300); + }, - overlayElement.className = ""; - setTimeout(function() { - if (overlayElement.parentNode) { - overlayElement.parentNode.removeChild(overlayElement); - } - }, 300); + createCloseButton: function (overlayElement) { + if (document.getElementById("rxp-frame-close-" + randomId) !== null) { + return; } - - 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+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIge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gOgtt4FyRdCgPRarX4+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"; - closeButton.style.top = "20px"; - closeButton.style.left = "initial"; - closeButton.style.marginLeft = "0px"; - closeButton.style.right = "20px"; - } - - closeButton.addEventListener("click", closeModal, true); - overlayElement.appendChild(closeButton); - } + var closeButton = document.createElement("img"); + closeButton.setAttribute("id","rxp-frame-close-" + randomId); + closeButton.setAttribute("src", "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOT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dQi/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"; + closeButton.style.top = "20px"; + closeButton.style.left = "initial"; + closeButton.style.marginLeft = "0px"; + closeButton.style.right = "20px"; } - function createForm(doc){ - var form = document.createElement("form"); - form.setAttribute("method", "POST"); - form.setAttribute("action", hppUrl); + return closeButton; + }, - for ( var key in token) { - form.appendChild(createFormHiddenInput(key, token[key])); - } + createForm: function (doc, token, ignorePostMessage) { + var form = document.createElement("form"); + form.setAttribute("method", "POST"); + form.setAttribute("action", hppUrl); - form.appendChild(createFormHiddenInput("HPP_VERSION", "2")); + for (var key in token) { + form.appendChild(internal.createFormHiddenInput(key, token[key])); + } - var parser = document.createElement('a'); - parser.href = window.location.href; + form.appendChild(internal.createFormHiddenInput("HPP_VERSION", "2")); + + if (ignorePostMessage) { + form.appendChild(internal.createFormHiddenInput("MERCHANT_RESPONSE_URL", redirectUrl)); + } else { + var parser = internal.getUrlParser(window.location.href); var hppOriginParam = parser.protocol + '//' + parser.host; - form.appendChild(createFormHiddenInput("HPP_POST_RESPONSE", hppOriginParam)); - form.appendChild(createFormHiddenInput("HPP_POST_DIMENSIONS", hppOriginParam)); - return form; + form.appendChild(internal.createFormHiddenInput("HPP_POST_RESPONSE", hppOriginParam)); + form.appendChild(internal.createFormHiddenInput("HPP_POST_DIMENSIONS", hppOriginParam)); } + return form; + }, - function createIFrame() { - - //Create the spinner - spinner = document.createElement("img"); - spinner.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/359f369vjHjvSjRvOXLfORIfOQHvjDh/rduvSaM/jEifvlzPzu3v37+Pvixfzr2Pzt3Pa1afa3b/nQovnSpfaxYvjFi/rbt/rcufWsWPjGjfSjRPShQfjChPOUJva0aPa2a/awX/e6dPWnTfWkSPScNve4cPWpUfSdOvOSI/OVKPayZPe9efauW/WpUvOYL/SiQ/OZMfScOPOTJfavXfWmSwAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAHAAcAAAH/4AAgoOEhYaHiIUKKYmNh0ofjoklL4RLUQ+DVZmSAAswOYIKTE1UglUCVZ0AGBYwPwBHTU44AFU8PKuCEzpARB5OTjYAPEi5jQYNgzE7QS1ET1JTD7iqgi6chAcOFRsmABUQBoQuSAIALjwpMwqHCBYcJyrHhulF9xiJFx0WMo0Y99o18oBCWSIXKZI0eoBhkaQHEA0JIIAAQoYPKiSlwIKFyIAUnAYUSBAhAogVkmZc0aChI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ArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"); - spinner.setAttribute("id", "rxp-loader-" + randomId); - spinner.style.left="50%"; - spinner.style.position="fixed"; - spinner.style.background="#FFFFFF"; - spinner.style.borderRadius="50%"; - spinner.style.width="30px"; - spinner.style.marginLeft="-15px"; - spinner.style.zIndex="200"; - spinner.style.marginLeft="-15px"; - spinner.style.top="120px"; - - document.body.appendChild(spinner); - - //Create the iframe - iFrame = document.createElement("iframe"); - iFrame.setAttribute("name", "rxp-frame-" + randomId); - iFrame.setAttribute("id", "rxp-frame-" + randomId); - iFrame.setAttribute("height", "85%"); - iFrame.setAttribute("frameBorder", "0"); - iFrame.setAttribute("width", "360px"); - iFrame.setAttribute("seamless", "seamless"); - - if (!isMobileIFrame) { - iFrame.setAttribute("scrolling", "no"); - } + createSpinner: function () { + var spinner = document.createElement("img"); + spinner.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/359f369vjHjvSjRvOXLfORIfOQHvjDh/rduvSaM/jEifvlzPzu3v37+Pvixfzr2Pzt3Pa1afa3b/nQovnSpfaxYvjFi/rbt/rcufWsWPjGjfSjRPShQfjChPOUJva0aPa2a/awX/e6dPWnTfWkSPScNve4cPWpUfSdOvOSI/OVKPayZPe9efauW/WpUvOYL/SiQ/OZMfScOPOTJfavXfWmSwAAAAAAACH/C05FVFNDQVBFMi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SKgAP05ONgACPLApKUUujAsesABIek46CkmuAjNFp4IPPIuEQ3p2dDgAJBEmhdAuLikDGljDhTY6OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+EaVUmSJJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"); + spinner.setAttribute("id", "rxp-loader-" + randomId); + spinner.style.left = "50%"; + spinner.style.position = "fixed"; + spinner.style.background = "#FFFFFF"; + spinner.style.borderRadius = "50%"; + spinner.style.width = "30px"; + spinner.style.zIndex = "200"; + spinner.style.marginLeft = "-15px"; + spinner.style.top = "120px"; + return spinner; + }, - 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"; - iFrame.style.left = "0px"; - iFrame.style.marginLeft = "0px;"; - iFrame.style.width = "100%"; - iFrame.style.height = "100%"; - iFrame.style.minHeight = "100%"; - iFrame.style.WebkitTransform = "translate3d(0,0,0)"; - iFrame.style.transform = "translate3d(0, 0, 0)"; - var metaTag=document.createElement('meta'); - metaTag.name = "viewport"; - metaTag.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"; - document.getElementsByTagName('head')[0].appendChild(metaTag); - }else{ - iFrame.style.top="40px"; - iFrame.style.left="50%"; - iFrame.style.marginLeft="-180px"; - } + createIFrame: function (overlayElement, token) { + //Create the spinner + var spinner = internal.createSpinner(); + document.body.appendChild(spinner); + + //Create the iframe + var iFrame = document.createElement("iframe"); + iFrame.setAttribute("name", "rxp-frame-" + randomId); + iFrame.setAttribute("id", "rxp-frame-" + randomId); + iFrame.setAttribute("height", "562px"); + iFrame.setAttribute("frameBorder", "0"); + iFrame.setAttribute("width", "360px"); + iFrame.setAttribute("seamless", "seamless"); + + 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"; + iFrame.style.left = "0px"; + iFrame.style.marginLeft = "0px;"; + iFrame.style.width = "100%"; + iFrame.style.height = "100%"; + iFrame.style.minHeight = "100%"; + iFrame.style.WebkitTransform = "translate3d(0,0,0)"; + iFrame.style.transform = "translate3d(0, 0, 0)"; + + var metaTag = document.createElement('meta'); + metaTag.name = "viewport"; + metaTag.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"; + document.getElementsByTagName('head')[0].appendChild(metaTag); + } else { + iFrame.style.top = "40px"; + iFrame.style.left = "50%"; + iFrame.style.marginLeft = "-180px"; + } - iFrame.onload = function() { - iFrame.style.opacity="1"; - iFrame.style.transform="scale(1)"; - iFrame.style.backgroundColor = "#ffffff"; + var closeButton; - if (spinner.parentNode) { - spinner.parentNode.removeChild(spinner); - } - createCloseButton(); - }; + iFrame.onload = function () { + iFrame.style.opacity = "1"; + iFrame.style.transform = "scale(1)"; + iFrame.style.backgroundColor = "#ffffff"; - var form = createForm(document); - if (iFrame.contentWindow.document.body) { - iFrame.contentWindow.document.body.appendChild(form); - } else { - iFrame.contentWindow.document.appendChild(form); + if (spinner.parentNode) { + spinner.parentNode.removeChild(spinner); } - form.submit(); - } + closeButton = internal.createCloseButton(); + overlayElement.appendChild(closeButton); + closeButton.addEventListener("click", function () { + internal.closeModal(closeButton, iFrame, spinner, overlayElement); + }, true); + }; - 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"); - name.value="viewport"; - meta.setAttributeNode(name); - var content = doc.createAttribute("content"); - 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(); + var form = internal.createForm(document, token); + if (iFrame.contentWindow.document.body) { + iFrame.contentWindow.document.body.appendChild(form); + } else { + iFrame.contentWindow.document.appendChild(form); } - return { - lightbox : function() { + form.submit(); - if(isMobileNewTab){ - openWindow(); - } else { - createOverlay(); - createIFrame(); - } - }, - close : function() { - closeModal(); - }, - setToken : function(hppToken) { - token = hppToken; - } + return { + spinner: spinner, + iFrame: iFrame, + closeButton: closeButton }; - } - - 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); + openWindow: function (token) { + //open new window + var tabWindow = window.open(); - return instance; + // browsers can prevent a new window from being created + // e.g. mobile Safari + if (!tabWindow) { + return null; } - }; - })(); + 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"); + name.value = "viewport"; + meta.setAttributeNode(name); + var content = doc.createAttribute("content"); + content.value = "width=device-width"; + meta.setAttributeNode(content); + doc.head.appendChild(meta); - var lightboxInit = function(idOfLightboxButton, merchantUrl, serverSdkJson) { + //create form, append to new window and submit + var form = internal.createForm(doc, token); + doc.body.appendChild(form); + form.submit(); - //Get the lightbox instance (it's a singleton) and set the sdk json - var lightboxInstance = RxpLightbox.getInstance(serverSdkJson); + return tabWindow; + }, - // Sets the event listener on the PAY button. The click will invoke the lightbox method - if (document.getElementById(idOfLightboxButton).addEventListener) { - document.getElementById(idOfLightboxButton).addEventListener("click", lightboxInstance.lightbox, true); - } else { - document.getElementById(idOfLightboxButton).attachEvent('onclick', lightboxInstance.lightbox); - } + getUrlParser: function (url) { + var parser = document.createElement('a'); + parser.href = url; + return parser; + }, - function getHostnameFromUrl(url) { - var parser = document.createElement('a'); - parser.href = url; - return parser.hostname; - } + getHostnameFromUrl: function (url) { + return internal.getUrlParser(url).hostname; + }, - function receiveMessage(event) { + isMessageFromHpp: function (origin, hppUrl) { + return internal.getHostnameFromUrl(origin) === internal.getHostnameFromUrl(hppUrl); + }, - //Check the origin of the response comes from HPP - if (getHostnameFromUrl(event.origin) === getHostnameFromUrl(hppUrl)) { + receiveMessage: function (lightboxInstance, merchantUrl, isEmbedded) { + return function (event) { + //Check the origin of the response comes from HPP + if (!internal.isMessageFromHpp(event.origin, hppUrl)) { + return; + } // check for iframe resize values if (event.data && JSON.parse(event.data).iframe) { - if(!isMobileNewTab){ + 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); + var iFrame; + var resized = false; + + if (isEmbedded) { + iFrame = lightboxInstance.getIframe(); + } else { + iFrame = document.getElementById("rxp-frame-" + randomId); + } + + if (iframeWidth === "390px" && iframeHeight === "440px") { + iFrame.setAttribute("width", iframeWidth); + iFrame.setAttribute("height", iframeHeight); + resized = true; + } + iFrame.style.backgroundColor="#ffffff"; - if(isMobileIFrame){ - var overlay = document.getElementById("rxp-overlay-" + randomId); + if (isMobileIFrame) { iFrame.style.marginLeft = "0px"; iFrame.style.WebkitOverflowScrolling = "touch"; iFrame.style.overflowX = "scroll"; iFrame.style.overflowY = "scroll"; - overlay.style.overflowX = "scroll"; - overlay.style.overflowY = "scroll"; - }else{ - iFrame.style.marginLeft = (parseInt(iframeWidth.replace("px", ""), 10)/2 * -1 ) + "px"; + if (!isEmbedded) { + var overlay = document.getElementById("rxp-overlay-" + randomId); + overlay.style.overflowX = "scroll"; + overlay.style.overflowY = "scroll"; + } + } else if (!isEmbedded && resized) { + iFrame.style.marginLeft = (parseInt(iframeWidth.replace("px", ""), 10) / 2 * -1) + "px"; } - var closeButton = document.getElementById("rxp-frame-close-" + randomId); - closeButton.style.marginLeft = ((parseInt(iframeWidth.replace("px", ""), 10)/2) -7) + "px"; - } - + if (!isEmbedded && resized) { + // wrap the below in a setTimeout to prevent a timing issue on a + // cache-miss load + setTimeout(function () { + var closeButton = document.getElementById("rxp-frame-close-" + randomId); + closeButton.style.marginLeft = ((parseInt(iframeWidth.replace("px", ""), 10) / 2) -7) + "px"; + }, 200); + } + } } else { - - if(isMobileNewTab){ + if (isMobileNewTab && tabWindow) { //Close the new window - if(tabWindow){ - tabWindow.close(); - } + tabWindow.close(); } else { //Close the lightbox lightboxInstance.close(); @@ -370,29 +352,242 @@ var RealexHpp = (function() { form.setAttribute("method", "POST"); form.setAttribute("action", merchantUrl); - form.appendChild(createFormHiddenInput("hppResponse", response)); + form.appendChild(internal.createFormHiddenInput("hppResponse", response)); document.body.appendChild(form); form.submit(); } + }; + } + }; + + // Initialising some variables used throughout this file. + var RxpLightbox = (function () { + var instance; + + function init() { + var overlayElement; + var spinner; + var iFrame; + var closeButton; + var token; + var isLandscape = internal.checkDevicesOrientation(); + + if (isMobileIFrame) { + if (window.addEventListener) { + window.addEventListener("orientationchange", function () { + isLandscape = internal.checkDevicesOrientation(); + }, false); + } + } + + return { + lightbox: function () { + if (isMobileNewTab) { + tabWindow = internal.openWindow(token); + } else { + overlayElement = internal.createOverlay(); + var temp = internal.createIFrame(overlayElement, token); + spinner = temp.spinner; + iFrame = temp.iFrame; + closeButton = temp.closeButton; + } + }, + close: function () { + internal.closeModal(); + }, + setToken: function (hppToken) { + token = hppToken; + } + }; + } + + 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; + }, + init: function (idOfLightboxButton, merchantUrl, serverSdkJson) { + //Get the lightbox instance (it's a singleton) and set the sdk json + var lightboxInstance = RxpLightbox.getInstance(serverSdkJson); + + // Sets the event listener on the PAY button. The click will invoke the lightbox method + if (document.getElementById(idOfLightboxButton).addEventListener) { + document.getElementById(idOfLightboxButton).addEventListener("click", lightboxInstance.lightbox, true); + } else { + document.getElementById(idOfLightboxButton).attachEvent('onclick', lightboxInstance.lightbox); + } + + if (window.addEventListener) { + window.addEventListener("message", internal.receiveMessage(lightboxInstance, merchantUrl), false); + } else { + window.attachEvent('message', internal.receiveMessage(lightboxInstance, merchantUrl)); + } } + }; + })(); + + // Initialising some variables used throughout this file. + var RxpEmbedded = (function () { + var instance; + + function init() { + var overlayElement; + var spinner; + var iFrame; + var closeButton; + var token; + + return { + embedded: function () { + var form = internal.createForm(document, token); + if (iFrame) { + if (iFrame.contentWindow.document.body) { + iFrame.contentWindow.document.body.appendChild(form); + } else { + iFrame.contentWindow.document.appendChild(form); + } + form.submit(); + iFrame.style.display = "inherit"; + } + }, + close: function () { + iFrame.style.display = "none"; + }, + setToken: function (hppToken) { + token = hppToken; + }, + setIframe: function (iframeId) { + iFrame = document.getElementById(iframeId); + }, + getIframe: function () { + return iFrame; + } + }; } - if (window.addEventListener) { - window.addEventListener("message", receiveMessage, false); - } else { - window.attachEvent('message', receiveMessage); + 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; + }, + init: function (idOfEmbeddedButton, idOfTargetIframe, merchantUrl, serverSdkJson) { + //Get the embedded instance (it's a singleton) and set the sdk json + var embeddedInstance = RxpEmbedded.getInstance(serverSdkJson); + + embeddedInstance.setIframe(idOfTargetIframe); + + // Sets the event listener on the PAY button. The click will invoke the embedded method + if (document.getElementById(idOfEmbeddedButton).addEventListener) { + document.getElementById(idOfEmbeddedButton).addEventListener("click", embeddedInstance.embedded, true); + } else { + document.getElementById(idOfEmbeddedButton).attachEvent('onclick', embeddedInstance.embedded); + } + + if (window.addEventListener) { + window.addEventListener("message", internal.receiveMessage(embeddedInstance, merchantUrl, true), false); + } else { + window.attachEvent('message', internal.receiveMessage(embeddedInstance, merchantUrl, true)); + } + } + }; + })(); + + var RxpRedirect = (function () { + var instance; + + function init() { + var overlayElement; + var spinner; + var iFrame; + var closeButton; + var token; + var isLandscape = internal.checkDevicesOrientation(); + + if (isMobileIFrame) { + if (window.addEventListener) { + window.addEventListener("orientationchange", function () { + isLandscape = internal.checkDevicesOrientation(); + }, false); + } + } + + return { + redirect: function () { + var form = internal.createForm(document, token, true); + document.body.append(form); + form.submit(); + }, + setToken: function (hppToken) { + token = hppToken; + } + }; } + 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; + }, + init: function (idOfButton, merchantUrl, serverSdkJson) { + // Get the redirect instance (it's a singleton) and set the sdk json + var redirectInstance = RxpRedirect.getInstance(serverSdkJson); + redirectUrl = merchantUrl; + + // Sets the event listener on the PAY button. The click will invoke the redirect method + if (document.getElementById(idOfButton).addEventListener) { + document.getElementById(idOfButton).addEventListener("click", redirectInstance.redirect, true); + } else { + document.getElementById(idOfButton).attachEvent('onclick', redirectInstance.redirect); + } + + if (window.addEventListener) { + window.addEventListener("message", internal.receiveMessage(redirectInstance, merchantUrl), false); + } else { + window.attachEvent('message', internal.receiveMessage(redirectInstance, merchantUrl)); + } + } + }; + }()); + + // RealexHpp return { - init : lightboxInit, + init: RxpLightbox.init, lightbox: { - init: lightboxInit + init: RxpLightbox.init + }, + embedded: { + init: RxpEmbedded.init + }, + redirect: { + init: RxpRedirect.init }, - setHppUrl : setHppUrl + setHppUrl: setHppUrl, + _internal: internal }; }()); diff --git a/dist/rxp-js.min.js b/dist/rxp-js.min.js index 368e9b2..93046f4 100644 --- a/dist/rxp-js.min.js +++ b/dist/rxp-js.min.js @@ -1,7 +1,7 @@ -/*! rxp-js - v1.2.1 - 2017-10-03 +/*! rxp-js - v1.2.1 - 2017-12-05 * The official Realex Payments JS SDK * https://github.com/realexpayments/rxp-js * Licensed MIT */ -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/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5U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IQQsfl/jNJUik8Duzs/XmW9mN7Xb7VRc5vP5zWKxaK5Wq8Zmu72FqobfJG0YQ9M0+/l8/qFQKDzGY1JxENd1288vLy1s786KRZXJZCLber1Wn7MZt4PLarVnWdZ9AmQ8Hncc17UvymVdBMB/MgPQm+cFFcuy6/V6lzqDf57ntWGwYdBIVx0TfkBD6I9M35iRJgfIoAVjBLDZbA4CiJ5+9AdQi/EahibqDTkQx6fRSIHcPwA8Uy9A9Gcc47Xv+w2wzhRDYzqdVihLIbsIiCvP1NNOoX/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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MZAALgJIAg8KGDwKGlinAEkKLoU1Tnt1BABVAtOEKb4PBhIMR4c+cU5OaymILiYlCwtHmIcxQU4fjAYMDFjdiApQSGBU5QgGRjOmEFgQCUMKZf8AKLgBAgiZNvkaURkSo8aUI+wAYJDSYcyONloibexIoYQwQS6oEPgxpOGMXPQOPdjCMFESCgcZHdFiYUROQ0dChCgRkRCFOg4cRMCCiIcGAjhCUDgq6AiHDhWyxShAhJACKFweJJHAAgoFQ1dfrAwQlKRMhAwpfnCZMkXEihqCHmAwUIXRkAgRoLiQgsIHABsrVDRl1OPMDQAPZIzAAcAEjRVzOT2gI+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!(i0?window.innerWidth:screen.width)<=360||(window.innerHeight>0?window.innerHeight:screen.Height)<=360,a=i,d=!i&&(o||r),s={createFormHiddenInput:function(e,t){var A=document.createElement("input");return A.setAttribute("type","hidden"),A.setAttribute("name",e),A.setAttribute("value",t),A},checkDevicesOrientation:function(){return 90===window.orientation||-90===window.orientation},createOverlay:function(){var e=document.createElement("div");return e.setAttribute("id","rxp-overlay-"+n),e.style.position="fixed",e.style.width="100%",e.style.height="100%",e.style.top="0",e.style.left="0",e.style.transition="all 0.3s ease-in-out",e.style.zIndex="100",a&&(e.style.position="absolute !important",e.style.WebkitOverflowScrolling="touch",e.style.overflowX="hidden",e.style.overflowY="scroll"),document.body.appendChild(e),setTimeout(function(){e.style.background="rgba(0, 0, 0, 0.7)"},1),e},closeModal:function(e,t,A,n){e&&e.parentNode&&e.parentNode.removeChild(e),t&&t.parentNode&&t.parentNode.removeChild(t),A&&A.parentNode&&A.parentNode.removeChild(A),n&&(n.className="",setTimeout(function(){n.parentNode&&n.parentNode.removeChild(n)},300))},createCloseButton:function(e){if(null===document.getElementById("rxp-frame-close-"+n)){var t=document.createElement("img");return t.setAttribute("id","rxp-frame-close-"+n),t.setAttribute("src","data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zL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hINKpZLgSISZgoqh5iiLQrojAFICVwGS7tCfe5DbZzkP56XS4NVxwvTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="),t.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(){t.style.opacity="1"},500),a&&(t.style.position="absolute",t.style.float="right",t.style.top="20px",t.style.left="initial",t.style.marginLeft="0px",t.style.right="20px"),t}},createForm:function(e,n,i){var o=document.createElement("form");o.setAttribute("method","POST"),o.setAttribute("action",A);for(var r in n)o.appendChild(s.createFormHiddenInput(r,n[r]));if(o.appendChild(s.createFormHiddenInput("HPP_VERSION","2")),i)o.appendChild(s.createFormHiddenInput("MERCHANT_RESPONSE_URL",t));else{var a=s.getUrlParser(window.location.href),d=a.protocol+"//"+a.host;o.appendChild(s.createFormHiddenInput("HPP_POST_RESPONSE",d)),o.appendChild(s.createFormHiddenInput("HPP_POST_DIMENSIONS",d))}return o},createSpinner:function(){var e=document.createElement("img");return e.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/359f369vjHjvSjRvOXLfORIfOQHvjDh/rduvSaM/jEifvlzPzu3v37+Pv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l1OPMDQAPZIzAAcAEjRVzOT2gI+XTjREMBF0RUZMThhyyAGyYYGCQhtaoCJVQMjk3ISQafAtHFAgAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iGD4mMh1UCjYkNXlWDSQKVgo+Rgkl3HZkCSEmdMwqcgnNOWoI8SDwAD0VFSKgAP05ONgACPLApKUUujAsesABIek46CkmuAjNFp4IPPIuEQ3p2dDgAJBEmhdAuLikDGljDhTY6OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+EaVUmSJJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"),e.setAttribute("id","rxp-loader-"+n),e.style.left="50%",e.style.position="fixed",e.style.background="#FFFFFF",e.style.borderRadius="50%",e.style.width="30px",e.style.zIndex="200",e.style.marginLeft="-15px",e.style.top="120px",e},createIFrame:function(e,t){var A=s.createSpinner();document.body.appendChild(A);var i=document.createElement("iframe");if(i.setAttribute("name","rxp-frame-"+n),i.setAttribute("id","rxp-frame-"+n),i.setAttribute("height","562px"),i.setAttribute("frameBorder","0"),i.setAttribute("width","360px"),i.setAttribute("seamless","seamless"),i.style.zIndex="10001",i.style.position="absolute",i.style.transition="transform 0.5s ease-in-out",i.style.transform="scale(0.7)",i.style.opacity="0",e.appendChild(i),a){i.style.top="0px",i.style.bottom="0px",i.style.left="0px",i.style.marginLeft="0px;",i.style.width="100%",i.style.height="100%",i.style.minHeight="100%",i.style.WebkitTransform="translate3d(0,0,0)",i.style.transform="translate3d(0, 0, 0)";var o=document.createElement("meta");o.name="viewport",o.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0",document.getElementsByTagName("head")[0].appendChild(o)}else i.style.top="40px",i.style.left="50%",i.style.marginLeft="-180px";var r;i.onload=function(){i.style.opacity="1",i.style.transform="scale(1)",i.style.backgroundColor="#ffffff",A.parentNode&&A.parentNode.removeChild(A),r=s.createCloseButton(),e.appendChild(r),r.addEventListener("click",function(){s.closeModal(r,i,A,e)},!0)};var d=s.createForm(document,t);return i.contentWindow.document.body?i.contentWindow.document.body.appendChild(d):i.contentWindow.document.appendChild(d),d.submit(),{spinner:A,iFrame:i,closeButton:r}},openWindow:function(e){var t=window.open();if(!t)return null;var A=t.document,n=A.createElement("meta"),i=A.createAttribute("name");i.value="viewport",n.setAttributeNode(i);var o=A.createAttribute("content");o.value="width=device-width",n.setAttributeNode(o),A.head.appendChild(n);var r=s.createForm(A,e);return A.body.appendChild(r),r.submit(),t},getUrlParser:function(e){var t=document.createElement("a");return t.href=e,t},getHostnameFromUrl:function(e){return s.getUrlParser(e).hostname},isMessageFromHpp:function(e,t){return s.getHostnameFromUrl(e)===s.getHostnameFromUrl(t)},receiveMessage:function(t,i,o){return function(r){if(s.isMessageFromHpp(r.origin,A))if(r.data&&JSON.parse(r.data).iframe){if(!d){var c,g=JSON.parse(r.data).iframe.width,l=JSON.parse(r.data).iframe.height,I=!1;if(c=o?t.getIframe():document.getElementById("rxp-frame-"+n),"390px"===g&&"440px"===l&&(c.setAttribute("width",g),c.setAttribute("height",l),I=!0),c.style.backgroundColor="#ffffff",a){if(c.style.marginLeft="0px",c.style.WebkitOverflowScrolling="touch",c.style.overflowX="scroll",c.style.overflowY="scroll",!o){var E=document.getElementById("rxp-overlay-"+n);E.style.overflowX="scroll",E.style.overflowY="scroll"}}else!o&&I&&(c.style.marginLeft=parseInt(g.replace("px",""),10)/2*-1+"px");!o&&I&&setTimeout(function(){document.getElementById("rxp-frame-close-"+n).style.marginLeft=parseInt(g.replace("px",""),10)/2-7+"px"},200)}}else{d&&e?e.close():t.close();var u=r.data,C=document.createElement("form");C.setAttribute("method","POST"),C.setAttribute("action",i),C.appendChild(s.createFormHiddenInput("hppResponse",u)),document.body.appendChild(C),C.submit()}}}},c=function(){function t(){var t,A,n,i,o,r=s.checkDevicesOrientation();return a&&window.addEventListener&&window.addEventListener("orientationchange",function(){r=s.checkDevicesOrientation()},!1),{lightbox:function(){if(d)e=s.openWindow(o);else{t=s.createOverlay();var r=s.createIFrame(t,o);A=r.spinner,n=r.iFrame,i=r.closeButton}},close:function(){s.closeModal()},setToken:function(e){o=e}}}var A;return{getInstance:function(e){return A||(A=t()),A.setToken(e),A},init:function(e,t,A){var n=c.getInstance(A);document.getElementById(e).addEventListener?document.getElementById(e).addEventListener("click",n.lightbox,!0):document.getElementById(e).attachEvent("onclick",n.lightbox),window.addEventListener?window.addEventListener("message",s.receiveMessage(n,t),!1):window.attachEvent("message",s.receiveMessage(n,t))}}}(),g=function(){function e(){var e,t;return{embedded:function(){var A=s.createForm(document,t);e&&(e.contentWindow.document.body?e.contentWindow.document.body.appendChild(A):e.contentWindow.document.appendChild(A),A.submit(),e.style.display="inherit")},close:function(){e.style.display="none"},setToken:function(e){t=e},setIframe:function(t){e=document.getElementById(t)},getIframe:function(){return e}}}var t;return{getInstance:function(A){return t||(t=e()),t.setToken(A),t},init:function(e,t,A,n){var i=g.getInstance(n);i.setIframe(t),document.getElementById(e).addEventListener?document.getElementById(e).addEventListener("click",i.embedded,!0):document.getElementById(e).attachEvent("onclick",i.embedded),window.addEventListener?window.addEventListener("message",s.receiveMessage(i,A,!0),!1):window.attachEvent("message",s.receiveMessage(i,A,!0))}}}(),l=function(){function e(){var e,t=s.checkDevicesOrientation();return a&&window.addEventListener&&window.addEventListener("orientationchange",function(){t=s.checkDevicesOrientation()},!1),{redirect:function(){var t=s.createForm(document,e,!0);document.body.append(t),t.submit()},setToken:function(t){e=t}}}var A;return{getInstance:function(t){return A||(A=e()),A.setToken(t),A},init:function(e,A,n){var i=l.getInstance(n);t=A,document.getElementById(e).addEventListener?document.getElementById(e).addEventListener("click",i.redirect,!0):document.getElementById(e).attachEvent("onclick",i.redirect),window.addEventListener?window.addEventListener("message",s.receiveMessage(i,A),!1):window.attachEvent("message",s.receiveMessage(i,A))}}}();return{init:c.init,lightbox:{init:c.init},embedded:{init:g.init},redirect:{init:l.init},setHppUrl:function(e){A=e},_internal:s}}(),RealexRemote=function(){"use strict";var e=function(e){if(!/^\d{4}$/.test(e))return!1;var t=parseInt(e.substring(0,2),10);parseInt(e.substring(2,4),10);return!(t<1||t>12)};return{validateCardNumber:function(e){if(!/^\d{12,19}$/.test(e))return!1;for(var t=0,A=0,n=0,i=!1,o=e.length-1;o>=0;o--)A=parseInt(e.substring(o,o+1),10),i?(n=2*A)>9&&(n-=9):n=A,t+=n,i=!i;return 0==t%10},validateCardHolderName:function(e){return!!e&&!!e.trim()&&!!/^[\u0020-\u007E\u00A0-\u00FF]{1,100}$/.test(e)},validateCvn:function(e){return!!/^\d{3}$/.test(e)},validateAmexCvn:function(e){return!!/^\d{4}$/.test(e)},validateExpiryDateFormat:e,validateExpiryDateNotInPast:function(t){if(!e(t))return!1;var A=parseInt(t.substring(0,2),10),n=parseInt(t.substring(2,4),10),i=new Date,o=i.getMonth()+1,r=i.getFullYear();return!(n + + + HPP Lightbox Demo + + + + + + + +
+ + + diff --git a/examples/hpp/process-a-payment.html b/examples/hpp/process-a-payment-lightbox.html similarity index 57% rename from examples/hpp/process-a-payment.html rename to examples/hpp/process-a-payment-lightbox.html index fd12437..dad1621 100644 --- a/examples/hpp/process-a-payment.html +++ b/examples/hpp/process-a-payment-lightbox.html @@ -9,13 +9,14 @@ RealexHpp.setHppUrl('https://pay.sandbox.realexpayments.com/pay'); // get the HPP JSON from the server-side SDK $(document).ready(function () { - $.getJSON("/examples/hpp/proxy-request.php", function (jsonFromServerSdk) { - RealexHpp.init("payButtonId", "https://dev.rlxcarts.com/mobileSDKs/response.php", jsonFromServerSdk); + $.getJSON("/examples/hpp/proxy-request.php?slug=process-a-payment", function (jsonFromServerSdk) { + RealexHpp.lightbox.init("payButtonId", "https://dev.rlxcarts.com/mobileSDKsV2/response.php", jsonFromServerSdk); + $('body').addClass('loaded'); }); }); - + - \ No newline at end of file + diff --git a/examples/hpp/proxy-request.php b/examples/hpp/proxy-request.php index aaa4b35..1da28ce 100644 --- a/examples/hpp/proxy-request.php +++ b/examples/hpp/proxy-request.php @@ -1,11 +1,79 @@ $value) { - $response[$key] = base64_decode($value); + if (!$value) { + continue; + } + $response[$key] = $value; } -echo json_encode($response); +$response["ORDER_ID"] = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789'), 0, 22); +$response["TIMESTAMP"] = (new DateTime())->format("YmdHis"); +$response["SHA1HASH"] = generateHash($response, 'secret'); + +$jsonResponse = json_encode($response); + +error_log('sending: ' . $jsonResponse); +echo $jsonResponse; diff --git a/examples/hpp/redirect-for-payment.html b/examples/hpp/redirect-for-payment.html new file mode 100644 index 0000000..2f24635 --- /dev/null +++ b/examples/hpp/redirect-for-payment.html @@ -0,0 +1,22 @@ + + + + HPP Redirect Demo + + + + + + + + + diff --git a/lib/rxp-hpp.js b/lib/rxp-hpp.js index afac58f..d280f42 100644 --- a/lib/rxp-hpp.js +++ b/lib/rxp-hpp.js @@ -1,5 +1,5 @@ /*jslint browser:true */ -var RealexHpp = (function() { +var RealexHpp = (function () { 'use strict'; @@ -22,338 +22,320 @@ var RealexHpp = (function() { 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; - } + var redirectUrl; - // Initialising some variables used throughout this file. - var RxpLightbox = (function() { - - var instance; - - function init() { - var overlayElement; - var spinner; - var iFrame; - var closeButton; - var token; + var internal = { + createFormHiddenInput: function (name, value) { + var el = document.createElement("input"); + el.setAttribute("type", "hidden"); + el.setAttribute("name", name); + el.setAttribute("value", value); + return el; + }, - function checkDevicesOrientation(){ - if(window.orientation === 90 || window.orientation === -90){ - return true; - }else{ - return false; - } + checkDevicesOrientation: function () { + if (window.orientation === 90 || window.orientation === -90) { + return true; + } else { + return false; } + }, - var isLandscape = checkDevicesOrientation(); - - if(isMobileIFrame){ - if(window.addEventListener){ - window.addEventListener("orientationchange", function() { - isLandscape = checkDevicesOrientation(); - }, false); - } + createOverlay: function () { + var overlay = document.createElement("div"); + overlay.setAttribute("id", "rxp-overlay-" + randomId); + overlay.style.position = "fixed"; + overlay.style.width = "100%"; + overlay.style.height = "100%"; + overlay.style.top = "0"; + overlay.style.left = "0"; + overlay.style.transition = "all 0.3s ease-in-out"; + overlay.style.zIndex = "100"; + + if (isMobileIFrame) { + overlay.style.position = "absolute !important"; + overlay.style.WebkitOverflowScrolling = "touch"; + overlay.style.overflowX = "hidden"; + overlay.style.overflowY = "scroll"; } - // Initialising some variables used throughout this function. - function createOverlay() { - var overlay = document.createElement("div"); - overlay.setAttribute("id", "rxp-overlay-" + randomId); - overlay.style.position="fixed"; - overlay.style.width="100%"; - overlay.style.height="100%"; - overlay.style.top="0"; - overlay.style.left="0"; - overlay.style.transition="all 0.3s ease-in-out"; - 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); - document.body.appendChild(overlay); + setTimeout(function () { + overlay.style.background = "rgba(0, 0, 0, 0.7)"; + }, 1); - setTimeout(function() { - overlay.style.background="rgba(0, 0, 0, 0.7)"; - }, 1); + return overlay; + }, - overlayElement = overlay; + closeModal: function (closeButton, iFrame, spinner, overlayElement) { + if (closeButton && closeButton.parentNode) { + closeButton.parentNode.removeChild(closeButton); } - function closeModal() { + if (iFrame && iFrame.parentNode) { + iFrame.parentNode.removeChild(iFrame); + } - if (closeButton.parentNode) { - closeButton.parentNode.removeChild(closeButton); - } + if (spinner && spinner.parentNode) { + spinner.parentNode.removeChild(spinner); + } - if (iFrame.parentNode) { - iFrame.parentNode.removeChild(iFrame); - } + if (!overlayElement) { + return; + } - if (spinner.parentNode) { - spinner.parentNode.removeChild(spinner); + overlayElement.className = ""; + setTimeout(function () { + if (overlayElement.parentNode) { + overlayElement.parentNode.removeChild(overlayElement); } + }, 300); + }, - overlayElement.className = ""; - setTimeout(function() { - if (overlayElement.parentNode) { - overlayElement.parentNode.removeChild(overlayElement); - } - }, 300); + createCloseButton: function (overlayElement) { + if (document.getElementById("rxp-frame-close-" + randomId) !== null) { + return; } - - 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+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbn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bZzkP56XS4NVxwvTI/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"; - closeButton.style.top = "20px"; - closeButton.style.left = "initial"; - closeButton.style.marginLeft = "0px"; - closeButton.style.right = "20px"; - } - - closeButton.addEventListener("click", closeModal, true); - overlayElement.appendChild(closeButton); - } + var closeButton = document.createElement("img"); + closeButton.setAttribute("id","rxp-frame-close-" + randomId); + closeButton.setAttribute("src", "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3h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I4TXWMAmCIGFhCQLAdZ8jym/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"; + closeButton.style.top = "20px"; + closeButton.style.left = "initial"; + closeButton.style.marginLeft = "0px"; + closeButton.style.right = "20px"; } - function createForm(doc){ - var form = document.createElement("form"); - form.setAttribute("method", "POST"); - form.setAttribute("action", hppUrl); + return closeButton; + }, - for ( var key in token) { - form.appendChild(createFormHiddenInput(key, token[key])); - } + createForm: function (doc, token, ignorePostMessage) { + var form = document.createElement("form"); + form.setAttribute("method", "POST"); + form.setAttribute("action", hppUrl); - form.appendChild(createFormHiddenInput("HPP_VERSION", "2")); + for (var key in token) { + form.appendChild(internal.createFormHiddenInput(key, token[key])); + } - var parser = document.createElement('a'); - parser.href = window.location.href; + form.appendChild(internal.createFormHiddenInput("HPP_VERSION", "2")); + + if (ignorePostMessage) { + form.appendChild(internal.createFormHiddenInput("MERCHANT_RESPONSE_URL", redirectUrl)); + } else { + var parser = internal.getUrlParser(window.location.href); var hppOriginParam = parser.protocol + '//' + parser.host; - form.appendChild(createFormHiddenInput("HPP_POST_RESPONSE", hppOriginParam)); - form.appendChild(createFormHiddenInput("HPP_POST_DIMENSIONS", hppOriginParam)); - return form; + form.appendChild(internal.createFormHiddenInput("HPP_POST_RESPONSE", hppOriginParam)); + form.appendChild(internal.createFormHiddenInput("HPP_POST_DIMENSIONS", hppOriginParam)); } + return form; + }, - function createIFrame() { - - //Create the spinner - spinner = document.createElement("img"); - spinner.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/359f369vjHjvSjRvOXLfORIfOQHvjDh/rduvSaM/jEifvlzPzu3v37+Pvixfzr2Pzt3Pa1afa3b/nQovnSpfaxYvjFi/rbt/rcufWsWPjGjfSjRPShQfjChPOUJva0aPa2a/awX/e6dPWnTfWkSPScNve4cPWpUfSdOvOSI/OVKPayZPe9efauW/WpUvOYL/SiQ/OZMfScOPOTJfavXfWmSwAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAHAAcAAAH/4AAgoOEhYaHiIUKKYmNh0ofjoklL4RLUQ+DVZmSAAswOYIKTE1UglUCVZ0AGBYwPwBHTU44AFU8PKuCEzpARB5OTjYAPEi5jQYNgzE7QS1ET1JTD7iqgi6chAcOFRsmABUQBoQuSAIALjwpMwqHCBYcJyrHhulF9xiJFx0WMo0Y99o18oBCWSIXKZI0eoBhkaQHEA0JIIAAQoYPKiSlwIKFyIAUnAYUSBAhAogVkmZc0aChIz0ACiQQCLFAEhIMKXhkO8RiRqMqBnYe0iAigwoXiah4KMEI0QIII1rQyHeoypUFWH0aWjABAgkPLigIKUIIiQQNrDQs8EC2EAMKBlIV9EBgRAHWFEes1DiWpI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-" + randomId); - spinner.style.left="50%"; - spinner.style.position="fixed"; - spinner.style.background="#FFFFFF"; - spinner.style.borderRadius="50%"; - spinner.style.width="30px"; - spinner.style.marginLeft="-15px"; - spinner.style.zIndex="200"; - spinner.style.marginLeft="-15px"; - spinner.style.top="120px"; - - document.body.appendChild(spinner); - - //Create the iframe - iFrame = document.createElement("iframe"); - iFrame.setAttribute("name", "rxp-frame-" + randomId); - iFrame.setAttribute("id", "rxp-frame-" + randomId); - iFrame.setAttribute("height", "85%"); - iFrame.setAttribute("frameBorder", "0"); - iFrame.setAttribute("width", "360px"); - iFrame.setAttribute("seamless", "seamless"); - - if (!isMobileIFrame) { - iFrame.setAttribute("scrolling", "no"); - } + createSpinner: function () { + var spinner = document.createElement("img"); + spinner.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/359f369vjHjvSjRvOXLfORIfOQHvjDh/rduvSaM/jEifvlzPzu3v37+Pvixfzr2Pzt3Pa1afa3b/nQovnSpfaxYvjFi/rbt/rcufWsWPjGjfSjRPShQfjChPOUJva0aPa2a/awX/e6dPWnTfWkSPScNve4cPWpUfSdOvOSI/OVKPayZPe9efauW/WpUvOYL/SiQ/OZMfScOPOTJfavXfWmSwAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAHAAcAAAH/4AAgoOEhYaHiIUKKYmNh0ofjoklL4RLUQ+DVZmSAAsw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+EaVUmSJJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"); + spinner.setAttribute("id", "rxp-loader-" + randomId); + spinner.style.left = "50%"; + spinner.style.position = "fixed"; + spinner.style.background = "#FFFFFF"; + spinner.style.borderRadius = "50%"; + spinner.style.width = "30px"; + spinner.style.zIndex = "200"; + spinner.style.marginLeft = "-15px"; + spinner.style.top = "120px"; + return spinner; + }, - 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"; - iFrame.style.left = "0px"; - iFrame.style.marginLeft = "0px;"; - iFrame.style.width = "100%"; - iFrame.style.height = "100%"; - iFrame.style.minHeight = "100%"; - iFrame.style.WebkitTransform = "translate3d(0,0,0)"; - iFrame.style.transform = "translate3d(0, 0, 0)"; - var metaTag=document.createElement('meta'); - metaTag.name = "viewport"; - metaTag.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"; - document.getElementsByTagName('head')[0].appendChild(metaTag); - }else{ - iFrame.style.top="40px"; - iFrame.style.left="50%"; - iFrame.style.marginLeft="-180px"; - } + createIFrame: function (overlayElement, token) { + //Create the spinner + var spinner = internal.createSpinner(); + document.body.appendChild(spinner); + + //Create the iframe + var iFrame = document.createElement("iframe"); + iFrame.setAttribute("name", "rxp-frame-" + randomId); + iFrame.setAttribute("id", "rxp-frame-" + randomId); + iFrame.setAttribute("height", "562px"); + iFrame.setAttribute("frameBorder", "0"); + iFrame.setAttribute("width", "360px"); + iFrame.setAttribute("seamless", "seamless"); + + 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"; + iFrame.style.left = "0px"; + iFrame.style.marginLeft = "0px;"; + iFrame.style.width = "100%"; + iFrame.style.height = "100%"; + iFrame.style.minHeight = "100%"; + iFrame.style.WebkitTransform = "translate3d(0,0,0)"; + iFrame.style.transform = "translate3d(0, 0, 0)"; + + var metaTag = document.createElement('meta'); + metaTag.name = "viewport"; + metaTag.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"; + document.getElementsByTagName('head')[0].appendChild(metaTag); + } else { + iFrame.style.top = "40px"; + iFrame.style.left = "50%"; + iFrame.style.marginLeft = "-180px"; + } - iFrame.onload = function() { - iFrame.style.opacity="1"; - iFrame.style.transform="scale(1)"; - iFrame.style.backgroundColor = "#ffffff"; + var closeButton; - if (spinner.parentNode) { - spinner.parentNode.removeChild(spinner); - } - createCloseButton(); - }; + iFrame.onload = function () { + iFrame.style.opacity = "1"; + iFrame.style.transform = "scale(1)"; + iFrame.style.backgroundColor = "#ffffff"; - var form = createForm(document); - if (iFrame.contentWindow.document.body) { - iFrame.contentWindow.document.body.appendChild(form); - } else { - iFrame.contentWindow.document.appendChild(form); + if (spinner.parentNode) { + spinner.parentNode.removeChild(spinner); } - form.submit(); - } + closeButton = internal.createCloseButton(); + overlayElement.appendChild(closeButton); + closeButton.addEventListener("click", function () { + internal.closeModal(closeButton, iFrame, spinner, overlayElement); + }, true); + }; - 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"); - name.value="viewport"; - meta.setAttributeNode(name); - var content = doc.createAttribute("content"); - 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(); + var form = internal.createForm(document, token); + if (iFrame.contentWindow.document.body) { + iFrame.contentWindow.document.body.appendChild(form); + } else { + iFrame.contentWindow.document.appendChild(form); } - return { - lightbox : function() { + form.submit(); - if(isMobileNewTab){ - openWindow(); - } else { - createOverlay(); - createIFrame(); - } - }, - close : function() { - closeModal(); - }, - setToken : function(hppToken) { - token = hppToken; - } + return { + spinner: spinner, + iFrame: iFrame, + closeButton: closeButton }; - } - - 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); + openWindow: function (token) { + //open new window + var tabWindow = window.open(); - return instance; + // browsers can prevent a new window from being created + // e.g. mobile Safari + if (!tabWindow) { + return null; } - }; - })(); + 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"); + name.value = "viewport"; + meta.setAttributeNode(name); + var content = doc.createAttribute("content"); + content.value = "width=device-width"; + meta.setAttributeNode(content); + doc.head.appendChild(meta); - var lightboxInit = function(idOfLightboxButton, merchantUrl, serverSdkJson) { + //create form, append to new window and submit + var form = internal.createForm(doc, token); + doc.body.appendChild(form); + form.submit(); - //Get the lightbox instance (it's a singleton) and set the sdk json - var lightboxInstance = RxpLightbox.getInstance(serverSdkJson); + return tabWindow; + }, - // Sets the event listener on the PAY button. The click will invoke the lightbox method - if (document.getElementById(idOfLightboxButton).addEventListener) { - document.getElementById(idOfLightboxButton).addEventListener("click", lightboxInstance.lightbox, true); - } else { - document.getElementById(idOfLightboxButton).attachEvent('onclick', lightboxInstance.lightbox); - } + getUrlParser: function (url) { + var parser = document.createElement('a'); + parser.href = url; + return parser; + }, - function getHostnameFromUrl(url) { - var parser = document.createElement('a'); - parser.href = url; - return parser.hostname; - } + getHostnameFromUrl: function (url) { + return internal.getUrlParser(url).hostname; + }, - function receiveMessage(event) { + isMessageFromHpp: function (origin, hppUrl) { + return internal.getHostnameFromUrl(origin) === internal.getHostnameFromUrl(hppUrl); + }, - //Check the origin of the response comes from HPP - if (getHostnameFromUrl(event.origin) === getHostnameFromUrl(hppUrl)) { + receiveMessage: function (lightboxInstance, merchantUrl, isEmbedded) { + return function (event) { + //Check the origin of the response comes from HPP + if (!internal.isMessageFromHpp(event.origin, hppUrl)) { + return; + } // check for iframe resize values if (event.data && JSON.parse(event.data).iframe) { - if(!isMobileNewTab){ + 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); + var iFrame; + var resized = false; + + if (isEmbedded) { + iFrame = lightboxInstance.getIframe(); + } else { + iFrame = document.getElementById("rxp-frame-" + randomId); + } + + if (iframeWidth === "390px" && iframeHeight === "440px") { + iFrame.setAttribute("width", iframeWidth); + iFrame.setAttribute("height", iframeHeight); + resized = true; + } + iFrame.style.backgroundColor="#ffffff"; - if(isMobileIFrame){ - var overlay = document.getElementById("rxp-overlay-" + randomId); + if (isMobileIFrame) { iFrame.style.marginLeft = "0px"; iFrame.style.WebkitOverflowScrolling = "touch"; iFrame.style.overflowX = "scroll"; iFrame.style.overflowY = "scroll"; - overlay.style.overflowX = "scroll"; - overlay.style.overflowY = "scroll"; - }else{ - iFrame.style.marginLeft = (parseInt(iframeWidth.replace("px", ""), 10)/2 * -1 ) + "px"; + if (!isEmbedded) { + var overlay = document.getElementById("rxp-overlay-" + randomId); + overlay.style.overflowX = "scroll"; + overlay.style.overflowY = "scroll"; + } + } else if (!isEmbedded && resized) { + iFrame.style.marginLeft = (parseInt(iframeWidth.replace("px", ""), 10) / 2 * -1) + "px"; } - var closeButton = document.getElementById("rxp-frame-close-" + randomId); - closeButton.style.marginLeft = ((parseInt(iframeWidth.replace("px", ""), 10)/2) -7) + "px"; - } - + if (!isEmbedded && resized) { + // wrap the below in a setTimeout to prevent a timing issue on a + // cache-miss load + setTimeout(function () { + var closeButton = document.getElementById("rxp-frame-close-" + randomId); + closeButton.style.marginLeft = ((parseInt(iframeWidth.replace("px", ""), 10) / 2) -7) + "px"; + }, 200); + } + } } else { - - if(isMobileNewTab){ + if (isMobileNewTab && tabWindow) { //Close the new window - if(tabWindow){ - tabWindow.close(); - } + tabWindow.close(); } else { //Close the lightbox lightboxInstance.close(); @@ -366,29 +348,242 @@ var RealexHpp = (function() { form.setAttribute("method", "POST"); form.setAttribute("action", merchantUrl); - form.appendChild(createFormHiddenInput("hppResponse", response)); + form.appendChild(internal.createFormHiddenInput("hppResponse", response)); document.body.appendChild(form); form.submit(); } + }; + } + }; + + // Initialising some variables used throughout this file. + var RxpLightbox = (function () { + var instance; + + function init() { + var overlayElement; + var spinner; + var iFrame; + var closeButton; + var token; + var isLandscape = internal.checkDevicesOrientation(); + + if (isMobileIFrame) { + if (window.addEventListener) { + window.addEventListener("orientationchange", function () { + isLandscape = internal.checkDevicesOrientation(); + }, false); + } + } + + return { + lightbox: function () { + if (isMobileNewTab) { + tabWindow = internal.openWindow(token); + } else { + overlayElement = internal.createOverlay(); + var temp = internal.createIFrame(overlayElement, token); + spinner = temp.spinner; + iFrame = temp.iFrame; + closeButton = temp.closeButton; + } + }, + close: function () { + internal.closeModal(); + }, + setToken: function (hppToken) { + token = hppToken; + } + }; + } + + 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; + }, + init: function (idOfLightboxButton, merchantUrl, serverSdkJson) { + //Get the lightbox instance (it's a singleton) and set the sdk json + var lightboxInstance = RxpLightbox.getInstance(serverSdkJson); + + // Sets the event listener on the PAY button. The click will invoke the lightbox method + if (document.getElementById(idOfLightboxButton).addEventListener) { + document.getElementById(idOfLightboxButton).addEventListener("click", lightboxInstance.lightbox, true); + } else { + document.getElementById(idOfLightboxButton).attachEvent('onclick', lightboxInstance.lightbox); + } + + if (window.addEventListener) { + window.addEventListener("message", internal.receiveMessage(lightboxInstance, merchantUrl), false); + } else { + window.attachEvent('message', internal.receiveMessage(lightboxInstance, merchantUrl)); + } } + }; + })(); + + // Initialising some variables used throughout this file. + var RxpEmbedded = (function () { + var instance; + + function init() { + var overlayElement; + var spinner; + var iFrame; + var closeButton; + var token; + + return { + embedded: function () { + var form = internal.createForm(document, token); + if (iFrame) { + if (iFrame.contentWindow.document.body) { + iFrame.contentWindow.document.body.appendChild(form); + } else { + iFrame.contentWindow.document.appendChild(form); + } + form.submit(); + iFrame.style.display = "inherit"; + } + }, + close: function () { + iFrame.style.display = "none"; + }, + setToken: function (hppToken) { + token = hppToken; + }, + setIframe: function (iframeId) { + iFrame = document.getElementById(iframeId); + }, + getIframe: function () { + return iFrame; + } + }; } - if (window.addEventListener) { - window.addEventListener("message", receiveMessage, false); - } else { - window.attachEvent('message', receiveMessage); + 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; + }, + init: function (idOfEmbeddedButton, idOfTargetIframe, merchantUrl, serverSdkJson) { + //Get the embedded instance (it's a singleton) and set the sdk json + var embeddedInstance = RxpEmbedded.getInstance(serverSdkJson); + + embeddedInstance.setIframe(idOfTargetIframe); + + // Sets the event listener on the PAY button. The click will invoke the embedded method + if (document.getElementById(idOfEmbeddedButton).addEventListener) { + document.getElementById(idOfEmbeddedButton).addEventListener("click", embeddedInstance.embedded, true); + } else { + document.getElementById(idOfEmbeddedButton).attachEvent('onclick', embeddedInstance.embedded); + } + + if (window.addEventListener) { + window.addEventListener("message", internal.receiveMessage(embeddedInstance, merchantUrl, true), false); + } else { + window.attachEvent('message', internal.receiveMessage(embeddedInstance, merchantUrl, true)); + } + } + }; + })(); + + var RxpRedirect = (function () { + var instance; + + function init() { + var overlayElement; + var spinner; + var iFrame; + var closeButton; + var token; + var isLandscape = internal.checkDevicesOrientation(); + + if (isMobileIFrame) { + if (window.addEventListener) { + window.addEventListener("orientationchange", function () { + isLandscape = internal.checkDevicesOrientation(); + }, false); + } + } + + return { + redirect: function () { + var form = internal.createForm(document, token, true); + document.body.append(form); + form.submit(); + }, + setToken: function (hppToken) { + token = hppToken; + } + }; } + 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; + }, + init: function (idOfButton, merchantUrl, serverSdkJson) { + // Get the redirect instance (it's a singleton) and set the sdk json + var redirectInstance = RxpRedirect.getInstance(serverSdkJson); + redirectUrl = merchantUrl; + + // Sets the event listener on the PAY button. The click will invoke the redirect method + if (document.getElementById(idOfButton).addEventListener) { + document.getElementById(idOfButton).addEventListener("click", redirectInstance.redirect, true); + } else { + document.getElementById(idOfButton).attachEvent('onclick', redirectInstance.redirect); + } + + if (window.addEventListener) { + window.addEventListener("message", internal.receiveMessage(redirectInstance, merchantUrl), false); + } else { + window.attachEvent('message', internal.receiveMessage(redirectInstance, merchantUrl)); + } + } + }; + }()); + + // RealexHpp return { - init : lightboxInit, + init: RxpLightbox.init, lightbox: { - init: lightboxInit + init: RxpLightbox.init + }, + embedded: { + init: RxpEmbedded.init + }, + redirect: { + init: RxpRedirect.init }, - setHppUrl : setHppUrl + setHppUrl: setHppUrl, + _internal: internal }; }()); diff --git a/package.json b/package.json index 8eaaa4b..372cb49 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,16 @@ "node": ">= 0.10.0" }, "devDependencies": { + "chromedriver": "^2.31.0", + "geckodriver": "^1.8.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" + "grunt-contrib-watch": "^1.0.0", + "grunt-php": "^1.5.1", + "intern": "^3.4.6" }, "keywords": [], "scripts": { diff --git a/specs/functional/hpp/embedded-positives_spec.js b/specs/functional/hpp/embedded-positives_spec.js new file mode 100644 index 0000000..bbd9848 --- /dev/null +++ b/specs/functional/hpp/embedded-positives_spec.js @@ -0,0 +1,35 @@ +define(function (require) { + var bdd = require('intern!bdd'); + var assert = require('intern/chai!assert'); + var successHelper = require('intern/dojo/node!../../helpers/hpp').iframeSuccessHelper; + + bdd.describe('RealexRemote - HPP Embedded Positive Tests', function () { + bdd.it('should process a payment successfully', + successHelper( + // url + require.toUrl('http://localhost:8989/examples/hpp/process-a-payment-embedded.html'), + // iframe selector + '#targetIframe', + // fields to enter + [ + { name: 'pas_ccnum', type: 'text', value: '4111111111111111' }, + { name: 'pas_expiry', type: 'text', value: '1225' }, + { name: 'pas_cccvc', type: 'text', value: '012' }, + { name: 'pas_ccname', type: 'text', value: 'Jane Doe' }, + ], + // callback to assert against result + function (command) { + return command + .execute(() => document.body.innerText) + .then(function (text) { + // make our assertions on the HPP response + var json = JSON.parse(text); + json = JSON.parse(json.response); + assert.isOk(json.AUTHCODE); + }) + .end(); + } + ).bind(this) + ); + }); +}); diff --git a/specs/functional/hpp/lightbox-positives_spec.js b/specs/functional/hpp/lightbox-positives_spec.js new file mode 100644 index 0000000..8b73b47 --- /dev/null +++ b/specs/functional/hpp/lightbox-positives_spec.js @@ -0,0 +1,35 @@ +define(function (require) { + var bdd = require('intern!bdd'); + var assert = require('intern/chai!assert'); + var successHelper = require('intern/dojo/node!../../helpers/hpp').iframeSuccessHelper; + + bdd.describe('RealexRemote - HPP Lightbox Positive Tests', function () { + bdd.it('should process a payment successfully', + successHelper( + // url + require.toUrl('http://localhost:8989/examples/hpp/process-a-payment-lightbox.html'), + // iframe selector + '[id^="rxp-frame-"]', + // fields to enter + [ + { name: 'pas_ccnum', type: 'text', value: '4111111111111111' }, + { name: 'pas_expiry', type: 'text', value: '1225' }, + { name: 'pas_cccvc', type: 'text', value: '012' }, + { name: 'pas_ccname', type: 'text', value: 'Jane Doe' }, + ], + // callback to assert against result + function (command) { + return command + .execute(() => document.body.innerText) + .then(function (text) { + // make our assertions on the HPP response + var json = JSON.parse(text); + json = JSON.parse(json.response); + assert.isOk(json.AUTHCODE); + }) + .end(); + } + ).bind(this) + ); + }); +}); diff --git a/specs/functional/hpp/redirect-positives_spec.js b/specs/functional/hpp/redirect-positives_spec.js new file mode 100644 index 0000000..55a911c --- /dev/null +++ b/specs/functional/hpp/redirect-positives_spec.js @@ -0,0 +1,31 @@ +define(function (require) { + var bdd = require('intern!bdd'); + var assert = require('intern/chai!assert'); + var successHelper = require('intern/dojo/node!../../helpers/hpp').redirectSuccessHelper; + + bdd.describe('RealexRemote - HPP Redirect Positive Tests', function () { + bdd.it('should process a payment successfully', + successHelper( + // url + require.toUrl('http://localhost:8989/examples/hpp/redirect-for-payment.html'), + // fields to enter + [ + { name: 'pas_ccnum', type: 'text', value: '4111111111111111' }, + { name: 'pas_expiry', type: 'text', value: '1225' }, + { name: 'pas_cccvc', type: 'text', value: '012' }, + { name: 'pas_ccname', type: 'text', value: 'Jane Doe' }, + ], + // callback to assert against result + function (command) { + return command + .execute(() => document.body.innerText) + .then(function (text) { + // make our assertions on the HPP response + assert.isOk(text.indexOf('Your transaction has been successful') !== -1); + }) + .end(); + } + ).bind(this) + ); + }); +}); diff --git a/specs/helpers/hpp.js b/specs/helpers/hpp.js new file mode 100644 index 0000000..7f6b5f2 --- /dev/null +++ b/specs/helpers/hpp.js @@ -0,0 +1,142 @@ +/** + * Sets the current command/session to the desired URL. + * + * Require's the desired URL to add a `loaded` class to the + * body on load complete. + * + * @param {leadfoot/Command} command + * @param {string} url + */ +function loadUrlAndWait(command, url) { + return command + // navigate to our test page + .get(url) + .setFindTimeout(5000) + // wait until the HPP request producer finishes + .findByCssSelector('body.loaded'); +} + +/** + * Sets a page's field base on the defined field type. + * + * @param {leadfoot/Command} command + * @param {object} field + */ +function setField(command, field) { + switch (field.type) { + case 'text': + default: + return command + .findById(field.name) + .click() + .type(field.value) + .end(); + } +} + +/** + * Set's the given fields. Will call `callback` + * with the command/session to complete any assertions. + * + * @param {leadfoot/Command} command + * @param {object[]} fields + * @param {Function} callback + */ +function setFieldsAndSubmit(command, fields, callback) { + // start - enter form data + for (var i = 0; i < fields.length; i++) { + command = setField(command, fields[i]); + } + // end - enter form data + + command = command + // submit HPP + .findById('rxp-primary-btn') + .click() + .end() + // wait for redirect to HPP response consumer + // TODO: figure out a way to do this without `sleep` + .sleep(1500); + return callback(command); +} + +/** + * Focuses a frame and set's the given fields. Will call `callback` + * with the command/session to complete any assertions. + * + * @param {leadfoot/Command} command + * @param {object[]} fields + * @param {Function} callback + */ +function setFrameFieldsAndSubmit(command, fields, callback) { + return function (iframe) { + // focus to the iframe + command = command.switchToFrame(iframe); + + // start - enter form data + for (var i = 0; i < fields.length; i++) { + command = setField(command, fields[i]); + } + // end - enter form data + + command = command + // submit HPP + .findById('rxp-primary-btn') + .click() + .end() + // wait for redirect to HPP response consumer + // TODO: figure out a way to do this without `sleep` + .sleep(1500) + // ensure we're targeting the parent and not a non-existing iframe + .switchToParentFrame(); + return callback(command); + }; +} + +/** + * Completes an HPP lightbox with the given fields. Will call `callback` + * with the command/session to complete any assertions. + * + * @param {string} url + * @param {object[]} fields + * @param {Function} callback + */ +function iframeSuccessHelper(url, iframeSelector, fields, callback) { + return function () { + var command = this.remote; + return loadUrlAndWait(command, url) + // start HPP + .findById('payButtonId') + .click() + .end() + // find the first iframe with an id that starts with our identifier + .findByCssSelector(iframeSelector) + .then(setFrameFieldsAndSubmit(command, fields, callback)) + .end(); + }; +} + +/** + * Completes an HPP redirect with the given fields. Will call `callback` + * with the command/session to complete any assertions. + * + * @param {string} url + * @param {object[]} fields + * @param {Function} callback + */ +function redirectSuccessHelper(url, fields, callback) { + return function () { + var command = this.remote; + return loadUrlAndWait(command, url) + // start HPP + .findById('payButtonId') + .click() + .end() + .then(() => setFieldsAndSubmit(command, fields, callback)); + }; +} + +module.exports = { + iframeSuccessHelper: iframeSuccessHelper, + redirectSuccessHelper: redirectSuccessHelper, +}; diff --git a/specs/intern.config.js b/specs/intern.config.js new file mode 100644 index 0000000..2f3d774 --- /dev/null +++ b/specs/intern.config.js @@ -0,0 +1,30 @@ +// Learn more about configuring this file at . +// These default settings work OK for most people. The options that *must* be changed below are the +// packages, suites, excludeInstrumentation, and (if you want functional tests) functionalSuites. +define({ + // Browsers to run integration testing against. Options that will be permutated are browserName, version, platform, + // and platformVersion; any other capabilities options specified for an environment will be copied as-is. Note that + // browser and platform names, and version number formats, may differ between cloud testing systems. + environments: [ + { + browserName: 'chrome', + // Run headless when possible + // Comment below line when using `leaveRemoteOpen: true` + chromeOptions: { args: ['headless', 'disable-gpu'], }, fixSessionCapabilities: false, + }, + ], + + // Uncomment to keep browser automation session open to inspect results of tests + // leaveRemoteOpen: true, + + // Name of the tunnel class to use for WebDriver tests. + // See for built-in options + tunnel: 'SeleniumTunnel', + + // Unit test suite(s) to run in each browser + functionalSuites: [ 'specs/functional/**/*_spec.js' ], + + // A regular expression matching URLs to files that should not be included in code coverage analysis. Set to `true` + // to completely disable code coverage. + excludeInstrumentation: true +}); diff --git a/specs/unit/rxp-hpp_spec.js b/specs/unit/rxp-hpp_spec.js new file mode 100644 index 0000000..acea304 --- /dev/null +++ b/specs/unit/rxp-hpp_spec.js @@ -0,0 +1,178 @@ +/* + * Unit tests for rxp-hpp.js + */ +describe('rxp-hpp library', function () { + /* + * Unit tests for createFormHiddenInput + */ + describe('form input creation (createFormHiddenInput)', function () { + it('creates element', function () { + var field = RealexHpp._internal.createFormHiddenInput("name", "value"); + expect(field).not.toBe(null); + expect(field.name).toBe("name"); + expect(field.value).toBe("value"); + }); + + it('empty name', function () { + var field = RealexHpp._internal.createFormHiddenInput("", "value"); + expect(field).not.toBe(null); + expect(field.name).toBe(""); + expect(field.value).toBe("value"); + }); + + it('empty value', function () { + var field = RealexHpp._internal.createFormHiddenInput("name", ""); + expect(field).not.toBe(null); + expect(field.name).toBe("name"); + expect(field.value).toBe(""); + }); + + it('empty name and value', function () { + var field = RealexHpp._internal.createFormHiddenInput("", ""); + expect(field).not.toBe(null); + expect(field.name).toBe(""); + expect(field.value).toBe(""); + }); + }); + + /* + * Unit tests for checkDevicesOrientation + */ + describe('device orientation (checkDevicesOrientation)', function () { + it('0', function () { + window.orientation = 0; + var orientation = RealexHpp._internal.checkDevicesOrientation(); + expect(orientation).toBe(false); + }); + + it('90', function () { + window.orientation = 90; + var orientation = RealexHpp._internal.checkDevicesOrientation(); + expect(orientation).toBe(true); + }); + + it('180', function () { + window.orientation = 180; + var orientation = RealexHpp._internal.checkDevicesOrientation(); + expect(orientation).toBe(false); + }); + + it('-90', function () { + window.orientation = -90; + var orientation = RealexHpp._internal.checkDevicesOrientation(); + expect(orientation).toBe(true); + }); + }); + + /* + * Unit tests for createOverlay + */ + describe('lightbox overlay (createOverlay)', function () { + it('creates an overlay', function () { + var overlay = RealexHpp._internal.createOverlay(); + expect(overlay).not.toBe(null); + expect(overlay.getAttribute('id')).toMatch(/rxp\-overlay\-/); + + var injectedOverlay = document.getElementById(overlay.getAttribute('id')); + expect(overlay).toBe(injectedOverlay); + }); + }); + + /* + * Unit tests for createCloseButton + */ + describe('lightbox overlay close button (createCloseButton)', function () { + it('creates an overlay', function () { + var overlay = RealexHpp._internal.createOverlay(); + expect(overlay).not.toBe(null); + + var close = RealexHpp._internal.createCloseButton(overlay); + expect(close).not.toBe(null); + expect(close.getAttribute('id')).toMatch(/rxp\-frame\-close\-/); + }); + }); + + /* + * Unit tests for createForm + */ + describe('request form(createForm)', function () { + it('creates form with no extra data', function () { + var form = RealexHpp._internal.createForm(document, {}); + expect(form).not.toBe(null); + expect(form.children.length).toBe(3); + }); + + it('creates redirect form with no extra data', function () { + var form = RealexHpp._internal.createForm(document, {}, true); + expect(form).not.toBe(null); + expect(form.children.length).toBe(2); + }); + + it('creates form with extra data', function () { + var form = RealexHpp._internal.createForm(document, {NAME: 'value'}); + expect(form).not.toBe(null); + expect(form.children.length).toBe(4); + }); + + it('creates redirect form with extra data', function () { + var form = RealexHpp._internal.createForm(document, {NAME: 'value'}, true); + expect(form).not.toBe(null); + expect(form.children.length).toBe(3); + }); + }); + + /* + * Unit tests for createSpinner + */ + describe('lightbox load indicator (createSpinner)', function () { + it('creates an image', function () { + var spinner = RealexHpp._internal.createSpinner(); + expect(spinner).not.toBe(null); + expect(spinner.getAttribute('id')).toMatch(/rxp\-loader\-/); + }); + }); + + /* + * Unit tests for getUrlParser + */ + describe('url parsing (getUrlParser)', function () { + var testUrl = 'http://hostname.com/path?query=true'; + + it('parses url', function () { + var url = RealexHpp._internal.getUrlParser(testUrl); + expect(url).not.toBe(null); + expect(url.hostname).toBe('hostname.com'); + expect(url.pathname).toBe('/path'); + }); + }); + + /* + * Unit tests for getHostnameFromUrl + */ + describe('url parsing (getHostnameFromUrl)', function () { + var testUrl = 'http://hostname.com/path?query=true'; + + it('parses hostname', function () { + var host = RealexHpp._internal.getHostnameFromUrl(testUrl); + expect(host).toBe('hostname.com'); + }); + }); + + + /* + * Unit tests for getHostnameFromUrl + */ + describe('url parsing (getHostnameFromUrl)', function () { + var testUrl = 'http://hostname.com/path?query=true'; + + it('same host returns true', function () { + var host = RealexHpp._internal.isMessageFromHpp(testUrl, testUrl); + expect(host).toBe(true); + }); + + it('different hosts return false', function () { + var host = RealexHpp._internal.isMessageFromHpp(testUrl, '#'); + expect(host).toBe(false); + }); + }); +}); diff --git a/specs/rxp-remote_spec.js b/specs/unit/rxp-remote_spec.js similarity index 100% rename from specs/rxp-remote_spec.js rename to specs/unit/rxp-remote_spec.js