Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Help make paynode compatible with node 0.6.x #14

Merged
merged 1 commit into from

4 participants

@xavi-

Removed uses of require.paths as well as references to sys library. Also fixed some unit tests.

@indexzero
Collaborator

@jamescarr This looks good to me.

@tcurdt
Collaborator

not really nice with all the ../ but let's merge for now. thanks for the work!

@tcurdt tcurdt merged commit dcbc441 into from
@indexzero
Collaborator

@tcurdt There is no way around ./ in node.js now

@tcurdt
Collaborator

yeah, doesn't make it any prettier though :)

@xavi-

Yeah, ../../../ is pretty ugly, but what can you do? =P

BTW, any chance you can publish a new version of paynode to npm with these changes? =]

@jamescarr
Owner

@indexzero do you or @tcurdt have publish permissions for paynode?

@tcurdt
Collaborator
$ npm owner ls paynode
jamescarr <james.r.carr@gmail.com>
$

@jamescarr will you do it? or can you make me a owner, too?

@xavi-

Hello,

Was a new version ever pushed to npm?

Thanks,
Xavi

@jamescarr
Owner
@tcurdt
Collaborator

Thanks for looking into that @jamescarr

@jamescarr
Owner

0.3.6 has been published.

@jamescarr
Owner

tcurdt and indexzero: you two are now owners of this package too. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 12, 2012
  1. @xavi-

    Removed uses of require.paths as well as references to sys library. A…

    xavi- authored
    …lso fixed some unit tests.
This page is out of date. Refresh to see the latest.
Showing with 92 additions and 144 deletions.
  1. +2 −2 docs/PayflowPro.md
  2. +2 −4 lib/authorizenet/client.js
  3. +0 −2  lib/chargify/client.js
  4. +1 −2  lib/gateway-client.js
  5. +4 −6 lib/payflowpro/client.js
  6. +1 −1  lib/payflowpro/paypal-network-client.js
  7. +2 −3 lib/payflowpro/response-parser.js
  8. +0 −2  lib/paynode.js
  9. +1 −3 spec/helpers/prenuptials.js
  10. +1 −1  spec/helpers/transactions.js
  11. +26 −30 spec/integration/authorizenet/performAimTransaction.spec.js
  12. +3 −3 spec/integration/chargify/customers.spec.js
  13. +1 −1  spec/integration/chargify/subscriptions.spec.js
  14. +4 −8 spec/integration/payflowpro/SetExpressCheckout.spec.js
  15. +3 −5 spec/integration/payflowpro/TransactionRelated.spec.js
  16. +7 −11 spec/integration/payflowpro/doDirectPayment.spec.js
  17. +4 −7 spec/integration/payflowpro/getBalance.spec.js
  18. +5 −8 spec/integration/payflowpro/getTransactionDetails.spec.js
  19. +8 −11 spec/integration/payflowpro/paypal-network-client.spec.js
  20. +1 −4 spec/unit/authorizenet/aim-response-parser.spec.js
  21. +1 −2  spec/unit/chargify-client.spec.js
  22. +1 −2  spec/unit/gateway-client.spec.js
  23. +7 −8 spec/unit/levels.spec.js
  24. +1 −2  spec/unit/modules.spec.js
  25. +1 −4 spec/unit/request-builder.spec.js
  26. +1 −2  spec/unit/response-builder.spec.js
  27. +2 −6 spec/unit/response-parser.spec.js
  28. +1 −2  spec/unit/value-matcher.spec.js
  29. +1 −2  spike.js
View
4 docs/PayflowPro.md
@@ -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)
})
})
View
6 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({
@@ -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){
View
2  lib/chargify/client.js
@@ -1,5 +1,3 @@
-require.paths.unshift(__dirname+'/../');
-
var https = require ('https'),
events = require ('events'),
querystring = require ('querystring');
View
3  lib/gateway-client.js
@@ -1,5 +1,4 @@
var qs = require('querystring'),
- sys = require('sys'),
https = require('https');
function GatewayClient(opts, authInfo){
@@ -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))
})
})
}
View
10 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',
@@ -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';
@@ -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;
View
2  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){
View
5 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' ]
@@ -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){
View
2  lib/paynode.js
@@ -1,5 +1,3 @@
-require.paths.unshift(__dirname);
-
exports.use = function(name){
return require(__dirname + '/'+name+'/client')
}
View
4 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)
}
View
2  spec/helpers/transactions.js
@@ -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'
View
56 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
@@ -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"}
@@ -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)
},
View
6 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({
@@ -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')
View
2  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({
View
12 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':{
View
8 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 () {
View
18 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)
@@ -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);
View
11 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': {
View
13 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);
View
19 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(){
View
5 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({
View
3  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":{
View
3  spec/unit/gateway-client.spec.js
@@ -1,7 +1,6 @@
-require.paths.unshift(__dirname+'/../../lib/')
var vows = require('vows'),
assert = require('assert'),
- Client = require('gateway-client').GatewayClient
+ Client = require('../../lib/gateway-client').GatewayClient
var returnExceptionFrom = function(fn){
return function(){
View
15 spec/unit/levels.spec.js
@@ -1,7 +1,6 @@
-require.paths.unshift(__dirname+'/../../lib/')
var vows = require('vows'),
assert = require('assert'),
- levels = require('paynode').use('payflowpro').levels
+ levels = require('../../lib/paynode').use('payflowpro').levels
vows.describe('Environment Levels').addBatch({
'sandbox url':{
@@ -10,10 +9,10 @@ vows.describe('Environment Levels').addBatch({
return {user:'someuser', password:'somepassword', signature:'sig'}
},
'should return correct sandbox url':function(opts){
- assert.equal('api-3t.sandbox.paypal.com', levels.sandbox(opts))
+ assert.equal('api-3t.sandbox.paypal.com', levels.sandbox(opts).api)
},
'should return the correct live url':function(opts){
- assert.equal('api-3t.paypal.com', levels.live(opts))
+ assert.equal('api-3t.paypal.com', levels.live(opts).api)
}
},
'for cert':{
@@ -21,10 +20,10 @@ vows.describe('Environment Levels').addBatch({
return {user:'someuser', password:'somepassword', cert:'cert', key:'key'}
},
'should return correct sandbox url':function(opts){
- assert.equal('api.sandbox.paypal.com', levels.sandbox(opts))
+ assert.equal('api.sandbox.paypal.com', levels.sandbox(opts).api)
},
'should return the correct live url':function(opts){
- assert.equal('api.paypal.com', levels.live(opts))
+ assert.equal('api.paypal.com', levels.live(opts).api)
}
},
'when both are present, use cert':{
@@ -32,10 +31,10 @@ vows.describe('Environment Levels').addBatch({
return {user:'someuser', password:'somepassword', cert:'cert', key:'key', signature:'sig'}
},
'should return correct sandbox url':function(opts){
- assert.equal('api.sandbox.paypal.com', levels.sandbox(opts))
+ assert.equal('api.sandbox.paypal.com', levels.sandbox(opts).api)
},
'should return the correct live url':function(opts){
- assert.equal('api.paypal.com', levels.live(opts))
+ assert.equal('api.paypal.com', levels.live(opts).api)
}
}
}
View
3  spec/unit/modules.spec.js
@@ -1,7 +1,6 @@
-require.paths.unshift(__dirname+'../../../lib/');
var vows = require('vows');
var assert = require('assert');
-var paynode = require('paynode');
+var paynode = require('../../lib/paynode');
vows.describe('modules').addBatch({
View
5 spec/unit/request-builder.spec.js
@@ -1,9 +1,6 @@
-require.paths.unshift(__dirname+'/../../lib/')
-require.paths.unshift(__dirname+'/../../lib/payflowpro/')
-
var vows = require('vows'),
assert = require('assert'),
- builder = require('request-builder')
+ builder = require('../../lib/payflowpro/request-builder')
var exampleRequest = {maxamt:1000.00,
paymentrequest:[
View
3  spec/unit/response-builder.spec.js
@@ -1,7 +1,6 @@
-require.paths.unshift(__dirname+'../../../lib/');
var vows = require('vows');
var assert = require('assert');
-var r = require('payflowpro/response-parser');
+var r = require('../../lib/payflowpro/response-parser');
vows.describe('building a response').addBatch({
View
8 spec/unit/response-parser.spec.js
@@ -1,11 +1,7 @@
-require.paths.unshift(__dirname+'/../helpers/')
-require.paths.unshift(__dirname+'/../../lib/')
-require.paths.unshift(__dirname+'/../../lib/payflowpro')
-
var vows = require('vows'),
- one = require('prenuptials').one,
+ one = require('../helpers/prenuptials').one,
assert = require('assert'),
- response = require('response-parser')
+ response = require('../../lib/payflowpro/response-parser')
vows.describe('Response Parser').addBatch({
View
3  spec/unit/value-matcher.spec.js
@@ -1,7 +1,6 @@
-require.paths.unshift(__dirname+'../../../lib/');
var vows = require('vows');
var assert = require('assert');
-var val = require('value-matcher').val;
+var val = require('../../lib/value-matcher').val;
vows.describe('Value Matcher').addBatch({
View
3  spike.js
@@ -1,7 +1,6 @@
var http = require('http'),
crypto = require('crypto'),
fs = require('fs'),
- sys = require('sys'),
qs = require('querystring')
var transaction = {user:'cert_1279865159_biz_api1.gmail.com'
@@ -38,7 +37,7 @@ function start(key, cert){
req.on('response', function(res){
res.on('data', function(data){
- sys.puts(sys.inspect(qs.parse(data)))
+ console.dir(qs.parse(data));
})
})
}
Something went wrong with that request. Please try again.