From 48e11d9571809ed4a37416cf8dbe2b5dc275ca7d Mon Sep 17 00:00:00 2001 From: danielaguado Date: Fri, 24 Jul 2015 16:06:18 +0100 Subject: [PATCH 1/5] First commit of the JS SDK library --- .gitignore | 1 + .jshintrc | 14 +++ Gruntfile.js | 70 +++++++++++ LICENSE-MIT | 22 ++++ dist/rxp-js.js | 294 ++++++++++++++++++++++++++++++++++++++++++++ dist/rxp-js.min.js | 4 + lib/.jshintrc | 13 ++ lib/rxp-js.js | 298 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 36 ++++++ 9 files changed, 752 insertions(+) create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 Gruntfile.js create mode 100644 LICENSE-MIT create mode 100644 dist/rxp-js.js create mode 100644 dist/rxp-js.min.js create mode 100644 lib/.jshintrc create mode 100644 lib/rxp-js.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ccbe46 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..8c86fc7 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,14 @@ +{ + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "unused": true, + "boss": true, + "eqnull": true, + "node": true +} diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..c4198e3 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,70 @@ +'use strict'; + +module.exports = function(grunt) { + + // Project configuration. + grunt.initConfig({ + // Metadata. + pkg: grunt.file.readJSON('package.json'), + banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + + '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n', + // Task configuration. + concat: { + options: { + banner: '<%= banner %>', + stripBanners: true + }, + dist: { + src: ['lib/<%= pkg.name %>.js'], + dest: 'dist/<%= pkg.name %>.js' + }, + }, + uglify: { + options: { + banner: '<%= banner %>' + }, + dist: { + src: '<%= concat.dist.dest %>', + dest: 'dist/<%= pkg.name %>.min.js' + }, + }, + jshint: { + options: { + jshintrc: '.jshintrc' + }, + gruntfile: { + src: 'Gruntfile.js' + }, + lib: { + options: { + jshintrc: 'lib/.jshintrc' + }, + src: ['lib/**/*.js'] + } + }, + watch: { + gruntfile: { + files: '<%= jshint.gruntfile.src %>', + tasks: ['jshint:gruntfile'] + }, + lib: { + files: '<%= jshint.lib.src %>', + tasks: ['jshint:lib', 'nodeunit'] + } + }, + }); + + // These plugins provide necessary tasks. + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-nodeunit'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-watch'); + + // Default task. + grunt.registerTask('default', ['jshint', 'concat', 'uglify']); + +}; diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..a6632e9 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,22 @@ +Copyright (c) 2015 Realex Developer + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/dist/rxp-js.js b/dist/rxp-js.js new file mode 100644 index 0000000..768dcaa --- /dev/null +++ b/dist/rxp-js.js @@ -0,0 +1,294 @@ +/*! rxp-js - v0.1.0 - 2015-07-24 +* https://github.com/realexpayments-developers/rxp-js +* Copyright (c) 2015 Realex Developer; Licensed MIT */ +/*jslint browser:true */ +var RealexHpp = (function() { + + 'use strict'; + + var hppUrl = "https://hpp.realexpayments.com/pay"; + + var setHppUrl = function(url) { + hppUrl = url; + }; + + // Initialising some variables used throughout this file. + var RxpLightbox = (function() { + + var instance; + + function init() { + var overlayElement; + var spinner; + var iFrame; + var closeButton; + var whiteBg; + + var token; + + var randomId = randomId || Math.random().toString(16).substr(2,8); + + // 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"; + + document.body.appendChild(overlay); + + setTimeout(function() { + overlay.style.background="rgba(0, 0, 0, 0.7)"; + }, 1); + + overlayElement = overlay; + } + + + function createCloseButton(){ + closeButton = document.createElement("img"); + closeButton.setAttribute("id","rxp-frame-close-" + randomId); + closeButton.setAttribute("src", "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prY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fl/jNJUik8Duzs/XmW9mN7Xb7VRc5vP5zWKxaK5Wq8Zmu72FqobfJG0YQ9M0+/l8/qFQKDzGY1JxENd1288vLy1s786KRZXJZCLber1Wn7MZt4PLarVnWdZ9AmQ8Hncc17UvymVdBMB/MgPQm+cFFcuy6/V6lzqDf57ntWGwYdBIVx0TfkBD6I9M35iRJgfIoAVjBLDZbA4CiJ5+9AdQi/EahibqDTkQx6fRSIHcPwA8Uy9A9Gcc47Xv+w2wzhRDYzqdVihLIbsIiCvP1NNOoX/29FQx3vgOgtt4FyRdCgPRarX4+goB9vkyAMh443cOEsIAAcjncuoI4TXWMAmCIGFhCQLAdZ8jym/cRJ+Y5nC5XCYAhINKpZLgSISZgoqh5iiLQrojAFICVwGS7tCfe5DbZzkP56XS4NVxwvTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="); + closeButton.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 135px; z-index: 99999999; top: 65px;"); + + setTimeout(function(){ + closeButton.style.opacity = "1"; + },500); + + closeButton.addEventListener("click", closeModal, true); + overlayElement.appendChild(closeButton); + } + + function createWhiteBg() { + whiteBg = document.createElement("div"); + whiteBg.setAttribute("id", "rxp-white-bg-" + randomId); + whiteBg.style.position="absolute"; + whiteBg.style.width="360px"; + whiteBg.style.height="480px"; + whiteBg.style.backgroundColor="#ffffff"; + whiteBg.style.left="50%"; + whiteBg.style.marginLeft="-180px"; + whiteBg.style.zIndex="101"; + + overlayElement.appendChild(whiteBg); + } + + function createIFrame() { + + //Create the spinner + spinner = document.createElement("img"); + spinner.setAttribute("src", "data:image/gif;base64,R0lGODlhHAAcAPYAAP////OQHv338fzw4frfwPjIkP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I1HMZAALgJIAg8KGDwKGlinAEkKLoU1Tnt1BABVAtOEKb4PBhIMR4c+cU5OaymILiYlCwtHmIcxQU4fjAYMDFjdiApQSGBU5QgGRjOmEFgQCUMKZf8AKLgBAgiZNvkaURkSo8aUI+wAYJDSYcyONloibexIoYQwQS6oEPgxpOGMXPQOPdjCMFESCgcZHdFiYUROQ0dChCgRkRCFOg4cRMCCiIcGAjhCUDgq6AiHDhWyxShAhJACKFweJJHAAgoFQ1dfrAwQlKRMhAwpfnCZMkXEihqCHmAwUIXRkAgRoLiQgsIHABsrVDRl1OPMDQAPZIzAAcAEjRVzOT2gI+XTjREMBF0RUZMThhyyAGyYYGCQhtaoCJVQMjk3ISQafAtHFAgAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iGD4mMh1UCjYkNXlWDSQKVgo+Rgkl3HZkCSEmdMwqcgnNOWoI8SDwAD0VFSKgAP05ONgACPLApKUUujAsesABIek46CkmuAjNFp4IPPIuEQ3p2dDgAJBEmhdAuLikDGljDhTY6OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+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.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"); + + iFrame.style.top="40px"; + iFrame.style.left="50%"; + iFrame.style.marginLeft="-180px"; + 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); + + iFrame.onload = function() { + iFrame.style.opacity="1"; + iFrame.style.transform="scale(1)"; + + if (spinner.parentNode) { + spinner.parentNode.removeChild(spinner); + } + createCloseButton(); + setTimeout(function(){ + createWhiteBg(); + },500); + }; + + var form = document.createElement("form"); + form.setAttribute("method", "POST"); + form.setAttribute("action", hppUrl); + + for ( var key in token) { + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("type", "hidden"); + hiddenField.setAttribute("name", key); + hiddenField.setAttribute("value", token[key]); + + form.appendChild(hiddenField); + } + + var hppTemplateType = document.createElement("input"); + hppTemplateType.setAttribute("type", "hidden"); + hppTemplateType.setAttribute("name", "HPP_TEMPLATE_TYPE"); + hppTemplateType.setAttribute("value", "LIGHTBOX"); + + form.appendChild(hppTemplateType); + + var parser = document.createElement('a'); + parser.href = window.location.href; + var hppOriginParam = parser.protocol + '//' + parser.host; + + var hppOrigin = document.createElement("input"); + hppOrigin.setAttribute("type", "hidden"); + hppOrigin.setAttribute("name", "HPP_ORIGIN"); + hppOrigin.setAttribute("value", hppOriginParam); + + form.appendChild(hppOrigin); + + if (iFrame.contentWindow.document.body) { + iFrame.contentWindow.document.body.appendChild(form); + } else { + iFrame.contentWindow.document.appendChild(form); + } + + form.submit(); + + } + + function closeModal() { + + if (closeButton.parentNode) { + closeButton.parentNode.removeChild(closeButton); + } + + if (iFrame.parentNode) { + iFrame.parentNode.removeChild(iFrame); + } + + if (whiteBg.parentNode) { + whiteBg.parentNode.removeChild(whiteBg); + } + + if (spinner.parentNode) { + spinner.parentNode.removeChild(spinner); + } + + overlayElement.className = ""; + setTimeout(function() { + if (overlayElement.parentNode) { + overlayElement.parentNode.removeChild(overlayElement); + } + }, 300); + } + + return { + lightbox : function() { + createOverlay(); + createIFrame(); + }, + close : function() { + 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; + } + }; + + })(); + + + var 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); + } + + function receiveMessage(event) { + + //Check the origin of the response comes from HPP + if (getHostnameFromUrl(event.origin) === getHostnameFromUrl(hppUrl)) { + + //Close the lightbox + lightboxInstance.close(); + + var response = event.data; + + //Create a form and submit the hpp response to the merchant's response url + var form = document.createElement("form"); + form.setAttribute("method", "POST"); + form.setAttribute("action", merchantUrl); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("type", "hidden"); + hiddenField.setAttribute("name", "hppResponse"); + hiddenField.setAttribute("value", response); + + form.appendChild(hiddenField); + + document.body.appendChild(form); + + form.submit(); + } + } + + if (window.addEventListener) { + window.addEventListener("message", receiveMessage, false); + } else { + window.attachEvent('message', receiveMessage); + } + + }; + + function getHostnameFromUrl(url) { + var parser = document.createElement('a'); + parser.href = url; + return parser.hostname; + } + + return { + init : init, + setHppUrl : setHppUrl + }; + +}()); diff --git a/dist/rxp-js.min.js b/dist/rxp-js.min.js new file mode 100644 index 0000000..95be37b --- /dev/null +++ b/dist/rxp-js.min.js @@ -0,0 +1,4 @@ +/*! rxp-js - v0.1.0 - 2015-07-24 +* https://github.com/realexpayments-developers/rxp-js +* Copyright (c) 2015 Realex Developer; Licensed MIT */ +var RealexHpp=function(){"use strict";function a(a){var b=document.createElement("a");return b.href=a,b.hostname}var b="https://hpp.realexpayments.com/pay",c=function(a){b=a},d=function(){function a(){function a(){var a=document.createElement("div");a.setAttribute("id","rxp-overlay-"+m),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",document.body.appendChild(a),setTimeout(function(){a.style.background="rgba(0, 0, 0, 0.7)"},1),g=a}function c(){j=document.createElement("img"),j.setAttribute("id","rxp-frame-close-"+m),j.setAttribute("src","data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLm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INKpZLgSISZgoqh5iiLQrojAFICVwGS7tCfe5DbZzkP56XS4NVxwvTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="),j.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 135px; z-index: 99999999; top: 65px;"),setTimeout(function(){j.style.opacity="1"},500),j.addEventListener("click",f,!0),g.appendChild(j)}function d(){k=document.createElement("div"),k.setAttribute("id","rxp-white-bg-"+m),k.style.position="absolute",k.style.width="360px",k.style.height="480px",k.style.backgroundColor="#ffffff",k.style.left="50%",k.style.marginLeft="-180px",k.style.zIndex="101",g.appendChild(k)}function e(){h=document.createElement("img"),h.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/hpDcmVhdG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ABIek46CkmuAjNFp4IPPIuEQ3p2dDgAJBEmhdAuLikDGljDhTY6OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+EaVUmSJJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"),h.setAttribute("id","rxp-loader-"+m),h.style.left="50%",h.style.position="fixed",h.style.background="#FFFFFF",h.style.borderRadius="50%",h.style.width="30px",h.style.marginLeft="-15px",h.style.zIndex="200",h.style.marginLeft="-15px",h.style.top="120px",document.body.appendChild(h),i=document.createElement("iframe"),i.setAttribute("name","rxp-frame-"+m),i.setAttribute("id","rxp-frame-"+m),i.setAttribute("height","85%"),i.setAttribute("frameBorder","0"),i.setAttribute("width","360px"),i.setAttribute("seamless","seamless"),i.style.top="40px",i.style.left="50%",i.style.marginLeft="-180px",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",g.appendChild(i),i.onload=function(){i.style.opacity="1",i.style.transform="scale(1)",h.parentNode&&h.parentNode.removeChild(h),c(),setTimeout(function(){d()},500)};var a=document.createElement("form");a.setAttribute("method","POST"),a.setAttribute("action",b);for(var e in l){var f=document.createElement("input");f.setAttribute("type","hidden"),f.setAttribute("name",e),f.setAttribute("value",l[e]),a.appendChild(f)}var j=document.createElement("input");j.setAttribute("type","hidden"),j.setAttribute("name","HPP_TEMPLATE_TYPE"),j.setAttribute("value","LIGHTBOX"),a.appendChild(j);var k=document.createElement("a");k.href=window.location.href;var n=k.protocol+"//"+k.host,o=document.createElement("input");o.setAttribute("type","hidden"),o.setAttribute("name","HPP_ORIGIN"),o.setAttribute("value",n),a.appendChild(o),i.contentWindow.document.body?i.contentWindow.document.body.appendChild(a):i.contentWindow.document.appendChild(a),a.submit()}function f(){j.parentNode&&j.parentNode.removeChild(j),i.parentNode&&i.parentNode.removeChild(i),k.parentNode&&k.parentNode.removeChild(k),h.parentNode&&h.parentNode.removeChild(h),g.className="",setTimeout(function(){g.parentNode&&g.parentNode.removeChild(g)},300)}var g,h,i,j,k,l,m=m||Math.random().toString(16).substr(2,8);return{lightbox:function(){a(),e()},close:function(){f()},setToken:function(a){l=a}}}var c;return{getInstance:function(b){return c||(c=a()),c.setToken(b),c}}}(),e=function(c,e,f){function g(c){if(a(c.origin)===a(b)){h.close();var d=c.data,f=document.createElement("form");f.setAttribute("method","POST"),f.setAttribute("action",e);var g=document.createElement("input");g.setAttribute("type","hidden"),g.setAttribute("name","hppResponse"),g.setAttribute("value",d),f.appendChild(g),document.body.appendChild(f),f.submit()}}var h=d.getInstance(f);document.getElementById(c).addEventListener?document.getElementById(c).addEventListener("click",h.lightbox,!0):document.getElementById(c).attachEvent("onclick",h.lightbox),window.addEventListener?window.addEventListener("message",g,!1):window.attachEvent("message",g)};return{init:e,setHppUrl:c}}(); \ No newline at end of file diff --git a/lib/.jshintrc b/lib/.jshintrc new file mode 100644 index 0000000..9ed4773 --- /dev/null +++ b/lib/.jshintrc @@ -0,0 +1,13 @@ +{ + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "boss": true, + "eqnull": true, + "predef": ["exports"] +} diff --git a/lib/rxp-js.js b/lib/rxp-js.js new file mode 100644 index 0000000..f11d585 --- /dev/null +++ b/lib/rxp-js.js @@ -0,0 +1,298 @@ +/* + * rxp-js + * https://github.com/realexpayments-developers/rxp-js + * + * Copyright (c) 2015 Realex Developer + * Licensed under the MIT license. + */ +/*jslint browser:true */ +var RealexHpp = (function() { + + 'use strict'; + + var hppUrl = "https://hpp.realexpayments.com/pay"; + + var setHppUrl = function(url) { + hppUrl = url; + }; + + // Initialising some variables used throughout this file. + var RxpLightbox = (function() { + + var instance; + + function init() { + var overlayElement; + var spinner; + var iFrame; + var closeButton; + var whiteBg; + + var token; + + var randomId = randomId || Math.random().toString(16).substr(2,8); + + // 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"; + + document.body.appendChild(overlay); + + setTimeout(function() { + overlay.style.background="rgba(0, 0, 0, 0.7)"; + }, 1); + + overlayElement = overlay; + } + + + function createCloseButton(){ + closeButton = document.createElement("img"); + closeButton.setAttribute("id","rxp-frame-close-" + randomId); + closeButton.setAttribute("src", "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8x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MAmCIGFhCQLAdZ8jym/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: 135px; z-index: 99999999; top: 65px;"); + + setTimeout(function(){ + closeButton.style.opacity = "1"; + },500); + + closeButton.addEventListener("click", closeModal, true); + overlayElement.appendChild(closeButton); + } + + function createWhiteBg() { + whiteBg = document.createElement("div"); + whiteBg.setAttribute("id", "rxp-white-bg-" + randomId); + whiteBg.style.position="absolute"; + whiteBg.style.width="360px"; + whiteBg.style.height="480px"; + whiteBg.style.backgroundColor="#ffffff"; + whiteBg.style.left="50%"; + whiteBg.style.marginLeft="-180px"; + whiteBg.style.zIndex="101"; + + overlayElement.appendChild(whiteBg); + } + + 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/nQovnSpfax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TjREMBF0RUZMThhyyAGyYYGCQhtaoCJVQMjk3ISQafAtHFAgAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iGD4mMh1UCjYkNXlWDSQKVgo+Rgkl3HZkCSEmdMwqcgnNOWoI8SDwAD0VFSKgAP05ONgACPLApKUUujAsesABIek46CkmuAjNFp4IPPIuEQ3p2dDgAJBEmhdAuLikDGljDhTY6OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+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.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"); + + iFrame.style.top="40px"; + iFrame.style.left="50%"; + iFrame.style.marginLeft="-180px"; + 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); + + iFrame.onload = function() { + iFrame.style.opacity="1"; + iFrame.style.transform="scale(1)"; + + if (spinner.parentNode) { + spinner.parentNode.removeChild(spinner); + } + createCloseButton(); + setTimeout(function(){ + createWhiteBg(); + },500); + }; + + var form = document.createElement("form"); + form.setAttribute("method", "POST"); + form.setAttribute("action", hppUrl); + + for ( var key in token) { + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("type", "hidden"); + hiddenField.setAttribute("name", key); + hiddenField.setAttribute("value", token[key]); + + form.appendChild(hiddenField); + } + + var hppTemplateType = document.createElement("input"); + hppTemplateType.setAttribute("type", "hidden"); + hppTemplateType.setAttribute("name", "HPP_TEMPLATE_TYPE"); + hppTemplateType.setAttribute("value", "LIGHTBOX"); + + form.appendChild(hppTemplateType); + + var parser = document.createElement('a'); + parser.href = window.location.href; + var hppOriginParam = parser.protocol + '//' + parser.host; + + var hppOrigin = document.createElement("input"); + hppOrigin.setAttribute("type", "hidden"); + hppOrigin.setAttribute("name", "HPP_ORIGIN"); + hppOrigin.setAttribute("value", hppOriginParam); + + form.appendChild(hppOrigin); + + if (iFrame.contentWindow.document.body) { + iFrame.contentWindow.document.body.appendChild(form); + } else { + iFrame.contentWindow.document.appendChild(form); + } + + form.submit(); + + } + + function closeModal() { + + if (closeButton.parentNode) { + closeButton.parentNode.removeChild(closeButton); + } + + if (iFrame.parentNode) { + iFrame.parentNode.removeChild(iFrame); + } + + if (whiteBg.parentNode) { + whiteBg.parentNode.removeChild(whiteBg); + } + + if (spinner.parentNode) { + spinner.parentNode.removeChild(spinner); + } + + overlayElement.className = ""; + setTimeout(function() { + if (overlayElement.parentNode) { + overlayElement.parentNode.removeChild(overlayElement); + } + }, 300); + } + + return { + lightbox : function() { + createOverlay(); + createIFrame(); + }, + close : function() { + 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; + } + }; + + })(); + + + var 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); + } + + function receiveMessage(event) { + + //Check the origin of the response comes from HPP + if (getHostnameFromUrl(event.origin) === getHostnameFromUrl(hppUrl)) { + + //Close the lightbox + lightboxInstance.close(); + + var response = event.data; + + //Create a form and submit the hpp response to the merchant's response url + var form = document.createElement("form"); + form.setAttribute("method", "POST"); + form.setAttribute("action", merchantUrl); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("type", "hidden"); + hiddenField.setAttribute("name", "hppResponse"); + hiddenField.setAttribute("value", response); + + form.appendChild(hiddenField); + + document.body.appendChild(form); + + form.submit(); + } + } + + if (window.addEventListener) { + window.addEventListener("message", receiveMessage, false); + } else { + window.attachEvent('message', receiveMessage); + } + + }; + + function getHostnameFromUrl(url) { + var parser = document.createElement('a'); + parser.href = url; + return parser.hostname; + } + + return { + init : init, + setHppUrl : setHppUrl + }; + +}()); diff --git a/package.json b/package.json new file mode 100644 index 0000000..0e59266 --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "rxp-js", + "description": "The official Realex Payments JS SDK", + "version": "0.1.0", + "homepage": "https://github.com/realexpayments-developers/rxp-js", + "author": { + "name": "Realex Developer", + "url": "http://www.realexpayments.ie/" + }, + "repository": { + "type": "git", + "url": "https://github.com/realexpayments-developers/rxp-js" + }, + "bugs": { + "url": "https://github.com/realexpayments-developers/rxp-js/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/realexpayments-developers/rxp-js/blob/master/LICENSE-MIT" + } + ], + "main": "lib/rxp-js", + "engines": { + "node": ">= 0.10.0" + }, + "devDependencies": { + "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-uglify": "~0.2.0", + "grunt-contrib-jshint": "~0.6.0", + "grunt-contrib-nodeunit": "~0.2.0", + "grunt-contrib-watch": "~0.4.0", + "grunt": "~0.4.5" + }, + "keywords": [] +} \ No newline at end of file From f1560af3e7f94bc01f09de121798c73538660cd0 Mon Sep 17 00:00:00 2001 From: Mark Stanford Date: Wed, 29 Jul 2015 11:05:03 +0100 Subject: [PATCH 2/5] ATP-106 - Client side remote JS SDK initial commit --- Gruntfile.js | 133 ++++++++++--------- dist/rxp-js.js | 158 +++++++++++++++++++++- dist/rxp-js.min.js | 10 +- lib/{rxp-js.js => rxp-hpp.js} | 2 +- lib/rxp-remote.js | 155 ++++++++++++++++++++++ package.json | 23 ++-- specs/rxp-remote_spec.js | 240 ++++++++++++++++++++++++++++++++++ 7 files changed, 639 insertions(+), 82 deletions(-) rename lib/{rxp-js.js => rxp-hpp.js} (99%) create mode 100644 lib/rxp-remote.js create mode 100644 specs/rxp-remote_spec.js diff --git a/Gruntfile.js b/Gruntfile.js index c4198e3..a00c27b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,69 +2,80 @@ module.exports = function(grunt) { - // Project configuration. - grunt.initConfig({ - // Metadata. - pkg: grunt.file.readJSON('package.json'), - banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + - '<%= grunt.template.today("yyyy-mm-dd") %>\n' + - '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + - '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + - ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n', - // Task configuration. - concat: { - options: { - banner: '<%= banner %>', - stripBanners: true - }, - dist: { - src: ['lib/<%= pkg.name %>.js'], - dest: 'dist/<%= pkg.name %>.js' - }, - }, - uglify: { - options: { - banner: '<%= banner %>' - }, - dist: { - src: '<%= concat.dist.dest %>', - dest: 'dist/<%= pkg.name %>.min.js' - }, - }, - jshint: { - options: { - jshintrc: '.jshintrc' - }, - gruntfile: { - src: 'Gruntfile.js' - }, - lib: { - options: { - jshintrc: 'lib/.jshintrc' + // Project configuration. + grunt.initConfig({ + // Metadata. + pkg: grunt.file.readJSON('package.json'), + banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>' + + '\n * <%= pkg.description %>' + + '<%= pkg.homepage ? "\\n * " + pkg.homepage : "" %>' + + '\n * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>' + + '\n */\n', + // Task configuration. + concat: { + options: { + banner: '<%= banner %>', + stripBanners: true + }, + dist: { + src: ['lib/*.js'], + dest: 'dist/<%= pkg.name %>.js' + }, }, - src: ['lib/**/*.js'] - } - }, - watch: { - gruntfile: { - files: '<%= jshint.gruntfile.src %>', - tasks: ['jshint:gruntfile'] - }, - lib: { - files: '<%= jshint.lib.src %>', - tasks: ['jshint:lib', 'nodeunit'] - } - }, - }); + uglify: { + options: { + banner: '<%= banner %>' + }, + dist: { + src: '<%= concat.dist.dest %>', + dest: 'dist/<%= pkg.name %>.min.js' + }, + }, + jshint: { + options: { + jshintrc: '.jshintrc' + }, + gruntfile: { + src: 'Gruntfile.js' + }, + lib: { + options: { + jshintrc: 'lib/.jshintrc' + }, + src: ['lib/**/*.js'] + } + }, + watch: { + gruntfile: { + files: '<%= jshint.gruntfile.src %>', + tasks: ['jshint:gruntfile'] + }, + lib: { + files: '<%= jshint.lib.src %>', + tasks: ['jshint:lib', 'jasmine'] + }, + specs: { + files: 'specs/*.js', + tasks: ['jasmine'] + } + }, + jasmine : { + src : 'lib/*.js', + options: { + specs: 'specs/*spec.js', + helpers: 'specs/*helper.js' + } + } + }); - // These plugins provide necessary tasks. - grunt.loadNpmTasks('grunt-contrib-concat'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-nodeunit'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-watch'); + // These plugins provide necessary tasks. + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-jasmine'); - // Default task. - grunt.registerTask('default', ['jshint', 'concat', 'uglify']); + // Default task. + grunt.registerTask('default', ['jshint', 'jasmine', 'concat', 'uglify']); }; diff --git a/dist/rxp-js.js b/dist/rxp-js.js index 768dcaa..9e7a525 100644 --- a/dist/rxp-js.js +++ b/dist/rxp-js.js @@ -1,6 +1,8 @@ -/*! rxp-js - v0.1.0 - 2015-07-24 -* https://github.com/realexpayments-developers/rxp-js -* Copyright (c) 2015 Realex Developer; Licensed MIT */ +/*! rxp-js - v1.0.0 - 2015-07-30 + * The official Realex Payments JS SDK + * https://github.com/realexpayments/rxp-js + * Licensed MIT + */ /*jslint browser:true */ var RealexHpp = (function() { @@ -292,3 +294,153 @@ var RealexHpp = (function() { }; }()); + +var RealexRemote = (function() { + + 'use strict'; + + /* + * Validate Card Number. Returns true if card number valid. Only allows + * non-empty numeric values between 14 and 23 characters. A Luhn check is + * also run against the card number. + */ + var validateCardNumber = function(cardNumber) { + // test numeric and length between 14 and 23 + if (!/^\d{14,23}$/.test(cardNumber)) { + return false; + } + + // luhn check + var sum = 0; + var digit = 0; + var addend = 0; + var timesTwo = false; + + for (var i = cardNumber.length - 1; i >= 0; i--) { + digit = parseInt(cardNumber.substring(i, i + 1), 10); + if (timesTwo) { + addend = digit * 2; + if (addend > 9) { + addend -= 9; + } + } else { + addend = digit; + } + sum += addend; + timesTwo = !timesTwo; + } + + var modulus = sum % 10; + if (modulus !== 0) { + return false; + } + + return true; + }; + + /* + * Validate Card Holder Name. Returns true if card numebr valid. Only allows + * non-empty ISO/IEC 8859-1 values 100 characters or less. + */ + var validateCardHolderName = function(cardHolderName) { + // test for undefined + if (!cardHolderName) { + return false; + } + + // test white space only + if (!cardHolderName.trim()) { + return false; + } + + // test ISO/IEC 8859-1 characters between 1 and 100 + if (!/^[\u0020-\u007E\u00A0-\u00FF]{1,100}$/.test(cardHolderName)) { + return false; + } + + return true; + }; + + /* + * Validate CVN. Applies to non-Amex card types. Only allows 3 numeric + * characters. + */ + var validateCvn = function(cvn) { + // test numeric length 3 + if (!/^\d{3}$/.test(cvn)) { + return false; + } + + return true; + }; + + /* + * Validate Amex CVN. Applies to Amex card types. Only allows 4 numeric + * characters. + */ + var validateAmexCvn = function(cvn) { + // test numeric length 4 + if (!/^\d{4}$/.test(cvn)) { + return false; + } + + return true; + }; + + /* + * Validate Expiry Date Format. Only allows 4 numeric characters. Month must + * be between 1 and 12. + */ + var validateExpiryDateFormat = function(expiryDate) { + + // test numeric of length 4 + if (!/^\d{4}$/.test(expiryDate)) { + return false; + } + + var month = parseInt(expiryDate.substring(0, 2), 10); + var year = parseInt(expiryDate.substring(2, 4), 10); + + // test month range is 1-12 + if (month < 1 || month > 12) { + return false; + } + + return true; + }; + + /* + * Validate Expiry Date Not In Past. Also runs checks from + * validateExpiryDateFormat. + */ + var validateExpiryDateNotInPast = function(expiryDate) { + // test valid format + if (!validateExpiryDateFormat(expiryDate)) { + return false; + } + + var month = parseInt(expiryDate.substring(0, 2), 10); + var year = parseInt(expiryDate.substring(2, 4), 10); + + // test date is not in the past + var now = new Date(); + var currentMonth = now.getMonth() + 1; + var currentYear = now.getFullYear(); + if (year < (currentYear % 100)) { + return false; + } else if (year === (currentYear % 100) && month < currentMonth) { + return false; + } + + return true; + }; + + return { + validateCardNumber : validateCardNumber, + validateCardHolderName : validateCardHolderName, + validateCvn : validateCvn, + validateAmexCvn : validateAmexCvn, + validateExpiryDateFormat : validateExpiryDateFormat, + validateExpiryDateNotInPast : validateExpiryDateNotInPast + }; +}()); diff --git a/dist/rxp-js.min.js b/dist/rxp-js.min.js index 95be37b..05389cd 100644 --- a/dist/rxp-js.min.js +++ b/dist/rxp-js.min.js @@ -1,4 +1,6 @@ -/*! rxp-js - v0.1.0 - 2015-07-24 -* https://github.com/realexpayments-developers/rxp-js -* Copyright (c) 2015 Realex Developer; Licensed MIT */ -var RealexHpp=function(){"use strict";function a(a){var b=document.createElement("a");return b.href=a,b.hostname}var b="https://hpp.realexpayments.com/pay",c=function(a){b=a},d=function(){function a(){function a(){var a=document.createElement("div");a.setAttribute("id","rxp-overlay-"+m),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",document.body.appendChild(a),setTimeout(function(){a.style.background="rgba(0, 0, 0, 0.7)"},1),g=a}function c(){j=document.createElement("img"),j.setAttribute("id","rxp-frame-close-"+m),j.setAttribute("src","data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh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vTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="),j.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 135px; z-index: 99999999; top: 65px;"),setTimeout(function(){j.style.opacity="1"},500),j.addEventListener("click",f,!0),g.appendChild(j)}function d(){k=document.createElement("div"),k.setAttribute("id","rxp-white-bg-"+m),k.style.position="absolute",k.style.width="360px",k.style.height="480px",k.style.backgroundColor="#ffffff",k.style.left="50%",k.style.marginLeft="-180px",k.style.zIndex="101",g.appendChild(k)}function e(){h=document.createElement("img"),h.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+QQJCgAAACwAAAAAHAAc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OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+EaVUmSJJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"),h.setAttribute("id","rxp-loader-"+m),h.style.left="50%",h.style.position="fixed",h.style.background="#FFFFFF",h.style.borderRadius="50%",h.style.width="30px",h.style.marginLeft="-15px",h.style.zIndex="200",h.style.marginLeft="-15px",h.style.top="120px",document.body.appendChild(h),i=document.createElement("iframe"),i.setAttribute("name","rxp-frame-"+m),i.setAttribute("id","rxp-frame-"+m),i.setAttribute("height","85%"),i.setAttribute("frameBorder","0"),i.setAttribute("width","360px"),i.setAttribute("seamless","seamless"),i.style.top="40px",i.style.left="50%",i.style.marginLeft="-180px",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",g.appendChild(i),i.onload=function(){i.style.opacity="1",i.style.transform="scale(1)",h.parentNode&&h.parentNode.removeChild(h),c(),setTimeout(function(){d()},500)};var a=document.createElement("form");a.setAttribute("method","POST"),a.setAttribute("action",b);for(var e in l){var f=document.createElement("input");f.setAttribute("type","hidden"),f.setAttribute("name",e),f.setAttribute("value",l[e]),a.appendChild(f)}var j=document.createElement("input");j.setAttribute("type","hidden"),j.setAttribute("name","HPP_TEMPLATE_TYPE"),j.setAttribute("value","LIGHTBOX"),a.appendChild(j);var k=document.createElement("a");k.href=window.location.href;var n=k.protocol+"//"+k.host,o=document.createElement("input");o.setAttribute("type","hidden"),o.setAttribute("name","HPP_ORIGIN"),o.setAttribute("value",n),a.appendChild(o),i.contentWindow.document.body?i.contentWindow.document.body.appendChild(a):i.contentWindow.document.appendChild(a),a.submit()}function f(){j.parentNode&&j.parentNode.removeChild(j),i.parentNode&&i.parentNode.removeChild(i),k.parentNode&&k.parentNode.removeChild(k),h.parentNode&&h.parentNode.removeChild(h),g.className="",setTimeout(function(){g.parentNode&&g.parentNode.removeChild(g)},300)}var g,h,i,j,k,l,m=m||Math.random().toString(16).substr(2,8);return{lightbox:function(){a(),e()},close:function(){f()},setToken:function(a){l=a}}}var c;return{getInstance:function(b){return c||(c=a()),c.setToken(b),c}}}(),e=function(c,e,f){function g(c){if(a(c.origin)===a(b)){h.close();var d=c.data,f=document.createElement("form");f.setAttribute("method","POST"),f.setAttribute("action",e);var g=document.createElement("input");g.setAttribute("type","hidden"),g.setAttribute("name","hppResponse"),g.setAttribute("value",d),f.appendChild(g),document.body.appendChild(f),f.submit()}}var h=d.getInstance(f);document.getElementById(c).addEventListener?document.getElementById(c).addEventListener("click",h.lightbox,!0):document.getElementById(c).attachEvent("onclick",h.lightbox),window.addEventListener?window.addEventListener("message",g,!1):window.attachEvent("message",g)};return{init:e,setHppUrl:c}}(); \ No newline at end of file +/*! rxp-js - v1.0.0 - 2015-07-30 + * The official Realex Payments JS SDK + * https://github.com/realexpayments/rxp-js + * Licensed MIT + */ +var RealexHpp=function(){"use strict";function a(a){var b=document.createElement("a");return b.href=a,b.hostname}var b="https://hpp.realexpayments.com/pay",c=function(a){b=a},d=function(){function a(){function a(){var a=document.createElement("div");a.setAttribute("id","rxp-overlay-"+m),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",document.body.appendChild(a),setTimeout(function(){a.style.background="rgba(0, 0, 0, 0.7)"},1),g=a}function c(){j=document.createElement("img"),j.setAttribute("id","rxp-frame-close-"+m),j.setAttribute("src","data:image/gif;base64,iVBORw0KGgoAAAANSU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0RkJGMUM5NSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PlHco5QAAAHpSURBVHjafFRdTsJAEF42JaTKn4glGIg++qgX4AAchHAJkiZcwnAQD8AF4NFHCaC2VgWkIQQsfl/jNJUik8Duzs/XmW9mN7Xb7VRc5vP5zWKxaK5Wq8Zmu72FqobfJG0YQ9M0+/l8/qFQKDzGY1JxENd1288vLy1s786KRZXJZCLber1Wn7MZt4PLarVnWdZ9AmQ8Hncc17UvymVdBMB/MgPQm+cFFcuy6/V6lzqDf57ntWGwYdBIVx0TfkBD6I9M35iRJgfIoAVjBLDZbA4CiJ5+9AdQi/EahibqDTkQx6fRSIHcPwA8Uy9A9Gcc47Xv+w2wzhRDYzqdVihLIbsIiCvP1NNOoX/29FQx3vgOgtt4FyRdCgPRarX4+goB9vkyAMh443cOEsIAAcjncuoI4TXWMAmCIGFhCQLAdZ8jym/cRJ+Y5nC5XCYAhINKpZLgSISZgoqh5iiLQrojAFICVwGS7tCfe5DbZzkP56XS4NVxwvTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="),j.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 135px; z-index: 99999999; top: 65px;"),setTimeout(function(){j.style.opacity="1"},500),j.addEventListener("click",f,!0),g.appendChild(j)}function d(){k=document.createElement("div"),k.setAttribute("id","rxp-white-bg-"+m),k.style.position="absolute",k.style.width="360px",k.style.height="480px",k.style.backgroundColor="#ffffff",k.style.left="50%",k.style.marginLeft="-180px",k.style.zIndex="101",g.appendChild(k)}function e(){h=document.createElement("img"),h.setAttribute("src","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A2RgwKUgilFSIICV5ucAEhIn6ECqVgarqhJPDyLRUUKAFRYVI1HMZAALgJIAg8KGDwKGlinAEkKLoU1Tnt1BABVAtOEKb4PBhIMR4c+cU5OaymILiYlCwtHmIcxQU4fjAYMDFjdiApQSGBU5QgGRjOmEFgQCUMKZf8AKLgBAgiZNvkaURkSo8aUI+wAYJDSYcyONloibexIoYQwQS6oEPgxpOGMXPQOPdjCMFESCgcZHdFiYUROQ0dChCgRkRCFOg4cRMCCiIcGAjhCUDgq6AiHDhWyxShAhJACKFweJJHAAgoFQ1dfrAwQlKRMhAwpfnCZMkXEihqCHmAwUIXRkAgRoLiQgsIHABsrVDRl1OPMDQAPZIzAAcAEjRVzOT2gI+XTjREMBF0RUZMThhyyAGyYYGCQhtaoCJVQMjk3ISQafAtHFAgAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iGD4mMh1UCjYkNXlWDSQKVgo+Rgkl3HZkCSEmdMwqcgnNOWoI8SDwAD0VFSKgAP05ONgACPLApKUUujAsesABIek46CkmuAjNFp4IPPIuEQ3p2dDgAJBEmhdAuLikDGljDhTY6OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+EaVUmSJJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"),h.setAttribute("id","rxp-loader-"+m),h.style.left="50%",h.style.position="fixed",h.style.background="#FFFFFF",h.style.borderRadius="50%",h.style.width="30px",h.style.marginLeft="-15px",h.style.zIndex="200",h.style.marginLeft="-15px",h.style.top="120px",document.body.appendChild(h),i=document.createElement("iframe"),i.setAttribute("name","rxp-frame-"+m),i.setAttribute("id","rxp-frame-"+m),i.setAttribute("height","85%"),i.setAttribute("frameBorder","0"),i.setAttribute("width","360px"),i.setAttribute("seamless","seamless"),i.style.top="40px",i.style.left="50%",i.style.marginLeft="-180px",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",g.appendChild(i),i.onload=function(){i.style.opacity="1",i.style.transform="scale(1)",h.parentNode&&h.parentNode.removeChild(h),c(),setTimeout(function(){d()},500)};var a=document.createElement("form");a.setAttribute("method","POST"),a.setAttribute("action",b);for(var e in l){var f=document.createElement("input");f.setAttribute("type","hidden"),f.setAttribute("name",e),f.setAttribute("value",l[e]),a.appendChild(f)}var j=document.createElement("input");j.setAttribute("type","hidden"),j.setAttribute("name","HPP_TEMPLATE_TYPE"),j.setAttribute("value","LIGHTBOX"),a.appendChild(j);var k=document.createElement("a");k.href=window.location.href;var n=k.protocol+"//"+k.host,o=document.createElement("input");o.setAttribute("type","hidden"),o.setAttribute("name","HPP_ORIGIN"),o.setAttribute("value",n),a.appendChild(o),i.contentWindow.document.body?i.contentWindow.document.body.appendChild(a):i.contentWindow.document.appendChild(a),a.submit()}function f(){j.parentNode&&j.parentNode.removeChild(j),i.parentNode&&i.parentNode.removeChild(i),k.parentNode&&k.parentNode.removeChild(k),h.parentNode&&h.parentNode.removeChild(h),g.className="",setTimeout(function(){g.parentNode&&g.parentNode.removeChild(g)},300)}var g,h,i,j,k,l,m=m||Math.random().toString(16).substr(2,8);return{lightbox:function(){a(),e()},close:function(){f()},setToken:function(a){l=a}}}var c;return{getInstance:function(b){return c||(c=a()),c.setToken(b),c}}}(),e=function(c,e,f){function g(c){if(a(c.origin)===a(b)){h.close();var d=c.data,f=document.createElement("form");f.setAttribute("method","POST"),f.setAttribute("action",e);var g=document.createElement("input");g.setAttribute("type","hidden"),g.setAttribute("name","hppResponse"),g.setAttribute("value",d),f.appendChild(g),document.body.appendChild(f),f.submit()}}var h=d.getInstance(f);document.getElementById(c).addEventListener?document.getElementById(c).addEventListener("click",h.lightbox,!0):document.getElementById(c).attachEvent("onclick",h.lightbox),window.addEventListener?window.addEventListener("message",g,!1):window.attachEvent("message",g)};return{init:e,setHppUrl:c}}(),RealexRemote=function(){"use strict";var a=function(a){if(!/^\d{14,23}$/.test(a))return!1;for(var b=0,c=0,d=0,e=!1,f=a.length-1;f>=0;f--)c=parseInt(a.substring(f,f+1),10),e?(d=2*c,d>9&&(d-=9)):d=c,b+=d,e=!e;var g=b%10;return 0!==g?!1:!0},b=function(a){return a&&a.trim()&&/^[\u0020-\u007E\u00A0-\u00FF]{1,100}$/.test(a)?!0:!1},c=function(a){return/^\d{3}$/.test(a)?!0:!1},d=function(a){return/^\d{4}$/.test(a)?!0:!1},e=function(a){if(!/^\d{4}$/.test(a))return!1;var b=parseInt(a.substring(0,2),10);parseInt(a.substring(2,4),10);return 1>b||b>12?!1:!0},f=function(a){if(!e(a))return!1;var b=parseInt(a.substring(0,2),10),c=parseInt(a.substring(2,4),10),d=new Date,f=d.getMonth()+1,g=d.getFullYear();return g%100>c?!1:c===g%100&&f>b?!1:!0};return{validateCardNumber:a,validateCardHolderName:b,validateCvn:c,validateAmexCvn:d,validateExpiryDateFormat:e,validateExpiryDateNotInPast:f}}(); \ No newline at end of file diff --git a/lib/rxp-js.js b/lib/rxp-hpp.js similarity index 99% rename from lib/rxp-js.js rename to lib/rxp-hpp.js index f11d585..6d02820 100644 --- a/lib/rxp-js.js +++ b/lib/rxp-hpp.js @@ -1,5 +1,5 @@ /* - * rxp-js + * rxp-hpp.js * https://github.com/realexpayments-developers/rxp-js * * Copyright (c) 2015 Realex Developer diff --git a/lib/rxp-remote.js b/lib/rxp-remote.js new file mode 100644 index 0000000..1c18ab4 --- /dev/null +++ b/lib/rxp-remote.js @@ -0,0 +1,155 @@ +/* + * rxp-remote.js + * https://github.com/realexpayments/rxp-js + * + * Licensed under the MIT license. + */ +var RealexRemote = (function() { + + 'use strict'; + + /* + * Validate Card Number. Returns true if card number valid. Only allows + * non-empty numeric values between 14 and 23 characters. A Luhn check is + * also run against the card number. + */ + var validateCardNumber = function(cardNumber) { + // test numeric and length between 14 and 23 + if (!/^\d{14,23}$/.test(cardNumber)) { + return false; + } + + // luhn check + var sum = 0; + var digit = 0; + var addend = 0; + var timesTwo = false; + + for (var i = cardNumber.length - 1; i >= 0; i--) { + digit = parseInt(cardNumber.substring(i, i + 1), 10); + if (timesTwo) { + addend = digit * 2; + if (addend > 9) { + addend -= 9; + } + } else { + addend = digit; + } + sum += addend; + timesTwo = !timesTwo; + } + + var modulus = sum % 10; + if (modulus !== 0) { + return false; + } + + return true; + }; + + /* + * Validate Card Holder Name. Returns true if card numebr valid. Only allows + * non-empty ISO/IEC 8859-1 values 100 characters or less. + */ + var validateCardHolderName = function(cardHolderName) { + // test for undefined + if (!cardHolderName) { + return false; + } + + // test white space only + if (!cardHolderName.trim()) { + return false; + } + + // test ISO/IEC 8859-1 characters between 1 and 100 + if (!/^[\u0020-\u007E\u00A0-\u00FF]{1,100}$/.test(cardHolderName)) { + return false; + } + + return true; + }; + + /* + * Validate CVN. Applies to non-Amex card types. Only allows 3 numeric + * characters. + */ + var validateCvn = function(cvn) { + // test numeric length 3 + if (!/^\d{3}$/.test(cvn)) { + return false; + } + + return true; + }; + + /* + * Validate Amex CVN. Applies to Amex card types. Only allows 4 numeric + * characters. + */ + var validateAmexCvn = function(cvn) { + // test numeric length 4 + if (!/^\d{4}$/.test(cvn)) { + return false; + } + + return true; + }; + + /* + * Validate Expiry Date Format. Only allows 4 numeric characters. Month must + * be between 1 and 12. + */ + var validateExpiryDateFormat = function(expiryDate) { + + // test numeric of length 4 + if (!/^\d{4}$/.test(expiryDate)) { + return false; + } + + var month = parseInt(expiryDate.substring(0, 2), 10); + var year = parseInt(expiryDate.substring(2, 4), 10); + + // test month range is 1-12 + if (month < 1 || month > 12) { + return false; + } + + return true; + }; + + /* + * Validate Expiry Date Not In Past. Also runs checks from + * validateExpiryDateFormat. + */ + var validateExpiryDateNotInPast = function(expiryDate) { + // test valid format + if (!validateExpiryDateFormat(expiryDate)) { + return false; + } + + var month = parseInt(expiryDate.substring(0, 2), 10); + var year = parseInt(expiryDate.substring(2, 4), 10); + + // test date is not in the past + var now = new Date(); + var currentMonth = now.getMonth() + 1; + var currentYear = now.getFullYear(); + if (year < (currentYear % 100)) { + return false; + } else if (year === (currentYear % 100) && month < currentMonth) { + return false; + } + + return true; + }; + + return { + validateCardNumber : validateCardNumber, + validateCardHolderName : validateCardHolderName, + validateCvn : validateCvn, + validateAmexCvn : validateAmexCvn, + validateExpiryDateFormat : validateExpiryDateFormat, + validateExpiryDateNotInPast : validateExpiryDateNotInPast + }; +}()); diff --git a/package.json b/package.json index 0e59266..02e6e41 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,20 @@ { "name": "rxp-js", "description": "The official Realex Payments JS SDK", - "version": "0.1.0", - "homepage": "https://github.com/realexpayments-developers/rxp-js", + "version": "1.0.0", + "homepage": "https://github.com/realexpayments/rxp-js", "author": { "name": "Realex Developer", - "url": "http://www.realexpayments.ie/" + "url": "http://www.realexpayments.com" }, "repository": { "type": "git", - "url": "https://github.com/realexpayments-developers/rxp-js" - }, - "bugs": { - "url": "https://github.com/realexpayments-developers/rxp-js/issues" + "url": "https://github.com/realexpayments/rxp-js" }, "licenses": [ { "type": "MIT", - "url": "https://github.com/realexpayments-developers/rxp-js/blob/master/LICENSE-MIT" + "url": "https://github.com/realexpayments/rxp-js/blob/master/LICENSE-MIT" } ], "main": "lib/rxp-js", @@ -25,12 +22,12 @@ "node": ">= 0.10.0" }, "devDependencies": { + "grunt": "~0.4.5", "grunt-contrib-concat": "~0.3.0", - "grunt-contrib-uglify": "~0.2.0", + "grunt-contrib-jasmine": "^0.9.0", "grunt-contrib-jshint": "~0.6.0", - "grunt-contrib-nodeunit": "~0.2.0", - "grunt-contrib-watch": "~0.4.0", - "grunt": "~0.4.5" + "grunt-contrib-uglify": "~0.2.0", + "grunt-contrib-watch": "~0.4.0" }, "keywords": [] -} \ No newline at end of file +} diff --git a/specs/rxp-remote_spec.js b/specs/rxp-remote_spec.js new file mode 100644 index 0000000..1536b7f --- /dev/null +++ b/specs/rxp-remote_spec.js @@ -0,0 +1,240 @@ +/* + * Unit tests for rxp-remote.js + */ +describe( 'rxp-remote library', function () { + + /* + * Unit tests for validateCardNumber + */ + describe( 'card validation (validateCardNumber)', function () { + it('passes valid card', function () { + expect(RealexRemote.validateCardNumber('42424242424242424242')).toBe(true); + }); + + it('fails non-numeric card', function () { + expect(RealexRemote.validateCardNumber('a2424242424242424242')).toBe(false); + }); + + it('fails card with spaces', function () { + expect(RealexRemote.validateCardNumber('4242 4242424242424242')).toBe(false); + }); + + it('fails empty card', function () { + expect(RealexRemote.validateCardNumber('')).toBe(false); + }); + + it('fails undefined card', function () { + expect(RealexRemote.validateCardNumber()).toBe(false); + }); + + it('fails white space only', function () { + expect(RealexRemote.validateCardNumber(' ')).toBe(false); + }); + + it('fails length < 14', function () { + expect(RealexRemote.validateCardNumber('1111111111112')).toBe(false); + }); + + it('fails length > 23', function () { + expect(RealexRemote.validateCardNumber('242424242424242424242402')).toBe(false); + }); + + it('pass length = 14', function () { + expect(RealexRemote.validateCardNumber('11111111111110')).toBe(true); + }); + + it('pass length = 23', function () { + expect(RealexRemote.validateCardNumber('24242424242424242424240')).toBe(true); + }); + + it('fails luhn check', function () { + expect(RealexRemote.validateCardNumber('42424242424242424241')).toBe(false); + }); + }); + + /* + * Unit tests for validateCardHolderName + */ + describe( 'card holder name validation (validateCardHolderName)', function () { + it('passes valid name', function () { + expect(RealexRemote.validateCardHolderName('Joe Smith')).toBe(true); + }); + + it('fails empty name', function () { + expect(RealexRemote.validateCardHolderName('')).toBe(false); + }); + + it('fails undefined name', function () { + expect(RealexRemote.validateCardHolderName()).toBe(false); + }); + + it('fails white space only', function () { + expect(RealexRemote.validateCardHolderName(' ')).toBe(false); + }); + + it('passes name of 100 characters', function () { + expect(RealexRemote.validateCardHolderName('abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij')).toBe(true); + }); + + it('fails name over 100 characters', function () { + expect(RealexRemote.validateCardHolderName('abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghija')).toBe(false); + }); + + it('passes ISO/IEC 8859-1 characters 1', function () { + expect(RealexRemote.validateCardHolderName('!\" # $ % & \' ( ) * + - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R')).toBe(true); + }); + + it('passes ISO/IEC 8859-1 characters 2', function () { + expect(RealexRemote.validateCardHolderName('S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ ¡ ¢ £ ¤ ¥')).toBe(true); + }); + + it('passes ISO/IEC 8859-1 characters 3', function () { + expect(RealexRemote.validateCardHolderName('¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö')).toBe(true); + }); + + it('passes ISO/IEC 8859-1 characters 4', function () { + expect(RealexRemote.validateCardHolderName('× Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ')).toBe(true); + }); + + it('fails non-ISO/IEC 8859-1 characters', function () { + expect(RealexRemote.validateCardHolderName('€')).toBe(false); + }); + + }); + + /* + * Unit tests for validateAmexCvn + */ + describe( 'CVN Amex validation (validateAmexCvn)', function () { + it('passes valid Amex CVN', function () { + expect(RealexRemote.validateAmexCvn('1234')).toBe(true); + }); + + it('fails empty CVN', function () { + expect(RealexRemote.validateAmexCvn('')).toBe(false); + }); + + it('fails undefined CVN', function () { + expect(RealexRemote.validateAmexCvn()).toBe(false); + }); + + it('fails white space only', function () { + expect(RealexRemote.validateAmexCvn(' ')).toBe(false); + }); + + it('fails Amex CVN of 5 numbers', function () { + expect(RealexRemote.validateAmexCvn('12345')).toBe(false); + }); + + it('fails Amex CVN of 3 numbers', function () { + expect(RealexRemote.validateAmexCvn('123')).toBe(false); + }); + + it('fails non-numeric Amex CVN of 4 characters', function () { + expect(RealexRemote.validateAmexCvn('123a')).toBe(false); + }); + + }); + + /* + * Unit tests for validateCvn + */ + describe( 'CVN non-Amex validation (validateCvn)', function () { + it('passes valid non-Amex CVN', function () { + expect(RealexRemote.validateCvn('123')).toBe(true); + }); + + it('fails empty CVN', function () { + expect(RealexRemote.validateCvn('')).toBe(false); + }); + + it('fails undefined CVN', function () { + expect(RealexRemote.validateCvn()).toBe(false); + }); + + it('fails white space only', function () { + expect(RealexRemote.validateCvn(' ')).toBe(false); + }); + + it('fails non-Amex CVN of 4 numbers', function () { + expect(RealexRemote.validateCvn('1234')).toBe(false); + }); + + it('fails non-Amex CVN of 2 numbers', function () { + expect(RealexRemote.validateCvn('12')).toBe(false); + }); + + it('fails non-numeric non-Amex CVN of 3 characters', function () { + expect(RealexRemote.validateCvn('12a')).toBe(false); + }); + }); + + /* + * Unit tests for validateExpiryDateFormat + */ + describe( 'Expiry date format validation (validateExpiryDateFormat)', function () { + + it('passes valid date 1299', function () { + expect(RealexRemote.validateExpiryDateFormat('1299')).toBe(true); + }); + + it('passes valid date 0199', function () { + expect(RealexRemote.validateExpiryDateFormat('0199')).toBe(true); + }); + + it('fails non-numeric date', function () { + expect(RealexRemote.validateExpiryDateFormat('a199')).toBe(false); + }); + + it('fails date with spaces', function () { + expect(RealexRemote.validateExpiryDateFormat('1 99')).toBe(false); + }); + + it('fails empty date', function () { + expect(RealexRemote.validateExpiryDateFormat('')).toBe(false); + }); + + it('fails undefined date', function () { + expect(RealexRemote.validateExpiryDateFormat()).toBe(false); + }); + + it('fails white space only', function () { + expect(RealexRemote.validateExpiryDateFormat(' ')).toBe(false); + }); + + it('fails length > 4', function () { + expect(RealexRemote.validateExpiryDateFormat('12099')).toBe(false); + }); + + it('fails length < 4', function () { + expect(RealexRemote.validateExpiryDateFormat('199')).toBe(false); + }); + + it('fails invalid month 00', function () { + expect(RealexRemote.validateExpiryDateFormat('0099')).toBe(false); + }); + + it('fails invalid month 13', function () { + expect(RealexRemote.validateExpiryDateFormat('1399')).toBe(false); + }); + }); + + /* + * Unit tests for validateExpiryDateNotInPast + */ + describe( 'Expiry date not in past validation (validateExpiryDateNotInPast)', function () { + + it('fails date in past', function () { + expect(RealexRemote.validateExpiryDateNotInPast('0615')).toBe(false); + }); + + it('pass current month', function () { + var now = new Date(); + var nowMonth = '' + (now.getMonth() + 1); + nowMonth = nowMonth.length < 2 ? '0' + nowMonth : nowMonth; + var nowYear = ('' + now.getFullYear()).substr(2,4); + expect(RealexRemote.validateExpiryDateNotInPast(nowMonth + nowYear)).toBe(true); + }); + }); + +}); \ No newline at end of file From d2e5111122acda23ef0c5f4c12a551c50fb22ef5 Mon Sep 17 00:00:00 2001 From: Mark Stanford Date: Thu, 30 Jul 2015 15:56:23 +0100 Subject: [PATCH 3/5] ATP-106 - Updated unit test messages --- specs/rxp-remote_spec.js | 98 ++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/specs/rxp-remote_spec.js b/specs/rxp-remote_spec.js index 1536b7f..a53dd69 100644 --- a/specs/rxp-remote_spec.js +++ b/specs/rxp-remote_spec.js @@ -7,47 +7,47 @@ describe( 'rxp-remote library', function () { * Unit tests for validateCardNumber */ describe( 'card validation (validateCardNumber)', function () { - it('passes valid card', function () { + it('valid card', function () { expect(RealexRemote.validateCardNumber('42424242424242424242')).toBe(true); }); - it('fails non-numeric card', function () { + it('non-numeric card', function () { expect(RealexRemote.validateCardNumber('a2424242424242424242')).toBe(false); }); - it('fails card with spaces', function () { + it('card with spaces', function () { expect(RealexRemote.validateCardNumber('4242 4242424242424242')).toBe(false); }); - it('fails empty card', function () { + it('empty card', function () { expect(RealexRemote.validateCardNumber('')).toBe(false); }); - it('fails undefined card', function () { + it('undefined card', function () { expect(RealexRemote.validateCardNumber()).toBe(false); }); - it('fails white space only', function () { + it('white space only', function () { expect(RealexRemote.validateCardNumber(' ')).toBe(false); }); - it('fails length < 14', function () { + it('length < 14', function () { expect(RealexRemote.validateCardNumber('1111111111112')).toBe(false); }); - it('fails length > 23', function () { + it('length > 23', function () { expect(RealexRemote.validateCardNumber('242424242424242424242402')).toBe(false); }); - it('pass length = 14', function () { + it('length = 14', function () { expect(RealexRemote.validateCardNumber('11111111111110')).toBe(true); }); - it('pass length = 23', function () { + it('length = 23', function () { expect(RealexRemote.validateCardNumber('24242424242424242424240')).toBe(true); }); - it('fails luhn check', function () { + it('luhn check', function () { expect(RealexRemote.validateCardNumber('42424242424242424241')).toBe(false); }); }); @@ -56,47 +56,47 @@ describe( 'rxp-remote library', function () { * Unit tests for validateCardHolderName */ describe( 'card holder name validation (validateCardHolderName)', function () { - it('passes valid name', function () { + it('valid name', function () { expect(RealexRemote.validateCardHolderName('Joe Smith')).toBe(true); }); - it('fails empty name', function () { + it('empty name', function () { expect(RealexRemote.validateCardHolderName('')).toBe(false); }); - it('fails undefined name', function () { + it('undefined name', function () { expect(RealexRemote.validateCardHolderName()).toBe(false); }); - it('fails white space only', function () { + it('white space only', function () { expect(RealexRemote.validateCardHolderName(' ')).toBe(false); }); - it('passes name of 100 characters', function () { + it('name of 100 characters', function () { expect(RealexRemote.validateCardHolderName('abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij')).toBe(true); }); - it('fails name over 100 characters', function () { + it('name over 100 characters', function () { expect(RealexRemote.validateCardHolderName('abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghija')).toBe(false); }); - it('passes ISO/IEC 8859-1 characters 1', function () { + it('ISO/IEC 8859-1 characters 1', function () { expect(RealexRemote.validateCardHolderName('!\" # $ % & \' ( ) * + - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R')).toBe(true); }); - it('passes ISO/IEC 8859-1 characters 2', function () { + it('ISO/IEC 8859-1 characters 2', function () { expect(RealexRemote.validateCardHolderName('S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ ¡ ¢ £ ¤ ¥')).toBe(true); }); - it('passes ISO/IEC 8859-1 characters 3', function () { + it('ISO/IEC 8859-1 characters 3', function () { expect(RealexRemote.validateCardHolderName('¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö')).toBe(true); }); - it('passes ISO/IEC 8859-1 characters 4', function () { + it('ISO/IEC 8859-1 characters 4', function () { expect(RealexRemote.validateCardHolderName('× Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ')).toBe(true); }); - it('fails non-ISO/IEC 8859-1 characters', function () { + it('non-ISO/IEC 8859-1 characters', function () { expect(RealexRemote.validateCardHolderName('€')).toBe(false); }); @@ -106,31 +106,31 @@ describe( 'rxp-remote library', function () { * Unit tests for validateAmexCvn */ describe( 'CVN Amex validation (validateAmexCvn)', function () { - it('passes valid Amex CVN', function () { + it('valid Amex CVN', function () { expect(RealexRemote.validateAmexCvn('1234')).toBe(true); }); - it('fails empty CVN', function () { + it('empty CVN', function () { expect(RealexRemote.validateAmexCvn('')).toBe(false); }); - it('fails undefined CVN', function () { + it('undefined CVN', function () { expect(RealexRemote.validateAmexCvn()).toBe(false); }); - it('fails white space only', function () { + it('white space only', function () { expect(RealexRemote.validateAmexCvn(' ')).toBe(false); }); - it('fails Amex CVN of 5 numbers', function () { + it('Amex CVN of 5 numbers', function () { expect(RealexRemote.validateAmexCvn('12345')).toBe(false); }); - it('fails Amex CVN of 3 numbers', function () { + it('Amex CVN of 3 numbers', function () { expect(RealexRemote.validateAmexCvn('123')).toBe(false); }); - it('fails non-numeric Amex CVN of 4 characters', function () { + it('non-numeric Amex CVN of 4 characters', function () { expect(RealexRemote.validateAmexCvn('123a')).toBe(false); }); @@ -140,31 +140,31 @@ describe( 'rxp-remote library', function () { * Unit tests for validateCvn */ describe( 'CVN non-Amex validation (validateCvn)', function () { - it('passes valid non-Amex CVN', function () { + it('valid non-Amex CVN', function () { expect(RealexRemote.validateCvn('123')).toBe(true); }); - it('fails empty CVN', function () { + it('empty CVN', function () { expect(RealexRemote.validateCvn('')).toBe(false); }); - it('fails undefined CVN', function () { + it('undefined CVN', function () { expect(RealexRemote.validateCvn()).toBe(false); }); - it('fails white space only', function () { + it('white space only', function () { expect(RealexRemote.validateCvn(' ')).toBe(false); }); - it('fails non-Amex CVN of 4 numbers', function () { + it('non-Amex CVN of 4 numbers', function () { expect(RealexRemote.validateCvn('1234')).toBe(false); }); - it('fails non-Amex CVN of 2 numbers', function () { + it('non-Amex CVN of 2 numbers', function () { expect(RealexRemote.validateCvn('12')).toBe(false); }); - it('fails non-numeric non-Amex CVN of 3 characters', function () { + it('non-numeric non-Amex CVN of 3 characters', function () { expect(RealexRemote.validateCvn('12a')).toBe(false); }); }); @@ -174,47 +174,47 @@ describe( 'rxp-remote library', function () { */ describe( 'Expiry date format validation (validateExpiryDateFormat)', function () { - it('passes valid date 1299', function () { + it('valid date 1299', function () { expect(RealexRemote.validateExpiryDateFormat('1299')).toBe(true); }); - it('passes valid date 0199', function () { + it('valid date 0199', function () { expect(RealexRemote.validateExpiryDateFormat('0199')).toBe(true); }); - it('fails non-numeric date', function () { + it('non-numeric date', function () { expect(RealexRemote.validateExpiryDateFormat('a199')).toBe(false); }); - it('fails date with spaces', function () { + it('date with spaces', function () { expect(RealexRemote.validateExpiryDateFormat('1 99')).toBe(false); }); - it('fails empty date', function () { + it('empty date', function () { expect(RealexRemote.validateExpiryDateFormat('')).toBe(false); }); - it('fails undefined date', function () { + it('undefined date', function () { expect(RealexRemote.validateExpiryDateFormat()).toBe(false); }); - it('fails white space only', function () { + it('white space only', function () { expect(RealexRemote.validateExpiryDateFormat(' ')).toBe(false); }); - it('fails length > 4', function () { + it('length > 4', function () { expect(RealexRemote.validateExpiryDateFormat('12099')).toBe(false); }); - it('fails length < 4', function () { + it('length < 4', function () { expect(RealexRemote.validateExpiryDateFormat('199')).toBe(false); }); - it('fails invalid month 00', function () { + it('invalid month 00', function () { expect(RealexRemote.validateExpiryDateFormat('0099')).toBe(false); }); - it('fails invalid month 13', function () { + it('invalid month 13', function () { expect(RealexRemote.validateExpiryDateFormat('1399')).toBe(false); }); }); @@ -224,11 +224,11 @@ describe( 'rxp-remote library', function () { */ describe( 'Expiry date not in past validation (validateExpiryDateNotInPast)', function () { - it('fails date in past', function () { + it('date in past', function () { expect(RealexRemote.validateExpiryDateNotInPast('0615')).toBe(false); }); - it('pass current month', function () { + it('current month', function () { var now = new Date(); var nowMonth = '' + (now.getMonth() + 1); nowMonth = nowMonth.length < 2 ? '0' + nowMonth : nowMonth; From be05b4a6bc86da2556a4ed9a0bff00db8b4add59 Mon Sep 17 00:00:00 2001 From: Mark Stanford Date: Wed, 5 Aug 2015 09:19:24 +0100 Subject: [PATCH 4/5] ATP-106 - Updated README and comment --- README.md | 41 +++++++++++++++++++++++++++++++++++++++-- dist/rxp-js.js | 4 ++-- dist/rxp-js.min.js | 2 +- lib/rxp-remote.js | 2 +- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c75bf2c..f93d83a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,39 @@ -# rxp-js -The official Realex Payments JS SDK +# Realex JS SDK +You can sign up for a Realex account at https://www.realexpayments.com. + +## Hosted Payment Page (HPP) JS SDK + +### Usage +The Javascript required to initialise the SDK is below. This code must only be executed when the DOM is fully loaded. +```javascript +RealexHpp.init(payButtonId, merchantUrl, jsonFromServerSdk); +``` +* payButtonId - The ID of the button used to launch the lightbox. +* merchantUrl - The URL to which the JSON response from Realex will be posted. +* jsonFromServerSdk - The JSON output from the Realex HPP Server SDK. + +### Consuming the resulting POST +Once the payment has completed the Realex JSON response will be posted within to the supplied merchantUrl. The name of the field containing the JSON response is hppResponse. + +## Remote JS SDK + +### Validation functions +* validateCardNumber - validates card number format and performs a Luhn check +* validateCardHolderName - validates card holder name is made up from ISO/IEC 8859-1:1998 characters +* validateCvn - validates non-Amex CVN +* validateAmexCvn - validates Amex CVN +* validateExpiryDateFormat - validates expiry date format +* validateExpiryDateNotInPast - validates expirfy date is not in past + +### Usage +```javascript +RealexRemote.validateCardNumber(cardNumber); +RealexRemote.validateCardHolderName(cardHolderName); +RealexRemote.validateCvn(cvn); +RealexRemote.validateAmexCvn(amexCvn); +RealexRemote.validateExpiryDateFormat(expiryDate); +RealexRemote.validateExpiryDateNotInPast(expiryDate); +``` + +## License +See the LICENSE file. diff --git a/dist/rxp-js.js b/dist/rxp-js.js index 9e7a525..8955ce0 100644 --- a/dist/rxp-js.js +++ b/dist/rxp-js.js @@ -1,4 +1,4 @@ -/*! rxp-js - v1.0.0 - 2015-07-30 +/*! rxp-js - v1.0.0 - 2015-07-31 * The official Realex Payments JS SDK * https://github.com/realexpayments/rxp-js * Licensed MIT @@ -339,7 +339,7 @@ var RealexRemote = (function() { }; /* - * Validate Card Holder Name. Returns true if card numebr valid. Only allows + * Validate Card Holder Name. Returns true if card holder valid. Only allows * non-empty ISO/IEC 8859-1 values 100 characters or less. */ var validateCardHolderName = function(cardHolderName) { diff --git a/dist/rxp-js.min.js b/dist/rxp-js.min.js index 05389cd..2e930c5 100644 --- a/dist/rxp-js.min.js +++ b/dist/rxp-js.min.js @@ -1,4 +1,4 @@ -/*! rxp-js - v1.0.0 - 2015-07-30 +/*! rxp-js - v1.0.0 - 2015-07-31 * The official Realex Payments JS SDK * https://github.com/realexpayments/rxp-js * Licensed MIT diff --git a/lib/rxp-remote.js b/lib/rxp-remote.js index 1c18ab4..525932f 100644 --- a/lib/rxp-remote.js +++ b/lib/rxp-remote.js @@ -48,7 +48,7 @@ var RealexRemote = (function() { }; /* - * Validate Card Holder Name. Returns true if card numebr valid. Only allows + * Validate Card Holder Name. Returns true if card holder valid. Only allows * non-empty ISO/IEC 8859-1 values 100 characters or less. */ var validateCardHolderName = function(cardHolderName) { From 0fbe5aad761755552bacedbc80970e45d1ceef0b Mon Sep 17 00:00:00 2001 From: Mark Stanford Date: Fri, 7 Aug 2015 12:11:28 +0100 Subject: [PATCH 5/5] ATP-106 - Updated card length validation --- dist/rxp-js.js | 8 ++++---- dist/rxp-js.min.js | 4 ++-- lib/rxp-remote.js | 6 +++--- specs/rxp-remote_spec.js | 24 ++++++++++++------------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/dist/rxp-js.js b/dist/rxp-js.js index 8955ce0..60f1b55 100644 --- a/dist/rxp-js.js +++ b/dist/rxp-js.js @@ -1,4 +1,4 @@ -/*! rxp-js - v1.0.0 - 2015-07-31 +/*! rxp-js - v1.0.0 - 2015-08-07 * The official Realex Payments JS SDK * https://github.com/realexpayments/rxp-js * Licensed MIT @@ -301,12 +301,12 @@ var RealexRemote = (function() { /* * Validate Card Number. Returns true if card number valid. Only allows - * non-empty numeric values between 14 and 23 characters. A Luhn check is + * non-empty numeric values between 12 and 19 characters. A Luhn check is * also run against the card number. */ var validateCardNumber = function(cardNumber) { - // test numeric and length between 14 and 23 - if (!/^\d{14,23}$/.test(cardNumber)) { + // test numeric and length between 12 and 19 + if (!/^\d{12,19}$/.test(cardNumber)) { return false; } diff --git a/dist/rxp-js.min.js b/dist/rxp-js.min.js index 2e930c5..bd19127 100644 --- a/dist/rxp-js.min.js +++ b/dist/rxp-js.min.js @@ -1,6 +1,6 @@ -/*! rxp-js - v1.0.0 - 2015-07-31 +/*! rxp-js - v1.0.0 - 2015-08-07 * The official Realex Payments JS SDK * https://github.com/realexpayments/rxp-js * Licensed MIT */ -var RealexHpp=function(){"use strict";function a(a){var b=document.createElement("a");return b.href=a,b.hostname}var b="https://hpp.realexpayments.com/pay",c=function(a){b=a},d=function(){function a(){function a(){var a=document.createElement("div");a.setAttribute("id","rxp-overlay-"+m),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",document.body.appendChild(a),setTimeout(function(){a.style.background="rgba(0, 0, 0, 0.7)"},1),g=a}function c(){j=document.createElement("img"),j.setAttribute("id","rxp-frame-close-"+m),j.setAttribute("src","data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDp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zWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="),j.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 135px; z-index: 99999999; top: 65px;"),setTimeout(function(){j.style.opacity="1"},500),j.addEventListener("click",f,!0),g.appendChild(j)}function d(){k=document.createElement("div"),k.setAttribute("id","rxp-white-bg-"+m),k.style.position="absolute",k.style.width="360px",k.style.height="480px",k.style.backgroundColor="#ffffff",k.style.left="50%",k.style.marginLeft="-180px",k.style.zIndex="101",g.appendChild(k)}function e(){h=document.createElement("img"),h.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+DVZmSAAswOYIKTE1UglUCVZ0AGBYw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BkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"),h.setAttribute("id","rxp-loader-"+m),h.style.left="50%",h.style.position="fixed",h.style.background="#FFFFFF",h.style.borderRadius="50%",h.style.width="30px",h.style.marginLeft="-15px",h.style.zIndex="200",h.style.marginLeft="-15px",h.style.top="120px",document.body.appendChild(h),i=document.createElement("iframe"),i.setAttribute("name","rxp-frame-"+m),i.setAttribute("id","rxp-frame-"+m),i.setAttribute("height","85%"),i.setAttribute("frameBorder","0"),i.setAttribute("width","360px"),i.setAttribute("seamless","seamless"),i.style.top="40px",i.style.left="50%",i.style.marginLeft="-180px",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",g.appendChild(i),i.onload=function(){i.style.opacity="1",i.style.transform="scale(1)",h.parentNode&&h.parentNode.removeChild(h),c(),setTimeout(function(){d()},500)};var a=document.createElement("form");a.setAttribute("method","POST"),a.setAttribute("action",b);for(var e in l){var f=document.createElement("input");f.setAttribute("type","hidden"),f.setAttribute("name",e),f.setAttribute("value",l[e]),a.appendChild(f)}var j=document.createElement("input");j.setAttribute("type","hidden"),j.setAttribute("name","HPP_TEMPLATE_TYPE"),j.setAttribute("value","LIGHTBOX"),a.appendChild(j);var k=document.createElement("a");k.href=window.location.href;var n=k.protocol+"//"+k.host,o=document.createElement("input");o.setAttribute("type","hidden"),o.setAttribute("name","HPP_ORIGIN"),o.setAttribute("value",n),a.appendChild(o),i.contentWindow.document.body?i.contentWindow.document.body.appendChild(a):i.contentWindow.document.appendChild(a),a.submit()}function f(){j.parentNode&&j.parentNode.removeChild(j),i.parentNode&&i.parentNode.removeChild(i),k.parentNode&&k.parentNode.removeChild(k),h.parentNode&&h.parentNode.removeChild(h),g.className="",setTimeout(function(){g.parentNode&&g.parentNode.removeChild(g)},300)}var g,h,i,j,k,l,m=m||Math.random().toString(16).substr(2,8);return{lightbox:function(){a(),e()},close:function(){f()},setToken:function(a){l=a}}}var c;return{getInstance:function(b){return c||(c=a()),c.setToken(b),c}}}(),e=function(c,e,f){function g(c){if(a(c.origin)===a(b)){h.close();var d=c.data,f=document.createElement("form");f.setAttribute("method","POST"),f.setAttribute("action",e);var g=document.createElement("input");g.setAttribute("type","hidden"),g.setAttribute("name","hppResponse"),g.setAttribute("value",d),f.appendChild(g),document.body.appendChild(f),f.submit()}}var h=d.getInstance(f);document.getElementById(c).addEventListener?document.getElementById(c).addEventListener("click",h.lightbox,!0):document.getElementById(c).attachEvent("onclick",h.lightbox),window.addEventListener?window.addEventListener("message",g,!1):window.attachEvent("message",g)};return{init:e,setHppUrl:c}}(),RealexRemote=function(){"use strict";var a=function(a){if(!/^\d{14,23}$/.test(a))return!1;for(var b=0,c=0,d=0,e=!1,f=a.length-1;f>=0;f--)c=parseInt(a.substring(f,f+1),10),e?(d=2*c,d>9&&(d-=9)):d=c,b+=d,e=!e;var g=b%10;return 0!==g?!1:!0},b=function(a){return a&&a.trim()&&/^[\u0020-\u007E\u00A0-\u00FF]{1,100}$/.test(a)?!0:!1},c=function(a){return/^\d{3}$/.test(a)?!0:!1},d=function(a){return/^\d{4}$/.test(a)?!0:!1},e=function(a){if(!/^\d{4}$/.test(a))return!1;var b=parseInt(a.substring(0,2),10);parseInt(a.substring(2,4),10);return 1>b||b>12?!1:!0},f=function(a){if(!e(a))return!1;var b=parseInt(a.substring(0,2),10),c=parseInt(a.substring(2,4),10),d=new Date,f=d.getMonth()+1,g=d.getFullYear();return g%100>c?!1:c===g%100&&f>b?!1:!0};return{validateCardNumber:a,validateCardHolderName:b,validateCvn:c,validateAmexCvn:d,validateExpiryDateFormat:e,validateExpiryDateNotInPast:f}}(); \ No newline at end of file +var RealexHpp=function(){"use strict";function a(a){var b=document.createElement("a");return b.href=a,b.hostname}var b="https://hpp.realexpayments.com/pay",c=function(a){b=a},d=function(){function a(){function a(){var a=document.createElement("div");a.setAttribute("id","rxp-overlay-"+m),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",document.body.appendChild(a),setTimeout(function(){a.style.background="rgba(0, 0, 0, 0.7)"},1),g=a}function c(){j=document.createElement("img"),j.setAttribute("id","rxp-frame-close-"+m),j.setAttribute("src","data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZV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dx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="),j.setAttribute("style","transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 135px; z-index: 99999999; top: 65px;"),setTimeout(function(){j.style.opacity="1"},500),j.addEventListener("click",f,!0),g.appendChild(j)}function d(){k=document.createElement("div"),k.setAttribute("id","rxp-white-bg-"+m),k.style.position="absolute",k.style.width="360px",k.style.height="480px",k.style.backgroundColor="#ffffff",k.style.left="50%",k.style.marginLeft="-180px",k.style.zIndex="101",g.appendChild(k)}function e(){h=document.createElement("img"),h.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+DVZmSAAswOYIKTE1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JJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"),h.setAttribute("id","rxp-loader-"+m),h.style.left="50%",h.style.position="fixed",h.style.background="#FFFFFF",h.style.borderRadius="50%",h.style.width="30px",h.style.marginLeft="-15px",h.style.zIndex="200",h.style.marginLeft="-15px",h.style.top="120px",document.body.appendChild(h),i=document.createElement("iframe"),i.setAttribute("name","rxp-frame-"+m),i.setAttribute("id","rxp-frame-"+m),i.setAttribute("height","85%"),i.setAttribute("frameBorder","0"),i.setAttribute("width","360px"),i.setAttribute("seamless","seamless"),i.style.top="40px",i.style.left="50%",i.style.marginLeft="-180px",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",g.appendChild(i),i.onload=function(){i.style.opacity="1",i.style.transform="scale(1)",h.parentNode&&h.parentNode.removeChild(h),c(),setTimeout(function(){d()},500)};var a=document.createElement("form");a.setAttribute("method","POST"),a.setAttribute("action",b);for(var e in l){var f=document.createElement("input");f.setAttribute("type","hidden"),f.setAttribute("name",e),f.setAttribute("value",l[e]),a.appendChild(f)}var j=document.createElement("input");j.setAttribute("type","hidden"),j.setAttribute("name","HPP_TEMPLATE_TYPE"),j.setAttribute("value","LIGHTBOX"),a.appendChild(j);var k=document.createElement("a");k.href=window.location.href;var n=k.protocol+"//"+k.host,o=document.createElement("input");o.setAttribute("type","hidden"),o.setAttribute("name","HPP_ORIGIN"),o.setAttribute("value",n),a.appendChild(o),i.contentWindow.document.body?i.contentWindow.document.body.appendChild(a):i.contentWindow.document.appendChild(a),a.submit()}function f(){j.parentNode&&j.parentNode.removeChild(j),i.parentNode&&i.parentNode.removeChild(i),k.parentNode&&k.parentNode.removeChild(k),h.parentNode&&h.parentNode.removeChild(h),g.className="",setTimeout(function(){g.parentNode&&g.parentNode.removeChild(g)},300)}var g,h,i,j,k,l,m=m||Math.random().toString(16).substr(2,8);return{lightbox:function(){a(),e()},close:function(){f()},setToken:function(a){l=a}}}var c;return{getInstance:function(b){return c||(c=a()),c.setToken(b),c}}}(),e=function(c,e,f){function g(c){if(a(c.origin)===a(b)){h.close();var d=c.data,f=document.createElement("form");f.setAttribute("method","POST"),f.setAttribute("action",e);var g=document.createElement("input");g.setAttribute("type","hidden"),g.setAttribute("name","hppResponse"),g.setAttribute("value",d),f.appendChild(g),document.body.appendChild(f),f.submit()}}var h=d.getInstance(f);document.getElementById(c).addEventListener?document.getElementById(c).addEventListener("click",h.lightbox,!0):document.getElementById(c).attachEvent("onclick",h.lightbox),window.addEventListener?window.addEventListener("message",g,!1):window.attachEvent("message",g)};return{init:e,setHppUrl:c}}(),RealexRemote=function(){"use strict";var a=function(a){if(!/^\d{12,19}$/.test(a))return!1;for(var b=0,c=0,d=0,e=!1,f=a.length-1;f>=0;f--)c=parseInt(a.substring(f,f+1),10),e?(d=2*c,d>9&&(d-=9)):d=c,b+=d,e=!e;var g=b%10;return 0!==g?!1:!0},b=function(a){return a&&a.trim()&&/^[\u0020-\u007E\u00A0-\u00FF]{1,100}$/.test(a)?!0:!1},c=function(a){return/^\d{3}$/.test(a)?!0:!1},d=function(a){return/^\d{4}$/.test(a)?!0:!1},e=function(a){if(!/^\d{4}$/.test(a))return!1;var b=parseInt(a.substring(0,2),10);parseInt(a.substring(2,4),10);return 1>b||b>12?!1:!0},f=function(a){if(!e(a))return!1;var b=parseInt(a.substring(0,2),10),c=parseInt(a.substring(2,4),10),d=new Date,f=d.getMonth()+1,g=d.getFullYear();return g%100>c?!1:c===g%100&&f>b?!1:!0};return{validateCardNumber:a,validateCardHolderName:b,validateCvn:c,validateAmexCvn:d,validateExpiryDateFormat:e,validateExpiryDateNotInPast:f}}(); \ No newline at end of file diff --git a/lib/rxp-remote.js b/lib/rxp-remote.js index 525932f..8d22551 100644 --- a/lib/rxp-remote.js +++ b/lib/rxp-remote.js @@ -10,12 +10,12 @@ var RealexRemote = (function() { /* * Validate Card Number. Returns true if card number valid. Only allows - * non-empty numeric values between 14 and 23 characters. A Luhn check is + * non-empty numeric values between 12 and 19 characters. A Luhn check is * also run against the card number. */ var validateCardNumber = function(cardNumber) { - // test numeric and length between 14 and 23 - if (!/^\d{14,23}$/.test(cardNumber)) { + // test numeric and length between 12 and 19 + if (!/^\d{12,19}$/.test(cardNumber)) { return false; } diff --git a/specs/rxp-remote_spec.js b/specs/rxp-remote_spec.js index a53dd69..98d127a 100644 --- a/specs/rxp-remote_spec.js +++ b/specs/rxp-remote_spec.js @@ -8,15 +8,15 @@ describe( 'rxp-remote library', function () { */ describe( 'card validation (validateCardNumber)', function () { it('valid card', function () { - expect(RealexRemote.validateCardNumber('42424242424242424242')).toBe(true); + expect(RealexRemote.validateCardNumber('424242424242424242')).toBe(true); }); it('non-numeric card', function () { - expect(RealexRemote.validateCardNumber('a2424242424242424242')).toBe(false); + expect(RealexRemote.validateCardNumber('a24242424242424242')).toBe(false); }); it('card with spaces', function () { - expect(RealexRemote.validateCardNumber('4242 4242424242424242')).toBe(false); + expect(RealexRemote.validateCardNumber('4242 424242424242')).toBe(false); }); it('empty card', function () { @@ -31,24 +31,24 @@ describe( 'rxp-remote library', function () { expect(RealexRemote.validateCardNumber(' ')).toBe(false); }); - it('length < 14', function () { - expect(RealexRemote.validateCardNumber('1111111111112')).toBe(false); + it('length < 12', function () { + expect(RealexRemote.validateCardNumber('42424242420')).toBe(false); }); - it('length > 23', function () { - expect(RealexRemote.validateCardNumber('242424242424242424242402')).toBe(false); + it('length > 19', function () { + expect(RealexRemote.validateCardNumber('42424242424242424242')).toBe(false); }); - it('length = 14', function () { - expect(RealexRemote.validateCardNumber('11111111111110')).toBe(true); + it('length = 12', function () { + expect(RealexRemote.validateCardNumber('424242424242')).toBe(true); }); - it('length = 23', function () { - expect(RealexRemote.validateCardNumber('24242424242424242424240')).toBe(true); + it('length = 19', function () { + expect(RealexRemote.validateCardNumber('4242424242424242428')).toBe(true); }); it('luhn check', function () { - expect(RealexRemote.validateCardNumber('42424242424242424241')).toBe(false); + expect(RealexRemote.validateCardNumber('4242424242424242427')).toBe(false); }); });