Secure your banking transaction
In your JavaScript file, you have to initialize EWC after a call to the init. This is the place where to provide the reader configuration regarding the Dynamic Signature primitives and templates. The PCR will use this configuration to display the required fields of the transaction and compute the resulting CAP token.
After initialization, you have to build the array of the primitives you want to use in the current transaction. Then call the swys function.
As incoming first parameter you have to provide a callback to catch the result.
As incoming second parameter you have to choose the transaction purpose. Two values are available:
As incoming third parameter you have to provide the transaction template.
As last parameter you have to choose the algorithm to apply to compute the signature. Three values are available:
Mind that parameter is only available for EWC library v2.x
// Create a callback to treat the return var resultCallback = { success : function( a_oConnection, a_sToken ) { // Reset the token display on the HTML page alert("Your token " + a_sToken + " has been successfully generated"); }, failure : function( a_oConnection, a_oError ) { var sMessage = "Your token has NOT been generated."; sMessage += " Error (" + a_oError.errorCode + ")."; sMessage += " Message (" + a_oError.message + ")"; alert(sMessage); } }; var cnx = enex.getConnection( ); if( ( null == cnx ) || ( typeof( cnx ) == "undefined" ) ) { alert("no available connection to the smart card"); return; } try { var aidList = "BANK", algo = enex.SWYS_ALGO_GEMALTO, data = [ ["INPUT_CHALLENGE", "12345"], ["INPUT_BUY_SELL", "SELL"], ["INPUT_DATA", "1234"], ["INPUT_DATA_2", "2345"], ["INPUT_DATA_3", "3456"], ["INPUT_DATA_4", "4567"], ["INPUT_DATA_5", "5678"], ["INPUT_CURRENCY", "USD"], ["INPUT_AMOUNT_WITH_CURRENCY", "99.99"], ["FREE_TEXT", [ "Do you agree ?", "Press ok" ] ] ]; cnx.swys(resultCallback, aidList, data, algo); } catch (e) { var message = "Caught exception"; message += " name: " + e.name; message += " message: " + e.message; }