private bool SetPaymentConfigSettings(AdminPeripheralSetting setting, ref string exceptionMessage)
        {
            try
            {
                logger.Info(PAYMENT_LOG, string.Format("Updating c3config setting : {0}", setting.ControlName));

                switch (setting.ControlType)
                {
                case SettingDataType.String:

                    if (setting.RealName.Equals("AXIS_COM") || setting.RealName.Equals("AXIS_COM2"))
                    {
                        return(IniFilesSimple.WriteValue(setting.RealName, string.Format("socket {0}", ((string)setting.CurrentValue).Trim()), Path.Combine(DriverLocation, C3NET_CONFIG), ref exceptionMessage));
                    }
                    //This is a treatment for the previous case where the COM was a string type not a SerialPortSelection type setting
                    else if (setting.RealName.Equals("L10_COM"))
                    {
                        //The user is only able to modify the com port, not the speed, parity and other properties of the COM
                        return(IniFilesSimple.WriteValue(setting.RealName, string.Format("{0} 115200/8/1/0", ((string)setting.CurrentValue).Trim()), Path.Combine(DriverLocation, C3NET_CONFIG), ref exceptionMessage));
                    }
                    //For any other setting
                    else
                    {
                        return(IniFilesSimple.WriteValue(setting.RealName, (string)setting.CurrentValue, Path.Combine(DriverLocation, C3NET_CONFIG), ref exceptionMessage));
                    }

                case SettingDataType.SerialPortSelection:

                    //The user is only able to modify the com port, not the speed, parity and other properties of the COM
                    return(IniFilesSimple.WriteValue(setting.RealName, string.Format("{0} 115200/8/1/0", ((string)setting.CurrentValue).Trim()), Path.Combine(DriverLocation, C3NET_CONFIG), ref exceptionMessage));

                case SettingDataType.Int:
                    return(IniFilesSimple.WriteValue(setting.RealName, setting.CurrentValue.ToString(), Path.Combine(DriverLocation, C3NET_CONFIG), ref exceptionMessage));

                case SettingDataType.Bool:
                    return(IniFilesSimple.WriteValue(setting.RealName, setting.CurrentValue.ToString(), Path.Combine(DriverLocation, C3NET_CONFIG), ref exceptionMessage));

                default:
                    return(false);
                }
            }
            catch (Exception ex)
            {
                logger.Error(PAYMENT_LOG, string.Format("SetPaymentConfigSettings : Failed to write payment setting.\r\n{0}", ex.ToString()));
                return(false);
            }
        }
        /// <summary>
        /// Update the settings in all the configuration files with the ones stored in the Account
        /// This method will be called when the a device is Set from Admin or when a device is loaded at Core startup
        /// </summary>
        /// <param name="configJson"></param>
        /// <param name="overwrite"></param>
        /// <returns></returns>
        public bool UpdateSettings(string configJson, bool overwrite = false)
        {
            string exceptionMessage = "";

            try
            {
                //Deserialize the config object to get access to the driver settings
                Payment payment = JsonConvert.DeserializeObject <Payment>(configJson);

                //Check if the config object is empty
                if (currentPaymentInitConfig != payment)
                {
                    //Save the settings
                    foreach (AdminPeripheralSetting paymentSetting in payment.ConfigurationSettings)
                    {
                        switch (paymentSetting.RealName)
                        {
                        case "Currency":
                            currency = paymentSetting;
                            break;

                        case "L10_COM":
                            //Update the c3config filed
                            if (!SetPaymentConfigSettings(paymentSetting, ref exceptionMessage))
                            {
                                logger.Info(PAYMENT_LOG, $"Failed to update c3config setting : {paymentSetting.ControlName}. {exceptionMessage}");
                                return(false);
                            }
                            comPort = paymentSetting;
                            break;

                        case "QTPV":
                            //Update the c3config filed
                            if (!SetPaymentConfigSettings(paymentSetting, ref exceptionMessage))
                            {
                                logger.Info(PAYMENT_LOG, $"Failed to update c3config setting : {paymentSetting.ControlName}. {exceptionMessage}");
                                return(false);
                            }
                            terminalID = paymentSetting;
                            break;

                        case "AXIS_COM":
                            //Update the c3config filed
                            if (!SetPaymentConfigSettings(paymentSetting, ref exceptionMessage))
                            {
                                logger.Info(PAYMENT_LOG, $"Failed to update c3config setting : {paymentSetting.ControlName}. {exceptionMessage}");
                                return(false);
                            }
                            first_server = paymentSetting;
                            break;

                        case "AXIS_COM2":
                            //Update the c3config filed
                            if (!SetPaymentConfigSettings(paymentSetting, ref exceptionMessage))
                            {
                                logger.Info(PAYMENT_LOG, $"Failed to update c3config setting : {paymentSetting.ControlName}. {exceptionMessage}");
                                return(false);
                            }
                            second_server = paymentSetting;
                            break;

                        case "REPOS_1":
                            //Update the c3config filed
                            if (!SetPaymentConfigSettings(paymentSetting, ref exceptionMessage))
                            {
                                logger.Info(PAYMENT_LOG, $"Failed to update c3config setting : {paymentSetting.ControlName}. {exceptionMessage}");
                                return(false);
                            }
                            messageLineOne = paymentSetting;
                            break;

                        case "REPOS_2":
                            //Update the c3config filed
                            if (!SetPaymentConfigSettings(paymentSetting, ref exceptionMessage))
                            {
                                logger.Info(PAYMENT_LOG, $"Failed to update c3config setting : {paymentSetting.ControlName}. {exceptionMessage}");
                                return(false);
                            }
                            messageLineTwo = paymentSetting;
                            break;

                        case "CARTES":
                            //Update the c3config filed
                            if (!SetPaymentConfigSettings(paymentSetting, ref exceptionMessage))
                            {
                                logger.Info(PAYMENT_LOG, $"Failed to update c3config setting : {paymentSetting.ControlName}. {exceptionMessage}");
                                return(false);
                            }
                            cardApplications = paymentSetting;
                            break;
                        }
                    }

                    //Update the c3config "VISA_RRP_DATA" filed with this new Value.
                    //This update it will not allow contact-less payments to be processed off-line(which we now can't do because of UK Law)
                    logger.Info(PAYMENT_LOG, "Updating c3config setting : VISA_RRP_DATA");

                    if (!IniFilesSimple.WriteValue("VISA_RRP_DATA", VISA_RRP_DATA_VALUE, Path.Combine(DriverLocation, C3NET_CONFIG), ref exceptionMessage))
                    {
                        logger.Info(PAYMENT_LOG, $"Failed to update c3config setting : VISA_RRP_DATA. \r\n {exceptionMessage}");
                        return(false);
                    }
                }
                //Return with failure if the payment config is empty
                else
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                logger.Error(PAYMENT_LOG, string.Format("Failed to initialize payment settings.\r\n{0}", ex.ToString()));
            }
            return(false);
        }
        public Payment_ROI_IPP350(ILogger logger = null)
        {
            this.logger = logger;

            paymentStatus = new PaymentStatus();

            communicator = new Communicator(logger);

            DriverLocation = $@"C:\Acrelec\Core\Peripherals\Payments\Drivers\{PAYMENT_NAME}\{DriverVersion}\Driver\{DRIVER_FOLDER_NAME}";

            //Create the object that is in charge with the sevice management
            c3NetManager = new C3NetManager(logger, DriverLocation);

            //Hook the payment callback to the current callback
            communicator.CommunicatorCallbacks = this;

            //COM PORT
            comPort             = new AdminPeripheralSetting();
            comPort.ControlName = "COM Port";
            comPort.RealName    = "L10_COM";
            //comPort.SettingFileName = C3NET_CONFIG;
            comPort.CurrentValue = "";
            comPort.ControlType  = SettingDataType.SerialPortSelection;

            terminalID                    = new AdminPeripheralSetting();
            terminalID.ControlType        = SettingDataType.String;
            terminalID.ControlName        = "Terminal ID";
            terminalID.RealName           = "QTPV";
            terminalID.CurrentValue       = ""; //Set a default application name
            terminalID.ControlDescription = "The payment terminal ID.";

            //Init the Axis 1
            first_server                    = new AdminPeripheralSetting();
            first_server.ControlName        = "Communication Server 1";
            first_server.RealName           = "AXIS_COM";
            first_server.SettingFileName    = C3NET_CONFIG;
            first_server.ControlDescription = "Ingenico communication Server. Example: 111.121.131.141 1234.";
            first_server.CurrentValue       = "0.0.0.0 0000";
            first_server.SetttingSection    = "";
            first_server.ControlType        = SettingDataType.String;

            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict.Add("EUR", "Euro");
            dict.Add("GBP", "Pound");
            currency                    = new AdminPeripheralSetting();
            currency.ControlType        = SettingDataType.SingleSelection;
            currency.ControlName        = "Currency";
            currency.RealName           = "Currency";
            currency.CurrentValue       = "GBP";
            currency.PossibleValues     = dict;
            currency.ControlDescription = "Flag that will control the currency of the payment.";

            //Init the Axis 2

            second_server                    = new AdminPeripheralSetting();
            second_server.ControlName        = "Communication Server 2";
            second_server.RealName           = "AXIS_COM2";
            second_server.SettingFileName    = C3NET_CONFIG;
            second_server.ControlDescription = "Ingenico secondary communication Server. Example: 111.121.131.141 1234.";
            second_server.CurrentValue       = "0.0.0.0 0000";
            second_server.SetttingSection    = "";
            second_server.ControlType        = SettingDataType.String;

            /// Idle Message line one
            messageLineOne                 = new AdminPeripheralSetting();
            messageLineOne.ControlName     = "Welcome Message Line 1";
            messageLineOne.RealName        = "REPOS_1";
            messageLineOne.SettingFileName = C3NET_CONFIG;
            messageLineOne.CurrentValue    = IniFilesSimple.ReadString("REPOS_1", "", Path.Combine(DriverLocation, C3NET_CONFIG));
            messageLineOne.SetttingSection = "";
            messageLineOne.ControlType     = SettingDataType.String;

            /// Idle Message line two
            messageLineTwo                 = new AdminPeripheralSetting();
            messageLineTwo.ControlName     = "Welcome Message Line 2";
            messageLineTwo.RealName        = "REPOS_2";
            messageLineTwo.SettingFileName = C3NET_CONFIG;
            messageLineTwo.CurrentValue    = IniFilesSimple.ReadString("REPOS_2", "", Path.Combine(DriverLocation, C3NET_CONFIG));
            messageLineTwo.SetttingSection = "";
            messageLineTwo.ControlType     = SettingDataType.String;

            //CARD APPLICATIONS
            cardApplications                    = new AdminPeripheralSetting();
            cardApplications.ControlName        = "ACTIVE APPLICATIONS";
            cardApplications.RealName           = "CARTES";
            cardApplications.SettingFileName    = C3NET_CONFIG;
            cardApplications.CurrentValue       = "ADM CLS";
            cardApplications.SetttingSection    = "";
            cardApplications.ControlDescription = "Applications that will be active after the initialization of the terminal. Example: ADM EMV SSC";
            cardApplications.ControlType        = SettingDataType.String;

            currentPaymentInitConfig = new Payment
            {
                PaymentName           = PAYMENT_NAME,
                DriverFolderName      = DRIVER_FOLDER_NAME,
                ConfigurationSettings = new List <AdminPeripheralSetting>(),
                Id   = PAYMENT_ID,
                Type = PAYMENT_TYPE.ToString()
            };
        }