-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4f98f70
Showing
14 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"env": { | ||
"development": { | ||
"presets": ["env"], | ||
"plugins": [ | ||
"add-module-exports" | ||
] | ||
}, | ||
"production": { | ||
"presets": ["env", "minify"], | ||
"plugins": [ | ||
"add-module-exports" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# EditorConfig helps developers define and maintain | ||
# consistent coding styles between different editors and IDEs. | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": "airbnb", | ||
"env": { | ||
"mocha": true | ||
}, | ||
"rules": { | ||
"comma-dangle": ["error", "only-multiline"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Editors | ||
.idea | ||
|
||
# Lib | ||
lib | ||
|
||
# npm package lock | ||
package-lock.json | ||
yarn.lock | ||
|
||
others | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
*.log | ||
npm-debug.log* | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
.nyc_output | ||
|
||
# Dependency directories | ||
node_modules | ||
|
||
# npm package lock | ||
package-lock.json | ||
yarn.lock | ||
|
||
# project files | ||
src | ||
test | ||
examples | ||
CHANGELOG.md | ||
.travis.yml | ||
.editorconfig | ||
.eslintignore | ||
.eslintrc | ||
.babelrc | ||
.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: node_js | ||
node_js: | ||
- '8' | ||
- '6' | ||
script: | ||
- npm run test | ||
- npm run build | ||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Meet Dave <[email protected]> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Node CCAvenue | ||
|
||
Readme will be updated soon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* eslint-disable no-console */ | ||
const defaultAwesomeFunction = require('../lib').default; | ||
const { awesomeFunction } = require('../lib'); | ||
|
||
const defaultVal = defaultAwesomeFunction('CCAvenue'); | ||
const val = awesomeFunction(); | ||
|
||
console.log(defaultVal); | ||
console.log(val); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const example = require('./example'); | ||
|
||
module.exports = { | ||
example | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"name": "node-ccavenue", | ||
"version": "0.0.1", | ||
"description": "NPM Module for integrating CCAvenue Payment gateway in Node.js", | ||
"main": "./lib/index.js", | ||
"scripts": { | ||
"clean": "rimraf lib", | ||
"test": "npm run lint && npm run cover", | ||
"test:prod": "cross-env BABEL_ENV=production npm run test", | ||
"test:only": "mocha --require babel-core/register --require babel-polyfill --recursive", | ||
"test:watch": "npm test -- --watch", | ||
"test:examples": "node examples/", | ||
"cover": "istanbul cover _mocha -- --require babel-core/register --require babel-polyfill --recursive", | ||
"lint": "eslint src test", | ||
"build": "cross-env BABEL_ENV=production babel src --out-dir lib", | ||
"prepublish": "npm run clean && npm run lint && npm run test && npm run build" | ||
}, | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/meetdave3/node-ccavenue.git" | ||
}, | ||
"keywords": [ | ||
"ccavenue", | ||
"payment gateway", | ||
"nodejs", | ||
"javascript" | ||
], | ||
"author": "Meet Dave <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/meetdave3/node-ccavenue/issues" | ||
}, | ||
"homepage": "https://github.com/meetdave3/node-ccavenue#readme", | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^8.2.1", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-polyfill": "^6.26.0", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-minify": "^0.3.0", | ||
"chai": "^4.1.2", | ||
"cross-env": "^5.1.3", | ||
"eslint": "^4.16.0", | ||
"eslint-config-airbnb": "^16.1.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.2", | ||
"eslint-plugin-react": "^7.4.0", | ||
"istanbul": "^1.0.0-alpha", | ||
"mocha": "^5.0.0", | ||
"rimraf": "^2.6.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const { | ||
createHash, | ||
createCipheriv, | ||
createDecipheriv | ||
} = require('crypto'); | ||
|
||
let initOptions = {}; | ||
|
||
class Configure { | ||
constructor(options) { | ||
initOptions = options || {}; | ||
} | ||
|
||
validateKey() { | ||
return initOptions && initOptions.workingKey ? true : false; | ||
} | ||
|
||
throwError(requirement) { | ||
console.error(`${requirement} is required to perform this action`); | ||
} | ||
|
||
encrypt(plainText) { | ||
if (this.validateKey && plainText) { | ||
const { workingKey } = initOptions; | ||
const m = createHash('md5'); | ||
m.update(workingKey); | ||
const key = m.digest(); | ||
const iv = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'; | ||
const cipher = createCipheriv('aes-128-cbc', key, iv); | ||
let encoded = cipher.update(plainText, 'utf8', 'hex'); | ||
encoded += cipher.final('hex'); | ||
return encoded; | ||
} else if (!plainText) { | ||
throwError('Plain text'); | ||
return false; | ||
} else { | ||
throwError('Working Key'); | ||
return false; | ||
} | ||
} | ||
|
||
decrypt(encText) { | ||
if (this.validateKey && encText) { | ||
const { workingKey } = initOptions; | ||
const m = createHash('md5'); | ||
m.update(workingKey); | ||
const key = m.digest(); | ||
const iv = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'; | ||
const decipher = createDecipheriv('aes-128-cbc', key, iv); | ||
let decoded = decipher.update(encText, 'hex', 'utf8'); | ||
decoded += decipher.final('utf8'); | ||
return decoded; | ||
} else if (!encText) { | ||
throwError('Encrypted text'); | ||
return false; | ||
} else { | ||
throwError('Working Key'); | ||
return false; | ||
} | ||
} | ||
|
||
} | ||
|
||
export { Configure }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// import { assert } from 'chai'; | ||
// import defaultAwesomeFunction, { awesomeFunction } from '../src'; | ||
|
||
// describe('Awesome test.', () => { | ||
// it('should test default awesome function', () => { | ||
// const expectedVal = 'I am the Default Awesome Function, fellow comrade!' | ||
// assert(defaultAwesomeFunction('Dinesh') === expectedVal, 'Default not awesome :('); | ||
// }); | ||
|
||
// it('should test awesome function', () => { | ||
// const expectedVal = 'I am just an Awesome Function' | ||
// assert(awesomeFunction() === expectedVal, 'Named awesome :('); | ||
// }); | ||
// }); |