node-nab-api
NAB payment gateway API wrapper for node.js
Last updated a year ago by maxfi .
UNLICENSED · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install node-nab-api 
SYNC missed versions from official npm registry.

node-nab-api

XO code style

NAB payment gateway API wrapper for node.js

Usage

import NAB from 'node-nab-api'

const merchantId = process.env.NAB_MERCHANT_ID
const password = process.env.NAB_PASSWORD
const testMode = process.env.NAB_MODE !== 'PRODUCTION'

const nab = new NAB({ merchantId, password }, { testMode })

Classes

NAB

Methods

addToken(messageId, tokenDetails)Promise
lookupToken(messageId, tokenValue)Promise
deleteToken(messageId, tokenValue)Promise
triggerPayment(messageId, paymentDetails)Promise

NAB

Kind: class

new NAB(config, [options])

Creates an instance of the NAB class.

Param Type Description
config Object Config.
config.merchantId String 5 character merchant ID supplied by NAB Transact.
config.password String Transaction password. Password used for authentication of the merchant's request message, supplied by NAB Transact.
[options] Object Options.
options.testMode Boolean Set to true to direct requests to the NAB payment gateway test environment.
options.timeout String Timeout value used, in seconds.

addToken(messageId, tokenDetails) ⇒ Promise

Kind: instance method of NAB Summary: Add a new token
Returns: Promise - {MessageInfo, RequestType, MerchantInfo, Status, Data}

Param Type Description
messageId String The messageId is a reference for the xml request. If you had a server internally you could store all your xml request and this would be a way to locate the request if a payment was to fail. A request will still be sent if they have the same messageId and will be treated as a new xml request.
tokenDetails Object Token details.
tokenDetails.cardNumber String Credit card number.
tokenDetails.expiryDate String Credit card expiry date.

Example response:

const result = {
  MessageInfo: {
    messageID: '123456789',
    messageTimestamp: '2017-10-20T00:00:00.000Z',
    apiVersion: 'xml-4.2'
  },
  RequestType: 'Payment',
  MerchantInfo: {
    merchantID: 'XYZ0010'
  },
  Status: {
    statusCode: '0',
    statusDescription: 'Normal'
  },
  Data: {
    responseCode: '00',
    responseText: 'Successful',
    successful: 'yes',
    tokenValue: '8714448311797575',
    CreditCardInfo: {
      pan: '444433XXXXXXX111',
      expiryDate: '08/23',
      cardType: '6',
      cardDescription: 'Visa'
    },
    amount: '100',
    transactionReference: {}
  }
}

lookupToken(messageId, tokenValue) ⇒ Promise

Kind: instance method of NAB Returns: Promise - {MessageInfo, RequestType, MerchantInfo, Status, Data}

Param Type Description
messageId String The messageId is a reference for the xml request. If you had a server internally you could store all your xml request and this would be a way to locate the request if a payment was to fail. A request will still be sent if they have the same messageId and will be treated as a new xml request.
tokenValue String The token value that represents a stored card within NAB Transact.

Example response:

const result = {
  MessageInfo: {
    messageID: '123456789',
    messageTimestamp: '2017-10-20T00:00:00.000Z',
    apiVersion: 'xml-4.2'
  },
  RequestType: 'lookupToken',
  MerchantInfo: { merchantID: 'XYZ0010' },
  Status: { statusCode: '0', statusDescription: 'Normal' },
  Data: {
    responseCode: '00',
    responseText: 'Successful',
    successful: 'yes',
    tokenValue: '8714448311797575',
    CreditCardInfo: {
      pan: '444433XXXXXXX111',
      expiryDate: '08/23',
      cardType: '6',
      cardDescription: 'Visa'
    },
    amount: '100',
    transactionReference: {}
  }
}

deleteToken(messageId, tokenValue) ⇒ Promise

Kind: instance method of NAB Returns: Promise - {MessageInfo, RequestType, MerchantInfo, Status, Data}

Param Type Description
messageId String The messageId is a reference for the xml request. If you had a server internally you could store all your xml request and this would be a way to locate the request if a payment was to fail. A request will still be sent if they have the same messageId and will be treated as a new xml request.
tokenValue String The token value that represents a stored card within NAB

Example response:

const result = {
  MessageInfo: {
    messageID: '123456789',
    messageTimestamp: '20172211194828703000+660',
    apiVersion: 'spxml-3.0'
  },
  RequestType: 'deleteToken',
  MerchantInfo: { merchantID: 'XYZ0010' },
  Status: { statusCode: '0', statusDescription: 'Normal' },
  Data: {
    responseCode: '00',
    responseText: 'Successful',
    successful: 'yes',
    CreditCardInfo: {
      pan: {},
      expiryDate: {},
      cardType: '0',
      cardDescription: {}
    },
    amount: '100',
    transactionReference: {}
  }
}

module.exports.triggerPayment(messageId, paymentDetails) ⇒ Promise

Kind: instance method of NAB Returns: Promise - {MessageInfo, RequestType, MerchantInfo, Status, Data}

Param Type Description
messageId String The messageId is a reference for the xml request. If you had a server internally you could store all your xml request and this would be a way to locate the request if a payment was to fail. A request will still be sent if they have the same messageId and will be treated as a new xml request.
paymentDetails Object Payment Details
paymentDetails.crn String Unique identifier of customer or token.
paymentDetails.currency String Default currency is "AUD" – Australian Dollars.
paymentDetails.amount String Transaction amount in cents.
paymentDetails.transactionReference String The transaction identifier. This value will appear against all processed transactions. Typically an invoice number. E.g. "invoice12345".

Example response:

const result = {
  MessageInfo: {
    messageID: '123456789',
    messageTimestamp: '20172211193559912000+660',
    apiVersion: 'spxml-3.0',
  },
  RequestType: 'Periodic',
  MerchantInfo: { merchantID: 'XYZ0010' },
  Status: { statusCode: '0', statusDescription: 'Normal' },
  Data: {
    crn: 'testTokenId180703',
    actionType: 'trigger',
    periodicType: '8',
    responseCode: '00',
    responseText: 'Approved',
    successful: 'yes',
    transactionReference: 'test transaction - node-nab-api',
    amount: '100',
    currency: 'AUD',
    txnID: '815056',
    settlementDate: '20171122',
    CreditCardInfo: {
      pan: '555555...444',
      expiryDate: '12/23',
      cardType: '5',
      cardDescription: 'Master Card',
    },
  }
}

Tests

npm install
npm test

Dependencies

  • is-plain-object: Returns true if an object was created by the Object constructor.
  • node-fetch: A light-weight module that brings window.fetch to node.js and io.js
  • xml-js: A convertor between XML text and Javascript object / JSON text.

License

UNLICENSED

Current Tags

  • 0.2.0                                ...           latest (a year ago)

3 Versions

  • 0.2.0                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 3
This Month 3
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (17)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |