1 25 package org.ofbiz.pos.jpos.service; 26 27 import jpos.MSRConst; 28 import jpos.JposException; 29 import jpos.events.DataEvent; 30 31 import org.ofbiz.base.util.GeneralException; 32 33 39 public class MsrTestService extends BaseService implements jpos.services.MSRService17 { 40 41 public static final String module = MsrTestService.class.getName(); 42 public static final int JPOS_MSR_ACCT_ERR = 100; 43 public static final int JPOS_MSR_EXPD_ERR = 101; 44 protected static MsrTestService instance = null; 45 46 protected String title = ""; 47 protected String firstname = "John"; 48 protected String middle = ""; 49 protected String surname = "Doe"; 50 protected String suffix = ""; 51 52 protected String [] accountNumber = {"4111111111111111", "4111111111111111" }; 53 protected String [] expireDate = { "0909", "0909" }; 54 protected String serviceCode = ""; 55 56 protected byte[] track1DiscretionaryData = new byte[0]; 57 protected byte[] track2DiscretionaryData = new byte[0]; 58 protected byte[] track1Data = new byte[0]; 59 protected byte[] track2Data = new byte[0]; 60 protected byte[] track3Data = new byte[0]; 61 protected int[] sentinels = new int[0]; 62 protected int[] lrc = new int[0]; 63 64 protected boolean parseDecodeData = true; 65 protected boolean decodeData = true; 66 protected boolean autoDisable = false; 67 protected boolean sendSentinels = true; 68 69 protected int tracksToRead = MSRConst.MSR_TR_1_2_3; 70 protected int errorType = MSRConst.MSR_ERT_CARD; 71 72 public MsrTestService() { 73 instance = this; 74 } 75 76 public boolean getCapISO() throws JposException { 78 return true; 80 } 81 82 public boolean getCapJISOne() throws JposException { 83 return false; 85 } 86 87 public boolean getCapJISTwo() throws JposException { 88 return false; 90 } 91 92 public String getAccountNumber() throws JposException { 93 return this.accountNumber[1]; 94 } 95 96 public boolean getAutoDisable() throws JposException { 97 return this.autoDisable; 98 } 99 100 public void setAutoDisable(boolean b) throws JposException { 101 this.autoDisable = b; 102 } 103 104 public boolean getDecodeData() throws JposException { 105 return this.decodeData; 106 } 107 108 public void setDecodeData(boolean b) throws JposException { 109 this.decodeData = b; 110 if (!b) { 111 this.parseDecodeData = false; 112 } 113 } 114 115 public int getErrorReportingType() throws JposException { 116 return this.errorType; 117 } 118 119 public void setErrorReportingType(int i) throws JposException { 120 this.errorType = i; 121 } 122 123 public String getExpirationDate() throws JposException { 124 return this.expireDate[1]; 125 } 126 127 public String getFirstName() throws JposException { 128 return this.firstname; 129 } 130 131 public String getMiddleInitial() throws JposException { 132 return this.middle; 133 } 134 135 public boolean getParseDecodeData() throws JposException { 136 return this.parseDecodeData; 137 } 138 139 public void setParseDecodeData(boolean b) throws JposException { 140 this.parseDecodeData = b; 141 } 142 143 public String getServiceCode() throws JposException { 144 return this.serviceCode; 145 } 146 147 public String getSuffix() throws JposException { 148 return this.suffix; 149 } 150 151 public String getSurname() throws JposException { 152 return this.surname; 153 } 154 155 public String getTitle() throws JposException { 156 return this.title; 157 } 158 159 public byte[] getTrack1Data() throws JposException { 160 return this.track1Data; 161 } 162 163 public byte[] getTrack1DiscretionaryData() throws JposException { 164 return this.track1DiscretionaryData; 165 } 166 167 public byte[] getTrack2Data() throws JposException { 168 return this.track2Data; 169 } 170 171 public byte[] getTrack2DiscretionaryData() throws JposException { 172 return this.track2DiscretionaryData; 173 } 174 175 public byte[] getTrack3Data() throws JposException { 176 return this.track3Data; 177 } 178 179 public int getTracksToRead() throws JposException { 180 return this.tracksToRead; 181 } 182 183 public void setTracksToRead(int i) throws JposException { 184 this.tracksToRead = i; 185 } 186 187 public void clearInput() throws JposException { 188 } 189 190 public int getCapPowerReporting() throws JposException { 192 return 0; } 194 195 public int getPowerNotify() throws JposException { 196 return 0; } 198 199 public void setPowerNotify(int i) throws JposException { 200 } 202 203 public int getPowerState() throws JposException { 204 return 0; } 206 207 public boolean getCapTransmitSentinels() throws JposException { 209 return true; 210 } 211 212 public byte[] getTrack4Data() throws JposException { 213 return new byte[0]; } 215 216 public boolean getTransmitSentinels() throws JposException { 217 return this.sendSentinels; 218 } 219 220 public void setTransmitSentinels(boolean b) throws JposException { 221 this.sendSentinels = b; 222 } 223 224 public static void sendTest() throws GeneralException { 225 if (instance == null) { 226 throw new GeneralException("MsrTestService instance is null; make sure 'TestMsr' is configured in pos-containers.xml"); 227 } 228 DataEvent event = new DataEvent(instance, 0); 229 instance.fireEvent(event); 230 } 231 } 232 | Popular Tags |