Ejemplo n.º 1
0
 private bool IsPaySimpleSetup()
 {
     //verify the selected clinic has a username and API key entered
     if (string.IsNullOrWhiteSpace(ProgramProperties.GetPropValForClinicOrDefault(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimpleApiUserName, _clinicNum)) ||
         string.IsNullOrWhiteSpace(ProgramProperties.GetPropValForClinicOrDefault(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimpleApiKey, _clinicNum)))
     {
         MsgBox.Show(this, "The PaySimple username and/or key has not been set.");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 2
0
        private void FormRecurringCharges_Load(object sender, EventArgs e)
        {
            if (Programs.HasMultipleCreditCardProgramsEnabled())
            {
                gridMain.HScrollVisible = true;
            }
            if (!PrefC.IsODHQ)
            {
                checkHideBold.Checked = true;
                checkHideBold.Visible = false;
            }
            Program progCur = null;

            if (Programs.IsEnabled(ProgramName.PaySimple))
            {
                progCur = Programs.GetCur(ProgramName.PaySimple);
                labelUpdated.Visible         = false;
                checkForceDuplicates.Checked = false;
                checkForceDuplicates.Visible = false;              //PaySimple always rejects identical transactions made within 5 minutes of eachother.
            }
            if (Programs.IsEnabled(ProgramName.PayConnect))
            {
                progCur = Programs.GetCur(ProgramName.PayConnect);
                labelUpdated.Visible         = false;
                checkForceDuplicates.Visible = true;
                checkForceDuplicates.Checked = PIn.Bool(ProgramProperties.GetPropValForClinicOrDefault(progCur.ProgramNum,
                                                                                                       PayConnect.ProgramProperties.PayConnectForceRecurringCharge, Clinics.ClinicNum));
            }
            if (Programs.IsEnabled(ProgramName.Xcharge))
            {
                progCur = Programs.GetCur(ProgramName.Xcharge);
                labelUpdated.Visible         = true;
                checkForceDuplicates.Visible = true;
                string xPath = Programs.GetProgramPath(progCur);
                checkForceDuplicates.Checked = PIn.Bool(ProgramProperties.GetPropValForClinicOrDefault(progCur.ProgramNum,
                                                                                                       ProgramProperties.PropertyDescs.XCharge.XChargeForceRecurringCharge, Clinics.ClinicNum));
                if (!File.Exists(xPath))                 //program path is invalid
                //if user has setup permission and they want to edit the program path, show the X-Charge setup window
                {
                    if (Security.IsAuthorized(Permissions.Setup) &&
                        MsgBox.Show(this, MsgBoxButtons.YesNo, "The X-Charge path is not valid.  Would you like to edit the path?"))
                    {
                        FormXchargeSetup FormX = new FormXchargeSetup();
                        FormX.ShowDialog();
                        if (FormX.DialogResult == DialogResult.OK)
                        {
                            //The user could have correctly enabled the X-Charge bridge, we need to update our local _programCur and _xPath variable2
                            progCur = Programs.GetCur(ProgramName.Xcharge);
                            xPath   = Programs.GetProgramPath(progCur);
                        }
                    }
                    //if the program path still does not exist, whether or not they attempted to edit the program link, tell them to edit and close the form
                    if (!File.Exists(xPath))
                    {
                        MsgBox.Show(this, "The X-Charge program path is not valid.  Edit the program link in order to use the CC Recurring Charges feature.");
                        Close();
                        return;
                    }
                }
            }
            if (progCur == null)
            {
                MsgBox.Show(this, "The PayConnect, PaySimple, or X-Charge program link must be enabled in order to use the CC Recurring Charges feature.");
                Close();
                return;
            }
            _isSelecting     = true;
            _listUserClinics = new List <Clinic>();
            if (PrefC.HasClinicsEnabled)
            {
                if (!Security.CurUser.ClinicIsRestricted)
                {
                    _listUserClinics.Add(new Clinic()
                    {
                        Description = Lan.g(this, "Unassigned")
                    });
                }
                Clinics.GetForUserod(Security.CurUser).ForEach(x => _listUserClinics.Add(x));
                for (int i = 0; i < _listUserClinics.Count; i++)
                {
                    listClinics.Items.Add(_listUserClinics[i].Description);
                    listClinics.SetSelected(i, true);
                }
                //checkAllClin.Checked=true;//checked true by default in designer so we don't trigger the event to select all and fill grid
            }
            else
            {
                groupClinics.Visible = false;
            }
            _charger = new RecurringChargerator(new ShowErrors(this), true);
            _charger.SingleCardFinished = new Action(() => {
                this.Invoke(() => {
                    labelCharged.Text = Lans.g(this, "Charged=") + _charger.Success;
                    labelFailed.Text  = Lans.g(this, "Failed=") + _charger.Failed;
                    labelUpdated.Text = Lans.g(this, "Updated=") + _charger.Updated;
                });
            });
            GeneralProgramEvent.Fired += StopRecurringCharges;          //This is so we'll be alerted in case of a shutdown.
            labelCharged.Text          = Lan.g(this, "Charged=") + "0";
            labelFailed.Text           = Lan.g(this, "Failed=") + "0";
            FillGrid(true);
            gridMain.SetSelected(true);
            labelSelected.Text = Lan.g(this, "Selected=") + gridMain.SelectedIndices.Length.ToString();
        }
Ejemplo n.º 3
0
 private void FormPayConnect_Load(object sender, EventArgs e)
 {
     _progCur = Programs.GetCur(ProgramName.PayConnect);
     if (_progCur == null)
     {
         MsgBox.Show(this, "PayConnect does not exist in the database.");
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, "TerminalProcessingEnabled", _clinicNum)))
     {
         try {
             //If the config file for the DentalXChange credit card processing .dll doesn't exist, construct it from the included resource.
             if (!File.Exists("DpsPos.dll.config"))
             {
                 File.WriteAllText("DpsPos.dll.config", Properties.Resources.DpsPos_dll_config);
             }
         }
         catch (Exception ex) {
             FriendlyException.Show("Unable to create the config file for the terminal. Trying running the program as an administrator.", ex);
             //We will still allow them to run the transaction. Probably the worse that will happen is the timeout variable will be less than desired.
         }
     }
     if (!PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, "TerminalProcessingEnabled", _clinicNum)) ||
         _isAddingCard)                    //When adding a card, the web service must be used.
     {
         groupProcessMethod.Visible = false;
         Height -= 55;              //All the controls except for the Transaction Type group box should be anchored to the bottom, so they will move themselves up.
     }
     else
     {
         string procMethod = ProgramProperties.GetPropValForClinicOrDefault(_progCur.ProgramNum,
                                                                            PayConnect.ProgramProperties.DefaultProcessingMethod, _clinicNum);
         if (procMethod == "0")
         {
             radioWebService.Checked = true;
         }
         else if (procMethod == "1")
         {
             radioTerminal.Checked = true;
         }
     }
     textAmount.Text = POut.Decimal(_amountInit);
     if (_patCur == null)           //Prepaid card
     {
         radioAuthorization.Enabled = false;
         radioVoid.Enabled          = false;
         radioReturn.Enabled        = false;
         textZipCode.ReadOnly       = true;
         textNameOnCard.ReadOnly    = true;
         checkSaveToken.Enabled     = false;
         sigBoxWrapper.Enabled      = false;
     }
     else              //Other cards
     {
         textZipCode.Text       = _patCur.Zip;
         textNameOnCard.Text    = _patCur.GetNameFL();
         checkSaveToken.Checked = PrefC.GetBool(PrefName.StoreCCtokens);
         if (PrefC.GetBool(PrefName.StoreCCnumbers))
         {
             labelStoreCCNumWarning.Visible = true;
         }
         FillFieldsFromCard();
     }
     if (_isAddingCard)             //We will run a 0.01 authorization so we will not allow the user to change the transaction type or the amount.
     {
         radioAuthorization.Checked = true;
         _trantype = PayConnectService.transType.AUTH;
         groupTransType.Enabled      = false;
         labelAmount.Visible         = false;
         textAmount.Visible          = false;
         checkSaveToken.Checked      = true;
         checkSaveToken.Enabled      = false;
         checkForceDuplicate.Checked = true;
         checkForceDuplicate.Enabled = false;
     }
     if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, _clinicNum)))
     {
         textCardNumber.ReadOnly = true;
     }
 }
Ejemplo n.º 4
0
        private bool VerifyData(out int expYear, out int expMonth)
        {
            expYear  = 0;
            expMonth = 0;
            if (_trantype == PaySimple.TransType.SALE && !Regex.IsMatch(textAmount.Text, "^[0-9]+$") && !Regex.IsMatch(textAmount.Text, "^[0-9]*\\.[0-9]+$"))
            {
                MsgBox.Show(this, "Invalid amount.");
                return(false);
            }
            if ((_trantype == PaySimple.TransType.VOID || _trantype == PaySimple.TransType.RETURN) &&    //The reference number is optional for terminal returns.
                textRefNumber.Text == "")
            {
                MsgBox.Show(this, "Ref Number required.");
                return(false);
            }
            string paytype = ProgramProperties.GetPropValForClinicOrDefault(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimplePayTypeCC, _clinicNum);

            if (!Defs.GetDefsForCategory(DefCat.PaymentTypes, true).Any(x => x.DefNum.ToString() == paytype))           //paytype is not a valid DefNum
            {
                MsgBox.Show(this, "The PaySimple payment type has not been set.");
                return(false);
            }
            //Processing through Web Service
            // Consider adding more advanced verification methods using PaySimple validation requests.
            if (textCardNumber.Text.Trim().Length < 5)
            {
                MsgBox.Show(this, "Invalid Card Number.");
                return(false);
            }
            try {                                                         //PIn.Int will throw an exception if not a valid format
                if (Regex.IsMatch(textExpDate.Text, @"^\d\d[/\- ]\d\d$")) //08/07 or 08-07 or 08 07
                {
                    expYear  = PIn.Int("20" + textExpDate.Text.Substring(3, 2));
                    expMonth = PIn.Int(textExpDate.Text.Substring(0, 2));
                }
                else if (Regex.IsMatch(textExpDate.Text, @"^\d{4}$"))                //0807
                {
                    expYear  = PIn.Int("20" + textExpDate.Text.Substring(2, 2));
                    expMonth = PIn.Int(textExpDate.Text.Substring(0, 2));
                }
                else
                {
                    MsgBox.Show(this, "Expiration format invalid.");
                    return(false);
                }
            }
            catch (Exception) {
                MsgBox.Show(this, "Expiration format invalid.");
                return(false);
            }
            if (_creditCardCur == null)           //if the user selected a new CC, verify through PaySimple
            //using a new CC and the card number entered contains something other than digits
            {
                if (textCardNumber.Text.Any(x => !char.IsDigit(x)))
                {
                    MsgBox.Show(this, "Invalid card number.");
                    return(false);
                }
            }
            else if (_creditCardCur.PaySimpleToken == "" && Regex.IsMatch(textCardNumber.Text, @"X+[0-9]{4}"))          //using a stored CC
            {
                MsgBox.Show(this, "There is no saved PaySimple token for this credit card.  The card number and expiration must be re-entered.");
                return(false);
            }
            if (textNameOnCard.Text.Trim() == "" && _patCur != null && _patCur.PatNum > 0)       //Name required for patient credit cards, not prepaid cards.
            {
                MsgBox.Show(this, "Name On Card required.");
                return(false);
            }
            return(IsPaySimpleSetup());
        }