///<summary>Exception means failed. Return means success. paymentsAllowed should be check after return. If false then assume payments cannot be made for this clinic.</summary>
        public static void GetPayConnectPatPortalCreds(long clinicNum, out PayConnect.WebPaymentProperties payConnectProps)
        {
            //No need to check RemotingRole;no call to db.
            //Secure arguments are held in the db.
            payConnectProps = new PayConnect.WebPaymentProperties();
            OpenDentBusiness.Program programPayConnect = OpenDentBusiness.Programs.GetCur(OpenDentBusiness.ProgramName.PayConnect);
            if (programPayConnect == null)            //PayConnect not setup.
            {
                throw new ODException("PayConnect program link not found.", ODException.ErrorCodes.PayConnectProgramProperties);
            }
            if (!programPayConnect.Enabled)              //PayConnect not turned on.
            {
                throw new ODException("PayConnect program link is disabled.", ODException.ErrorCodes.PayConnectProgramProperties);
            }
            //Validate the online token, since it is requiored for PayConnect online payments to work.
            List <OpenDentBusiness.ProgramProperty> listPayConnectProperties = OpenDentBusiness.ProgramProperties.GetListForProgramAndClinic(programPayConnect.ProgramNum, clinicNum);

            payConnectProps.Token = OpenDentBusiness.ProgramProperties.GetPropValFromList(listPayConnectProperties, PayConnect.ProgramProperties.PatientPortalPaymentsToken, clinicNum);
            if (string.IsNullOrEmpty(payConnectProps.Token))
            {
                throw new ODException("PayConnect online token not found.", ODException.ErrorCodes.PayConnectProgramProperties);
            }
            string paymentsAllowedVal = OpenDentBusiness.ProgramProperties.GetPropValFromList(listPayConnectProperties, PayConnect.ProgramProperties.PatientPortalPaymentsEnabled, clinicNum);

            payConnectProps.IsPaymentsAllowed = OpenDentBusiness.PIn.Bool(paymentsAllowedVal);
        }
        ///<summary>Exception means failed. Return means success. paymentsAllowed should be check after return. If false then assume payments cannot be made for this clinic.</summary>
        public static void GetXWebCreds(long clinicNum, out OpenDentBusiness.WebTypes.Shared.XWeb.WebPaymentProperties xwebProperties)
        {
            string xWebID;
            string authKey;
            string terminalID;
            long   paymentTypeDefNum;

            xwebProperties = new WebTypes.Shared.XWeb.WebPaymentProperties();
            //No need to check RemotingRole;no call to db.
            //Secure arguments are held in the db.
            OpenDentBusiness.Program programXcharge = OpenDentBusiness.Programs.GetCur(OpenDentBusiness.ProgramName.Xcharge);
            if (programXcharge == null)            //XCharge not setup.
            {
                throw new ODException("X-Charge program link not found.", ODException.ErrorCodes.XWebProgramProperties);
            }
            if (!programXcharge.Enabled)              //XCharge not turned on.
            {
                throw new ODException("X-Charge program link is disabled.", ODException.ErrorCodes.XWebProgramProperties);
            }
            //Validate ALL XWebID, AuthKey, and TerminalID.  Each is required for X-Web to work.
            List <OpenDentBusiness.ProgramProperty> listXchargeProperties = OpenDentBusiness.ProgramProperties.GetListForProgramAndClinic(programXcharge.ProgramNum, clinicNum);

            xWebID     = OpenDentBusiness.ProgramProperties.GetPropValFromList(listXchargeProperties, "XWebID", clinicNum);
            authKey    = OpenDentBusiness.ProgramProperties.GetPropValFromList(listXchargeProperties, "AuthKey", clinicNum);
            terminalID = OpenDentBusiness.ProgramProperties.GetPropValFromList(listXchargeProperties, "TerminalID", clinicNum);
            string paymentTypeDefString = OpenDentBusiness.ProgramProperties.GetPropValFromList(listXchargeProperties, "PaymentType", clinicNum);

            if (string.IsNullOrEmpty(xWebID) || string.IsNullOrEmpty(authKey) || string.IsNullOrEmpty(terminalID) || !long.TryParse(paymentTypeDefString, out paymentTypeDefNum))
            {
                throw new ODException("X-Web program properties not found.", ODException.ErrorCodes.XWebProgramProperties);
            }
            //XWeb ID must be 12 digits, Auth Key 32 alphanumeric characters, and Terminal ID 8 digits.
            if (!Regex.IsMatch(xWebID, "^[0-9]{12}$") ||
                !Regex.IsMatch(authKey, "^[A-Za-z0-9]{32}$") ||
                !Regex.IsMatch(terminalID, "^[0-9]{8}$"))
            {
                throw new ODException("X-Web program properties not valid.", ODException.ErrorCodes.XWebProgramProperties);
            }
            string asString = OpenDentBusiness.ProgramProperties.GetPropValFromList(listXchargeProperties, "IsOnlinePaymentsEnabled", clinicNum);

            xwebProperties.XWebID            = xWebID;
            xwebProperties.TerminalID        = terminalID;
            xwebProperties.AuthKey           = authKey;
            xwebProperties.PaymentTypeDefNum = paymentTypeDefNum;
            xwebProperties.IsPaymentsAllowed = OpenDentBusiness.PIn.Bool(asString);
        }