Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dwolla

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dwolla - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

config.js

182

lib/dwolla.js

@@ -22,10 +22,10 @@ var https = require('https');

data = JSON.parse(data);
if (data.Success) {
fn(null, data.Response);
} else {
fn(data.Message, null);
}
} catch (e) {
fn('Error parsing response from dwolla api.', data);
fn('Error parsing response from Dwolla API.', data);
}
if (data.Success) {
fn(null, data.Response);
} else {
fn(data.Message);
}
});

@@ -36,2 +36,33 @@ });

function _post(path, post_data, fn) {
var options = {
host: 'www.dwolla.com'
, path: API_PATH + path
, method: 'POST'
, headers: {
'Content-Type': 'application/json'
}
};
var req = https.request(options, function(res) {
var data = '';
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
try {
data = JSON.parse(data);
} catch (e) {
fn('Error parsing response from Dwolla API.', data);
}
if (data.Success) {
fn(null, data.Response);
} else {
fn(data.Message);
}
});
});
req.write(JSON.stringify(post_data));
req.end();
}
/**

@@ -47,2 +78,7 @@ * Retrieves the basic account information for the Dwolla account associated with the account identifier.

exports.basicAccountInfo = function(client_id, client_secret, id, fn) {
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!client_id) { throw new Error('Missing arg client_id'); }
if (!client_secret) { throw new Error('Missing arg client_secret'); }
if (!id) { throw new Error('Missing arg id'); }
var path = '/users/' + id;

@@ -63,2 +99,5 @@ var params = {};

exports.fullAccountInfo = function(oauth_token, fn) {
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!oauth_token) { throw new Error('Missing arg oauth_token'); }
var params = { oauth_token: oauth_token };

@@ -76,2 +115,5 @@ _request('/users/', params, fn);

exports.balance = function(oauth_token, fn) {
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!oauth_token) { throw new Error('Missing arg oauth_token'); }
var params = { oauth_token: oauth_token };

@@ -101,2 +143,5 @@ _request('/balance/', params, fn);

}
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!oauth_token) { throw new Error('Missing arg oauth_token'); }
params = params || {};

@@ -131,13 +176,15 @@ params.oauth_token = oauth_token;

}
if (client_id !== null) {
params = params || {};
params.client_id = client_id;
params.client_secret = client_secret;
params.latitude = lat;
params.longitude = lon;
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!client_id) { throw new Error('Missing arg client_id'); }
if (!client_secret) { throw new Error('Missing arg client_secret'); }
if (!lat) { throw new Error('Missing arg lat'); }
if (!lon) { throw new Error('Missing arg lon'); }
_request('/contacts/nearby', params, fn);
} else {
console.log('Missing client_id and client_secret');
}
params = params || {};
params.client_id = client_id;
params.client_secret = client_secret;
params.latitude = lat;
params.longitude = lon;
_request('/contacts/nearby', params, fn);
};

@@ -155,2 +202,5 @@

exports.transactionById = function(oauth_token, id, fn) {
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!oauth_token) { throw new Error('Missing arg oauth_token'); }
var params = { oauth_token: oauth_token };

@@ -182,2 +232,5 @@ _request('/transactions/' + id, params, fn);

}
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!oauth_token) { throw new Error('Missing arg oauth_token'); }
params = params || {};

@@ -208,2 +261,5 @@ params.oauth_token = oauth_token;

}
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!oauth_token) { throw new Error('Missing arg oauth_token'); }
params = params || {};

@@ -213,1 +269,95 @@ params.oauth_token = oauth_token;

};
/**
* Send funds to a destination user for the user associated with the authorized access token.
* https://www.dwolla.com/developers/endpoints/transactions/send
*
* Optional params:
*
* - destinationType
* - facilitatorAmount
* - assumeCosts
* - notes
*
* @param {String} oauth_token
* @param {Number} pin
* @param {String} destinationId
* @param {String} amount
* @param {Function} fn
*/
exports.send = function(oauth_token, pin, destinationId, amount, params, fn) {
// params are optional
if (!fn || typeof params === 'function') {
fn = params;
params = {};
}
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!oauth_token) { throw new Error('Missing arg oauth_token'); }
if (!pin) { throw new Error('Missing arg pin'); }
if (!destinationId) { throw new Error('Missing arg destinationId'); }
if (!amount) { throw new Error('Missing arg amount'); }
params = params || {};
params.oauth_token = oauth_token;
params.pin = pin;
params.destinationId = destinationId;
params.amount = amount;
_post('/transactions/send', params, fn);
};
/**
* Request funds from a source user for the user associated with the authorized access token.
* https://www.dwolla.com/developers/endpoints/transactions/request
*
* Optional params:
*
* - sourceType
* - facilitatorAmount
* - notes
*
* @param {String} oauth_token
* @param {Number} pin
* @param {String} sourceId
* @param {String} amount
* @param {Function} fn
*/
exports.request = function(oauth_token, pin, sourceId, amount, params, fn) {
// params are optional
if (!fn || typeof params === 'function') {
fn = params;
params = {};
}
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!oauth_token) { throw new Error('Missing arg oauth_token'); }
if (!pin) { throw new Error('Missing arg pin'); }
if (!sourceId) { throw new Error('Missing arg sourceId'); }
if (!amount) { throw new Error('Missing arg amount'); }
params = params || {};
params.oauth_token = oauth_token;
params.pin = pin;
params.sourceId= sourceId;
params.amount = amount;
_post('/transactions/request', params, fn);
};
/**
* Register a new Dwolla user account.
* https://www.dwolla.com/developers/endpoints/register/user
*
* @param {String} client_id
* @param {String} client_secret
* @param {Object} userInfo
* @param {Function} fn
*/
exports.register = function(client_id, client_secret, userInfo, fn) {
if (typeof fn !== 'function') { throw new Error('Missing callback'); }
if (!client_id) { throw new Error('Missing arg client_id'); }
if (!client_secret) { throw new Error('Missing arg client_secret'); }
if (!userInfo) { throw new Error('Missing arg userInfo'); }
var params = {};
params.client_id = client_id;
params.client_secret = client_secret;
_post('/register/?' + qs.stringify(params), userInfo, fn);
};

2

package.json

@@ -5,3 +5,3 @@ {

"description": "Dwolla API for node.js",
"version": "0.0.4",
"version": "0.0.5",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -10,6 +10,7 @@ # Dwolla API for node.js

* nearby(client_id, client_secret, lat, lon, [, params], callback)
* register(client_id, client_secret, userInfo, callback)
Requires a valid user OAuth2 token. Note token do not expire and may be
Requires a valid user OAuth2 token. Note tokens do not expire and may be
reused. See https://github.com/bnoguchi/everyauth for an example on how
to get authorize and get a Dwolla OAuth2 token.
to authorize a user and get a Dwolla OAuth2 token.

@@ -22,2 +23,4 @@ * fullAccountInfo(oauth_token, callback)

* transactionsStats(oauth_token[, params], callback)
* send(oauth_token, pin, destinationId, amount[, params], callback)
* request(oauth_token, pin, sourceId, amount[, params], callback)

@@ -31,3 +34,3 @@ All optional parameters are passed in as an optional object before the callback.

## Example Usage
See examples.js.
See more examples in the examples folder.

@@ -57,3 +60,6 @@ var dwolla = require('dwolla');

## Tests
Tests use mocha and should
Tests use mocha and should.js. Tests were made only for GET requests,
as tests of POST requests would be processed just like real requests.
Although working examples of each POST request can be found in the
examples folder.

@@ -60,0 +66,0 @@ $ npm test

var dwolla = require('../lib/dwolla');
var should = require('should');
var c = require('./config');
var c = require('../config');

@@ -5,0 +5,0 @@ describe('Balance', function() {

var dwolla = require('../lib/dwolla');
var should = require('should');
var c = require('./config');
var c = require('../config');

@@ -5,0 +5,0 @@ describe('Contacts', function() {

var dwolla = require('../lib/dwolla');
var should = require('should');
var c = require('./config');
var c = require('../config');

@@ -25,8 +25,2 @@ describe('Transactions', function() {

});
describe('Send', function() {
it('should return a transaction number');
});
describe('Request', function() {
it('should return a transaction number');
});
});
var dwolla = require('../lib/dwolla');
var should = require('should');
var c = require('./config');
var c = require('../config');

@@ -5,0 +5,0 @@ describe('Users', function() {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc