Permalink
Browse files

Merge pull request #14 from Xavi-/remove-require-paths

Help make paynode compatible with node 0.6.x
  • Loading branch information...
tcurdt committed Jan 17, 2012
2 parents 0fccaa1 + 4e2e1a5 commit dcbc441d29241876d924d126405661bf12800410
View
@@ -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)
})
})
@@ -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
@@ -1,5 +1,3 @@
-require.paths.unshift(__dirname+'/../');
-
var https = require ('https'),
events = require ('events'),
querystring = require ('querystring');
View
@@ -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
@@ -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;
@@ -1,5 +1,5 @@
var GatewayClient = require('../gateway-client').GatewayClient,
- paypalResponse = require('response-parser');
+ paypalResponse = require('./response-parser');
function PaypalNetworkClient(level, authInfo){
@@ -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
@@ -1,5 +1,3 @@
-require.paths.unshift(__dirname);
-
exports.use = function(name){
return require(__dirname + '/'+name+'/client')
}
@@ -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)
}
@@ -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'
@@ -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)
},
@@ -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')
@@ -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({
@@ -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':{
@@ -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 () {
@@ -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);
@@ -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': {
@@ -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);
@@ -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(){
@@ -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({
@@ -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":{
Oops, something went wrong.

0 comments on commit dcbc441

Please sign in to comment.