The Card Reader module decodes the card data when read through a card reader attachment. Currently this is available only on Zebra Technologies devices.
Only the foreground RhoElements application is given access to the card reader hardware, when an application is sent to the background its state will be saved and it will automatically relinquish control of the card reader. When brought back to the foreground, an application previously using the card reader will have its previous configuration (eg. pinTimeout) reapplied to the card reader automatically.
In order to use this API you must include the following extension in your build.yml
extensions: ["cardreader"]
The cardreader
extension is also included automatically if you specify the following in your build.yml
app_type: "rhoelements"
Be sure to review the JavaScript API Usage guide for important information about using this API in JavaScript
Be sure to review the Ruby API Usage guide for important information about using this API in Ruby
Closes the card reader
Synchronous Return:
Method Access:
myObject.close()
Rho.CardReader.close()
Rho::CardReader.close()
This method will return all of object/value pairs for the propertyNames of the API class.
Parameters
Async Callback Returning Parameters: HASH
Synchronous Return:
Method Access:
myObject.getAllProperties(CallBackHandler callback)
Rho.CardReader.getAllProperties(CallBackHandler callback)
Rho::CardReader.getAllProperties(CallBackHandler callback)
This method will return an object that represents the default instance of the API Class. For example Camera.getDefault will return a Camera object that represents the default camera.
Synchronous Return:
Method Access:
Rho.CardReader.getDefault()
Rho::CardReader.getDefault()
This method will return a set of object/value pairs for the list of the propertyName that is passed in. The propertyNames must be a valid property of the API class.
Parameters
List of properties I want to know about
Async Callback Returning Parameters: HASH
Synchronous Return:
Method Access:
myObject.getProperties(ARRAY arrayofNames, CallBackHandler callback)
Rho.CardReader.getProperties(ARRAY arrayofNames, CallBackHandler callback)
Rho::CardReader.getProperties(ARRAY arrayofNames, CallBackHandler callback)
This method will return the value of the propertyName that is passed in. The propertyName must be a valid property of the API class.
Parameters
The property to return info about.
Async Callback Returning Parameters: STRING
Synchronous Return:
Method Access:
myObject.getProperty(STRING propertyName, CallBackHandler callback)
Rho.CardReader.getProperty(STRING propertyName, CallBackHandler callback)
Rho::CardReader.getProperty(STRING propertyName, CallBackHandler callback)
Opens the card reader.
Parameters
Async Callback Returning Parameters: HASH
Data read by the card reader. This may be card data, the PAN data extracted from the card data, encrypted PIN block data, or a message. In case of an ISO/ABA card [eg: a financial card], data is encrypted. For other cards, data is in the clear.
Describes the data. This will be either: 'CR','ENCDATA','PAN', or 'MESSAGE'. This equates to card data, encrypted PIN block data, PAN data, or a message, respectively.
This provides the information regarding the card reader head configuration. Available only on Android.
This is the raw data read by the card reader from all the tracks. Available only on Android and the value is in HEX format.
The track1 clear/masked data read by the card reader. Available only on Android and the value is in HEX format. This value should be used only when the track1Status value returned is true.
The track2 clear/masked data read by the card reader. Available only on Android and the value is in HEX format. This value should be used only when the track2Status value returned is true.
The track3 clear/masked data read by the card reader. Available only on Android and the value is in HEX format. This value should be used only when the track3Status value returned is true.
The status of the track1 clear/masked data read by the card reader. Available only on Android.
The status of the track2 clear/masked data read by the card reader. Available only on Android.
The status of the track3 clear/masked data read by the card reader. Available only on Android.
The track1 encrypted data read by the card reader. Available only on Android and the value is in HEX format. This value should be used only when the track1EncryptedStatus value returned is true.
The track2 encrypted data read by the card reader. Available only on Android and the value is in HEX format. This value should be used only when the track2EncryptedStatus value returned is true.
The track3 encrypted data read by the card reader. Available only on Android and the value is in HEX format. This value should be used only when the track3EncryptedStatus value returned is true.
The status of the track1 encrypted data read by the card reader. Available only on Android.
The status of the track2 encrypted data read by the card reader. Available only on Android.
The status of the track3 encrypted data read by the card reader. Available only on Android.
The encrypted KSN serial number read by the card reader. Available only on Android and the value is in HEX format.
Synchronous Return:
Method Access:
myObject.open(CallBackHandler callback)
Rho.CardReader.open(CallBackHandler callback)
Rho::CardReader.open(CallBackHandler callback)
This method allows you to set the attributes of the default object instance by passing in an object of the same class.
Parameters
An instance object that is of the same class.
Synchronous Return:
Method Access:
Rho.CardReader.setDefault(SELF_INSTANCE: CardReader defaultInstance)
Rho::CardReader.setDefault(SELF_INSTANCE: CardReader defaultInstance)
This method will set the values of a list of properties for the API class. The propertyName must be a valid property for the class and must also not be read only.
Parameters
Map of properties I want to set
Synchronous Return:
Method Access:
myObject.setProperties(HASH propertyMap)
Rho.CardReader.setProperties(HASH propertyMap)
Rho::CardReader.setProperties(HASH propertyMap)
This method will set the value of a property for the API class. The propertyName must be a valid property for the class and must also not be read only.
Parameters
The one property name that I want to set
The one property value that I want to set
Synchronous Return:
Method Access:
myObject.setProperty(STRING propertyName, STRING propertyValue)
Rho.CardReader.setProperty(STRING propertyName, STRING propertyValue)
Rho::CardReader.setProperty(STRING propertyName, STRING propertyValue)
Default: false
Property Access:
myObject.autoEnter
Rho.CardReader.autoEnter
Rho::CardReader.autoEnter
Default: false
Property Access:
myObject.autoTab
Rho.CardReader.autoTab
Rho::CardReader.autoTab
Possible Values (STRING):
Property Access:
myObject.moduleName
Rho.CardReader.moduleName
Rho::CardReader.moduleName
(Only compatible with DCR7000-x00)
Property Access:
myObject.panData
Rho.CardReader.panData
Rho::CardReader.panData
(Only compatible with DCR7000-x00)
Property Access:
myObject.pinEntry
Rho.CardReader.pinEntry
Rho::CardReader.pinEntry
(Only compatible with DCR7000-x00)
Default: 30000
Property Access:
myObject.pinTimeout
Rho.CardReader.pinTimeout
Rho::CardReader.pinTimeout
#/app/Model def index Rho::CardReader.open(url_for(:action => :myswipeevent)) end def myswipeevent puts "Swipe params: #{@params}" puts "Mode is #{@params['mode']}" puts "Data is #{@params['data']}" end
function cardreader_callback(params) { alert("Received data from card reader: "+params["data"]); } function connect() { Rho.CardReader.open(cardreader_callback); }
def connect Rho::CardReader.open(url_for(:action => :cardreader_callback)) redirect :index end def cardreader_callback Alert.show_popup("Received card reader data: #{@params[:data]}") end
// Configure the MSR to output keystrokes instead of calling a function when a card is swiped // Note the absence of a callback parameter // Also, After emitting the keystrokes, automatically send a "Tab" keypress Rho.CardReader.autoTab = true; Rho.CardReader.open(); Rho.CardReader.autoEnter = true; Rho.CardReader.open();
# Configure the MSR to output keystrokes instead of calling a function when a card is swiped # Note the absence of a callback parameter # Also, After emitting the keystrokes, automatically send a "Tab" keypress Rho::CardReader.autoTab = true Rho::CardReader.open() # Instead of "Tab", we could request a simulated "Enter" Rho::CardReader.autoEnter = true Rho::CardReader.open()
If the CardReader open method is not specified with a callback, the cardreader data will be returned as keystrokes. If both the autotab and autoenter parameters are set to “enabled”, autoenter will take precedence. An opened card reader must be closed before the attached card reader device and associated modulename parameter are changed. Any attempt to set a parameter to an invalid value, will result in no effect on the parameter’s current value.
For the DCR7000 the ModuleName parameter must be set at least once before the readevent parameter is set. If the card reader is an MSR, when a card is swiped it returns the data read from the card. Setting ModuleName to a DCR will cause the card data to be returned followed by the PAN Data before waiting for a PIN to be entered on the keypad. Once entered the PIN will be encrypted and returned by a third ReadEvent. The card must be a validly formatted IATA or ABA card.
There is no way to abort a pending PIN entry (other than the customer pressing the Cancel button), for security reasons. Therefore if the reader is closed or RhoElements is quit during that time it will become unresponsive until a PIN is entered or the PIN timeout occurs.
In certain circumstances it is possible that the card reader may return empty card data. The JavaScript event function should be able to handle this correctly.
Applications running in RhoElements should be resilient against the card reader being detached and subsequently reattached. Card data parsing code should be robust against unexpected characters in the first read after reattachment.
The encrypted data is supported only on the card readres that are configured for encryption. Since the encrypted data might contain unreadable characters sometimes it is recommended to use only JSON object method rather than JavaScript ‘%s’ notation.