Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jedwatson/node-bpay
Node.JS BPAY Customer Reference Number Generator and Validator
https://github.com/jedwatson/node-bpay
Last synced: 22 days ago
JSON representation
Node.JS BPAY Customer Reference Number Generator and Validator
- Host: GitHub
- URL: https://github.com/jedwatson/node-bpay
- Owner: JedWatson
- License: mit
- Created: 2013-11-27T02:22:10.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-04T06:01:28.000Z (over 9 years ago)
- Last Synced: 2024-10-04T18:50:40.650Z (about 1 month ago)
- Language: JavaScript
- Size: 138 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Node-BPay
=========Node.JS BPAY Customer Reference Number Generator and Validator.
Also includes helpful methods for dealing with Luhn Check Digits.
See http://www.bpay.com.au/Business/Small-Medium-Business/Help/BPAY-Services-FAQs.aspx
and http://en.wikipedia.org/wiki/Luhn_algorithm
## Usage
npm install bpay --save
... then ...
var bpay = require('bpay');
var crn = bpay.generateBpayCRN(10); // generates a valid 10 digit CRN
console.log(bpay.validateBpayCRN(crn)); // true!## Methods
### `generateBpayCRN(len, prefix)`
Generates a valid BPay Customer Reference Number.
A BPay CRN is a 2-20 digit number with the last digit a luhn check digit.
#### Arguments:
* `len` (`String` or `Number`) - Length of number to generate (defaults to 10)
* `prefix` (`String` or `Number`) - Prefix to use (optional)#### Returns:
* `String` - The new CRN
### `validateBpayCRN(input)`
Validates a BPay Customer Reference Number.
#### Arguments:
* `input` (`String` or `Number`) - The CRN to validate
#### Returns:
* `Boolean` - Whether the CRN is valid
### `getLuhnCheckDigit(input)`
Calculates the Luhn check digit for the input.
#### Arguments:
* `input` (`String` or `Number`) - The input to generate a check digit for
#### Returns:
* `String` - The check digit
### `validateLuhnCheckDigit(input)`
Validates the Luhn check digit in the input.
#### Arguments:
* `input` (`String` or `Number`) - The input to validate
#### Returns:
* `Boolean` - Whether the check digit is valid