Пример #1
0
        protected void PostDisplayEvent(string uri, bool delayEFTPOSCommands, bool debugTrace, string tenderId, string originalEFTPOSCommandId, string dataField, string csdReservedString1, string csdReservedString5)
        {
            var eftposEventCommand = new EFTPOSCommand()
            {
                EFTPOSCommandType       = EFTPOSCommandType.DisplayEvent,
                TenderId                = tenderId,
                OriginalEFTPOSCommandId = originalEFTPOSCommandId,
                DataField               = dataField,
                CsdReservedString1      = csdReservedString1,
                CsdReservedString5      = csdReservedString5
            };

            var r = JsonConvert.DeserializeObject <PATResponse>(PostJsonString(uri, JsonConvert.SerializeObject(new PATRequest()
            {
                EFTPOSCommand = eftposEventCommand
            }), debugTrace));

            if (r.EFTPOSCommand == null)
            {
                throw new Exception("No EFTPOSCommand in POST response");
            }
            if (delayEFTPOSCommands)
            {
                System.Threading.Thread.Sleep(1000);
            }
        }
Пример #2
0
        public void Run()
        {
            PATResponse   r = null;
            List <Table>  tables = null;
            Order         order = null;
            Table         table = null;
            Tender        tender = null;
            Settings      settings = null;
            string        uri = null;
            EFTPOSCommand eftposRequestCommand = null, eftposEventCommand = null;
            string        eftposCommandId = string.Empty;

            // Get our settings
            GetSettings(ref settings);

            // Get tables
            GetTables(ref tables);

            // Find the first available order
            GetFirstOrderFromTables(tables, ref order, ref table);

            // Grab a receipt for this order
            if (settings.ReceiptOptions != null && settings.ReceiptOptions.Count > 0)
            {
                GetReceipt(order, settings.ReceiptOptions[0]);
            }

            // Create a tender (we can't continue without a default tender option)
            if (settings.TenderOptions == null || settings.TenderOptions.Count == 0)
            {
                throw new Exception("Can't continue without a tender option");
            }
            CreateTender(ref tender, settings.TenderOptions[0], order);

            // Send our txn request EFTPOS command\
            CreateEFTPOSRequest(ref eftposRequestCommand, tender);
            eftposCommandId = eftposRequestCommand.Id;

            // Send some display events
            uri = String.Format("{0}/api/eftpos/commands?key={1}", BaseUri, ApiKey);
            PostDisplayEvent(uri, DelayEFTPOSCommands, DebugTrace, tender.Id, eftposRequestCommand.Id, "     SWIPE CARD                         ", "100000003", "0");
            PostDisplayEvent(uri, DelayEFTPOSCommands, DebugTrace, tender.Id, eftposRequestCommand.Id, "   SELECT ACCOUNT                       ", "100000004", "0");
            PostDisplayEvent(uri, DelayEFTPOSCommands, DebugTrace, tender.Id, eftposRequestCommand.Id, "     ENTER  PIN                         ", "100000005", "0");
            PostDisplayEvent(uri, DelayEFTPOSCommands, DebugTrace, tender.Id, eftposRequestCommand.Id, "     PROCESSING         PLEASE WAIT     ", "000000000", "0");
            PostDisplayEvent(uri, DelayEFTPOSCommands, DebugTrace, tender.Id, eftposRequestCommand.Id, "     TRANSACTION          APPROVED      ", "100000005", "0");

            // Send the transaction event
            CreateEFTPOSEvent(ref eftposEventCommand, eftposRequestCommand, tender);

            // Update the tender
            UpdateTender(ref tender, order);

            // Check the order details. It should be complete.
            ValidateOrderComplete(order);

            Console.WriteLine("Complete");
        }
Пример #3
0
        /// <summary>
        /// Create a "TransactionEvent" EFTPOS command, throws an exception if data is invalid
        /// </summary>
        /// <param name="eftposEventCommand"></param>
        /// <param name="eftposRequestCommand"></param>
        /// <param name="tender"></param>
        void CreateEFTPOSEvent(ref EFTPOSCommand eftposEventCommand, EFTPOSCommand eftposRequestCommand, Tender tender)
        {
            var uri = String.Format("{0}/api/eftpos/commands?key={1}", BaseUri, ApiKey);

            eftposEventCommand = new EFTPOSCommand()
            {
                EFTPOSCommandType       = EFTPOSCommandType.TransactionEvent,
                TenderId                = tender.Id,
                OriginalEFTPOSCommandId = eftposRequestCommand.Id,
                AmtPurchase             = eftposRequestCommand.AmtPurchase,
                TxnType          = "P",
                STAN             = "26",
                ResponseType     = "210",
                Caid             = "000008156005003",
                Catid            = "00000000",
                Date             = "000000",
                Time             = "000000",
                ResponseCode     = "00",
                ResponseText     = "APPROVED",
                Merchant         = "0",
                Success          = true,
                AccountType      = "Credit",
                CardType         = "DEBIT CARD AC",
                CardName         = "00",
                TxnRef           = eftposRequestCommand.TxnRef,
                DateSettlement   = "000000",
                AuthCode         = "000023",
                CsdReservedBool1 = false,
                Rrn    = "000000000023",
                Track2 = "4343000000000005=0101?",
                Pan    = "4343000000000005"
            };
            var r = JsonConvert.DeserializeObject <PATResponse>(PostJsonString(uri, JsonConvert.SerializeObject(new PATRequest()
            {
                EFTPOSCommand = eftposEventCommand
            }), DebugTrace));

            if (r.EFTPOSCommand == null)
            {
                throw new Exception("No EFTPOSCommand in POST response");
            }
            Console.WriteLine("TransactionEvent EFTPOSCommand Created");
        }
Пример #4
0
        /// <summary>
        /// Create a "DoTransaction" EFTPOS command, throws an exception if data is invalid
        /// </summary>
        /// <param name="eftposRequestCommand"></param>
        /// <param name="tender"></param>
        void CreateEFTPOSRequest(ref EFTPOSCommand eftposRequestCommand, Tender tender)
        {
            var uri = String.Format("{0}/api/eftpos/commands?key={1}", BaseUri, ApiKey);

            eftposRequestCommand = new EFTPOSCommand()
            {
                EFTPOSCommandType = EFTPOSCommandType.DoTransaction, TenderId = tender.Id, AmtPurchase = tender.AmountPurchase, TxnType = "P", TxnRef = String.Format("{0:yyddMMHHmmsszzz}", DateTime.Now)
            };
            var r = JsonConvert.DeserializeObject <PATResponse>(PostJsonString(uri, JsonConvert.SerializeObject(new PATRequest()
            {
                EFTPOSCommand = eftposRequestCommand
            }), DebugTrace));

            if (r.EFTPOSCommand == null)
            {
                throw new Exception("No EFTPOSCommand in POST response");
            }
            Console.WriteLine("DoTransaction EFTPOSCommand Created");
        }