private void butPayments_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; string programNum = ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.Xcharge).ProgramNum, "PaymentType"); ReportSimpleGrid report = new ReportSimpleGrid(); report.Query = "SET @pos=0; " + "SELECT @pos:=@pos+1 as 'Count', patient.PatNum, LName, FName, DateEntry,PayDate, PayNote,PayAmt " + "FROM patient INNER JOIN payment ON payment.PatNum=patient.PatNum " + "WHERE PayType=" + programNum + " AND DateEntry BETWEEN " + POut.Date(date1.SelectionStart) + " AND " + POut.Date(date2.SelectionStart) + "ORDER BY PayDate ASC, patient.LName"; FormQuery FormQuery2 = new FormQuery(report); FormQuery2.IsReport = true; FormQuery2.SubmitReportQuery(); report.Title = "Payments From " + date1.SelectionStart.ToShortDateString() + " To " + date2.SelectionStart.ToShortDateString(); report.SubTitle.Add(PrefC.GetString(PrefName.PracticeTitle)); report.SetColumn(this, 0, "Count", 50); report.SetColumn(this, 1, "PatNum", 50); report.SetColumn(this, 2, "LName", 100); report.SetColumn(this, 3, "FName", 100); report.SetColumn(this, 4, "DateEntry", 100); report.SetColumn(this, 5, "PayDate", 100); report.SetColumn(this, 6, "PayNote", 150); report.SetColumn(this, 7, "PayAmt", 70, HorizontalAlignment.Right); Cursor = Cursors.Default; FormQuery2.ShowDialog(); }
private void FormXchargeTrans_Load(object sender, EventArgs e) { CashBackAmount = 0; textCashBackAmt.Text = CashBackAmount.ToString("F2"); listTransType.Items.Clear(); listTransType.Items.Add("Purchase"); listTransType.Items.Add("Return"); listTransType.Items.Add("Debit Purchase"); listTransType.Items.Add("Debit Return"); listTransType.Items.Add("Force"); listTransType.Items.Add("Pre-Authorization"); listTransType.Items.Add("Adjustment"); listTransType.Items.Add("Void"); listTransType.SelectedIndex = 0; checkSaveToken.Checked = PrefC.GetBool(PrefName.StoreCCtokens); Program prog = Programs.GetCur(ProgramName.Xcharge); if (prog == null) { return; } checkSignature.Checked = PromptSignature; checkPrintReceipt.Checked = PrintReceipt; if (PIn.Bool(ProgramProperties.GetPropVal(prog.ProgramNum, ProgramProperties.PropertyDescs.XCharge.XChargePreventSavingNewCC, ClinicNum))) { checkSaveToken.Checked = false; checkSaveToken.Enabled = false; } }
private void RefreshModuleScreen() { if (PatCur == null) { return; } if (PIn.Bool(ProgramProperties.GetPropVal(ProgramName.eClinicalWorks, "FeeSchedulesSetManually"))) { comboFeeSched.Enabled = true; } else { comboFeeSched.Enabled = false; } comboFeeSched.Items.Clear(); comboFeeSched.Items.Add(Lan.g(this, "none")); comboFeeSched.SelectedIndex = 0; for (int i = 0; i < FeeSchedC.ListShort.Count; i++) { comboFeeSched.Items.Add(FeeSchedC.ListShort[i].Description); if (FeeSchedC.ListShort[i].FeeSchedNum == PatCur.FeeSched) { comboFeeSched.SelectedIndex = i + 1; } } }
///<summary>Sends text message to callfire. If patNum=0 will not create commlog entry.</summary> private bool SendCallFire(long patNum, string wirelessPhone, string message) { string key = ProgramProperties.GetPropVal(ProgramName.CallFire, "Key From CallFire"); string msg = wirelessPhone + "," + message.Replace(",", ""); //ph#,msg Commas in msg cause error. try { CallFireService.SMSService callFire = new CallFireService.SMSService(); callFire.sendSMSCampaign( key, new string[] { msg }, "Open Dental"); } catch (Exception ex) { MsgBox.Show(this, "Error sending text message.\r\n\r\n" + ex.Message); return(false); } if (patNum == 0) //No patient selected, do not make commlog. { return(true); } Commlog commlog = new Commlog(); commlog.CommDateTime = DateTime.Now; commlog.DateTStamp = DateTime.Now; commlog.CommType = Commlogs.GetTypeAuto(CommItemTypeAuto.TEXT); commlog.Mode_ = CommItemMode.Text; commlog.Note = msg;//phone,note commlog.PatNum = patNum; commlog.SentOrReceived = CommSentOrReceived.Sent; commlog.UserNum = Security.CurUser.UserNum; commlog.DateTimeEnd = DateTime.Now; Commlogs.Insert(commlog); SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Insert Text Message"); return(true); }
private void butExtra_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; string programNum = ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.Xcharge).ProgramNum, "PaymentType"); ReportSimpleGrid report = new ReportSimpleGrid(); report.Query = "SELECT payment.PatNum, LName, FName, payment.DateEntry,payment.PayDate, payment.PayNote,payment.PayAmt " + "FROM patient INNER JOIN payment ON payment.PatNum=patient.PatNum " + "LEFT JOIN (SELECT TransactionDateTime,ClerkID,BatchNum,ItemNum,PatNum,CCType,CreditCardNum,Expiration,Result,Amount FROM xchargetransaction " + "WHERE DATE(TransactionDateTime) BETWEEN " + POut.Date(date1.SelectionStart) + " AND " + POut.Date(date2.SelectionStart) + @") AS X " + "ON X.PatNum=payment.PatNum AND DATE(X.TransactionDateTime)=payment.DateEntry AND X.Amount=payment.PayAmt " + "WHERE PayType=" + programNum + " AND DateEntry BETWEEN " + POut.Date(date1.SelectionStart) + " AND " + POut.Date(date2.SelectionStart) + " " + "AND X.TransactionDateTime IS NULL " + "ORDER BY PayDate ASC, patient.LName"; FormQuery FormQuery2 = new FormQuery(report); FormQuery2.IsReport = true; FormQuery2.SubmitReportQuery(); report.Title = "Payments From " + date1.SelectionStart.ToShortDateString() + " To " + date2.SelectionStart.ToShortDateString(); report.SubTitle.Add("No Matching X-Charge Transactions for these Payments"); report.SetColumn(this, 0, "PatNum", 50); report.SetColumn(this, 1, "LName", 100); report.SetColumn(this, 2, "FName", 100); report.SetColumn(this, 3, "DateEntry", 100); report.SetColumn(this, 4, "PayDate", 100); report.SetColumn(this, 5, "PayNote", 150); report.SetColumn(this, 6, "PayAmt", 70, HorizontalAlignment.Right); Cursor = Cursors.Default; FormQuery2.ShowDialog(); }
private void butMissing_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; string programNum = ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.Xcharge).ProgramNum, "PaymentType"); ReportSimpleGrid report = new ReportSimpleGrid(); report.Query = "SELECT TransactionDateTime,ClerkID,BatchNum,ItemNum,xchargetransaction.PatNum,CCType,CreditCardNum,Expiration,Result,Amount " + " FROM xchargetransaction LEFT JOIN (" + " SELECT patient.PatNum,LName,FName,DateEntry,PayDate,PayAmt,PayNote" + " FROM patient INNER JOIN payment ON payment.PatNum=patient.PatNum" + " WHERE PayType=" + programNum + " AND DateEntry BETWEEN " + POut.Date(date1.SelectionStart) + " AND " + POut.Date(date2.SelectionStart) + " ) AS P ON xchargetransaction.PatNum=P.PatNum AND DATE(xchargetransaction.TransactionDateTime)=P.DateEntry AND xchargetransaction.Amount=P.PayAmt " + " WHERE DATE(TransactionDateTime) BETWEEN " + POut.Date(date1.SelectionStart) + " AND " + POut.Date(date2.SelectionStart) + " AND P.PatNum IS NULL;"; FormQuery FormQuery2 = new FormQuery(report); FormQuery2.IsReport = true; FormQuery2.SubmitReportQuery(); report.Title = "XCharge Transactions From " + date1.SelectionStart.ToShortDateString() + " To " + date2.SelectionStart.ToShortDateString(); report.SubTitle.Add("No Matching Transaction Found in Open Dental"); report.SetColumn(this, 0, "Transaction Date/Time", 170); report.SetColumn(this, 1, "Clerk ID", 80); report.SetColumn(this, 2, "Batch#", 50); report.SetColumn(this, 3, "Item#", 50); report.SetColumn(this, 4, "PatNum", 50); report.SetColumn(this, 5, "CC Type", 55); report.SetColumn(this, 6, "Credit Card Num", 140); report.SetColumn(this, 7, "Exp", 50); report.SetColumn(this, 8, "Result", 50); report.SetColumn(this, 9, "Amount", 60, HorizontalAlignment.Right); Cursor = Cursors.Default; FormQuery2.ShowDialog(); }
public FormEcwDiag() { InitializeComponent(); server = ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "eCWServer"); port = ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "eCWPort"); buildConnectionString(); Lan.F(this); }
public FormEcwDiag() { InitializeComponent(); server = ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "eCWServer"); //this property will not exist if using Oracle, eCW will never use Oracle port = ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "eCWPort"); //this property will not exist if using Oracle, eCW will never use Oracle buildConnectionString(); Lan.F(this); }
private void FormPaySimple_Load(object sender, EventArgs e) { _progCur = Programs.GetCur(ProgramName.PaySimple); if (_progCur == null) { MsgBox.Show(this, "PaySimple does not exist in the database."); DialogResult = DialogResult.Cancel; return; } if (_patCur == null || _patCur.PatNum == 0) //Prepaid card { radioAuthorization.Enabled = false; checkOneTimePayment.Checked = true; checkOneTimePayment.Enabled = false; tabControl.TabPages.Remove(tabACH); } else { checkOneTimePayment.Checked = !PrefC.GetBool(PrefName.StoreCCtokens); checkOneTimePaymentACH.Checked = !PrefC.GetBool(PrefName.StoreCCtokens); textZipCode.Text = _patCur.Zip; textNameOnCard.Text = _patCur.GetNameFL(); if (_creditCardCur != null) { FillFieldsFromCard(); } } if (_isAddingCard) { radioAuthorization.Checked = true; _trantype = PaySimple.TransType.AUTH; groupTransType.Enabled = false; labelAmount.Visible = false; textAmount.Visible = false; labelAmountACH.Visible = false; textAmountACH.Visible = false; checkOneTimePayment.Checked = false; checkOneTimePayment.Enabled = false; checkOneTimePaymentACH.Checked = false; checkOneTimePaymentACH.Enabled = false; } if (_creditCardCur == null || _creditCardCur.CCSource != CreditCardSource.PaySimpleACH) { textCardNumber.Select(); } else { tabControl.SelectedTab = tabACH; textRoutingNumber.Select(); } if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimplePreventSavingNewCC, _clinicNum))) { textCardNumber.ReadOnly = true; textRoutingNumber.ReadOnly = true; textCheckSaveNumber.ReadOnly = true; textBankName.ReadOnly = true; } }
private void FormEcwDiagAdv_Load(object sender, EventArgs e) { fillQueryList(); server = ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "eCWServer"); //this property will not exist if using Oracle, eCW will never use Oracle port = ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "eCWPort"); //this property will not exist if using Oracle, eCW will never use Oracle buildConnectionString(); dummyConnString = "Server=" + server + ";" + "Port=" + port + ";" //although this does seem to cause a bug in Mono. We will revisit this bug if needed to exclude the port option only for Mono. + "Database=;" //ecwMaster;" //+"Connect Timeout=20;" + "User ID=" + username + ";" + "Password=;" //no password information. + "SslMode=none;" + "CharSet=utf8;" + "Treat Tiny As Boolean=false;" + "Allow User Variables=true;" + "Default Command Timeout=300;" //default is 30seconds + "Pooling=false" ; textConnString.Text = "Server=" + server + ";" + "Port=" + port + ";" //although this does seem to cause a bug in Mono. We will revisit this bug if needed to exclude the port option only for Mono. + "Database=;" //ecwMaster;" //+"Connect Timeout=20;" + "User ID=" + username + ";" + "Password=;" //no password information + "SslMode=none;" + "CharSet=utf8;" + "Treat Tiny As Boolean=false;" + "Allow User Variables=true;" + "Default Command Timeout=300;" //default is 30seconds + "Pooling=false" ;; //textQuery.Text="SHOW VARIABLES;"; //Show some relevent variables textQuery.Text = "SHOW VARIABLES " + "WHERE Variable_name IN " + "('basedir'," + " 'connect_timout'," + " 'datadir'," + " 'default_storage_engine'," + " 'general_log'," + " 'general_log_file'," + " 'hostname'," + " 'log_error'," + " 'pid_file'," + " 'port'," + " 'storage_engine'," + " 'tmpdir'," + " 'version'," + " 'version_compile_machine'," + " 'version_compile_os'" + ");"; RunQuery(); FillTables(); }
/// <summary>May be called from other parts of the program without showing this form. You must still create an instance of this form though. Checks CallFire bridge, if it is OK to send a text, etc. (Buttons to load this form are usually disabled if it is not OK, but this is needed for Confirmations, Recalls, etc.) </summary> public void SendText(long patNum, string wirelessPhone, string message, YN txtMsgOk) { if (Plugins.HookMethod(this, "FormTxtMsgEdit.SendText_Start", patNum, wirelessPhone, message, txtMsgOk)) { return; } if (wirelessPhone == "") { MsgBox.Show(this, "Please enter a phone number."); return; } if (!Programs.IsEnabled(ProgramName.CallFire)) { MsgBox.Show(this, "CallFire Program Link must be enabled."); return; } if (txtMsgOk == YN.Unknown && PrefC.GetBool(PrefName.TextMsgOkStatusTreatAsNo)) { MsgBox.Show(this, "It is not OK to text this patient."); return; } if (txtMsgOk == YN.No) { MsgBox.Show(this, "It is not OK to text this patient."); return; } string key = ProgramProperties.GetPropVal(ProgramName.CallFire, "Key From CallFire"); string msg = wirelessPhone + "," + message.Replace(",", ""); //ph#,msg Commas in msg cause error. try { CallFireService.SMSService callFire = new CallFireService.SMSService(); callFire.sendSMSCampaign( key, new string[] { msg }, "Open Dental"); } catch (Exception ex) { MsgBox.Show(this, "Error sending text message.\r\n\r\n" + ex.Message); return; } Commlog commlog = new Commlog(); commlog.CommDateTime = DateTime.Now; commlog.DateTStamp = DateTime.Now; commlog.CommType = DefC.Short[(int)DefCat.CommLogTypes][0].DefNum; //The first one in the list. We can enhance later. commlog.Mode_ = CommItemMode.Text; commlog.Note = msg; //phone,note commlog.PatNum = patNum; commlog.SentOrReceived = CommSentOrReceived.Sent; commlog.UserNum = Security.CurUser.UserNum; commlog.DateTimeEnd = DateTime.Now; Commlogs.Insert(commlog); SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Insert Text Message"); }
private void FormXchargeTokenTool_Load(object sender, EventArgs e) { Program prog = Programs.GetCur(ProgramName.Xcharge); if (prog == null || !prog.Enabled) { MsgBox.Show(this, "X-Charge program link is not set up."); DialogResult = DialogResult.Cancel; return; } string path = Programs.GetProgramPath(prog); if (!File.Exists(path)) { MsgBox.Show(this, "X-Charge path is not valid."); DialogResult = DialogResult.Cancel; return; } //In order for X-Charge to be enabled, the enabled flag must be set and there must be a valid Username, Password, and PaymentType //If clinics are enabled, the Username, Password, and PaymentType fields are allowed to be blank/invalid for any clinic not using X-Charge //Therefore, we will validate the credentials and payment type using FormOpenDental.ClinicNum string paymentType = ProgramProperties.GetPropVal(prog.ProgramNum, "PaymentType", Clinics.ClinicNum); List <Def> _listPayTypeDefs = Defs.GetDefsForCategory(DefCat.PaymentTypes, true).FindAll(x => x.DefNum.ToString() == paymentType); //should be a list of 0 or 1 _xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum); _xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum); if (string.IsNullOrEmpty(_xUsername) || string.IsNullOrEmpty(_xPassword) || _listPayTypeDefs.Count < 1) { MsgBox.Show(this, "X-Charge username, password, or payment type for this clinic is invalid."); DialogResult = DialogResult.Cancel; return; } _listCreditCards = CreditCards.GetCardsWithTokenBySource( new List <CreditCardSource> { CreditCardSource.XServer, CreditCardSource.XServerPayConnect }); textTotal.Text = _listCreditCards.Count.ToString(); textVerified.Text = "0"; textInvalid.Text = "0"; if (_listCreditCards.Count == 0) { MsgBox.Show(this, "There are no credit cards with stored X-Charge tokens in the database."); return; } }
private void FormFHIRSetup_Load(object sender, EventArgs e) { Program prog = Programs.GetCur(ProgramName.FHIR); checkEnabled.Checked = prog.Enabled; textSubInterval.Text = ProgramProperties.GetPropVal(prog.ProgramNum, "SubscriptionProcessingFrequency"); Cursor = Cursors.WaitCursor; _listApiKeysHQ = GetApiKeys(); Cursor = Cursors.Default; if (_listApiKeysHQ == null) { DialogResult = DialogResult.Cancel; //We have already shown them an error message. return; } _listApiKeysLocal = _listApiKeysHQ.Select(x => x.Copy()).ToList(); FillGrid(); FillPermissions(); }
private void FormTrojanCollectSetup_Load(object sender, EventArgs e) { if (ODBuild.IsWeb()) { MsgBox.Show(this, "This program is not available in web mode."); Close(); return; } _progCur = Programs.GetCur(ProgramName.TrojanExpressCollect); textExportFolder.Text = ProgramProperties.GetPropVal(_progCur.ProgramNum, "FolderPath"); long billtype = PIn.Long(ProgramProperties.GetPropVal(_progCur.ProgramNum, "BillingType")); _listBillingTypeDefs = Defs.GetDefsForCategory(DefCat.BillingTypes, true); comboBillType.Items.AddRange(_listBillingTypeDefs.Select(x => x.ItemName).ToArray()); comboBillType.SelectedIndex = Math.Max(_listBillingTypeDefs.FindIndex(x => x.DefNum == billtype), 0); textPassword.Text = ProgramProperties.GetPropVal(_progCur.ProgramNum, "Password"); checkEnabled.Checked = _progCur.Enabled; }
///<summary>Fill the rest of the UI with the current bridge settings.</summary> private void FillSettings() { //Set Enabled checkEnabled.Checked = Programs.IsEnabled(ProgramName.AvaTax); //Set radio buttons if (AvaTax.IsProduction) { radioProdEnv.Checked = true; } else { radioTestEnv.Checked = true; } //Set username and password textUsername.Text = ProgramProperties.GetPropVal(ProgramName.AvaTax, ProgramProperties.PropertyDescs.Username); textPassword.Text = ProgramProperties.GetPropVal(ProgramName.AvaTax, ProgramProperties.PropertyDescs.Password); //Fill Log Level options listBoxLogLevel.Items.Clear(); foreach (LogLevel lv in Enum.GetValues(typeof(LogLevel))) { ODBoxItem <LogLevel> currentItem = new ODBoxItem <LogLevel>(lv.ToString(), lv); listBoxLogLevel.Items.Add(currentItem); if (currentItem.Tag == AvaTax.LogDetailLevel) { listBoxLogLevel.SelectedItem = currentItem; } } //Set company code and sales tax def textCompanyCode.Text = AvaTax.CompanyCode; _defCurrentSalesTaxAdjType = Defs.GetDef(DefCat.AdjTypes, AvaTax.SalesTaxAdjType); textAdjType.Text = _defCurrentSalesTaxAdjType.ItemName; _defCurrentSalesTaxReturnAdjType = Defs.GetDef(DefCat.AdjTypes, AvaTax.SalesTaxReturnAdjType) ?? new Def(); textReturnAdjType.Text = _defCurrentSalesTaxReturnAdjType.ItemName; _patFieldDefCurrentTaxExempt = AvaTax.TaxExemptPatField; textTaxExempt.Text = (_patFieldDefCurrentTaxExempt != null) ? _patFieldDefCurrentTaxExempt.FieldName : ""; validTaxLockDate.Text = AvaTax.TaxLockDate.ToShortDateString(); //Set list of procCodes textPrePayCodes.Text = ProgramProperties.GetPropVal(ProgramName.AvaTax, "Prepay Proc Codes"); textDiscountCodes.Text = ProgramProperties.GetPropVal(ProgramName.AvaTax, "Discount Proc Codes"); //Set the list of overrides textOverrides.Text = ProgramProperties.GetPropVal(ProgramName.AvaTax, "Tax Code Overrides"); }
private void radioWebService_CheckedChanged(object sender, EventArgs e) { radioTerminal.Checked = !radioWebService.Checked; if (!radioWebService.Checked) { return; } foreach (TextBox textBox in Controls.OfType <TextBox>()) { textBox.ReadOnly = false; } radioForce.Enabled = true; checkSaveToken.Enabled = true; checkForceDuplicate.Enabled = true; FillFieldsFromCard(); textNameOnCard.Text = _patCur.GetNameFL(); if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, _clinicNum))) { textCardNumber.ReadOnly = true; } }
private void FormXchargeSetup_Load(object sender, EventArgs e) { prog = Programs.GetCur(ProgramName.Xcharge); if (prog == null) { return; } checkEnabled.Checked = prog.Enabled; textPath.Text = prog.Path; textUser.Text = ProgramProperties.GetPropVal(prog.ProgramNum, "Username"); textPassword.Text = ProgramProperties.GetPropVal(prog.ProgramNum, "Password"); string paymentType = ProgramProperties.GetPropVal(prog.ProgramNum, "PaymentType"); for (int i = 0; i < DefC.Short[(int)DefCat.PaymentTypes].Length; i++) { comboPaymentType.Items.Add(DefC.Short[(int)DefCat.PaymentTypes][i].ItemName); if (DefC.Short[(int)DefCat.PaymentTypes][i].DefNum.ToString() == paymentType) { comboPaymentType.SelectedIndex = i; } } }
private void FormFHIRSetup_Load(object sender, EventArgs e) { Program prog = Programs.GetCur(ProgramName.FHIR); checkEnabled.Checked = prog.Enabled; textSubInterval.Text = ProgramProperties.GetPropVal(prog.ProgramNum, "SubscriptionProcessingFrequency"); comboPayType.Items.AddDefs(Defs.GetDefsForCategory(DefCat.PaymentTypes, true)); comboPayType.SetSelectedDefNum(PrefC.GetLong(PrefName.ApiPaymentType)); //Let the load finish before we call HQ this.BeginInvoke(() => { Cursor = Cursors.WaitCursor; Application.DoEvents(); _listApiKeys = GetApiKeys(); Cursor = Cursors.Default; if (_listApiKeys == null) { DialogResult = DialogResult.Cancel; //We have already shown them an error message. return; } FillGrid(); }); }
private bool VerifyData(out int expYear, out int expMonth) { expYear = 0; expMonth = 0; if (ODBuild.IsWeb() && radioTerminal.Checked) { MsgBox.Show(this, "Terminal payments are not available while viewing through the web."); return(false); } if (!Regex.IsMatch(textAmount.Text, "^[0-9]+$") && !Regex.IsMatch(textAmount.Text, "^[0-9]*\\.[0-9]+$")) { MsgBox.Show(this, "Invalid amount."); return(false); } if ((_trantype == PayConnectService.transType.VOID || (_trantype == PayConnectService.transType.RETURN && radioWebService.Checked)) && //The reference number is optional for terminal returns. textRefNumber.Text == "") { MsgBox.Show(this, "Ref Number required."); return(false); } string paytype = ProgramProperties.GetPropVal(_progCur.ProgramNum, "PaymentType", _clinicNum); if (!Defs.GetDefsForCategory(DefCat.PaymentTypes, true).Any(x => x.DefNum.ToString() == paytype)) //paytype is not a valid DefNum { MsgBox.Show(this, "The PayConnect payment type has not been set."); return(false); } if (radioTerminal.Checked) { return(true); } //Processing through Web Service // Consider adding more advanced verification methods using PayConnect 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 PayConnect //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); } if (!PayConnect.IsValidCardAndExp(textCardNumber.Text, expYear, expMonth, x => MessageBox.Show(x))) //if exception happens, a message box will show with the error { MsgBox.Show(this, "Card number or expiration date failed validation with PayConnect."); return(false); } } else if (_creditCardCur.PayConnectToken == "" && Regex.IsMatch(textCardNumber.Text, @"X+[0-9]{4}")) //using a stored CC { MsgBox.Show(this, "There is no saved PayConnect token for this credit card. The card number and expiration must be re-entered."); return(false); } if (textNameOnCard.Text.Trim() == "" && _patCur != null) //Name required for patient credit cards, not prepaid cards. { MsgBox.Show(this, "Name On Card required."); return(false); } if (_trantype == PayConnectService.transType.FORCE && textRefNumber.Text == "") { MsgBox.Show(this, "Authorization Code required."); return(false); } //verify the selected clinic has a username and password type entered if (ProgramProperties.GetPropVal(_progCur.ProgramNum, "Username", _clinicNum) == "" || ProgramProperties.GetPropVal(_progCur.ProgramNum, "Password", _clinicNum) == "") //if username or password is blank { MsgBox.Show(this, "The PayConnect username and/or password has not been set."); return(false); } return(true); }
///<summary>Processes a PaySimple ACH payment via the PaySimple API.</summary> private PaySimple.ApiResponse ProcessPaymentACH() { PaySimple.ApiResponse retVal = null; string accountNumber = textCheckSaveNumber.Text; //if the user has chosen to store CC tokens and the stored CC has a token and the token is not expired, //then use it instead of the CC number and CC expiration. if (!checkOneTimePaymentACH.Checked && _creditCardCur != null && //if the user selected a saved CC !string.IsNullOrWhiteSpace(_creditCardCur.PaySimpleToken) && //there is a stored token for this card _creditCardCur.CCSource == CreditCardSource.PaySimpleACH) { accountNumber = _creditCardCur.PaySimpleToken; } else if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimplePreventSavingNewCC, _clinicNum))) { MsgBox.Show(this, "Cannot add a new ACH payment."); return(null); } try { if (_isAddingCard) { retVal = PaySimple.AddACHAccount(_patCur, textRoutingNumber.Text, textCheckSaveNumber.Text, textBankName.Text, radioCheckings.Checked, _clinicNum); } else { retVal = PaySimple.MakePaymentACH(_patCur, _creditCardCur, PIn.Decimal(textAmountACH.Text), textRoutingNumber.Text, textCheckSaveNumber.Text, textBankName.Text, radioCheckings.Checked, checkOneTimePaymentACH.Checked, _clinicNum); try { string result = WebServiceMainHQProxy.GetWebServiceMainHQInstance() .InsertPaySimpleACHId(PayloadHelper.CreatePayload( PayloadHelper.CreatePayloadContent(retVal.RefNumber.ToString(), "PaymentId"), eServiceCode.PaySimple)); PayloadHelper.CheckForError(result); } catch (Exception ex) { FriendlyException.Show("Unable to register for ACH Settled event", ex); } } } catch (PaySimpleException ex) { MessageBox.Show(ex.Message); if (ex.ErrorType == PaySimpleError.CustomerDoesNotExist && MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete the link to the customer id for this patient?")) { PatientLinks.DeletePatNumTos(ex.CustomerId, PatientLinkType.PaySimple); } return(null); } catch (ODException ex) { MessageBox.Show(ex.Message); //This should have already been Lans.g if applicable. return(null); } catch (Exception ex) { FriendlyException.Show(Lan.g(this, "Error:") + " " + ex.Message, ex); return(null); } if (!_isAddingCard) { retVal.BuildReceiptString(accountNumber, -1, -1, _patCur?.GetNameFL(), _clinicNum, wasSwiped: false, isACH: true); PrintReceipt(retVal.TransactionReceipt); } if (checkOneTimePaymentACH.Checked) //not storing the account token { return(retVal); } UpsertCreditCard(retVal, textCheckSaveNumber.Text.Right(4).PadLeft(textCheckSaveNumber.Text.Length, '*'), CreditCardSource.PaySimpleACH, DateTime.MinValue); return(retVal); }
///<summary>Processes a PaySimple payment via the PaySimple API.</summary> private PaySimple.ApiResponse ProcessPayment(int expYear, int expMonth) { PaySimple.ApiResponse retVal = null; string refNumber = ""; if (_trantype == PaySimple.TransType.VOID || _trantype == PaySimple.TransType.RETURN) { refNumber = textRefNumber.Text; } string magData = null; if (_parser != null) { magData = _parser.Track2; } string cardNumber = textCardNumber.Text; //if using a stored CC and there is an X-Charge token saved for the CC and the user enters the whole card number to get a PaySimple token //and the number entered doesn't have the same last 4 digits and exp date, then assume it's not the same card and clear out the X-Charge token. if (_creditCardCur != null && //using a saved CC !string.IsNullOrEmpty(_creditCardCur.XChargeToken) && //there is an X-Charge token saved (cardNumber.Right(4) != _creditCardCur.CCNumberMasked.Right(4) || //the card number entered doesn't have the same last 4 digits expYear != _creditCardCur.CCExpiration.Year || //the card exp date entered doesn't have the same year expMonth != _creditCardCur.CCExpiration.Month)) //the card exp date entered doesn't have the same month { if (MsgBox.Show(this, MsgBoxButtons.YesNo, "The card number or expiration date entered does not match the X-Charge card on file. Do you wish " + "to replace the X-Charge card with this one?")) { _creditCardCur.XChargeToken = ""; } else { Cursor = Cursors.Default; return(null); } } //if the user has chosen to store CC tokens and the stored CC has a token and the token is not expired, //then use it instead of the CC number and CC expiration. if (!checkOneTimePayment.Checked && _creditCardCur != null && //if the user selected a saved CC !string.IsNullOrWhiteSpace(_creditCardCur.PaySimpleToken)) //there is a stored token for this card { cardNumber = _creditCardCur.PaySimpleToken; expYear = _creditCardCur.CCExpiration.Year; expMonth = _creditCardCur.CCExpiration.Month; } else if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimplePreventSavingNewCC, _clinicNum))) { MsgBox.Show(this, "Cannot add a new credit card."); return(null); } try { switch (_trantype) { case PaySimple.TransType.SALE: //If _patCur is null or the PatNum is 0, we will make a one time payment for an UNKNOWN patient. //This is currently only intended for prepaid insurance cards. retVal = PaySimple.MakePayment((_patCur == null ? 0 : _patCur.PatNum), _creditCardCur, PIn.Decimal(textAmount.Text), textCardNumber.Text , new DateTime(expYear, expMonth, 1), checkOneTimePayment.Checked, textZipCode.Text, textSecurityCode.Text, _clinicNum, _carrierName); break; case PaySimple.TransType.AUTH: //Will retreive a new customer id from PaySimple if the patient doesn't exist already. long paySimpleCustomerId = PaySimple.GetCustomerIdForPat(_patCur.PatNum, _patCur.FName, _patCur.LName, _clinicNum); //I have no idea if an insurance can make an auth payment but incase they can I check for it. if (paySimpleCustomerId == 0) //Insurance payment, make a new customer id every time per Nathan on 04/26/2018 { if ((_patCur == null || _patCur.PatNum == 0)) { paySimpleCustomerId = PaySimple.AddCustomer("UNKNOWN", "UNKNOWN", "", _clinicNum); } else { throw new ODException(Lan.g(this, "Invalid PaySimple Customer Id found.")); } } try { retVal = PaySimple.AddCreditCard(paySimpleCustomerId, textCardNumber.Text, new DateTime(expYear, expMonth, 1), textZipCode.Text, _clinicNum); } catch (PaySimpleException ex) { PaySimple.HandlePaySimpleException(ex, paySimpleCustomerId); } break; case PaySimple.TransType.RETURN: if (string.IsNullOrWhiteSpace(textRefNumber.Text)) { throw new ODException(Lan.g(this, "Invalid PaySimple Payment ID.")); } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "You are about to return a payment. This action is irreversible. Continue?")) { throw new ODException(Lan.g(this, "Payment return was cancelled by user.")); } retVal = PaySimple.ReversePayment(textRefNumber.Text, _clinicNum); break; case PaySimple.TransType.VOID: if (string.IsNullOrWhiteSpace(textRefNumber.Text)) { throw new ODException(Lan.g(this, "Invalid PaySimple Payment ID.")); } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "You are about to void a payment. This action is irreversible. Continue?")) { throw new ODException(Lan.g(this, "Payment void was cancelled by user.")); } retVal = PaySimple.VoidPayment(textRefNumber.Text, _clinicNum); break; default: throw new Exception("Invalid transmission type: " + _trantype.ToString()); } } catch (PaySimpleException ex) { MessageBox.Show(ex.Message); if (ex.ErrorType == PaySimpleError.CustomerDoesNotExist && MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete the link to the customer id for this patient?")) { PatientLinks.DeletePatNumTos(ex.CustomerId, PatientLinkType.PaySimple); } return(null); } catch (ODException wex) { MessageBox.Show(wex.Message); //This should have already been Lans.g if applicable. return(null); } catch (Exception ex) { MessageBox.Show(Lan.g(this, "Error:") + " " + ex.Message); return(null); } if (_trantype.In(PaySimple.TransType.SALE, PaySimple.TransType.RETURN, PaySimple.TransType.VOID)) //Only print a receipt if transaction is an approved SALE, RETURN, or VOID //The isSwiped boolean could be incorrectly set if the user swipes a card and then changes the data that was entered to a different card. { retVal.BuildReceiptString(cardNumber, expMonth, expYear, textNameOnCard.Text, _clinicNum, _parser != null); PrintReceipt(retVal.TransactionReceipt); } if (checkOneTimePayment.Checked) //not storing the card token { return(retVal); } UpsertCreditCard(retVal, textCardNumber.Text.Right(4).PadLeft(textCardNumber.Text.Length, 'X'), CreditCardSource.PaySimple, new DateTime(expYear, expMonth, DateTime.DaysInMonth(expYear, expMonth))); return(retVal); }
private void butOK_Click(object sender, EventArgs e) { if (!VerifyData()) { return; } CreditCardCur.ExcludeProcSync = checkExcludeProcSync.Checked; CreditCardCur.Address = textAddress.Text; CreditCardCur.CCNumberMasked = textCardNumber.Text; CreditCardCur.PatNum = PatCur.PatNum; CreditCardCur.Zip = textZip.Text; //Create an Audit Trail whenever CanChargeWhenNoBal changes if (checkChrgWithNoBal.Checked != CreditCardCur.CanChargeWhenNoBal) { SecurityLogs.MakeLogEntry(Permissions.AccountModule, PatCur.PatNum, "Credit Card " + CreditCardCur.CCNumberMasked + " set to " + (CreditCardCur.CanChargeWhenNoBal?"":"not ") + "run charges even when no patient balance is present."); } CreditCardCur.CanChargeWhenNoBal = checkChrgWithNoBal.Checked; if (_isXChargeEnabled || _isPayConnectEnabled || _isPaySimpleEnabled) //Only update recurring if using X-Charge, PayConnect,or PaySimple. { CreditCardCur.ChargeAmt = PIn.Double(textChargeAmt.Text); CreditCardCur.DateStart = PIn.Date(textDateStart.Text); CreditCardCur.DateStop = PIn.Date(textDateStop.Text); CreditCardCur.Note = textNote.Text; if (comboPaymentPlans.SelectedIndex > 0) { CreditCardCur.PayPlanNum = PayPlanList[comboPaymentPlans.SelectedIndex - 1].PayPlanNum; } else { CreditCardCur.PayPlanNum = 0; //Allows users to change from a recurring payplan charge to a normal one. } CreditCardCur.ChargeFrequency = GetFormattedChargeFrequency(); } if (CreditCardCur.IsNew) { List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum); CreditCardCur.ItemOrder = itemOrderCount.Count; CreditCardCur.CCSource = CreditCardSource.None; CreditCardCur.ClinicNum = Clinics.ClinicNum; CreditCards.Insert(CreditCardCur); } else { #region X-Charge //Special logic for had a token and changed number or expiration date X-Charge if (_isXChargeEnabled && CreditCardCur.XChargeToken != "" && (_creditCardOld.CCNumberMasked != CreditCardCur.CCNumberMasked || _creditCardOld.CCExpiration != CreditCardCur.CCExpiration)) { Program prog = Programs.GetCur(ProgramName.Xcharge); string path = Programs.GetProgramPath(prog); if (prog == null) { MsgBox.Show(this, "X-Charge entry is missing from the database."); //should never happen return; } if (!prog.Enabled) { if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); } return; } if (!File.Exists(path)) { MsgBox.Show(this, "Path is not valid."); if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); } return; } //Either update the exp date or update credit card number by deleting archive so new token can be created next time it's used. ProcessStartInfo info = new ProcessStartInfo(path); string resultfile = PrefC.GetRandomTempFile("txt"); try { File.Delete(resultfile); //delete the old result file. } catch { MsgBox.Show(this, "Could not delete XResult.txt file. It may be in use by another program, flagged as read-only, or you might not have sufficient permissions."); return; } string xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum); string xPassword = CodeBase.MiscUtils.Decrypt(ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum)); //We can only change exp date for X-Charge via ARCHIVEAULTUPDATE. info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTUPDATE "; info.Arguments += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " "; if (CreditCardCur.CCExpiration != null && CreditCardCur.CCExpiration.Year > 2005) { info.Arguments += "/EXP:" + CreditCardCur.CCExpiration.ToString("MMyy") + " "; } info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + xUsername + " "; info.Arguments += "/PASSWORD:"******" "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string resulttext = ""; string line = ""; try { using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("RESULT=")) { if (line != "RESULT=SUCCESS") { CreditCardCur = CreditCards.GetOne(CreditCardCur.CreditCardNum); FillData(); return; } } line = reader.ReadLine(); } } } catch { MsgBox.Show(this, "There was a problem creating or editing this card with X-Charge. Please try again."); return; } } //End of special token logic #endregion #region PayConnect //Special logic for had a token and changed expiration date PayConnect //We have to compare the year and month of the expiration instead of just comparing expirations because the X-Charge logic stores the //expiration day of the month as the 1st in the db, but it makes more sense to set the expriation day of month to the last day in that month. //Since we only want to invalidate the PayConnect token if the expiration month or year is different, we will ignore any difference in day. if (_isPayConnectEnabled && CreditCardCur.PayConnectToken != "" && (_creditCardOld.CCExpiration.Year != CreditCardCur.CCExpiration.Year || _creditCardOld.CCExpiration.Month != CreditCardCur.CCExpiration.Month)) { //if the expiration is changed, the token is no longer valid, so clear the token and token expiration so a new one can be //generated the next time a payment is processed using this card. CreditCardCur.PayConnectToken = ""; CreditCardCur.PayConnectTokenExp = DateTime.MinValue; //To match PaySimple, this should be enhanced to validate the cc number and get a new token. } #endregion #region PaySimple //Special logic for had a token and changed number or expiration date PaySimple //We have to compare the year and month of the expiration instead of just comparing expirations because the X-Charge logic stores the //expiration day of the month as the 1st in the db, but it makes more sense to set the expriation day of month to the last day in that month. //Since we only want to invalidate the PayConnect token if the expiration month or year is different, we will ignore any difference in day. if (_isPaySimpleEnabled && CreditCardCur.PaySimpleToken != "" && (_creditCardOld.Zip != CreditCardCur.Zip || _creditCardOld.CCExpiration.Year != CreditCardCur.CCExpiration.Year || _creditCardOld.CCExpiration.Month != CreditCardCur.CCExpiration.Month)) { //TODO: Open form to have user enter the CC number. Then make API call to update cc instead of wiping out token. //If the billing zip or the expiration changes, the token is invalid and they need to get a new one. CreditCardCur.PaySimpleToken = ""; } #endregion CreditCards.Update(CreditCardCur); } DialogResult = DialogResult.OK; }
private void DeleteXChargeAlias() { Program prog = Programs.GetCur(ProgramName.Xcharge); string path = Programs.GetProgramPath(prog); if (prog == null) { MsgBox.Show(this, "X-Charge entry is missing from the database."); //should never happen return; } if (!prog.Enabled) { if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); } return; } if (!File.Exists(path)) { MsgBox.Show(this, "Path is not valid."); if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); } return; } ProcessStartInfo info = new ProcessStartInfo(path); string resultfile = PrefC.GetRandomTempFile("txt"); try { File.Delete(resultfile); //delete the old result file. } catch { MsgBox.Show(this, "Could not delete XResult.txt file. It may be in use by another program, flagged as read-only, or you might not have " + "sufficient permissions."); return; } string xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum); string xPassword = CodeBase.MiscUtils.Decrypt(ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum)); info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTDELETE "; info.Arguments += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + xUsername + " "; info.Arguments += "/PASSWORD:"******" "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string line = ""; try { using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (line == "RESULT=SUCCESS") { break; } if (line.StartsWith("DESCRIPTION") && !line.Contains("Alias does not exist")) //If token doesn't exist in X-Charge, still delete from OD { MsgBox.Show(this, "There was a problem deleting this card within X-Charge. Please try again."); return; //Don't delete the card from OD } line = reader.ReadLine(); } } } catch { MsgBox.Show(this, "Could not read XResult.txt file. It may be in use by another program, flagged as read-only, or you might not have " + "sufficient permissions."); return; } }
private void FilterCardList() { int verified = 0; int invalid = 0; textVerified.Text = "0"; textInvalid.Text = "0"; for (int i = _listCreditCards.Count - 1; i >= 0; i--) //looping backwards to remove cards that are valid { Program prog = Programs.GetCur(ProgramName.Xcharge); string path = Programs.GetProgramPath(prog); ProcessStartInfo info = new ProcessStartInfo(path); string resultfile = PrefC.GetRandomTempFile("txt"); try { File.Delete(resultfile); //delete the old result file. } catch { MsgBox.Show(this, "Could not delete XResult.txt file. It may be in use by another program, flagged as read-only, or you might not have sufficient permissions."); break; } info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTQUERY "; info.Arguments += "/XCACCOUNTID:" + _listCreditCards[i].XChargeToken + " "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum) + " "; info.Arguments += "/PASSWORD:"******"Password", Clinics.ClinicNum)) + " "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/NORESULTDIALOG "; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. string resulttext = ""; string line = ""; string account = ""; string exp = ""; try { using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("ACCOUNT=")) { account = line.Substring(8); } else if (line.StartsWith("EXPIRATION=")) { exp = line.Substring(11); } line = reader.ReadLine(); } if (_listCreditCards[i].CCNumberMasked.Length > 4 && account.Length > 4 && _listCreditCards[i].CCNumberMasked.Substring(_listCreditCards[i].CCNumberMasked.Length - 4) == account.Substring(account.Length - 4) && _listCreditCards[i].CCExpiration.ToString("MMyy") == exp) { //The credit card on file matches the one in X-Charge, so remove from the list. _listCreditCards.RemoveAt(i); verified++; } else { invalid++; } } } catch { MsgBox.Show(this, "Something went wrong validating X-Charge tokens. Please try again."); break; } textVerified.Text = verified.ToString(); textInvalid.Text = invalid.ToString(); } }
private List <CreditCard> FilterCardList() { int verified = 0; int invalid = 0; textVerified.Text = verified.ToString(); textInvalid.Text = invalid.ToString(); for (int i = CardList.Count - 1; i >= 0; i--) { Program prog = Programs.GetCur(ProgramName.Xcharge); string path = Programs.GetProgramPath(prog); ProgramProperty prop = (ProgramProperty)ProgramProperties.GetForProgram(prog.ProgramNum)[0]; ProcessStartInfo info = new ProcessStartInfo(path); string resultfile = Path.Combine(Path.GetDirectoryName(path), "XResult.txt"); File.Delete(resultfile); //delete the old result file. info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTQUERY "; info.Arguments += "/XCACCOUNTID:" + CardList[i].XChargeToken + " "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username") + " "; info.Arguments += "/PASSWORD:"******"Password") + " "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/NORESULTDIALOG "; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. string resulttext = ""; string line = ""; string account = ""; string exp = ""; using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("ACCOUNT=")) { account = line.Substring(8); } else if (line.StartsWith("EXPIRATION=")) { exp = line.Substring(11); } line = reader.ReadLine(); } if (CardList[i].CCNumberMasked.Length > 4 && account.Length > 4 && CardList[i].CCNumberMasked.Substring(CardList[i].CCNumberMasked.Length - 4) == account.Substring(account.Length - 4) && CardList[i].CCExpiration.ToString("MMyy") == exp) { //The credit card on file matches the one in X-Charge, so remove from the list. CardList.Remove(CardList[i]); verified++; } else { invalid++; } } textVerified.Text = verified.ToString(); textInvalid.Text = invalid.ToString(); } return(CardList); }
private void butAdd_Click(object sender, EventArgs e) { if (!PrefC.GetBool(PrefName.StoreCCnumbers)) { bool hasXCharge = false; bool hasPayConnect = false; bool hasPaySimple = false; Dictionary <string, int> dictEnabledProcessors = new Dictionary <string, int>(); int idx = 0; bool hasXChargePreventCcAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.Xcharge).ProgramNum, ProgramProperties.PropertyDescs.XCharge.XChargePreventSavingNewCC, Clinics.ClinicNum)); if (Programs.IsEnabled(ProgramName.Xcharge) && !hasXChargePreventCcAdd) { dictEnabledProcessors["X-Charge"] = idx++; } bool hasPayConnectPreventCcAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.PayConnect).ProgramNum, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, Clinics.ClinicNum)); if (Programs.IsEnabled(ProgramName.PayConnect) && !hasPayConnectPreventCcAdd) { dictEnabledProcessors["PayConnect"] = idx++; } bool hasPaySimplePreventCCAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.PaySimple).ProgramNum, PaySimple.PropertyDescs.PaySimplePreventSavingNewCC, Clinics.ClinicNum)); if (Programs.IsEnabled(ProgramName.PaySimple) && !hasPaySimplePreventCCAdd) { dictEnabledProcessors["PaySimple"] = idx++; } if (dictEnabledProcessors.Count > 1) { List <string> listCCProcessors = dictEnabledProcessors.Select(x => x.Key).ToList(); InputBox chooseProcessor = new InputBox(Lan.g(this, "For which credit card processing company would you like to add this card?"), listCCProcessors, true); if (chooseProcessor.ShowDialog() == DialogResult.Cancel) { return; } hasXCharge = dictEnabledProcessors.ContainsKey("X-Charge") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["X-Charge"]); hasPayConnect = dictEnabledProcessors.ContainsKey("PayConnect") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["PayConnect"]); hasPaySimple = dictEnabledProcessors.ContainsKey("PaySimple") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["PaySimple"]); } else if (Programs.IsEnabled(ProgramName.Xcharge) && !hasXChargePreventCcAdd) { hasXCharge = true; } else if (Programs.IsEnabled(ProgramName.PayConnect) && !hasPayConnectPreventCcAdd) { hasPayConnect = true; } else if (Programs.IsEnabled(ProgramName.PaySimple) && !hasPaySimplePreventCCAdd) { hasPaySimple = true; } else //not storing CC numbers and both PayConnect and X-Charge are disabled { MsgBox.Show(this, "Not allowed to store credit cards."); return; } CreditCard creditCardCur = null; if (hasXCharge) { if (ODBuild.IsWeb()) { MsgBox.Show(this, "XCharge is not available while viewing through the web."); return; } Program prog = Programs.GetCur(ProgramName.Xcharge); string path = Programs.GetProgramPath(prog); string xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum).Trim(); string xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum).Trim(); //Force user to retry entering information until it's correct or they press cancel while (!File.Exists(path) || string.IsNullOrEmpty(xPassword) || string.IsNullOrEmpty(xUsername)) { MsgBox.Show(this, "The Path, Username, and/or Password for X-Charge have not been set or are invalid."); if (!Security.IsAuthorized(Permissions.Setup)) { return; } FormXchargeSetup FormX = new FormXchargeSetup(); //refreshes program and program property caches on OK click FormX.ShowDialog(); if (FormX.DialogResult != DialogResult.OK) //if user presses cancel, return { return; } prog = Programs.GetCur(ProgramName.Xcharge); //refresh local variable prog to reflect any changes made in setup window path = Programs.GetProgramPath(prog); xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum).Trim(); xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum).Trim(); } xPassword = CodeBase.MiscUtils.Decrypt(xPassword); ProcessStartInfo info = new ProcessStartInfo(path); string resultfile = PrefC.GetRandomTempFile("txt"); try { File.Delete(resultfile); //delete the old result file. } catch { MsgBox.Show(this, "Could not delete XResult.txt file. It may be in use by another program, flagged as read-only, or you might not have sufficient permissions."); return; } info.Arguments = ""; info.Arguments += "/TRANSACTIONTYPE:ArchiveVaultAdd /LOCKTRANTYPE "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + xUsername + " "; info.Arguments += "/PASSWORD:"******" "; info.Arguments += "/VALIDATEARCHIVEVAULTACCOUNT "; info.Arguments += "/STAYONTOP "; info.Arguments += "/SMARTAUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/HIDEMAINWINDOW "; info.Arguments += "/SMALLWINDOW "; info.Arguments += "/NORESULTDIALOG "; info.Arguments += "/TOOLBAREXITBUTTON "; Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string resulttext = ""; string line = ""; string xChargeToken = ""; string accountMasked = ""; string exp = "";; bool insertCard = false; try { using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("RESULT=")) { if (line != "RESULT=SUCCESS") { throw new Exception(); } insertCard = true; } if (line.StartsWith("XCACCOUNTID=")) { xChargeToken = PIn.String(line.Substring(12)); } if (line.StartsWith("ACCOUNT=")) { accountMasked = PIn.String(line.Substring(8)); } if (line.StartsWith("EXPIRATION=")) { exp = PIn.String(line.Substring(11)); } line = reader.ReadLine(); } if (insertCard && xChargeToken != "") //Might not be necessary but we've had successful charges with no tokens returned before. { creditCardCur = new CreditCard(); List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum); creditCardCur.PatNum = PatCur.PatNum; creditCardCur.ItemOrder = itemOrderCount.Count; creditCardCur.CCNumberMasked = accountMasked; creditCardCur.XChargeToken = xChargeToken; creditCardCur.CCExpiration = new DateTime(Convert.ToInt32("20" + PIn.String(exp.Substring(2, 2))), Convert.ToInt32(PIn.String(exp.Substring(0, 2))), 1); creditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs); creditCardCur.CCSource = CreditCardSource.XServer; creditCardCur.ClinicNum = Clinics.ClinicNum; CreditCards.Insert(creditCardCur); } } } catch (Exception) { MsgBox.Show(this, "There was a problem adding the credit card. Please try again."); } } if (hasPayConnect) { FormPayConnect FormPC = new FormPayConnect(Clinics.ClinicNum, PatCur, (decimal)0.01, creditCardCur, true); FormPC.ShowDialog(); } if (hasPaySimple) { FormPaySimple formPS = new FormPaySimple(Clinics.ClinicNum, PatCur, (decimal)0.01, creditCardCur, true); formPS.ShowDialog(); } FillGrid(); if (gridMain.ListGridRows.Count > 0 && creditCardCur != null) { gridMain.SetSelected(gridMain.ListGridRows.Count - 1, true); } return; } //storing CC numbers allowed from here down FormCreditCardEdit FormCCE = new FormCreditCardEdit(PatCur); FormCCE.CreditCardCur = new CreditCard(); FormCCE.CreditCardCur.IsNew = true; FormCCE.CreditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs); FormCCE.ShowDialog(); if (FormCCE.DialogResult == DialogResult.OK) { FillGrid(); if (gridMain.ListGridRows.Count > 0) { gridMain.SetSelected(gridMain.ListGridRows.Count - 1, true); } } }
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; } }
private void butOK_Click(object sender, EventArgs e) { if (!VerifyData()) { return; } CreditCardCur.Address = textAddress.Text; CreditCardCur.CCNumberMasked = textCardNumber.Text; CreditCardCur.PatNum = PatCur.PatNum; CreditCardCur.Zip = textZip.Text; if (IsXCharge) //Only update recurring if using X-Charge. { CreditCardCur.ChargeAmt = PIn.Double(textChargeAmt.Text); CreditCardCur.DateStart = PIn.Date(textDateStart.Text); CreditCardCur.DateStop = PIn.Date(textDateStop.Text); CreditCardCur.Note = textNote.Text; if (comboPaymentPlans.SelectedIndex > 0) { CreditCardCur.PayPlanNum = PayPlanList[comboPaymentPlans.SelectedIndex - 1].PayPlanNum; } else { CreditCardCur.PayPlanNum = 0; //Allows users to change from a recurring payplan charge to a normal one. } } if (CreditCardCur.IsNew) { List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum); CreditCardCur.ItemOrder = itemOrderCount.Count; CreditCards.Insert(CreditCardCur); } else { #region X-Charge //Special logic for had a token and changed number or expiration date if (CreditCardCur.XChargeToken != "" && IsXCharge && (CreditCardOld.CCNumberMasked != CreditCardCur.CCNumberMasked || CreditCardOld.CCExpiration != CreditCardCur.CCExpiration)) { Program prog = Programs.GetCur(ProgramName.Xcharge); if (prog == null) { MsgBox.Show(this, "X-Charge entry is missing from the database."); //should never happen return; } if (!prog.Enabled) { if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); } return; } if (!File.Exists(prog.Path)) { MsgBox.Show(this, "Path is not valid."); if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); } return; } //Either update the exp date or update credit card number by deleting archive so new token can be created next time it's used. ProgramProperty prop = (ProgramProperty)ProgramProperties.GetForProgram(prog.ProgramNum)[0]; ProcessStartInfo info = new ProcessStartInfo(prog.Path); string resultfile = Path.Combine(Path.GetDirectoryName(prog.Path), "XResult.txt"); File.Delete(resultfile); //delete the old result file. if (CreditCardOld.CCNumberMasked != CreditCardCur.CCNumberMasked) //They changed card number which we have to delete archived token which will create a new one next time card is charged. { info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTDELETE "; info.Arguments += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username") + " "; info.Arguments += "/PASSWORD:"******"Password") + " "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; CreditCardCur.XChargeToken = ""; //Clear the XChargeToken in our db. } else //We can only change exp date for X-Charge via ARCHIVEAULTUPDATE. { info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTUPDATE "; info.Arguments += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " "; if (CreditCardCur.CCExpiration != null && CreditCardCur.CCExpiration.Year > 2005) { info.Arguments += "/EXP:" + CreditCardCur.CCExpiration.ToString("MMyy") + " "; } info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username") + " "; info.Arguments += "/PASSWORD:"******"Password") + " "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; } Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string resulttext = ""; string line = ""; using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("RESULT=")) { if (line != "RESULT=SUCCESS") { CreditCardCur = CreditCards.GetOne(CreditCardCur.CreditCardNum); FillData(); return; } } line = reader.ReadLine(); } } } //End of special token logic #endregion CreditCards.Update(CreditCardCur); } DialogResult = DialogResult.OK; }
private void butAdd_Click(object sender, EventArgs e) { if (!PrefC.GetBool(PrefName.StoreCCnumbers)) { if (Programs.IsEnabled(ProgramName.Xcharge)) { Program prog = Programs.GetCur(ProgramName.Xcharge); if (!File.Exists(prog.Path)) { MsgBox.Show(this, "Path is not valid."); if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); if (FormX.DialogResult != DialogResult.OK) { return; } } } string user = ProgramProperties.GetPropVal(prog.ProgramNum, "Username"); string password = ProgramProperties.GetPropVal(prog.ProgramNum, "Password"); ProcessStartInfo info = new ProcessStartInfo(prog.Path); string resultfile = Path.Combine(Path.GetDirectoryName(prog.Path), "XResult.txt"); File.Delete(resultfile); //delete the old result file. info.Arguments = ""; info.Arguments += "/TRANSACTIONTYPE:ArchiveVaultAdd /LOCKTRANTYPE "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + user + " "; info.Arguments += "/PASSWORD:"******" "; info.Arguments += "/VALIDATEARCHIVEVAULTACCOUNT "; info.Arguments += "/STAYONTOP "; info.Arguments += "/SMARTAUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/HIDEMAINWINDOW "; info.Arguments += "/SMALLWINDOW "; info.Arguments += "/NORESULTDIALOG "; info.Arguments += "/TOOLBAREXITBUTTON "; Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string resulttext = ""; string line = ""; string xChargeToken = ""; string accountMasked = ""; string exp = "";; bool insertCard = false; using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("RESULT=")) { if (line != "RESULT=SUCCESS") { break; } insertCard = true; } if (line.StartsWith("XCACCOUNTID=")) { xChargeToken = PIn.String(line.Substring(12)); } if (line.StartsWith("ACCOUNT=")) { accountMasked = PIn.String(line.Substring(8)); } if (line.StartsWith("EXPIRATION=")) { exp = PIn.String(line.Substring(11)); } line = reader.ReadLine(); } if (insertCard && xChargeToken != "") //Might not be necessary but we've had successful charges with no tokens returned before. { CreditCard creditCardCur = new CreditCard(); List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum); creditCardCur.PatNum = PatCur.PatNum; creditCardCur.ItemOrder = itemOrderCount.Count; creditCardCur.CCNumberMasked = accountMasked; creditCardCur.XChargeToken = xChargeToken; creditCardCur.CCExpiration = new DateTime(Convert.ToInt32("20" + PIn.String(exp.Substring(2, 2))), Convert.ToInt32(PIn.String(exp.Substring(0, 2))), 1); CreditCards.Insert(creditCardCur); } } RefreshCardList(); return; } else { MsgBox.Show(this, "Not allowed to store credit cards."); return; } } bool remember = false; int placement = listCreditCards.SelectedIndex; if (placement != -1) { remember = true; } FormCreditCardEdit FormCCE = new FormCreditCardEdit(PatCur); FormCCE.CreditCardCur = new CreditCard(); FormCCE.CreditCardCur.IsNew = true; FormCCE.ShowDialog(); RefreshCardList(); if (remember) //in case they canceled and had one selected { listCreditCards.SelectedIndex = placement; } if (FormCCE.DialogResult == DialogResult.OK && creditCards.Count > 0) { listCreditCards.SelectedIndex = 0; } }
///<summary>Processes a PayConnect payment via the PayConnect web service.</summary> private bool ProcessPaymentWebService(int expYear, int expMonth) { string refNumber = ""; if (_trantype == PayConnectService.transType.VOID || _trantype == PayConnectService.transType.RETURN) { refNumber = textRefNumber.Text; } string magData = null; if (_parser != null) { magData = _parser.Track2; } string cardNumber = textCardNumber.Text; //if using a stored CC and there is an X-Charge token saved for the CC and the user enters the whole card number to get a PayConnect token //and the number entered doesn't have the same last 4 digits and exp date, then assume it's not the same card and clear out the X-Charge token. if (_creditCardCur != null && //using a saved CC !string.IsNullOrEmpty(_creditCardCur.XChargeToken) && //there is an X-Charge token saved (cardNumber.Right(4) != _creditCardCur.CCNumberMasked.Right(4) || //the card number entered doesn't have the same last 4 digits expYear != _creditCardCur.CCExpiration.Year || //the card exp date entered doesn't have the same year expMonth != _creditCardCur.CCExpiration.Month)) //the card exp date entered doesn't have the same month { if (MsgBox.Show(this, MsgBoxButtons.YesNo, "The card number or expiration date entered does not match the X-Charge card on file. Do you wish " + "to replace the X-Charge card with this one?")) { _creditCardCur.XChargeToken = ""; } else { Cursor = Cursors.Default; return(false); } } //if the user has chosen to store CC tokens and the stored CC has a token and the token is not expired, //then use it instead of the CC number and CC expiration. if (checkSaveToken.Checked && _creditCardCur != null && //if the user selected a saved CC _creditCardCur.PayConnectToken != "" && //there is a stored token for this card _creditCardCur.PayConnectTokenExp.Date >= DateTime.Today.Date) //the token is not expired { cardNumber = _creditCardCur.PayConnectToken; expYear = _creditCardCur.PayConnectTokenExp.Year; expMonth = _creditCardCur.PayConnectTokenExp.Month; } else if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, _clinicNum))) { MsgBox.Show(this, "Cannot add a new credit card."); return(false); } string authCode = ""; if (_trantype == PayConnectService.transType.FORCE) { authCode = textRefNumber.Text; } _request = PayConnect.BuildSaleRequest(PIn.Decimal(textAmount.Text), cardNumber, expYear, expMonth, textNameOnCard.Text, textSecurityCode.Text, textZipCode.Text, magData, _trantype, refNumber, checkSaveToken.Checked, authCode, checkForceDuplicate.Checked); _response = PayConnect.ProcessCreditCard(_request, _clinicNum, x => MessageBox.Show(x)); if (_response == null || _response.Status.code != 0) //error in transaction { return(false); } PayConnectService.signatureResponse sigResponse = SendSignature(_response.RefNumber); if ((_trantype.In(PayConnectService.transType.SALE, PayConnectService.transType.RETURN, PayConnectService.transType.VOID)) && _response.Status.code == 0) //Only print a receipt if transaction is an approved SALE, RETURN, or VOID { _receiptStr = PayConnect.BuildReceiptString(_request, _response, sigResponse, _clinicNum); PrintReceipt(_receiptStr); } if (!PrefC.GetBool(PrefName.StoreCCnumbers) && !checkSaveToken.Checked) //not storing the card number or the token { return(true); } //response must be non-null and the status code must be 0=Approved //also, the user must have the pref StoreCCnumbers enabled or they have the checkSaveTokens checked if (_creditCardCur == null) //user selected Add new card from the payment window, save it or its token depending on settings { _creditCardCur = new CreditCard(); _creditCardCur.IsNew = true; _creditCardCur.PatNum = _patCur.PatNum; List <CreditCard> itemOrderCount = CreditCards.Refresh(_patCur.PatNum); _creditCardCur.ItemOrder = itemOrderCount.Count; } _creditCardCur.CCExpiration = new DateTime(expYear, expMonth, DateTime.DaysInMonth(expYear, expMonth)); if (PrefC.GetBool(PrefName.StoreCCnumbers)) { _creditCardCur.CCNumberMasked = textCardNumber.Text; } else { _creditCardCur.CCNumberMasked = textCardNumber.Text.Right(4).PadLeft(textCardNumber.Text.Length, 'X'); } _creditCardCur.Zip = textZipCode.Text; _creditCardCur.PayConnectToken = ""; _creditCardCur.PayConnectTokenExp = DateTime.MinValue; //Store the token and the masked CC number (only last four digits). if (checkSaveToken.Checked && _response.PaymentToken != null) { _creditCardCur.PayConnectToken = _response.PaymentToken.TokenId; _creditCardCur.PayConnectTokenExp = new DateTime(_response.PaymentToken.Expiration.year, _response.PaymentToken.Expiration.month, DateTime.DaysInMonth(_response.PaymentToken.Expiration.year, _response.PaymentToken.Expiration.month)); } _creditCardCur.CCSource = CreditCardSource.PayConnect; if (_creditCardCur.IsNew) { _creditCardCur.ClinicNum = _clinicNum; _creditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs); CreditCards.Insert(_creditCardCur); } else { if (_creditCardCur.CCSource == CreditCardSource.XServer) //This card has also been added for XCharge. { _creditCardCur.CCSource = CreditCardSource.XServerPayConnect; } CreditCards.Update(_creditCardCur); } return(true); }