@mvault/terminal
v1.0.24
Published
MVault terminal module
Downloads
4
Readme
Mvault Terminal
Mvault terminal is a module that provides differents way to use a Terminal Reader. It facilitate you things such as discovering connecting and collecting. Bellow you I'll find all you need to use Mvaul terminal
Usage/Examples
// terminal is a global variable, you don't neet to import it
const events = terminal.events()
// initialize terminal sdk (Must be connected using @mvault/auth with 'role' provider)
terminal.init()
// discover readers arround you ( method = 'Internet' || 'BluetoothProximity')
terminal.discover(method).then(() => {
events.on('readers', (readers) => {
if (readers.length) {
// connect the desired reader
terminal.connect(readers[0])
}
})
})
// collect payment with charge params
// subscribe to user instructions - these should be displayed to the user
events.on('display', (display) => {
// show instructions to user
})
events.on('input', (input) => {
// show input informations to user
})
terminal.collect(charge)
Terminal Reference
Initialize terminal
terminal.init()
Required You must be authenticated using @mvault/auth
Discover Reader
terminal.discover(method,simulated) <Promise>
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| mehod
| string
| Required.|
| simulated
| Bool
| Default false.|
Connect Reader
terminal.connect(reader)
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| reader
| object
| Required. reader from Discover|
Collect Charge
terminal.collect({transaction, amount, order, app}) <Promise>
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| amount
| integer
| Required. amount in cents|
Reader
reader()
Return informations about the Reader
Install Update
terminal.installUpdate()
Return the progress
Register Reader
terminal.registerReader(registration_code) <Promise>
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| registration_code
| integer
| Requirered|
Cancel Discover
terminal.cancelDiscover()
It cancel a discover
Cancel Collect
terminal.cancelCollect()
It cancel a payment collect
Events
terminal.events.on(event, callback)
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| event
| string
| Required.|
| callback
| func
| Required. returns event data|
events
| event | Description |
| :-------- | :-------------------------------- |
| redears
| Required. returns array of readers|
| display
| Required. returns instructions from payment to user|
| input
| Required.returns input informations (swipe/tap/insert)|
| update
| Required. returns update progress from 0 to 1|