/** * Initialize PDCX control with servers * and response timeout */ protected bool initDevice() { if (ax_control == null) { ax_control = new DsiPDCX(); ax_control.ServerIPConfig(server_list, 0); ax_control.SetResponseTimeout(CONNECT_TIMEOUT); InitPDCX(); } lock (pdcLock) { if (pdc_active) { ax_control.CancelRequest(); pdc_active = false; } } if (rba != null) { rba.SetParent(this.parent); rba.SetVerbose(this.verbose_mode); rba.stubStart(); } return(true); }
/** * Initialize EMVX control with servers * and response timeout */ protected bool ReInitDevice() { if (pdc_ax_control == null) { pdc_ax_control = new DsiPDCX(); pdc_ax_control.ServerIPConfig(server_list, 0); pdc_ax_control.SetResponseTimeout(CONNECT_TIMEOUT); InitPDCX(); } lock (pdcLock) { if (pdc_active) { Console.WriteLine("Reset PDC"); pdc_ax_control.CancelRequest(); pdc_active = false; } } if (emv_ax_control == null) { emv_ax_control = new DsiEMVX(); } FlaggedReset(); if (rba != null) { rba.SetParent(this.parent); rba.SetVerbose(this.verbose_mode); try { rba.stubStart(); } catch (Exception) {} } return(true); }
/** * Initialize EMVX control with servers * and response timeout */ protected bool initDevice() { if (pdc_ax_control == null) { pdc_ax_control = new DsiPDCX(); pdc_ax_control.ServerIPConfig(server_list, 0); InitPDCX(); } pdc_ax_control.CancelRequest(); if (emv_ax_control == null) { emv_ax_control = new DsiEMVX(); } PadReset(); if (rba != null) { rba.SetParent(this.parent); rba.SetVerbose(this.verbose_mode); rba.stubStart(); } return(true); }
/** * Initialize EMVX control with servers * and response timeout */ protected bool ReInitDevice() { if (pdc_ax_control == null) { pdc_ax_control = new DsiPDCX(); pdc_ax_control.ServerIPConfig(server_list, 0); pdc_ax_control.SetResponseTimeout(CONNECT_TIMEOUT); InitPDCX(); } lock (pdcLock) { if (pdc_active) { Console.WriteLine("Reset PDC"); pdc_ax_control.CancelRequest(); pdc_active = false; } } /* * lock (emvLock) { * if (emv_active) { * try { * Console.WriteLine("Reset EMV"); * emv_ax_control.CancelRequest(); * emv_active = false; * } catch (Exception) { * // I assume this will through if either the ActiveX DLL * // was generated against an older OCX that doesn't have * // this method or if the DLL has the method but the * // OCX does not. OCX v1.22+ should have the method. * } * } * } */ if (emv_ax_control == null) { emv_ax_control = new DsiEMVX(); } FlaggedReset(); if (rba != null) { rba.SetParent(this.parent); rba.SetVerbose(this.verbose_mode); try { rba.stubStart(); } catch (Exception) {} } return(true); }
/** * Initialize EMVX control with servers * and response timeout */ protected bool initDevice() { if (pdc_ax_control == null) { pdc_ax_control = new DsiPDCX(); pdc_ax_control.ServerIPConfig(server_list, 0); pdc_ax_control.SetResponseTimeout(CONNECT_TIMEOUT); InitPDCX(); } lock (pdcLock) { if (pdc_active) { Console.WriteLine("Reset PDC"); pdc_ax_control.CancelRequest(); } } if (emv_ax_control == null) { emv_ax_control = new DsiEMVX(); Console.WriteLine("Reset EMV"); PadReset(); } if (rba == null) { if (device_identifier == "INGENICOISC250_MERCURY_E2E") { rba = new RBA_Stub("COM" + com_port); rba.SetParent(this.parent); rba.SetVerbose(this.verbose_mode); rba.SetEMV(true); } } if (rba != null) { try { rba.stubStart(); } catch (Exception) {} } return(true); }
/** * Driver listens over TCP for incoming HTTP data. Driver * is providing a web-service style endpoint so POS behavior * does not have to change. Rather than POSTing information to * a remote processor it POSTs information to the driver. * * Driver strips off headers, feeds XML into the dsiEMVX control, * then sends the response back to the client. */ public override void Read() { ReInitDevice(); RBA_Stub emailRBA = null; if (device_identifier.Contains("INGENICO")) { emailRBA = new RBA_Stub("COM" + com_port); emailRBA.SetParent(this.parent); emailRBA.SetVerbose(this.verbose_mode); } TcpListener http = this.GetHTTP(); byte[] buffer = new byte[10]; while (SPH_Running) { string result = ""; string keyVal = "key"; bool saveResult = false; try { using (TcpClient client = http.AcceptTcpClient()) { client.ReceiveTimeout = 100; using (NetworkStream stream = client.GetStream()) { string message = ""; int bytes_read = 0; do { bytes_read = stream.Read(buffer, 0, buffer.Length); message += System.Text.Encoding.ASCII.GetString(buffer, 0, bytes_read); } while (stream.DataAvailable); if (rba != null) { rba.stubStop(); } message = GetHttpBody(message); message = message.Trim(new char[] { '"' }); try { XmlDocument request = new XmlDocument(); request.LoadXml(message); keyVal = request.SelectSingleNode("TStream/Transaction/InvoiceNo").InnerXml; } catch (Exception) { Console.WriteLine("Error parsing from\n" + message); } // Send EMV messages to EMVX, others // to PDCX if (message.Contains("EMV")) { result = ProcessEMV(message, true); saveResult = true; } else if (message.Contains("termSig")) { FlaggedReset(); result = GetSignature(true); } else if (device_identifier.Contains("INGENICO") && message.Contains("termEmail")) { result = emailRBA.getEmailSync(); } else if (message.Length > 0) { result = ProcessPDC(message); saveResult = true; } result = WrapHttpResponse(result); byte[] response = System.Text.Encoding.ASCII.GetBytes(result); stream.Write(response, 0, response.Length); stream.Close(); if (message.Contains("EMV")) { FlaggedReset(); } } client.Close(); } } catch (Exception ex) { this.LogMessage(ex.ToString()); try { if (saveResult && result.Length > 0) { parent.SqlLog(keyVal, result); } } catch (Exception) { this.LogMessage(keyVal + ": " + result); } } } }