node-card-capture
Version:
launches a child process in python to read from the magtek reader directly and returns the raw track data
29 lines (23 loc) • 802 B
JavaScript
let exec = require('child_process').exec
let execSync = require('child_process').execSync
var cardCapture = function(callback) {
exec('sudo python ' + __dirname + "/card-reader.py", function(err, stdout, stderr){
if (err){
console.log('there was an error running the python script, maybe try installing packages from README.md for node-card-capture')
callback(err)
}
else {
if (stderr) {
callback ( "ERROR " + stderr)
}
else if (stdout) {
callback (stdout)
}
}
})
}
var cardCaptureSync = function() {
return execSync('sudo python ' + __dirname + '/card-reader.py').toString('utf8')
}
module.exports = { cardCapture, cardCaptureSync }