private void cmdPersistConfig_Click(object sender, EventArgs e)
        {
            /*NOTE
             * Special consideration is necessary for protecting the identity token. You are required to be familure with the following
             * information regarding the identity token.
             * https://my.ipcommerce.com/Docs/TransactionProcessing/CWS/Implementation_Guidelines/2.0.17/ServiceInformationGuidelines/AuthenticationProcess/IdentityTokens.aspx
            */

            DialogResult Result;
            //Verify values to persist
            if (Helper.ApplicationProfileId.Length < 1 | Helper.ServiceID.Length < 1 | Helper.MerchantProfileId.Length < 1)
            {
                string sMessage = "Missing value(s) for\r\n";
                if (Helper.ApplicationProfileId.Length < 1) sMessage = sMessage + " - ApplicationProfileId\r\n";
                if (Helper.ServiceID.Length < 1) sMessage = sMessage + " - ServiceID\r\n";
                if (Helper.MerchantProfileId.Length < 1) sMessage = sMessage + " - MerchantProfileId\r\n";
                Result = MessageBox.Show(sMessage + "\r\nContinue?", "Verify Values to Save", MessageBoxButtons.YesNo);
                if (Result != DialogResult.Yes)
                    return;
            }

            string strIdentityToken = "";
            bool blnEncryptedIdentityToken = false;
            if (!chkEncryptIdentityToken.Checked)
            {
                MessageBox.Show("Since the identity token is not going to be encrypted, the " + 
                            "appilcation must securly protect the identity token with administrator file based securty");
                strIdentityToken = txtIdentityToken.Text; //The identity token will be stored as clear text
            }
            else
            {
                strIdentityToken = Helper.Encrypt(txtIdentityToken.Text);
                blnEncryptedIdentityToken = true;
            }
            _blnEncryptedIdentityToken = false;
            string strIdentityTokenMessage = "\r\n\tIdentity Token [NOT ENCRYPTED]";
            if (chkEncryptIdentityToken.Checked) 
            {
                strIdentityTokenMessage = "\r\n\tIdentity Token [ENCRYPTED]";
                _blnEncryptedIdentityToken = true;
            }
            MessageBox.Show("The following values will be persisted\r\n\r\n\tApplicationProfielId : " + Helper.ApplicationProfileId + "\r\n\tServiceId : " + Helper.ServiceID + "\r\n\tProfileId : " + Helper.MerchantProfileId + strIdentityTokenMessage);
            PersistAndCacheSettings PACS = new PersistAndCacheSettings(Helper.ApplicationProfileId, Helper.ServiceID, Helper.MerchantProfileId, blnEncryptedIdentityToken, strIdentityToken);
            SavePersistedConfig(PACS);
            LoadPersistedConfig();

            Result = MessageBox.Show("Configuration values successfully persisted. Continue to Transaction Processing", "Continue to Transaction Processing", MessageBoxButtons.YesNo);
            if (Result == DialogResult.Yes)
                tabControl1.SelectedTab = tbTransactionProcessing;
        }
        public bool SavePersistedConfig(PersistAndCacheSettings pacs)
        {
            //Save to file
            /*NOTE
              * SECURITY CONSIDERATIONS
              * Stored on file system with read/write permission for only the application/service and IT Administration
              * Stored in DB with read/write permission for only the application/service and IT Administration
            */

            try
            {
                //Save Settings
                XmlDocument doc = new XmlDocument();
                XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                doc.AppendChild(docNode);
                XmlNode transactionProcessingValues = doc.CreateElement("TransactionProcessing");
                doc.AppendChild(transactionProcessingValues);
                XmlNode configuration = doc.CreateElement("Configuration");
                transactionProcessingValues.AppendChild(configuration);
                
                XmlNode applicationProfielId = doc.CreateElement("ApplicationProfielId");
                applicationProfielId.InnerText = pacs.ApplicationProfileId;
                configuration.AppendChild(applicationProfielId);

                XmlNode serviceId = doc.CreateElement("ServiceId");
                serviceId.InnerText = pacs.ServiceId;
                XmlAttribute multipleServiceId = doc.CreateAttribute("MultipleServiceId");
                multipleServiceId.Value = (_si.BankcardServices.Count > 1 ? "True" : "False");
                serviceId.Attributes.Append(multipleServiceId);
                configuration.AppendChild(serviceId);

                XmlNode merchantProfielId = doc.CreateElement("MerchantProfielId");
                merchantProfielId.InnerText = pacs.MerchantProfileId;
                XmlAttribute multipleMerchants = doc.CreateAttribute("MultipleMerchants");
                multipleMerchants.Value = (MerchantProfileIds.Count > 2 ? "True" : "False");//Since by default empty comes back we need to validate at 2 and not 1
                merchantProfielId.Attributes.Append(multipleMerchants);
                configuration.AppendChild(merchantProfielId);

                XmlNode identityToken = doc.CreateElement("IdentityToken");
                identityToken.InnerText = pacs.IdentityToken;
                XmlAttribute encrypted = doc.CreateAttribute("Encrypted");
                encrypted.Value = pacs.EncryptedIdentityToken.ToString();//The following is dependant on the software company integration needs.
                identityToken.Attributes.Append(encrypted);
                configuration.AppendChild(identityToken);

                doc.Save(Helper.ServiceKey + "_TransactionProcessing.config");

                return true; 
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
            return false;
        }