Beispiel #1
0
        private static T ValidateResponse <T>(IRestResponse response) where T : new()
        {
            if (response.ErrorException != null)
            {
                const string message = "Error retrieving response.  Check inner details for more info.";
                var          error   = new PinError
                {
                    Error            = "Unknown error",
                    ErrorDescription = message
                };
                throw new PinPaymentsException(error, message, response.ErrorException);
            }

            // NOTE: Would like to get deserializer from RestClient but there is no public access to it.
            // We know that the PinPayments API will _always_ return JSON, so its cool.
            var deserializer = new RestSharpDataContractJsonDeserializer();

            // A non-20x status code response is an error from the PinPayments API
            if (response.StatusCode.IsNon20XCode())
            {
                var pinError = deserializer.Deserialize <PinError>(response);
                throw new PinPaymentsException(pinError, pinError.ErrorDescription);
            }

            return(deserializer.Deserialize <T>(response));
        }
Beispiel #2
0
    private void quickPin()
    {
        int    amount           = 70;
        String dispenserCommand = "";

        if (amount > saldo)
        {
            PinError pinError = new PinError();
            cancelled = true;
        }
        if (stock.checkIfAvailable(2, 0, 1))
        {
            dispenserCommand = "02,00,01,*";
        }
        else if (stock.checkIfAvailable(0, 1, 1))
        {
            dispenserCommand = "00,01,01,*";
        }
        else if (stock.checkIfAvailable(1, 3, 0))
        {
            dispenserCommand = "01,03,00,*";
        }
        else if (stock.checkIfAvailable(7, 0, 0))
        {
            dispenserCommand = "07,00,00,*";
        }
        else
        {
            cancelled = true;
        }
        if (cancelled == false)
        {
            stock.substractBiljets(dispenserCommand);
            uploadConnection.UpdateBalans(rekeningID, (saldo - amount * 100));
            uploadConnection.transaction(pasID, rekeningID, amount);
            arduino.dispenseMoney(dispenserCommand);
        }
        ByeScreen quickBye = new ByeScreen();

        endOfSession = true;
        quickBye.Hide();
    }
Beispiel #3
0
    private void quickPin()
    {
        int amount = 70;

        if (amount > saldo && amount != 0)
        {
            PinError pinError = new PinError();
            cancelled = true;
        }
        uploadConnection.UpdateBalans(Int32.Parse(rekeningID), (saldo - amount));
        uploadConnection.transaction(pasID, rekeningID, amount);
        if (cancelled == false)
        {
            arduino.dispenseMoney("02,00,01*");
        }
        ByeScreen quickBye = new ByeScreen();

        endOfSession = true;
        quickBye.Hide();
    }
Beispiel #4
0
    private void pin()
    {
        Boolean printTicket = false;
        Boolean goBack      = true;
        double  amount      = 0;
        String  input;

        cancelled = false;

        while (goBack == true)
        {
            pinsherm.Show();
            while (true)
            {
                input = arduino.getString();
                if (input.Contains("1"))
                {
                    amount = 10;
                    break;
                }
                else if (input.Contains("2"))
                {
                    amount = 20;
                    break;
                }
                else if (input.Contains("3"))
                {
                    amount = 50;
                    break;
                }
                else if (input.Contains("4"))
                {
                    amount = getAlternativeAmount();
                    break;
                }
                else if (input.Contains("#"))
                {
                    cancelled = true;
                    break;
                }
                else if (input.Contains("C"))
                {
                    cancelled    = true;
                    endOfSession = false;
                    break;
                }
            }
            pinsherm.Hide();
            if (amount > saldo && amount != 0)
            {
                PinError pinError = new PinError();
                cancelled = true;
            }
            if (cancelled == true)
            {
                break;
            }
            else
            {
                uploadConnection.UpdateBalans(Int32.Parse(rekeningID), (saldo - amount));
                uploadConnection.transaction(pasID, rekeningID, amount);
                //Error.show(amount.ToString());
            }
            asker.Show();
            while (true)
            {
                input = arduino.getString();
                if (input.Contains("*"))
                {
                    printTicket = true;
                    goBack      = false;
                    break;
                }
                else if (input.Contains("#"))
                {
                    //Error.show("Geen Bon", "bon");
                    goBack = false;
                    break;
                }
            }
            asker.Hide();
            if (printTicket == true)
            {
                Klant   tmp        = downloadConnection.getKlant(userName);
                String  printnaam  = String.Concat(tmp.Naam + " " + tmp.Achternaam);
                Printer bonPrinter = new Printer(printnaam, amount, rekeningID);
                bonPrinter.printTicket();
            }
            if (goBack == false)
            {
                ByeScreen goAway = new ByeScreen();
            }
        }
    }
Beispiel #5
0
 public PinException(HttpStatusCode httpStatusCode, PinError pinError, string message)
     : base(message)
 {
     HttpStatusCode = httpStatusCode;
     PinError       = pinError;
 }
Beispiel #6
0
    private void pin()
    {
        Boolean printTicket = false;
        Boolean goBack      = true;
        int     amount      = 0;
        String  input;
        String  dispenserCommand = "00,00,00,*";

        cancelled = false;

        while (goBack == true)
        {
            pinsherm.Show();
            while (true)
            {
                input = arduino.getString();
                if (input.Contains("1"))
                {
                    amount = 10;
                    break;
                }
                else if (input.Contains("2"))
                {
                    amount = 20;
                    break;
                }
                else if (input.Contains("3"))
                {
                    amount = 50;
                    break;
                }
                else if (input.Contains("4"))
                {
                    amount = getAlternativeAmount();
                    break;
                }
                else if (input.Contains("#"))
                {
                    cancelled = true;
                    break;
                }
                else if (input.Contains("C"))
                {
                    cancelled    = true;
                    endOfSession = false;
                    break;
                }
            }
            pinsherm.Hide();
            if ((amount > saldo && amount != 0) || amount >= 200)
            {
                PinError pinError = new PinError();
                cancelled = true;
            }
            if (cancelled == true)
            {
                break;
            }
            if (amount == 10 && stock.checkIfAvailable(1, 0, 0) == true)
            {
                dispenserCommand = "01,00,00,*";
            }
            else if (amount == 10)
            {
                BiljetScreen selector = new BiljetScreen();
                selector.showInsufficient();
                cancelled = true;
            }
            if (amount > 10)
            {
                dispenserCommand = biljetSelection(amount);
                if (dispenserCommand.Equals("00,00,00,*"))
                {
                    cancelled = true;
                    break;
                }
            }
            if (cancelled == true)
            {
                break;
            }
            uploadConnection.UpdateBalans(rekeningID, (saldo - amount * 100));
            uploadConnection.transaction(pasID, rekeningID, amount);
            asker.Show();
            while (true)
            {
                input = arduino.getString();
                if (input.Contains("*"))
                {
                    printTicket = true;
                    goBack      = false;
                    break;
                }
                else if (input.Contains("#"))
                {
                    goBack = false;
                    break;
                }
                else if (input.Contains("A"))
                {
                    Email mailer = new Email(userName, amount, rekeningID, klantID);
                    mailer.sendEmail();
                    goBack = false;
                    break;
                }
            }
            asker.Hide();
            stock.substractBiljets(dispenserCommand);
            arduino.dispenseMoney(dispenserCommand);
            if (printTicket == true)
            {
                Printer bonPrinter = new Printer(userName, amount, rekeningID);
                bonPrinter.printTicket();
            }
            if (goBack == false)
            {
                ByeScreen goAway = new ByeScreen();
            }
        }
    }
Beispiel #7
0
 public PinPaymentsException(PinError error, string message, Exception innerException)
     : base(message, innerException)
 {
     Error = error;
 }
Beispiel #8
0
 public PinPaymentsException(PinError error, string message)
     : base(message)
 {
     Error = error;
 }