I have an application that will reader credit cards and am trying to implement that functionality in Ruby using the CardReader module. According to the documentation (http://edgedocs.rhomobile.com/rhoelements/cardreader), "By default the Ruby Object 'CardReader' will exist on the current page and can be used to interact directly with the CardReader". However when I run the application, and get to the point of enabling the reader, I get this error:
"e.message" | "uninitialized constant Controller::CardReader" |
In my erb file I am using an ajax call to enable the CardReader:
function enableScanner() {
$.get('/app/Order/enable_cardReader', {});
}
In my controller I am attempting to enable the CardReader:
def enable_cardReader
begin
CardReader.enable
CardReader.pinTimeout = '30000';
CardReader.pinEntry = 'OFF';
CardReader.readEvent = url_for(:action => :cardReader_callback)
rescue Exception => e
puts e.message
end
end
Does anyone have a working example of how to use the CardReader funtionality?
Thank you.
Hello Patrick,
There is no enable method in CardReader Module.
Pleae try with CardReader.open in controller
def openmsr
CardReader.open
CardReader.pinEntry='Off'
CardReader.pinTimeout = '30000'
CardReader.readEvent = url_for(:action => :myreadevent)
end
def myreadevent
Alert.show_popup("Inside Event")
end
I think this should help you.
Thank You.
Patro
Points: 0
You voted ‘up’
Oh my mistake! I replaced .enable with .open but receive the same error.
It seems as though the Ruby module CardReader cannot be found or loaded.
Points: 0
You voted ‘up’
Patrick, I pulled in the code above and was able to swipe the MSR and show the data.
One thought that came into mind was the O/S version of the ET1 you are running. MSR and Scanner drivers were added in later builds.
# demo MSR reader for ET1
def msrpage
CardReader.open
CardReader.pinEntry='Off'
CardReader.pinTimeout = '30000'
CardReader.readEvent = url_for(:action => :msr_callback)
end
# MSR call back
def msr_callback
eMSR = @params['data']
Alert.show_popup("MSR Data: " + eMSR)
end
You also will need to test this on the ET1 as the simulator does not have an MSR.
HM
I modified the msr call back to show the data parameter from the MSR
Points: 0
You voted ‘up’
Hector,
Tony stopped by and loaded Build Number 03-271301-01846-0602-00-M1-060612 onto the ET1.
I tried your code above, with the alert modification, but the result is the same, the ET1 never receives the callback while the rho simulator results in the error message "uninitialized constant Controller::CardReader".
Points: 0
You voted ‘up’
On the ET1 the card reader capability is not available in 2.0, it will be introduced in 2.1. The accessory was not formally released when we released 2.0 I believe, could this be the issue?
Points: 0
You voted ‘up’
Darryn is correct - the build I tested with was the beta 2.1 version. the 2.1 build is currently in T&V and should be released soon (assuming all goes as expected in T&V).
Points: 0
You voted ‘up’
For clarification, the build I have on my ET1 is 2.0 and not 2.1? And if so, what date will I have access to 2.1?
Points: 0
You voted ‘up’
No, you will not have 2.1 on your device, we plan on releasing 2.1 towards the end of the month / early next month.
Points: 0
You voted ‘up’
Card reader is only available in RhoElements applications, please ensure you have app_type: rhoelements in your build.yml file.
Darryn.
Points: 0
You voted ‘up’
Yes, that is present.
Points: 0
You voted ‘up’