Skip to content

Commit

Permalink
Removed uses of require.paths as well as references to sys library. A…
Browse files Browse the repository at this point in the history
…lso fixed some unit tests.
  • Loading branch information
xavi- committed Jan 12, 2012
1 parent 0fccaa1 commit 4e2e1a5
Show file tree
Hide file tree
Showing 29 changed files with 92 additions and 144 deletions.
4 changes: 2 additions & 2 deletions docs/PayflowPro.md
Expand Up @@ -95,8 +95,8 @@ Get the balances of your account
})
client.getBalance().on('success', function(result){
result.balances.forEach(function(balance){
sys.puts(balance.amt)
sys.puts(balance.currencycode)
console.log(balance.amt)
console.log(balance.currencycode)
})
})

Expand Down
6 changes: 2 additions & 4 deletions lib/authorizenet/client.js
@@ -1,8 +1,6 @@
require.paths.unshift(__dirname)

var EventEmitter = require('events').EventEmitter,
GatewayClient = require('../gateway-client').GatewayClient,
response = require('response-parser')
response = require('./response-parser')

exports.createClient = function(options, netClient){
var conn = netClient || new GatewayClient({
Expand All @@ -14,7 +12,7 @@ exports.createClient = function(options, netClient){
return new Client(options, conn)
}

exports.levels = require('levels').levels
exports.levels = require('./levels').levels

function Client(options, netClient){
var addOptionAttributes = function(req){
Expand Down
2 changes: 0 additions & 2 deletions lib/chargify/client.js
@@ -1,5 +1,3 @@
require.paths.unshift(__dirname+'/../');

var https = require ('https'),
events = require ('events'),
querystring = require ('querystring');
Expand Down
3 changes: 1 addition & 2 deletions lib/gateway-client.js
@@ -1,5 +1,4 @@
var qs = require('querystring'),
sys = require('sys'),
https = require('https');

function GatewayClient(opts, authInfo){
Expand Down Expand Up @@ -30,7 +29,7 @@ function GatewayClient(opts, authInfo){
req.on('response', function(res){
res.on('data', function(data){
// TODO add error handling
callback(opts.responseParser.parseResponse(opts.responseOptions, request, data.toString()))
callback(opts.responseParser.parseResponse(requestString, data.toString(), opts.responseOptions))
})
})
}
Expand Down
10 changes: 4 additions & 6 deletions lib/payflowpro/client.js
@@ -1,8 +1,6 @@
require.paths.unshift(__dirname)

var EventEmitter = require('events').EventEmitter,
PaypalNetworkClient = require('paypal-network-client').PaypalNetworkClient,
requestBuilder = require("request-builder");
PaypalNetworkClient = require('./paypal-network-client').PaypalNetworkClient,
requestBuilder = require("./request-builder");

var SUPPORTED_API_METHODS = [
'transactionSearch',
Expand Down Expand Up @@ -31,7 +29,7 @@ var SUPPORTED_API_METHODS = [
'doExpressCheckoutPayment'
];

exports.levels = require('levels');
exports.levels = require('./levels');

exports.createClient = function(options){
options.version = '64.0';
Expand Down Expand Up @@ -59,7 +57,7 @@ function Client(options, paypal){
var emitter = new EventEmitter();

paypal.request(req, function(data){
emitter.emit((data.ack ? data.ack.toLowerCase() : 'fail'), data);
emitter.emit((data.ack ? data.ack.toLowerCase() : 'failure'), data);
});

return emitter;
Expand Down
2 changes: 1 addition & 1 deletion lib/payflowpro/paypal-network-client.js
@@ -1,5 +1,5 @@
var GatewayClient = require('../gateway-client').GatewayClient,
paypalResponse = require('response-parser');
paypalResponse = require('./response-parser');

function PaypalNetworkClient(level, authInfo){

Expand Down
5 changes: 2 additions & 3 deletions lib/payflowpro/response-parser.js
@@ -1,6 +1,5 @@
var qs = require('querystring')
var s = require('sys')
var val = require('value-matcher').val
var val = require('../value-matcher').val

var errorField = [ 'errorcode', 'shortmessage', 'longmessage', 'severitycode' ]
var balanceField = [ 'amt', 'currencycode' ]
Expand All @@ -20,7 +19,7 @@ var isSpecialNestedField = function(s){
return s.search(/_\d_/) > -1
}

function buildResponse(responseOptions, request, data){
function buildResponse(request, data, responseOptions){
var lowercaseKeys = function(data){
var result = {}
Object.keys(data).forEach(function(k){
Expand Down
2 changes: 0 additions & 2 deletions lib/paynode.js
@@ -1,5 +1,3 @@
require.paths.unshift(__dirname);

exports.use = function(name){
return require(__dirname + '/'+name+'/client')
}
4 changes: 1 addition & 3 deletions spec/helpers/prenuptials.js
@@ -1,9 +1,7 @@
var sys = require('sys')

exports.one = function(fn){
return function(err, result) { fn(err) }
}

exports.failWithDump = function(){
sys.puts(sys.inspect(arguments))
console.dir(arguments)
}
2 changes: 1 addition & 1 deletion spec/helpers/transactions.js
Expand Up @@ -4,7 +4,7 @@ exports.valid={amt:'99.06'
,ipaddress:'1.1.1.1'
,creditcardtype:'Visa'
,acct:'4834907016040081'
,expdate:'032011'
,expdate:'032015'
,cvv2:'000'
,firstname:'John'
,lastname:'Doe'
Expand Down
56 changes: 26 additions & 30 deletions spec/integration/authorizenet/performAimTransaction.spec.js
@@ -1,11 +1,7 @@
require.paths.unshift(__dirname+'/../../helpers/')
require.paths.unshift(__dirname+'/../../../lib/')

var vows = require('vows'),
assert = require('assert'),
clients = require('clients'),
authorizenet = require('paynode').use('authorizenet'),
sys = require('sys')
clients = require('../../helpers/clients'),
authorizenet = require('../../../lib/paynode').use('authorizenet')

var client = authorizenet.createClient({
level:authorizenet.levels.sandbox
Expand All @@ -20,18 +16,18 @@ var invalidAuthClient = authorizenet.createClient({
})

var goodTransaction = {
"x_type": "AUTH_CAPTURE",
"x_method": "CC",
"x_card_num": "4111111111111111",
"x_exp_date": "0115",
"x_amount": "19.99",
"x_description": "Sample Transaction",

"x_first_name": "John",
"x_last_name": "Doe",
"x_address": "1234 Street",
"x_state": "WA",
"x_type": "AUTH_CAPTURE",
"x_method": "CC",
"x_card_num": "4111111111111111",
"x_exp_date": "0115",

"x_amount": "19.99",
"x_description": "Sample Transaction",

"x_first_name": "John",
"x_last_name": "Doe",
"x_address": "1234 Street",
"x_state": "WA",
"x_zip": "98004"}


Expand Down Expand Up @@ -60,18 +56,18 @@ vows.describe('AIM Transaction').addBatch({
'a failed transaction due to invalid card':{
topic:function(){
client.performAimTransaction({
"x_type": "AUTH_CAPTURE",
"x_method": "CC",
"x_card_num": "4111111111111111",
"x_exp_date": "0105",
"x_amount": "19.99",
"x_description": "Sample Transaction",

"x_first_name": "John",
"x_last_name": "Doe",
"x_address": "1234 Street",
"x_state": "WA",
"x_type": "AUTH_CAPTURE",
"x_method": "CC",
"x_card_num": "4111111111111111",
"x_exp_date": "0105",

"x_amount": "19.99",
"x_description": "Sample Transaction",

"x_first_name": "John",
"x_last_name": "Doe",
"x_address": "1234 Street",
"x_state": "WA",
"x_zip": "98004"
}).on('failure', this.callback)
},
Expand Down
6 changes: 3 additions & 3 deletions spec/integration/chargify/customers.spec.js
@@ -1,7 +1,6 @@
require.paths.unshift(__dirname+'/../../../lib/');
var vows = require('vows');
var assert = require('assert');
var paynode = require('paynode').use('chargify');
var paynode = require('../../../lib/paynode').use('chargify');


var client = paynode.createClient({
Expand All @@ -20,13 +19,14 @@ vows.describe('module').addBatch({
},
'Given I have customer data': {
topic: function() {
var callback = this.callback;
client.customers.create({
customer:{
first_name:'Joe',
last_name:'Blow',
email:'joe.blow@example.com'
}
}).on('success', this.callback);
}).on('success', function(response) { callback(null, response) })
},
'should get response with same details sent': function(response) {
assert.equal(response.customer.first_name, 'Joe')
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/chargify/subscriptions.spec.js
@@ -1,6 +1,6 @@
var vows = require('vows');
var assert = require('assert');
var paynode = require('paynode').use('chargify');
var paynode = require('../../../lib/paynode').use('chargify');


vows.describe('subscriptions').addBatch({
Expand Down
12 changes: 4 additions & 8 deletions spec/integration/payflowpro/SetExpressCheckout.spec.js
@@ -1,13 +1,9 @@
require.paths.unshift(__dirname+'/../../helpers/')
require.paths.unshift(__dirname+'/../../../lib/')

var vows = require('vows'),
one = require('prenuptials').one,
one = require('../../helpers/prenuptials').one,
assert = require('assert'),
transactions = require("transactions"),
clients = require('clients'),
payflow = require('paynode').use('payflowpro'),
sys = require('sys')
transactions = require("../../helpers/transactions"),
clients = require('../../helpers/clients'),
payflow = require('../../../lib/paynode').use('payflowpro')

vows.describe('SetExpressCheckout').addBatch({
'successful transaction':{
Expand Down
8 changes: 3 additions & 5 deletions spec/integration/payflowpro/TransactionRelated.spec.js
@@ -1,11 +1,9 @@
require.paths.unshift(__dirname+'../../../lib/')
require.paths.unshift(__dirname+'/../../helpers/')
var vows = require('vows');
var assert = require('assert');
var clients = require('clients');
var transactions = require ('transactions');
var clients = require('../../helpers/clients');
var transactions = require ('../../helpers/transactions');

var client = clients.signatureAuth(require('paynode').use('payflowpro'));
var client = clients.signatureAuth(require('../../../lib/paynode').use('payflowpro'));

// promise for transaction execution
function executeTransaction () {
Expand Down
18 changes: 7 additions & 11 deletions spec/integration/payflowpro/doDirectPayment.spec.js
@@ -1,21 +1,17 @@
require.paths.unshift(__dirname+'/../../helpers/')
require.paths.unshift(__dirname+'/../../../lib/')

var vows = require('vows'),
one = require('prenuptials').one,
one = require('../../helpers/prenuptials').one,
assert = require('assert'),
transactions = require("transactions"),
payflow = require('paynode').use('payflowpro'),
clients = require('clients'),
sys = require('sys')
transactions = require("../../helpers/transactions"),
payflow = require('../../../lib/paynode').use('payflowpro'),
clients = require('../../helpers/clients')

function examplesUsing(client){
return {
'Successful Transaction':{
topic: function () {
client.doDirectPayment(transactions.valid)
.on('success', this.callback)
.on('failure', function(res){ console.log(sys.inspect(res)) })
.on('success', this.callback)
.on('failure', function(res){ console.dir(res) })
},
'emits a successful result': function (result, ignore){
assert.equal('Success', result.ack)
Expand Down Expand Up @@ -58,5 +54,5 @@ function examplesUsing(client){

vows.describe('doDirectPayment')
.addBatch(examplesUsing(clients.signatureAuth(payflow)))
.addBatch(examplesUsing(clients.certAuth(payflow)))
//.addBatch(examplesUsing(clients.certAuth(payflow)))
.export(module);
11 changes: 4 additions & 7 deletions spec/integration/payflowpro/getBalance.spec.js
@@ -1,13 +1,10 @@
require.paths.unshift(__dirname+'/../../helpers/')
require.paths.unshift(__dirname+'/../../../lib/')

var vows = require('vows'),
one = require('prenuptials').one,
one = require('../../helpers/prenuptials').one,
assert = require('assert'),
transactions = require("transactions"),
clients = require('clients')
transactions = require("../../helpers/transactions"),
clients = require('../../helpers/clients')

var client = clients.signatureAuth(require('paynode').use('payflowpro'));
var client = clients.signatureAuth(require('../../../lib/paynode').use('payflowpro'));

vows.describe('getBalance').addBatch({
'get single balances': {
Expand Down
13 changes: 5 additions & 8 deletions spec/integration/payflowpro/getTransactionDetails.spec.js
@@ -1,13 +1,10 @@
require.paths.unshift(__dirname+'/../../helpers/')
require.paths.unshift(__dirname+'/../../../lib/')

var vows = require('vows'),
one = require('prenuptials').one,
fail = require('prenuptials').failWithDump,
one = require('../../helpers/prenuptials').one,
fail = require('../../helpers/prenuptials').failWithDump,
assert = require('assert'),
transactions = require("transactions"),
clients = require('clients'),
payflow = require('paynode').use('payflowpro')
transactions = require("../../helpers/transactions"),
clients = require('../../helpers/clients'),
payflow = require('../../../lib/paynode').use('payflowpro')


var client = clients.signatureAuth(payflow);
Expand Down
19 changes: 8 additions & 11 deletions spec/integration/payflowpro/paypal-network-client.spec.js
@@ -1,19 +1,16 @@
require.paths.unshift(__dirname+'/../../helpers/')
require.paths.unshift(__dirname+'/../../../lib/')
require.paths.unshift(__dirname+'/../../../lib/payflowpro')

var vows = require('vows'),
one = require('prenuptials').one,
fail = require('prenuptials').failWithDump,
one = require('../../helpers/prenuptials').one,
fail = require('../../helpers/prenuptials').failWithDump,
assert = require('assert'),
transactions = require("transactions"),
certuser = require('clients').certuser
transactions = require("../../helpers/transactions"),
certuser = require('../../helpers/clients').certuser,
levels = require('../../../lib/payflowpro/levels')

var PaypalNetworkClient = require('paypal-network-client').PaypalNetworkClient;
var PaypalNetworkClient = require('../../../lib/payflowpro/paypal-network-client').PaypalNetworkClient;

(function(){
var client = new PaypalNetworkClient('api-3t.sandbox.paypal.com')
,certClient = new PaypalNetworkClient('api.sandbox.paypal.com', {cert:certuser.cert, key:certuser.key})
var client = new PaypalNetworkClient(levels.sandbox({}))
,certClient = new PaypalNetworkClient(levels.sandbox({ cert: true }), {cert:certuser.cert, key:certuser.key})
vows.describe('PaypalNetworkClient').addBatch({
'signature auth': {
topic:function(){
Expand Down
5 changes: 1 addition & 4 deletions spec/unit/authorizenet/aim-response-parser.spec.js
@@ -1,9 +1,6 @@
require.paths.unshift(__dirname+'/../helpers/')
require.paths.unshift(__dirname+'/../../../lib/')

var vows = require('vows'),
assert = require('assert'),
response = require('authorizenet/response-parser')
response = require('../../../lib/authorizenet/response-parser')


vows.describe('Authorize.net Response Parser').addBatch({
Expand Down
3 changes: 1 addition & 2 deletions spec/unit/chargify-client.spec.js
@@ -1,7 +1,6 @@
require.paths.unshift(__dirname+'/../../lib/');
var vows = require('vows');
var assert = require('assert');
var Client = require('paynode').use('chargify')._Client;
var Client = require('../../lib/paynode').use('chargify')._Client;

/// -- example data
var exampleSubscription = {"subscription":{
Expand Down

0 comments on commit 4e2e1a5

Please sign in to comment.