No commit activity in last 3 years
No release in over 3 years
Provides a convenient wrapper around libusb to read credit cards with a Magtek Credit Card Reader.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.2.0
 Project Readme

Magtek Card Reader

Overview

This gem provides a wrapper around libusb to facilite reading credit card information from a Magtek Credit Card Reader.

Install

Ubuntu

sudo apt-get install libusb-1.0-0-dev

gem install libusb magtek_card_reader

Notes

You must have appropriate permissions to the USB file descriptors. This may be accomplished by adding a line to your udev rules as follows: ATTRS{idVendor}=="0801", ATTRS{idProduct}=="0002", MODE="666", GROUP="plugdev" and adding the user to the plugdev group. Please note that your idProduct may differ.

Example


require 'magtek_card_reader'

puts Magtek.available_devices

mcr = Magtek::CardReader.new

mcr.open

success, number, name, exp_year, exp_month =  mcr.read(:timeout=>10000)

mcr.close

Server

The server is a daemon that collects credit card swipe data from Magtek reader and runs configured callbacks in order to log the data or pass the data on to another server. Credit card data is AES encrypted using a passphrase that must be provided when the server is started. This passphrase is only stored in memory. The AES encypted data is then RSA encrypted using a private/public key pair. Only the public key is stored on the server permitting only encryption. The double encrypted data is not stored locally but rather is transmitted over a encrypted SSL connection to another server. The credit card data can only be decrypted if both the AES passphrase and the private RSA key are provided. The RSA key and callback parameters are combined with the AES passphrase and a digital signature is created using a SHA512 hash such that the AES passphrase must be provided to use the RSA keys or make any callbacks.

To setup the server:

  • install necessary gems using 'bundle install'
  • choose a long AES passphrase
  • Generate RSA keys using 'rake generate_keys'
  • move conf/private.yaml off of the server to protect encryption
  • edit conf/callback.yaml.example providing local and/or remote callback endpoints
  • Sign the callbacks using 'rake sign_callbacks'
  • run credit_card_server with appropriate permissions to USB file descriptors (e.g., as root)

Acknowledgments

The Ruby wrapper libusb

The libusb library

Magtek reader script https://github.com/aughey/magtek

License

Copyright (c) 2012 Derrick Parkhurst (derrick.parkhurst@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.