Exemplo n.º 1
0
        ///<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);
        }
Exemplo n.º 2
0
 private void checkPatientPortalPayEnabled_Click(object sender, EventArgs e)
 {
     if (checkPatientPortalPayEnabled.Checked)
     {
         long clinicNum = 0;
         if (PrefC.HasClinicsEnabled)
         {
             clinicNum = _listUserClinicNums[comboClinic.SelectedIndex];
         }
         OpenDentBusiness.WebTypes.Shared.XWeb.WebPaymentProperties xwebProperties = new OpenDentBusiness.WebTypes.Shared.XWeb.WebPaymentProperties();
         try {
             ProgramProperties.GetXWebCreds(clinicNum, out xwebProperties);
         }
         catch (Exception ex) {
             ex.DoNothing();
         }
         string msg = "Online payments is already enabled for XWeb and must be disabled in order to use PayConnect online payments.  "
                      + "Would you like to disable XWeb online payments?";
         if (xwebProperties != null && xwebProperties.IsPaymentsAllowed && MessageBox.Show(msg, "", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
         {
             checkPatientPortalPayEnabled.Checked = false;
             return;
         }
         //User wants to disable XWeb online payments and use PayConnect online payments
         ProgramProperty ppOnlinePaymentEnabled = ProgramProperties.GetWhere(x =>
                                                                             x.ProgramNum == Programs.GetCur(ProgramName.Xcharge).ProgramNum &&
                                                                             x.ClinicNum == clinicNum &&
                                                                             x.PropertyDesc == "IsOnlinePaymentsEnabled")
                                                  .FirstOrDefault();
         if (ppOnlinePaymentEnabled == null)
         {
             return;                    //Should never happen since we successfully found it in the GetXWebCreds method.
         }
         _listXWebWebPayProgProps.Add(ppOnlinePaymentEnabled);
     }
 }