Skip to content

Commit 6ffab4b

Browse files
author
Luke Heath
committed
Initial commit
0 parents  commit 6ffab4b

10 files changed

+542
-0
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitignore

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
############################
2+
# npm
3+
############################
4+
node_modules
5+
npm-debug.log
6+
7+
8+
############################
9+
# tmp, editor & OS files
10+
############################
11+
.tmp
12+
*.swo
13+
*.swp
14+
*.swn
15+
*.swm
16+
.DS_STORE
17+
*#
18+
*~
19+
.idea
20+
nbproject
21+
22+
23+
############################
24+
# Tests
25+
############################
26+
coverage
27+
28+
29+
############################
30+
# Other
31+
############################
32+
.node_history

.jshintrc

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
// To fix column positions for JSHint errors you may want to add `"indent": 1` to your
3+
// **User** "jshint_options". This issue affects users with tabs for indentation.
4+
// This fix was reverted due to a conflict with using the `"white": true` option.
5+
// "indent": 1,
6+
"evil": true,
7+
"regexdash": true,
8+
"browser": true,
9+
"wsh": true,
10+
"sub": true,
11+
12+
// Suppress warnings about mixed tabs and spaces
13+
"smarttabs": true,
14+
15+
// Suppress warnings about trailing whitespace
16+
"trailing": false,
17+
18+
// Suppress warnings about the use of expressions where fn calls or assignments are expected
19+
"expr": true,
20+
21+
// Suppress warnings about using functions inside loops (useful for inifinityCounters)
22+
"loopfunc": true,
23+
24+
// Suppress warnings about using assignments where conditionals are expected
25+
"boss": true,
26+
27+
// Suppress warnings about "weird constructions"
28+
// i.e. allow code like:
29+
// (new (function OneTimeUsePrototype () { } ))
30+
"supernew": true,
31+
32+
// Allow backwards, node-dependency-style commas
33+
"laxcomma": true
34+
35+
// "bitwise": true,
36+
// "camelcase": true,
37+
// "node": true,
38+
// "undef": true,
39+
// "unused": true,
40+
// "curly": true,
41+
// "immed": true,
42+
// "latedef": true,
43+
// "noarg": true,
44+
// "noempty": true,
45+
// "plusplus": true,
46+
// "quotmark": "single",
47+
// "trailing": true,
48+
// "asi": false,
49+
// "eqnull": true,
50+
// "eval": true,
51+
// "sub": true,
52+
// "supernew": true,
53+
// "eqeqeq": true,
54+
// "eqnull": true
55+
}

.npmignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
*#
2+
node_modules
3+
ssl
4+
.DS_STORE
5+
*.swo
6+
*.swp
7+
*.swn
8+
*.swm
9+
*~
10+
.idea
11+
nbproject
12+
.git
13+
.gitignore
14+
.tmp
15+
.jshintrc
16+
.editorconfig
17+
CONTRIBUTING.md
18+
*.md
19+
**/*.md
20+
test

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
<h1>
3+
<a href="http://node-machine.org" title="Node-Machine public registry"><img alt="node-machine logo" title="Node-Machine Project" src="http://node-machine.org/images/machine-anthropomorph-for-white-bg.png" width="50" /></a>
4+
machinepack-wepay
5+
</h1>
6+
7+
### [Docs](http://node-machine.org/machinepack-wepay) &nbsp; [Browse other machines](http://node-machine.org/machinepacks) &nbsp; [FAQ](http://node-machine.org/implementing/FAQ) &nbsp; [Newsgroup](https://groups.google.com/forum/?hl=en#!forum/node-machine)
8+
9+
Communicate with WePay API to create merchants, charge payers, etc.
10+
11+
12+
## Installation &nbsp; [![NPM version](https://badge.fury.io/js/machinepack-wepay.svg)](http://badge.fury.io/js/machinepack-wepay) [![Build Status](https://travis-ci.org/mikermcneil/machinepack-wepay.png?branch=master)](https://travis-ci.org/mikermcneil/machinepack-wepay)
13+
14+
```sh
15+
$ npm install machinepack-wepay
16+
```
17+
18+
## Usage
19+
20+
For the latest usage documentation, version information, and test status of this module, see <a href="http://node-machine.org/machinepack-wepay" title="Communicate with WePay API to create merchants, charge payers, etc. (for node.js)">http://node-machine.org/machinepack-wepay</a>. The generated manpages for each machine contain a complete reference of all expected inputs, possible exit states, and example return values. If you need more help, or find a bug, jump into [Gitter](https://gitter.im/node-machine/general) or leave a message in the project [newsgroup](https://groups.google.com/forum/?hl=en#!forum/node-machine).
21+
22+
## About &nbsp; [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/node-machine/general?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
23+
24+
This is a [machinepack](http://node-machine.org/machinepacks), an NPM module which exposes a set of related Node.js [machines](http://node-machine.org/spec/machine) according to the [machinepack specification](http://node-machine.org/spec/machinepack).
25+
Documentation pages for the machines contained in this module (as well as all other NPM-hosted machines for Node.js) are automatically generated and kept up-to-date on the <a href="http://node-machine.org" title="Public machine registry for Node.js">public registry</a>.
26+
Learn more at <a href="http://node-machine.org/implementing/FAQ" title="Machine Project FAQ (for implementors)">http://node-machine.org/implementing/FAQ</a>.
27+
28+
## License
29+
30+
MIT &copy; 2016 contributors
31+

index.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This is a boilerplate file which should not need to be changed.
2+
module.exports = require('machine').pack({
3+
pkg: require('./package.json'),
4+
dir: __dirname
5+
});

machines/app-details.js

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
module.exports = {
2+
3+
friendlyName: 'Application Details',
4+
5+
6+
description: 'Get details about a WePay application.',
7+
8+
9+
extendedDescription: 'Lookup details about a WePay application by client id and secret',
10+
11+
12+
inputs: {
13+
14+
clientId: {
15+
example: 123456,
16+
description: 'The integer client ID issued to the app, found on your application\'s dashboard',
17+
required: true
18+
},
19+
20+
clientSecret: {
21+
example: '6446c521bd',
22+
description: 'The string client secret issued to the app, found on your application\'s dashboard',
23+
required: true
24+
}
25+
26+
},
27+
28+
29+
exits: {
30+
31+
error: {
32+
description: 'An unexpected error occurred.'
33+
},
34+
35+
success: {
36+
"api_version":567235,
37+
"client_id":"604f39f41e364951ced74070c6e8bfa49d346cdfee6191b03c2c2d9c9cda9184",
38+
"state":"BEARER",
39+
"status":1209600,
40+
"theme_object": {},
41+
"gaq_domains": ''
42+
}
43+
},
44+
45+
46+
fn: function(inputs, exits) {
47+
/**
48+
* Module Dependencies
49+
*/
50+
51+
var wepay = require('wepay').WEPAY;
52+
53+
// wepay request settings
54+
var wepay_settings = {
55+
'client_id': inputs.clientId,
56+
'client_secret': inputs.clientSecret
57+
// 'api_version': 'API_VERSION'
58+
}
59+
60+
// Instantiate new wepay instance with settings
61+
var wp = new wepay(wepay_settings);
62+
63+
// Set API environment
64+
if(inputs.useProduction){
65+
wp.use_production();
66+
}
67+
else{
68+
wp.use_staging();
69+
}
70+
71+
wp.call('/app',
72+
{
73+
'client_id': inputs.clientId,
74+
'client_secret': inputs.clientSecret
75+
},
76+
function(response) {
77+
78+
var responseObj = JSON.parse(String(response));
79+
80+
if(responseObj.error){
81+
return exits.error(responseObj)
82+
}
83+
else{
84+
return exits.success(responseObj);
85+
}
86+
87+
});
88+
},
89+
90+
91+
92+
};

0 commit comments

Comments
 (0)