private void sendCardData() throws JSONException { JSONObject response = new JSONObject(); response.put("Response.Type", mMTSCRA.getResponseType()); response.put("Track.Status", mMTSCRA.getTrackDecodeStatus()); response.put("Card.Status", mMTSCRA.getCardStatus()); response.put("Encryption.Status", mMTSCRA.getEncryptionStatus()); response.put("Battery.Level", mMTSCRA.getBatteryLevel()); // response.put("Swipe.Count", mMTSCRA.getSwipeCount()); response.put("Track.Masked", mMTSCRA.getMaskedTracks()); response.put("MagnePrint.Status", mMTSCRA.getMagnePrintStatus()); response.put("SessionID", mMTSCRA.getSessionID()); response.put("Card.SvcCode", mMTSCRA.getCardServiceCode()); response.put("Card.PANLength", mMTSCRA.getCardPANLength()); response.put("KSN", mMTSCRA.getKSN()); response.put("Device.SerialNumber", mMTSCRA.getDeviceSerial()); response.put("TLV.CARDIIN", mMTSCRA.getTagValue("TLV_CARDIIN", "")); response.put("MagTekSN", mMTSCRA.getMagTekDeviceSerial()); response.put("FirmPartNumber", mMTSCRA.getFirmware()); response.put("TLV.Version", mMTSCRA.getTLVVersion()); response.put("DevModelName", mMTSCRA.getDeviceName()); response.put("MSR.Capability", mMTSCRA.getCapMSR()); response.put("Tracks.Capability", mMTSCRA.getCapTracks()); response.put("Encryption.Capability", mMTSCRA.getCapMagStripeEncryption()); response.put("Card.IIN", mMTSCRA.getCardIIN()); response.put("Card.Name", mMTSCRA.getCardName()); response.put("Card.Last4", mMTSCRA.getCardLast4()); response.put("Card.ExpDate", mMTSCRA.getCardExpDate()); response.put("Track1.Masked", mMTSCRA.getTrack1Masked()); response.put("Track2.Masked", mMTSCRA.getTrack2Masked()); response.put("Track3.Masked", mMTSCRA.getTrack3Masked()); response.put("Track1", mMTSCRA.getTrack1()); response.put("Track2", mMTSCRA.getTrack2()); response.put("Track3", mMTSCRA.getTrack3()); response.put("MagnePrint", mMTSCRA.getMagnePrint()); response.put("RawResponse", mMTSCRA.getResponseData()); mEventListenerCb.success(response); }
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Unhandled execute call: " + action); if (action.equals("openDevice")) { if (mMTSCRA == null) { InitializeDevice(); } if (mbAudioConnected) { if (mMTSCRA.getDeviceType() == MagTekSCRA.DEVICE_TYPE_AUDIO) { // Thread tSetupAudioParams = new Thread() { // public void run() { try { mStringAudioConfigResult = setupAudioParameters(); } catch (Exception ex) { mStringAudioConfigResult = "Error:" + ex.getMessage(); } // } // } // tSetupAudioParams.start(); } else { } mMTSCRA.openDevice(); pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.isDeviceConnected()); } else { pr = new PluginResult(PluginResult.Status.ERROR, "No reader attached."); } } else if (action.equals("closeDevice")) { mMTSCRA.closeDevice(); pr = new PluginResult(PluginResult.Status.OK, !mMTSCRA.isDeviceConnected()); } else if (action.equals("isDeviceConnected")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.isDeviceConnected()); } else if (action.equals("isDeviceOpened")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.isDeviceConnected()); } else if (action.equals("clearCardData")) { pr = new PluginResult(PluginResult.Status.OK); } /* else if(action.equals("setCardData")) { try { ; } } else if(action.equals("getTrackDecodeStatus")) { try { ; } } */ else if (action.equals("getTrack1")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack1()); } else if (action.equals("getTrack2")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack2()); } else if (action.equals("getTrack3")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack3()); } else if (action.equals("getTrack1Masked")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack1Masked()); } else if (action.equals("getTrack2Masked")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack2Masked()); } else if (action.equals("getTrack3Masked")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack3Masked()); } else if (action.equals("getMagnePrintStatus")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getMagnePrintStatus()); } else if (action.equals("getMagnePrint")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getMagnePrint()); } else if (action.equals("getDeviceSerial")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getDeviceSerial()); } else if (action.equals("getSessionID")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getSessionID()); } /* else if(action.equals("setDeviceProtocolString")) { try { ; } } */ else if (action.equals("listenForEvents")) { pr = new PluginResult(PluginResult.Status.NO_RESULT); pr.setKeepCallback(true); mEventListenerCb = callbackContext; } else if (action.equals("getCardName")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardName()); } else if (action.equals("getCardIIN")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardIIN()); } else if (action.equals("getCardLast4")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardLast4()); } else if (action.equals("getCardExpDate")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardExpDate()); } else if (action.equals("getCardServiceCode")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardServiceCode()); } else if (action.equals("getCardStatus")) { pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardStatus()); } /* else if(action.equals("setDeviceType")) { try { ; } } */ else if (action.equals("setDeviceType")) {; } callbackContext.sendPluginResult(pr); return true; }