Get the smart card PAN
EWC can retrieve the EMV smart card's PAN. A dialog box is automatically displayed to invite the card holder to validate on his/her reader the PAN reading operation (if the inner GUI has been activated in the "init" function).
The PAN function is not exposed by the top level EWC API. When a smart card is inserted into the reader and validated as usable, a "Connection" object is automatically created by the EWC library. The "Connection" object exposes the PAN function. The first step is to get the "Connection" object. A reference to this object is passed as argument to the connection callback provided in the "init" function. This reference can also be retrieve directly when the function "getConnection" is called.
In your JavaScript file, you have to call the get_pan_psn function exposed by the "Connection" object.
Because the card holder have to validate the operation, the PAN function is asynchronous. The final result is reported to the web page by the callback provided as parameter of the PAN function.
// Create a callback to treat the return of the get PAN asynchronous function var resultCallback = { success : function( a_oConnection, a_PAN, a_PSN, a_ExpirationDate ) { var sMessage = "Your PAN is "; sMessage += a_PAN; sMessage += ".Your PSN is "; sMessage += a_PSN; sMessage += ".Your Expiration Date is "; sMessage += a_ExpirationDate; sMessage += "."; alert(sMessage); }, failure : function( a_oConnection, a_oError ) { var sMessage = "The PAN cannot be retrieved."; sMessage += " Error (" + a_oError.errorCode + ")"; sMessage += " Message (" + a_oError.message + ")"; alert(sMessage); }, }; // Call the function var cnx = enex.getConnection( ); if ( cnx ) { cnx.get_pan_psn( resultCallback ); }