Skip to content

brandedcrate/payjunction-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

payjunction-nodejs TravisCI

A PayJunction API client for node

Installation

$ npm install payjunction

Usage

You will need a PayJunction account in order to use this library. If you don't have one, you should sign up. If you already have an account, then you can get started by requiring this library and instantiating a PayJunctionClient object:

var PayJunctionClient = require('payjunction');

// set the connection parameters to your own values
var payjunction = new PayJunctionClient({
  username: 'YOUR-USERNAME',
  password: 'YOUR-PASSWORD',
  appkey: 'YOUR-APP-KEY',
  endpoint: 'test' // use 'live' for production
});

The API client has a property for each of the resources it supports (transactions, receipts and customers) and each property has a method for each of the supported actions. Each of the methods return an object that emits events for you to handle. The client itself uses restler under the hood, so you can read all about which events are available and callback signatures for each event in the restler documentation.

The examples here use the 'complete' event which can be used to handle both success and failure events in the same callback, but restler allows much more flexibility in this area if you need it.

Examples

Consult the PayJunction API Documentation for information about all the available API resources and actions including what parameters can be set and example responses.

Transactions

Create a transaction for a keyed credit card:

payjunction.transaction.create({
  cardNumber: 4444333322221111,
  cardExpMonth: '01',
  cardExpYear: '18',
  cardCvv: 999,
  amountBase: '99.50'
}).on('complete', function(data){
  console.log(data);
});

Create a transaction for a swiped credit card:

payjunction.transaction.create({
  cardTrack: '%B4444333322221111^First/Last^1712980100000?;4444333322221111=1712980100000?',
  amountBase: '12.00'
}).on('complete', function(data){
  console.log(data);
});

Create a transaction for an ACH transfer:

payjunction.transaction.create({
  achRoutingNumber: 104000016,
  achAccountNumber: 123456789,
  achAccountType: 'CHECKING',
  achType: 'PPD',
  amountBase: '21.00'
}).on('complete', function(data){
  console.log(data);
});

Create a new transaction from a previous transaction:

payjunction.transaction.create({
  transactionId: 74600
}).on('complete', function(data){
  console.log(data);
});

Void a transaction:

var transaction = payjunction.transaction.update(74600, {
  status: 'VOID'
}).on('complete', function(data){
  console.log(data);
});

Read a transaction:

var transaction = payjunction.transaction.read(74600).on('complete, function(data){
  console.log(data);
});

Add signature to transaction:

payjunction.transaction.addSignature({
  id: 74600,
  // JSON signature document or raw data from a capture device
  signature: '{"width":500,"height":100,"points":[[],[109,63],[109,63],[108,63],[108,62]]}'
}).on('complete', function(data){
  console.log(data);
});

receipts

Read receipt data by transaction id:

payjunction.receipt.read(74600).on('complete', function(data){
  console.log(data);
});

Sent an email receipt:

payjunction.receipt.email(74600, {
  to: '[email protected]',
  replyTo: '[email protected]'
}).on('complete', function(data){
  console.log(data);
});

customers

Create a customer:

client.customer.create({
  companyName: 'ACME, inc.',
  email: '[email protected]',
  identifier: 'your-custom-id',
  firstName: 'Joe',
  jobTitle: 'Wage Slave',
  lastName: 'Schmoe',
  middleName: 'Ignatius',
  phone: '5555551212',
  phone2: '1234567890',
  website: 'acme.com'
}).on('complete', function(data){
  console.log(data);
});

Delete a customer:

client.customer.delete(1).on('complete', function(data){
  console.log(data);
});

Running Tests

To run the test suite, first run npm install to install the development dependencies:

$ npm install

Then run the tests:

$ npm test

Maintainer

This package is maintained by Branded Crate.

License

This package is released under the MIT License.

About

PayJunction API client for node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published