@Test public void track2EquivalentTest() { EmvTrack2 track2 = TrackUtils.extractTrack2EquivalentData(BytesUtils.fromString("55 66 88 77 66 55 66 77 D1 50 62 01 69 28 07 65 90 00 0F")); Assertions.assertThat(track2).isNotNull(); Assertions.assertThat(track2.getCardNumber()).isEqualTo("5566887766556677"); SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy"); Assertions.assertThat(sdf.format(track2.getExpireDate())).isEqualTo("06/2015"); Assertions.assertThat(track2.getService()).isNotNull(); Assertions.assertThat(track2.getService().getServiceCode1()).isEqualTo(ServiceCode1Enum.INTERNATIONNAL_ICC); Assertions.assertThat(track2.getService().getServiceCode1().getInterchange()).isNotNull(); Assertions.assertThat(track2.getService().getServiceCode1().getTechnology()).isNotNull(); Assertions.assertThat(track2.getService().getServiceCode2()).isEqualTo(ServiceCode2Enum.NORMAL); Assertions.assertThat(track2.getService().getServiceCode2().getAuthorizationProcessing()).isNotNull(); Assertions.assertThat(track2.getService().getServiceCode3()).isEqualTo(ServiceCode3Enum.NO_RESTRICTION); Assertions.assertThat(track2.getService().getServiceCode3().getAllowedServices()).isNotNull(); Assertions.assertThat(track2.getService().getServiceCode3().getPinRequirements()).isNotNull(); }
public static EmvTrack2 extractTrack2EquivalentData(final byte[] pRawTrack2) { EmvTrack2 ret = null; if (pRawTrack2 != null) { EmvTrack2 track2 = new EmvTrack2(); track2.setRaw(pRawTrack2); String data = BytesUtils.bytesToStringNoSpace(pRawTrack2); Matcher m = TRACK2_EQUIVALENT_PATTERN.matcher(data); if (m.find()) { track2.setCardNumber(m.group(1)); SimpleDateFormat sdf = new SimpleDateFormat("yyMM", Locale.getDefault()); try { track2.setExpireDate(DateUtils.truncate(sdf.parse(m.group(2)), Calendar.MONTH)); } catch (ParseException e) { LOGGER.error("Unparsable expire card date : {}", e.getMessage()); return ret; } track2.setService(new Service(m.group(3))); ret = track2; } } return ret; }
TrackUtils { public static EmvTrack2 extractTrack2EquivalentData(final byte[] pRawTrack2) { EmvTrack2 ret = null; if (pRawTrack2 != null) { EmvTrack2 track2 = new EmvTrack2(); track2.setRaw(pRawTrack2); String data = BytesUtils.bytesToStringNoSpace(pRawTrack2); Matcher m = TRACK2_EQUIVALENT_PATTERN.matcher(data); if (m.find()) { track2.setCardNumber(m.group(1)); SimpleDateFormat sdf = new SimpleDateFormat("yyMM", Locale.getDefault()); try { track2.setExpireDate(DateUtils.truncate(sdf.parse(m.group(2)), Calendar.MONTH)); } catch (ParseException e) { LOGGER.error("Unparsable expire card date : {}", e.getMessage()); return ret; } track2.setService(new Service(m.group(3))); ret = track2; } } return ret; } }
TrackUtils { public static EmvTrack2 extractTrack2EquivalentData(final byte[] pRawTrack2) { EmvTrack2 ret = null; if (pRawTrack2 != null) { EmvTrack2 track2 = new EmvTrack2(); track2.setRaw(pRawTrack2); String data = BytesUtils.bytesToStringNoSpace(pRawTrack2); Matcher m = TRACK2_EQUIVALENT_PATTERN.matcher(data); if (m.find()) { track2.setCardNumber(m.group(1)); SimpleDateFormat sdf = new SimpleDateFormat("yyMM", Locale.getDefault()); try { track2.setExpireDate(DateUtils.truncate(sdf.parse(m.group(2)), Calendar.MONTH)); } catch (ParseException e) { LOGGER.error("Unparsable expire card date : {}", e.getMessage()); return ret; } track2.setService(new Service(m.group(3))); ret = track2; } } return ret; } private  TrackUtils(); }
TrackUtils { public static EmvTrack2 extractTrack2EquivalentData(final byte[] pRawTrack2) { EmvTrack2 ret = null; if (pRawTrack2 != null) { EmvTrack2 track2 = new EmvTrack2(); track2.setRaw(pRawTrack2); String data = BytesUtils.bytesToStringNoSpace(pRawTrack2); Matcher m = TRACK2_EQUIVALENT_PATTERN.matcher(data); if (m.find()) { track2.setCardNumber(m.group(1)); SimpleDateFormat sdf = new SimpleDateFormat("yyMM", Locale.getDefault()); try { track2.setExpireDate(DateUtils.truncate(sdf.parse(m.group(2)), Calendar.MONTH)); } catch (ParseException e) { LOGGER.error("Unparsable expire card date : {}", e.getMessage()); return ret; } track2.setService(new Service(m.group(3))); ret = track2; } } return ret; } private  TrackUtils(); static EmvTrack2 extractTrack2EquivalentData(final byte[] pRawTrack2); static EmvTrack1 extractTrack1Data(final byte[] pRawTrack1); }
TrackUtils { public static EmvTrack2 extractTrack2EquivalentData(final byte[] pRawTrack2) { EmvTrack2 ret = null; if (pRawTrack2 != null) { EmvTrack2 track2 = new EmvTrack2(); track2.setRaw(pRawTrack2); String data = BytesUtils.bytesToStringNoSpace(pRawTrack2); Matcher m = TRACK2_EQUIVALENT_PATTERN.matcher(data); if (m.find()) { track2.setCardNumber(m.group(1)); SimpleDateFormat sdf = new SimpleDateFormat("yyMM", Locale.getDefault()); try { track2.setExpireDate(DateUtils.truncate(sdf.parse(m.group(2)), Calendar.MONTH)); } catch (ParseException e) { LOGGER.error("Unparsable expire card date : {}", e.getMessage()); return ret; } track2.setService(new Service(m.group(3))); ret = track2; } } return ret; } private  TrackUtils(); static EmvTrack2 extractTrack2EquivalentData(final byte[] pRawTrack2); static EmvTrack1 extractTrack1Data(final byte[] pRawTrack1); static final String CARD_HOLDER_NAME_SEPARATOR; }