Пример #1
0
        public SPH_Datacap_EMVX(string p) : base(p)
        {
            device_identifier = p;
            if (p.Contains(":"))
            {
                string[] parts = p.Split(new char[] { ':' }, 2);
                device_identifier = parts[0];
                com_port          = parts[1];
                Console.WriteLine(com_port);
                if (System.Text.RegularExpressions.Regex.IsMatch(parts[1], @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"))
                {
                    Console.WriteLine("Is an IP Address");
                    com_port       = "1";
                    this.device_ip = parts[1];
                }
            }

            string my_location = AppDomain.CurrentDomain.BaseDirectory;
            char   sep         = Path.DirectorySeparatorChar;

            xml_log    = my_location + sep + "log.xml";
            pdc_active = false;
            emv_active = false;
            emv_reset  = true;

            if (device_identifier.Substring(0, 8) == "INGENICO")
            {
                rba = new RBA_Stub("COM" + com_port);
                rba.SetEMV(RbaButtons.EMV);
            }
        }
Пример #2
0
        public SPH_Datacap_Gen2(string p) : base(p)
        {
            device_identifier = p;
            if (p.Contains(":"))
            {
                string[] parts = p.Split(new char[] { ':' }, 2);
                device_identifier = parts[0];
                com_port          = parts[1];
            }

            string my_location = AppDomain.CurrentDomain.BaseDirectory;
            char   sep         = Path.DirectorySeparatorChar;

            xml_log    = my_location + sep + "log.xml";
            pdc_active = false;
            emv_active = false;
            emv_reset  = true;

            if (device_identifier == "INGENICOISC250_MERCURY_E2E")
            {
                rba = new RBA_Stub("COM" + com_port);
                rba.SetEMV(RbaButtons.EMV);
            }

            this.work_queue   = new BlockingCollection <IMessage>();
            this.http_mailbox = new BlockingCollection <string>();
        }
Пример #3
0
        /**
         * Supported options:
         *  -- Global Options --
         * logErrors [boolean] default false
         *      Write error information to the same debug_lane.log file as PHP.
         *      Errors are logged regardless of whether the verbose switch (-v)
         *      is used but not all verbose output is treated as an error & logged
         * logXML [boolean] default false
         *      Log XML requests & responses to "xml.log" in the current directory.
         *
         *  -- Ingencio Specific Options --
         * disableRBA [boolean] default false
         *      Stops all direct communication with Ingenico terminal.
         *      Driver will solely utilize Datacap functionality
         * disableButtons [boolean] default false
         *      Does not display payment type or cashback selection buttons.
         *      RBA commands can still be used to display static text
         *      Irrelevant if disableRBA is true
         * buttons [string] default Credit
         *      Change labeling of the buttons. Valid options are "credit"
         *      and "cashback" currently.
         *      Irrelevant if disableRBA or disableButtons is true
         * defaultMessage [string] default "Welcome"
         *      Message displayed onscreen at the start of a transaction
         *      Irrelevant if disableRBA is true
         * cashback [boolean] default true
         *      Show cashback selections if payment type debit or ebt cash
         *      is selected.
         *      Irrelevant if disableRBA or disableButtons is true
         * servers [string] default "x1.mercurypay.com;x2.backuppay.com"
         *      Set PDCX server list
         */
        public override void SetConfig(Dictionary <string, string> d)
        {
            if (d.ContainsKey("disableRBA") && d["disableRBA"].ToLower() == "true")
            {
                try {
                    if (this.rba != null)
                    {
                        rba.stubStop();
                    }
                } catch (Exception) {}
                this.rba = null;
            }

            if (this.rba != null && d.ContainsKey("disableButtons") && d["disableButtons"].ToLower() == "true")
            {
                this.rba.SetEMV(RbaButtons.None);
            }

            if (this.rba != null && d.ContainsKey("buttons"))
            {
                if (d["buttons"].ToLower() == "cashback")
                {
                    this.rba.SetEMV(RbaButtons.Cashback);
                }
            }

            if (this.rba != null && d.ContainsKey("defaultMessage"))
            {
                this.rba.SetDefaultMessage(d["defaultMessage"]);
            }

            if (d.ContainsKey("logXML") && d["logXML"].ToLower() == "true")
            {
                this.log_xml = true;
            }

            if (d.ContainsKey("logErrors") && d["logErrors"].ToLower() == "true")
            {
                this.enableUnifiedLog();
            }

            if (d.ContainsKey("showDialogs") && d["showDialogs"].ToLower() == "true")
            {
                this.hideDialogs = 0;
            }

            if (this.rba != null && d.ContainsKey("cashback") && (d["cashback"].ToLower() == "true" || d["cashback"].ToLower() == "false"))
            {
                this.rba.SetCashBack(d["cashback"].ToLower() == "true" ? true : false);
            }

            if (d.ContainsKey("servers"))
            {
                this.server_list = d["servers"];
            }
        }
Пример #4
0
        /**
         * Supported options:
         *  -- Global Options --
         * alwaysReset [boolean] default false
         *      Issue a PadReset command following a transaction. This will make
         *      the terminal beep until the customer removes their card. Control
         *      will not be returned to the cashier until the card is removed or
         *      the reset command times out.
         * logErrors [boolean] default false
         *      Write error information to the same debug_lane.log file as PHP.
         *      Errors are logged regardless of whether the verbose switch (-v)
         *      is used but not all verbose output is treated as an error & logged
         * logXML [boolean] default false
         *      Log XML requests & responses to "xml.log" in the current directory.
         *
         *  -- Ingencio Specific Options --
         * disableRBA [boolean] default false
         *      Stops all direct communication with Ingenico terminal.
         *      Driver will solely utilize Datacap functionality
         * disableButtons [boolean] default false
         *      Does not display payment type or cashback selection buttons.
         *      RBA commands can still be used to display static text
         *      Irrelevant if disableRBA is true
         * buttons [string] default EMV
         *      Change labeling of the buttons. Valid options are "credit"
         *      and "cashback" currently.
         *      Irrelevant if disableRBA or disableButtons is true
         * defaultMessage [string] default "Welcome"
         *      Message displayed onscreen at the start of a transaction
         *      Irrelevant if disableRBA is true
         * cashback [boolean] default true
         *      Show cashback selections if payment type debit or ebt cash
         *      is selected.
         *      Irrelevant if disableRBA or disableButtons is true
         */
        public override void SetConfig(Dictionary <string, string> d)
        {
            if (d.ContainsKey("disableRBA") && d["disableRBA"].ToLower() == "true")
            {
                try {
                    if (this.rba != null)
                    {
                        rba.stubStop();
                    }
                } catch (Exception) {}
                this.rba = null;
            }

            if (this.rba != null && d.ContainsKey("disableButtons") && d["disableButtons"].ToLower() == "true")
            {
                this.rba.SetEMV(RbaButtons.None);
            }

            if (this.rba != null && d.ContainsKey("buttons"))
            {
                if (d["buttons"].ToLower() == "credit")
                {
                    this.rba.SetEMV(RbaButtons.Credit);
                }
                else if (d["buttons"].ToLower() == "cashback")
                {
                    this.rba.SetEMV(RbaButtons.Cashback);
                }
            }

            if (this.rba != null && d.ContainsKey("defaultMessage"))
            {
                this.rba.SetDefaultMessage(d["defaultMessage"]);
            }

            if (d.ContainsKey("alwaysReset") && d["alwaysReset"].ToLower() == "true")
            {
                this.always_reset = true;
            }

            if (d.ContainsKey("logXML") && d["logXML"].ToLower() == "true")
            {
                this.enable_xml_log = true;
            }

            if (d.ContainsKey("logErrors") && d["logErrors"].ToLower() == "true")
            {
                this.enableUnifiedLog();
            }

            if (this.rba != null && d.ContainsKey("cashback") && (d["cashback"].ToLower() == "true" || d["cashback"].ToLower() == "false"))
            {
                this.rba.SetCashBack(d["cashback"].ToLower() == "true" ? true : false);
            }
        }
Пример #5
0
 public SPH_Datacap_PDCX(string p) : base(p)
 { 
     device_identifier=p;
     if (p.Contains(":")) {
         string[] parts = p.Split(new char[]{':'}, 2);
         device_identifier = parts[0];
         com_port = parts[1];
     }
     if (device_identifier == "INGENICOISC250_MERCURY_E2E") {
         rba = new RBA_Stub("COM"+com_port);
     }
 }
Пример #6
0
 public SPH_Datacap_PDCX(string p) : base(p)
 {
     device_identifier = p;
     if (p.Contains(":"))
     {
         string[] parts = p.Split(new char[] { ':' }, 2);
         device_identifier = parts[0];
         com_port          = parts[1];
     }
     if (device_identifier == "INGENICOISC250_MERCURY_E2E")
     {
         rba = new RBA_Stub("COM" + com_port);
     }
 }
Пример #7
0
 public override void SetConfig(string k, string v)
 {
     if (k == "disableRBA" && v == "true") {
     try {
         if (this.rba != null) {
             rba.stubStop();
         }
     } catch (Exception) {}
     this.rba = null;
     } else if (k == "disableButtons" && v == "true") {
     this.rba.SetEMV(RbaButtons.None);
     } else if (k == "logXML" && v == "true") {
     this.enable_xml_log = true;
     }
 }
Пример #8
0
        /**
         * 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);
        }
Пример #9
0
        public SPH_Datacap_EMVX(string p)
            : base(p)
        {
            device_identifier=p;
            if (p.Contains(":")) {
            string[] parts = p.Split(new char[]{':'}, 2);
            device_identifier = parts[0];
            com_port = parts[1];
            }

            string my_location = AppDomain.CurrentDomain.BaseDirectory;
            char sep = Path.DirectorySeparatorChar;
            xml_log = my_location + sep + "log.xml";
            pdc_active = false;
            emv_active = false;
            emv_reset = true;

            if (device_identifier.Substring(0, 8) == "INGENICO") {
            rba = new RBA_Stub("COM"+com_port);
            rba.SetEMV(RbaButtons.EMV);
            }
        }
Пример #10
0
        public SPH_Datacap_EMVX(string p) : base(p)
        {
            device_identifier = p;
            if (p.Contains(":"))
            {
                string[] parts = p.Split(new char[] { ':' }, 2);
                device_identifier = parts[0];
                com_port          = parts[1];
            }

            if (device_identifier == "INGENICOISC250_MERCURY_E2E")
            {
                rba = new RBA_Stub("COM" + com_port);
            }

            string my_location = AppDomain.CurrentDomain.BaseDirectory;
            char   sep         = Path.DirectorySeparatorChar;

            xml_log    = my_location + sep + "xml.log";
            emv_active = new ManualResetEvent(false);
            pdc_active = new ManualResetEvent(false);
        }
Пример #11
0
        /**
         * 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);
                    }
                }
            }
        }