Ejemplo n.º 1
0
        public COMConcertLibrary.ConcertErrMsg Ticket(uint timeout, out COMConcertLibrary.SerialPortReceive result)
        {
            Log.Info("Printing ticket...");
            var paymentMode = COMConcertLibrary.PAYMENT_MODE_EFT_HANDLING;
            var paymentType = COMConcertLibrary.PAYMENT_TYPE_SALE;

            var dataToSend = new COMConcertLibrary.SerialPortSend(1, 0, true,
                                                                  paymentMode, paymentType, 826 /*GBP*/, "TICKET", false, true);

            result = new COMConcertLibrary.SerialPortReceive();

            return(COMConcertLibrary.ConcertTransaction_(ref dataToSend, ref result, timeout));
        }
Ejemplo n.º 2
0
        public COMConcertLibrary.ConcertErrMsg Reverse(string transactionNumber, uint timeout, out COMConcertLibrary.SerialPortReceive result)
        {
            Log.Info($"Executing reverse");

            var paymentMode = COMConcertLibrary.PAYMENT_MODE_EFT_HANDLING;

            var dataToSend = new COMConcertLibrary.SerialPortSend(1, 0, true,
                                                                  paymentMode, 0, 826 /*GBP*/, $"REV{transactionNumber}", false, true);

            result = new COMConcertLibrary.SerialPortReceive();

            return(COMConcertLibrary.ConcertTransaction_(ref dataToSend, ref result, timeout));
        }
Ejemplo n.º 3
0
        public COMConcertLibrary.ConcertErrMsg Refund(int amount, uint timeout, bool forceOnline, out COMConcertLibrary.SerialPortReceive result)
        {
            Log.Info($"Executing refund - Amount: {amount}");

            var paymentMode = COMConcertLibrary.PAYMENT_MODE_EFT_HANDLING;
            var paymentType = COMConcertLibrary.PAYMENT_TYPE_REFUND;

            var dataToSend = new COMConcertLibrary.SerialPortSend(1, amount, true,
                                                                  paymentMode, paymentType, 826 /*GBP*/, null, false, true);

            result = new COMConcertLibrary.SerialPortReceive();

            return(COMConcertLibrary.ConcertTransaction_(ref dataToSend, ref result, timeout));
        }
Ejemplo n.º 4
0
        public COMConcertLibrary.ConcertErrMsg EndOfDayReport(uint timeout, out COMConcertLibrary.SerialPortReceive result)
        {
            Log.Info("Printing end of day report...");

            var paymentMode = COMConcertLibrary.PAYMENT_MODE_EFT_HANDLING;
            var paymentType = COMConcertLibrary.PAYMENT_TYPE_SALE;

            var dataToSend = new COMConcertLibrary.SerialPortSend(1, 0, true,
                                                                  paymentMode, paymentType, 826 /*GBP*/, "EOD", false, true);

            result = new COMConcertLibrary.SerialPortReceive();

            var transactionResult = COMConcertLibrary.ConcertTransaction_(ref dataToSend, ref result, timeout);

            if (transactionResult != COMConcertLibrary.ConcertErrMsg.None)
            {
                return(transactionResult);
            }

            dataToSend = new COMConcertLibrary.SerialPortSend(1, 0, true,
                                                              paymentMode, paymentType, 826 /*GBP*/, "REPORT", false, true);

            return(COMConcertLibrary.ConcertTransaction_(ref dataToSend, ref result, timeout));
        }
Ejemplo n.º 5
0
        private void PersistTransaction(COMConcertLibrary.SerialPortReceive result, XNode ticket)
        {
            try
            {
                var config          = AppConfiguration.Instance;
                var outputDirectory = Path.GetFullPath(config.OutPath);
                var outputPath      = Path.Combine(outputDirectory, $"{DateTime.Now:yyyyMMddHHmmss}_ticket.xml");

                if (!Directory.Exists(outputDirectory))
                {
                    Directory.CreateDirectory(outputDirectory);
                }

                var root = new XElement("transaction",
                                        new XElement("response",
                                                     new XElement("date", DateTime.Now.ToString("yyyyMMdd")),
                                                     new XElement("time", DateTime.Now.ToString("HHmmss")),
                                                     new XElement("eposNumber", result.eposNumber),
                                                     new XElement("responseCode", result.responseCode),
                                                     new XElement("amount", result.amount),
                                                     new XElement("paymentMode", result.paymentMode),
                                                     new XElement("responseData", result.responseData),
                                                     new XElement("currency", result.currency),
                                                     new XElement("privateData", result.privateData),
                                                     new XElement("option", result.option),
                                                     new XElement("nonConcertData", result.nonConcertData)
                                                     ));

                if (ticket != null)
                {
                    var customerReceipt = ticket.XPathSelectElement("//RECEIPT[@STYPE='CUSTOMER']");
                    if (customerReceipt != null)
                    {
                        root.Add(new XElement("customerReceipt",
                                              customerReceipt.Elements().Select(_ =>
                        {
                            var tag = new XElement("tag", _.Value);
                            if (_.Attribute("ID") != null)
                            {
                                tag.Add(new XAttribute("id", _.Attribute("ID").Value));
                            }

                            if (_.Attribute("ID_NAME") != null)
                            {
                                tag.Add(new XAttribute("name", _.Attribute("ID_NAME").Value));
                            }
                            return(tag);
                        })));
                    }


                    var merchantReceipt = ticket.XPathSelectElement("//RECEIPT[@STYPE='MERCHANT']");
                    if (merchantReceipt != null)
                    {
                        root.Add(new XElement("merchantReceipt",
                                              merchantReceipt.Elements().Select(_ =>
                        {
                            var tag = new XElement("tag", _.Value);
                            if (_.Attribute("ID") != null)
                            {
                                tag.Add(new XAttribute("id", _.Attribute("ID").Value));
                            }

                            if (_.Attribute("ID_NAME") != null)
                            {
                                tag.Add(new XAttribute("name", _.Attribute("ID_NAME").Value));
                            }
                            return(tag);
                        })));
                    }
                }

                var document = new XDocument(root);

                Log.Info($"Persist Transaction path: {ticketPath}");
                //Write the new ticket
                document.Save(outputPath);
            }
            catch (Exception ex)
            {
                Log.Error("Persist Transaction exception.");
                Log.Error(ex);
            }
        }