Skip to content

Commit

Permalink
Merge pull request #1 from realexpayments-developers/master
Browse files Browse the repository at this point in the history
Realex Payments JS SDK v1.0
  • Loading branch information
RealexITSO committed Aug 12, 2015
2 parents d2cb36c + 0fbe5aa commit 2131d4c
Show file tree
Hide file tree
Showing 12 changed files with 1,348 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
14 changes: 14 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -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
}
81 changes: 81 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
'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.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'
},
},
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-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jasmine');

// Default task.
grunt.registerTask('default', ['jshint', 'jasmine', 'concat', 'uglify']);

};
22 changes: 22 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -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.
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Loading

0 comments on commit 2131d4c

Please sign in to comment.